/// <summary> /// 调度任务, /// 根据cron表达式执行 /// </summary> /// <param name="jobDetail">任务明细</param> /// <param name="cron">cron表达式</param> public static void Schedule(IJobDetail jobDetail, string cron) { if (!_Scheduler.CheckExists(jobDetail.Key).Result) { //创建触发器 ITrigger trigger = TriggerBuilder.Create().WithCronSchedule(cron).Build(); //为调度者添加任务与触发器 _Scheduler.ScheduleJob(jobDetail, trigger); //开始调度 _Scheduler.Start(); } else { _Scheduler.ResumeJob(jobDetail.Key); } }