123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- using log4net;
- using Quartz;
- using SCADA.CommonLib.Scheduler;
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace SCADA_DAQ.Customer.Jobs
- {
- /// <summary>
- /// 自定义任务
- /// </summary>
- [DisplayName("自定义任务")]
- public class CustomerJob : BaseJob
- {
- /// <summary>
- ///
- /// </summary>
- public CustomerJob() : base()
- {
- }
- /// <summary>
- /// 执行策略
- /// </summary>
- public override string ExcutePolicy { get => "0 0 12 * * ?"; } //每天中午点清理旧日志
- /// <summary>
- /// 任务名称
- /// </summary>
- public override string JobName => "FileClearJob";
- /// <summary>
- /// 参数类
- /// </summary>
- public override Type JobParameterType { get; set; } = typeof(CustomerJobConfig);
- /// <summary>
- /// 任务执行
- /// </summary>
- protected override Func<IJobExecutionContext, ILog, JobExcuteFinishEventArgs> ExcuteHandler => (context, log) =>
- {
- var para = (CustomerJobConfig)JobServer.Instance.JobParameters[context.JobDetail.Key.ToString()];
- var excuteMsg = new JobExcuteFinishEventArgs();
- //TODO:这里执行需要的逻辑
- excuteMsg.IsSuccess = true;
- return excuteMsg;
- };
- }
- }
|