17,740
社区成员
发帖
与我相关
我的任务
分享
Thread th = new Thread(() =>
{
using (HLERPEntities db = new HLERPEntities())
{
DbEntityEntry<Log> entry = null;
//循环运行
while (true)
{
//1.0 同步订单
//1.1 获取所有accountId,根据accountId调用ebayTool方法同步订单
//ebay的platformId是1
var listAccount = db.Accounts.Where(a => a.platformId == 1).ToList();
for (int i = 0; i < listAccount.Count; i++)
{
int accountId = listAccount[i].id;
eBayTool tool = new eBayTool();
DateTime st = DateTime.Now.AddDays(-2);
DateTime et = DateTime.Now.AddDays(1);
try
{
tool.GetOrders(accountId, st, et);
}
catch (Exception e)
{
Log log = new Log();
log.controller = "GetOrders";
log.action = "Ebay";
log.msg = e.Message;
log.data = e.Data.ToString();
log.time = DateTime.Now;
entry = db.Entry<Log>(log);
entry.State = System.Data.EntityState.Added;
db.SaveChanges();
}
} operation.CountHalfMonthTotal();
//5.0 线程休眠60分钟
Thread.Sleep(3600000);
}
}
});
th.IsBackground = true;
th.Start();
- <Event xmlns="http://schemas.microsoft.com/win/2004/08/events/event">
- <System>
<Provider Name=".NET Runtime" />
<EventID Qualifiers="0">1026</EventID>
<Level>2</Level>
<Task>0</Task>
<Keywords>0x80000000000000</Keywords>
<TimeCreated SystemTime="2015-02-17T08:14:37.000000000Z" />
<EventRecordID>13607</EventRecordID>
<Channel>Application</Channel>
<Computer>WIN-92S1PMFFM0K</Computer>
<Security />
</System>
- <EventData>
<Data>应用程序: GetOrders.exe Framework 版本: v4.0.30319 说明: 由于未经处理的异常,进程终止。异常信息: System.Data.Entity.Validation.DbEntityValidationException 堆栈: 在 System.Data.Entity.Internal.InternalContext.SaveChanges() 在 System.Data.Entity.Internal.LazyInternalContext.SaveChanges() 在 System.Data.Entity.DbContext.SaveChanges() 在 GetOrders.Service1.<OnStart>b__0() 在 System.Threading.ThreadHelper.ThreadStart_Context(System.Object) 在 System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean) 在 System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean) 在 System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object) 在 System.Threading.ThreadHelper.ThreadStart()</Data>
</EventData>
</Event>