TaskNewsFeedJob.cs 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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 TaskNewsFeedJob : IJob
  10. {
  11. private readonly ILogger<TaskNewsFeedJob> _logger;
  12. public TaskNewsFeedJob(ILogger<TaskNewsFeedJob> logger)
  13. {
  14. _logger = logger;
  15. }
  16. /// <summary>
  17. /// 任务消息推送
  18. /// </summary>
  19. /// <param name="context"></param>
  20. /// <returns></returns>
  21. public async Task Execute(IJobExecutionContext context)
  22. {
  23. _logger.LogInformation("调用任务消息通知 " + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
  24. try
  25. {
  26. //在此处编写任务业务代码
  27. TaskNotification.PostTaskMessageNotification();
  28. }
  29. catch (Exception ex)
  30. {
  31. _logger.LogInformation($"调用任务消息通知ErrorMsg:{ex.Message} " + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
  32. }
  33. //return Task.CompletedTask;
  34. await Task.CompletedTask;
  35. }
  36. }
  37. }