|
|
@@ -21,7 +21,7 @@ namespace HKCardOUT.QuartzUtil.Job |
|
|
|
{ |
|
|
|
default: |
|
|
|
{ |
|
|
|
var WaitSync = DbContext.Context.Queryable<SaleLog>().Where(t => t.IsSync == false&&t.State==true).ToList(); |
|
|
|
var WaitSync = DbContext.Context.Queryable<SaleLog>().Where(t => t.IsSync == false && t.State == true).ToList(); |
|
|
|
List<SaleDto> dto = new List<SaleDto>(); |
|
|
|
if (WaitSync.Count > 0) |
|
|
|
{ |
|
|
@@ -46,14 +46,33 @@ namespace HKCardOUT.QuartzUtil.Job |
|
|
|
lock (obj) |
|
|
|
{ |
|
|
|
db.BeginTran(); |
|
|
|
foreach (var item in dto) |
|
|
|
var result = RemoteService.SyncSaleLogList(dto); |
|
|
|
if (result != null && result.Count > 0) |
|
|
|
{ |
|
|
|
var res = RemoteService.SyncSaleLogList(new List<SaleDto> { item }); |
|
|
|
if (res) |
|
|
|
DbContext.Context.Updateable<SaleLog>().SetColumns(t => t.IsSync == true).Where(t => t.Id==item.Id).ExecuteCommand(); |
|
|
|
else |
|
|
|
DbContext.Context.Updateable<SaleLog>().SetColumns(t => t.State==false).Where(t => t.Id == item.Id).ExecuteCommand(); |
|
|
|
var cardNum = result.Select(t => t.cardNum).ToList(); |
|
|
|
DbContext.Context.Updateable<SaleLog>().SetColumns(t => t.State == false).Where(t => cardNum.Contains(t.Id.ToString())).ExecuteCommand(); |
|
|
|
|
|
|
|
dto.RemoveAll(t => cardNum.Contains(t.CardNum)); |
|
|
|
|
|
|
|
var Sid = dto.Select(t => t.Id).ToList(); |
|
|
|
|
|
|
|
DbContext.Context.Updateable<SaleLog>().SetColumns(t => t.IsSync == true).Where(t => Sid.Contains(t.Id)).ExecuteCommand(); |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
var Sid = dto.Select(t => t.Id).ToList(); |
|
|
|
|
|
|
|
DbContext.Context.Updateable<SaleLog>().SetColumns(t => t.IsSync == true).Where(t => Sid.Contains(t.Id)).ExecuteCommand(); |
|
|
|
|
|
|
|
} |
|
|
|
//foreach (var item in dto) |
|
|
|
//{ |
|
|
|
// var res = (new List<SaleDto> { item }); |
|
|
|
// if (res) |
|
|
|
// DbContext.Context.Updateable<SaleLog>().SetColumns(t => t.IsSync == true).Where(t => t.Id == item.Id).ExecuteCommand(); |
|
|
|
// else |
|
|
|
// DbContext.Context.Updateable<SaleLog>().SetColumns(t => t.State == false).Where(t => t.Id == item.Id).ExecuteCommand(); |
|
|
|
//} |
|
|
|
db.CommitTran(); |
|
|
|
} |
|
|
|
} |
|
|
|