2014-11-05 2 views
0

내 작업 중 하나의 방아쇠를 변경하고 싶습니다. 그래서 내가하고있는 일은 내 일에 그 일과 관련이있는 트리거가 있는지 먼저 확인하는 것입니다. 그렇다면 사용자가 선택한 새 트리거가있는 Reschedule입니다. 그러나 내가 AdoJobStore을 볼 때 새로운 트리거는 거기에 없으며 작업은 다시 일정을 잡은 후에 실행을 멈 춥니 다.작업 일정 조정이 작동하지 않습니다.

은 내가 try-catch 블록이 전체 코드를 넣어 가지고,하지만 난 어떤 Exception의가 수신되지 않는,하지만 난 JobExecutionException의 대신 단지 Exception의를 잡을해야하기 때문에 그것은 어쩌면인가?

var jobKey = new JobKey(jobName, jobGroup); 
IScheduler sched = scheduler.GetScheduler(); 
IList<ITrigger> triggers = sched.GetTriggersOfJob(jobKey); 
if (triggers.Count != 0) 
{ 
    ITrigger existingTrigger = triggers[0]; 
    sched.UnscheduleJob(existingTrigger.Key); 
    ITrigger newTrigger = BuildTrigger(triggerName, triggerGroup); 
    IJobDetail job = sched.GetJobDetail(jobKey); 
    DialogResult dr = MsgBox.Show(string.Format("Confirm campaign '{0}' with the schedule '{1}'?", lblCampaignName.Text, txtbxMessage.Text), "Confirm Schedule", MsgBox.Buttons.YesNo, MsgBox.Icon.Question); 
    if (dr == DialogResult.Yes) 
    { 

     sched.RescheduleJob(existingTrigger.Key, newTrigger); 
     int updateResult = UpdateCampaignSchedule(); 
     if (updateResult == 1) 
      MsgBox.Show("Campaign schedule successfully updated!", "Edit schedule", MsgBox.Buttons.OK, MsgBox.Icon.Info); 
     else 
      MsgBox.Show("Unable to update campaign schedule in the database.", "Edit schedule", MsgBox.Buttons.OK, MsgBox.Icon.Error); 
    } 
} 
else 
{ 
.. 
} 

답변

0

전화가 sched.UnscheduleJob(existingTrigger.Key입니다. 그러면 작업 저장소에서 트리거가 삭제됩니다. 따라서 sched.RescheduleJob(existingTrigger.Key, newTrigger)을 호출하면 quartz는 새 트리거로 교체 할 이전 트리거를 찾을 수 없습니다 (반환 값을 보면 null이 됨). 새 트리거가 유효하지 않으면 예외를 throw하지 않습니다.

sched.UnscheduleJob(existingTrigger.Key, newTrigger을 제거하면 정상적으로 작동합니다.

관련 문제