diff --git a/HKCardOUT/Logic/Service/HKCore.cs b/HKCardOUT/Logic/Service/HKCore.cs index cecbd7d..c22ea72 100644 --- a/HKCardOUT/Logic/Service/HKCore.cs +++ b/HKCardOUT/Logic/Service/HKCore.cs @@ -20,37 +20,47 @@ namespace HKCardOUT.Logic.Service /// public bool DeviceSale(SaleLog input) { - if (RemoteService.CheckCardStuatas(input.CardNo) != 1) return false; - if (!DataBus.IsTest) - if (!Main.GetInstance.GetIsSwipe(input.Location.AsInt())) return false; - var Old = DbContext.Context.Queryable() - .Where(t => t.CardNo == input.CardNo).OrderByDescending(t => t.CreateTime).First(); - if (Old != null) + try { - var entity = DbContext.Context.Insertable(input).CallEntityMethod(t => t.Create()).ExecuteReturnEntity(); - if (entity.Id != Guid.Empty) + if (RemoteService.CheckCardStuatas(input.CardNo) != 1) return false; + if (!DataBus.IsTest) + if (!Main.GetInstance.GetIsSwipe(input.Location.AsInt())) return false; + var Old = DbContext.Context.Queryable() + .Where(t => t.CardNo == input.CardNo).OrderByDescending(t => t.CreateTime).First(); + if (Old != null) { - var res = RemoteService.SyncSaleLog(input.CardNo, input.Location); - if (!DataBus.IsTest) - Main.GetInstance.Start(input.Location.AsInt()); - DbContext.Context.Updateable().SetColumns(t => t.IsSync == true).Where(t => t.Id == entity.Id).ExecuteCommand(); - return res; + var entity = DbContext.Context.Insertable(input).CallEntityMethod(t => t.Create()).ExecuteReturnEntity(); + if (entity.Id != Guid.Empty) + { + var res = RemoteService.SyncSaleLog(input.CardNo, input.Location); + if (!DataBus.IsTest) + Main.GetInstance.Start(input.Location.AsInt()); + DbContext.Context.Updateable().SetColumns(t => t.IsSync == true).Where(t => t.Id == entity.Id).ExecuteCommand(); + return res; + } + return false; } - return false; - } - else - { - var entity = DbContext.Context.Insertable(input).CallEntityMethod(t => t.Create()).ExecuteReturnEntity(); - if (entity.Id != Guid.Empty) + else { - var res = RemoteService.SyncSaleLog(input.CardNo, input.Location); - if (!DataBus.IsTest) - Main.GetInstance.Start(input.Location.AsInt()); - DbContext.Context.Updateable().SetColumns(t => t.IsSync == true).Where(t => t.Id == entity.Id).ExecuteCommand(); - return res; + var entity = DbContext.Context.Insertable(input).CallEntityMethod(t => t.Create()).ExecuteReturnEntity(); + if (entity.Id != Guid.Empty) + { + var res = RemoteService.SyncSaleLog(input.CardNo, input.Location); + if (!DataBus.IsTest) + Main.GetInstance.Start(input.Location.AsInt()); + DbContext.Context.Updateable().SetColumns(t => t.IsSync == true).Where(t => t.Id == entity.Id).ExecuteCommand(); + return res; + } + return false; } + + } + catch (Exception ex) + { + HKLog.HKLogImport.WriteError(ex); return false; } + } /// /// 获取当天消费前100条展示