0
我想改變我的工作之一的觸發器。所以我正在做的是先看看我的工作是否有與之相關的觸發器。如果是這樣,我用Reschedule
用戶選擇了一個新的觸發器。但是當我看着我的AdoJobStore
時,新的觸發器不存在,重新計劃後作業將停止運行。工作重新安排不起作用
我已經把這個整個代碼在try-catch
塊,但我沒有收到任何Exception
S,但是這是也許是因爲我應該抓住JobExecutionException
!而非只是Exception
S'
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
{
..
}