我使用过石英计划,每次编辑非一次性计划的计划时,我都会收到以下异常。 (即每周或每小时。
2015-04-08 08:34:00.0464[SubscriptionService] JobScheduler Exception : System.Collections.Generic.KeyNotFoundException: The given key was not present in the dictionary.
at System.ThrowHelper.ThrowKeyNotFoundException()
at System.Collections.Generic.Dictionary`2.get_Item(TKey key)
at ReportingService.ReportEngine.GetParameterProperty(String param, Dictionary`2 dataset)
at ReportingService.ProgrammabilityManager..ctor(IEnumerable`1 procs, Dictionary`2 list, CallType callType, ReportEngine engine)
at ReportingService.ReportEngine.GetReportData(IEnumerable`1 parameter, IEnumerable`1 proc, IEnumerable`1 join, IEnumerable`1 field)
at ReportingService.ReportEngine.ProcessReportData(String section, String name, String[] parameters)
at ReportingService.ReportEngine.GetParameterizedReport(String section, String name, String format, String[] parameters)
at Zone24x7.MX4Broker.Services.ScheduledJobExecuter.RetrieveScheduledJob(String id)
at Zone24x7.MX4Broker.Services.Job.LongRunningJob(Object obj)
但每次在我的应用程序中单击编辑按钮时,我都会创建一个新的触发器和新作业。这与编辑时间表有关吗?这是因为没有使用RescheduleJob方法吗?请指教。
以下是我的触发器和作业创建代码:
IJobDetail _JobOne = JobBuilder.Create<Job>()
.WithIdentity(guid.ToString() + "*" + id)
.Build();
ITrigger trigger = TriggerBuilder.Create()
.ForJob(_JobOne)
.WithIdentity(guid.ToString() + "*" + id,"minuteWithEnd")
.WithSimpleSchedule(x => x
.WithIntervalInMinutes(minutes)
.RepeatForever())
.StartAt(DateBuilder.DateOf(StartHour, StartMinute, StartSeconds, StartDate, StartMonth, StartYear))
.EndAt(DateBuilder.DateOf(0,0,0,EndDay,EndMonth,EndYear))
.Build();
以下是我的工作班:
public class Job : IJob
{
public void Execute(IJobExecutionContext context)
{
NLog.Logger logger = LogManager.GetLogger("[SubscriptionService]");
SubscriptionServiceDAL dal = new SubscriptionServiceDAL();
string[] keys = context.JobDetail.Key.ToString().Split('.');
string JobKey = keys[1].ToString();
foreach (string s in keys)
logger.Debug("key is: " + s+"\n");
logger.Debug(JobKey);
ThreadPool.QueueUserWorkItem(LongRunningJob, JobKey);
}
public void LongRunningJob(object obj)
{
string id = obj.ToString().Split('*')[1];
NLog.Logger logger = LogManager.GetLogger("[SubscriptionService]");
SubscriptionServiceDAL dal = new SubscriptionServiceDAL();
logger.Debug("------------------- Job" + obj.ToString() + " Executed ---------------------");
try
{
logger.Debug("ID in Long Running Job is: " + id);
dal.UpdateLastExecuteDateTime(id);
logger.Debug("came after dal.UpdateLastExecuteDateTime ");
ScheduledJobExecuter exec = new ScheduledJobExecuter();
exec.RetrieveScheduledJob(id);
logger.Debug("exec.RetrieveScheduledJob ");
}
catch (Exception ex)
{
logger.Debug(" JobScheduler Exception : " + ex.ToString());
}
}
}