public async Task Execute(IJobExecutionContext context) { var jobId = context.JobDetail.JobDataMap["id"]?.ToString(); await Logger.Info(jobId, "任务开始"); try { await Execute(new TaskExecutionContext { JobId = jobId, JobExecutionContext = context }); } catch (Exception ex) { await Logger.Error(jobId, "任务异常:" + ex); } await Logger.Info(jobId, "任务结束"); }
public async Task Execute(IJobExecutionContext context) { var jobId = context.JobDetail.JobDataMap["id"]; Logger.JobId = jobId == null ? Guid.Empty : Guid.Parse(jobId.ToString()); await Logger.Info("任务开始"); try { await Execute(new TaskExecutionContext { JobId = Logger.JobId, JobExecutionContext = context }); } catch (Exception ex) { await Logger.Error("任务异常:" + ex); } await Logger.Info("任务结束"); }