C# 作业重新安排不起作用
我想换一份工作的触发器。所以我要做的是首先看看我的工作是否有任何与之相关的触发器。如果是这样,我将使用用户选择的新触发器重新安排。但是当我查看我的AdoJobStore时,新的触发器不在那里,作业将在重新调度后停止运行 我已经将整个代码放在一个try-catch块中,但我没有收到任何异常,但这可能是因为我应该捕获JobExecutionExceptions,而不仅仅是异常 这是因为调用sched.UnscheduleJobexistingTrigger.Key。这将从作业存储中删除触发器。因此,在调用sched.RescheduleJobexistingTrigger.Key时,如果查看返回值,newTrigger quartz将无法找到旧触发器以将其替换为新触发器。除非新触发器无效,否则它将为null,也不会引发异常 删除sched.UnscheduleJobexistingTrigger.Key和newTrigger,它应该可以工作C# 作业重新安排不起作用,c#,quartz.net,job-scheduling,C#,Quartz.net,Job Scheduling,我想换一份工作的触发器。所以我要做的是首先看看我的工作是否有任何与之相关的触发器。如果是这样,我将使用用户选择的新触发器重新安排。但是当我查看我的AdoJobStore时,新的触发器不在那里,作业将在重新调度后停止运行 我已经将整个代码放在一个try-catch块中,但我没有收到任何异常,但这可能是因为我应该捕获JobExecutionExceptions,而不仅仅是异常 这是因为调用sched.UnscheduleJobexistingTrigger.Key。这将从作业存储中删除触发器。因此,
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
{
..
}