TaskJob.cs 988 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. using OASystem.API.OAMethodLib.Quartz.Business;
  2. using Quartz;
  3. namespace OASystem.API.OAMethodLib.Quartz.Jobs
  4. {
  5. /// <summary>
  6. /// 任务指派
  7. /// 定时器
  8. /// </summary>
  9. public class TaskJob : IJob
  10. {
  11. private readonly ILogger<TaskJob> _logger;
  12. public TaskJob(ILogger<TaskJob> logger)
  13. {
  14. _logger = logger;
  15. }
  16. public Task Execute(IJobExecutionContext context)
  17. {
  18. _logger.LogInformation("调用任务状态变更Function " + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
  19. try
  20. {
  21. //在此处编写任务业务代码
  22. TaskAssignment.PostTaskUpdateStatus();
  23. }
  24. catch (Exception ex)
  25. {
  26. _logger.LogInformation($"调用任务状态变更Function ErrorMsg:{ex.Message} " + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
  27. }
  28. return Task.CompletedTask;
  29. }
  30. }
  31. }