fix log异常
This commit is contained in:
@@ -58,30 +58,28 @@ public class SyncPersonJob
|
||||
.ToListAsync();
|
||||
|
||||
var originUpdates = persons.Where(x => existsWorkCodes.Contains(x.ZWORKCODE)).ToList();
|
||||
_logger.LogInformation("SAP分批更新数:{count}", originUpdates.Count);
|
||||
var existsUpdateWorkCodes = originUpdates.Select(x => x.ZWORKCODE).ToList();
|
||||
var originInserts = persons.Where(x => searchCodes.Contains(x.ZWORKCODE)).Where(x => !existsUpdateWorkCodes.Contains(x.ZWORKCODE)).ToList();
|
||||
_logger.LogInformation("SAP分批新增数:{count}", originInserts.Count);
|
||||
|
||||
|
||||
int i = 0;
|
||||
var currentTotal = originUpdates.Count + originInserts.Count;
|
||||
|
||||
var updates = ToGainfoSap(originUpdates);
|
||||
_logger.LogInformation("SAP分批更新数:{count}", updates.Count);
|
||||
var inserts = ToGainfoSap(originInserts);
|
||||
|
||||
_logger.LogInformation("SAP分批新增数:{count}", inserts.Count);
|
||||
foreach (var item in inserts)
|
||||
{
|
||||
i++;
|
||||
try
|
||||
{
|
||||
await SavePerson(item);
|
||||
//conn.Execute(SqlGeneration.InsertSql, item);
|
||||
//log.Debug($"执行新增{i}/{currentTotal} name:{item.gname},ename:{item.ename}");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
failure++;
|
||||
//log.Error($"执行新增{i}/{currentTotal} name:{item.gname},ename:{item.ename}失败 \r\n{ex.Message}");
|
||||
_logger.LogError(ex, "执行新增失败:{message}", ex.Message);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -92,13 +90,11 @@ public class SyncPersonJob
|
||||
try
|
||||
{
|
||||
await UpdatePerson(item);
|
||||
//conn.Execute(SqlGeneration.UpdateSql, item);
|
||||
//log.Debug($"执行更新{i}/{currentTotal} name:{item.gname},ename:{item.ename}");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
failure++;
|
||||
//log.Error($"执行更新{i}/{currentTotal} name:{item.gname},ename:{item.ename}失败 \r\n{ex.Message}");
|
||||
_logger.LogError(ex, "执行更新失败:{message}", ex.Message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user