任务日志改用异步

This commit is contained in:
不做码农 2022-03-24 21:05:39 +08:00
parent b943a516e1
commit a88fd3a18d
2 changed files with 4 additions and 4 deletions

View File

@ -23,7 +23,7 @@ namespace ZR.Service.System
public SysTasksLog AddTaskLog(string jobId, SysTasksLog logModel)
{
//获取任务信息
var model = _tasksQzService.GetId(jobId);
var model = _tasksQzService.GetSingleAsync(f => f.ID == jobId).Result;
if (model != null)
{
@ -33,7 +33,7 @@ namespace ZR.Service.System
logModel.CreateTime = DateTime.Now;
}
Add(logModel);
InsertAsync(logModel);
return logModel;
}

View File

@ -78,11 +78,11 @@ namespace ZR.Tasks
//成功后执行次数+1
if (logModel.Status == "0")
{
taskQzService.Update(f => f.ID == job.Key.Name, f => new SysTasksQz()
taskQzService.UpdateAsync(f => new SysTasksQz()
{
RunTimes = f.RunTimes + 1,
LastRunTime = DateTime.Now
});
}, f => f.ID == job.Key.Name);
}
logger.Info($"执行任务【{job.Key.Name}|{logModel.JobName}】结果={logModel.JobMessage}");
}