CustomerJob.cs 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. using log4net;
  2. using Quartz;
  3. using SCADA.CommonLib.Scheduler;
  4. using System;
  5. using System.Collections.Generic;
  6. using System.ComponentModel;
  7. using System.Linq;
  8. using System.Text;
  9. using System.Threading.Tasks;
  10. namespace SCADA_DAQ.Customer.Jobs
  11. {
  12. /// <summary>
  13. /// 自定义任务
  14. /// </summary>
  15. [DisplayName("自定义任务")]
  16. public class CustomerJob : BaseJob
  17. {
  18. /// <summary>
  19. ///
  20. /// </summary>
  21. public CustomerJob() : base()
  22. {
  23. }
  24. /// <summary>
  25. /// 执行策略
  26. /// </summary>
  27. public override string ExcutePolicy { get => "0 0 12 * * ?"; } //每天中午点清理旧日志
  28. /// <summary>
  29. /// 任务名称
  30. /// </summary>
  31. public override string JobName => "FileClearJob";
  32. /// <summary>
  33. /// 参数类
  34. /// </summary>
  35. public override Type JobParameterType { get; set; } = typeof(CustomerJobConfig);
  36. /// <summary>
  37. /// 任务执行
  38. /// </summary>
  39. protected override Func<IJobExecutionContext, ILog, JobExcuteFinishEventArgs> ExcuteHandler => (context, log) =>
  40. {
  41. var para = (CustomerJobConfig)JobServer.Instance.JobParameters[context.JobDetail.Key.ToString()];
  42. var excuteMsg = new JobExcuteFinishEventArgs();
  43. //TODO:这里执行需要的逻辑
  44. excuteMsg.IsSuccess = true;
  45. return excuteMsg;
  46. };
  47. }
  48. }