异步全部await。_tasksQzService不用App.GetRequiredService方法

This commit is contained in:
King
2022-03-26 20:54:02 +08:00
parent 845c75ceb5
commit 4fff0a25a0
4 changed files with 15 additions and 12 deletions

View File

@@ -56,7 +56,7 @@ namespace ZR.Tasks
JobMessage = logMsg
};
RecordTaskLog(context, logModel);
await RecordTaskLog(context, logModel);
return logModel;
}
@@ -65,7 +65,7 @@ namespace ZR.Tasks
/// </summary>
/// <param name="context"></param>
/// <param name="logModel"></param>
protected void RecordTaskLog(IJobExecutionContext context, SysTasksLog logModel)
protected async Task RecordTaskLog(IJobExecutionContext context, SysTasksLog logModel)
{
var tasksLogService = (ISysTasksLogService)App.GetRequiredService(typeof(ISysTasksLogService));
var taskQzService = (ISysTasksQzService)App.GetRequiredService(typeof(ISysTasksQzService));
@@ -74,11 +74,11 @@ namespace ZR.Tasks
IJobDetail job = context.JobDetail;
logModel.InvokeTarget = job.JobType.FullName;
logModel = tasksLogService.AddTaskLog(job.Key.Name, logModel);
logModel = await tasksLogService.AddTaskLog(job.Key.Name, logModel);
//成功后执行次数+1
if (logModel.Status == "0")
{
taskQzService.UpdateAsync(f => new SysTasksQz()
await taskQzService.UpdateAsync(f => new SysTasksQz()
{
RunTimes = f.RunTimes + 1,
LastRunTime = DateTime.Now