/// <summary>
 /// 移除调度任务
 /// </summary>
 /// <param name="jobDetail">任务明细</param>
 public static void Remove(IJobDetail jobDetail)
 {
     if (_Scheduler.CheckExists(jobDetail.Key).Result)
     {
         _Scheduler.DeleteJob(jobDetail.Key);
     }
 }
Beispiel #2
0
 private void Unschedule(Unschedule msg)
 {
     try
     {
         _logger.Debug("Unscheduling job {Task}", msg.Key);
         _scheduler.DeleteJob(msg.Key.ToJobKey());
         _logger.Debug("Unscheduled job {Task}", msg.Key);
         Sender.Tell(new Unscheduled(msg.Key));
     }
     catch (Exception e)
     {
         _logger.Error(e, "Error while Unscheduled job {Task}", msg.Key);
         Sender.Tell(new Failure {
             Exception = e, Timestamp = BusinessDateTime.UtcNow
         });
     }
 }
Beispiel #3
0
        /// <summary>
        /// 修改
        /// </summary>
        /// <param name="scheduler"></param>
        /// <param name="modilist"></param>

        public static void modiJob(Quartz.IScheduler scheduler, List <Config> modilist)
        {
            //   scheduler.GetTrigger(new TriggerKey(

            foreach (var item in modilist)
            {
                //var old = scheduler.GetTrigger(new TriggerKey(item.jobname + "trigger", "触发器组"));
                //if (old == null)
                //    return;

                //var newtrigger = addTriger(item).Build();
                //scheduler.RescheduleJob(old.Key, newtrigger);

                JobKey key = new JobKey(item.jobname, item.groupname);
                scheduler.DeleteJob(key);
                addjob(scheduler, item);
            }
        }
Beispiel #4
0
 protected virtual void RemoveJobCommand(RemoveJob removeJob)
 {
     try
     {
         var deleted = _scheduler.DeleteJob(removeJob.JobKey);
         if (deleted)
         {
             Context.Sender.Tell(new JobRemoved(removeJob.JobKey, removeJob.TriggerKey));
         }
         else
         {
             Context.Sender.Tell(new RemoveJobFail(removeJob.JobKey, removeJob.TriggerKey, new JobNotFoundException()));
         }
     }
     catch (Exception ex)
     {
         Context.Sender.Tell(new RemoveJobFail(removeJob.JobKey, removeJob.TriggerKey, ex));
     }
 }
 public bool StopJob(string jobName)
 {
     lock (joblocker)
     {
         var jobcontent = Jobs.FirstOrDefault(x => x.JobName == jobName);
         if (jobcontent == null)
         {
             return(false);
         }
         jobcontent.OnInvoke = null;
         foreach (var a in jobcontent.Triggers)
         {
             try { Scheduler.PauseTrigger(a.Key); }  // 停止触发器
             catch { }
             try { Scheduler.UnscheduleJob(a.Key); } // 停止触发器
             catch { }
         }
         try { Scheduler.DeleteJob(jobcontent.JobDetail.Key); }// 删除任务
         catch { }
         Jobs.Remove(jobcontent);
         return(true);
     }
 }