private void AddAppSetJob(IScheduler scheduler, System.Collections.IDictionary param) { JobDetail job = scheduler.GetJobDetail("AppSetDealJob", "Jinher.AMP.BTP.Job"); job = new JobDetail("AppSetDealJob", "Jinher.AMP.BTP.Job", typeof(AppSetDealJob)); job.JobDataMap.PutAll(param); DateTime start = DateTime.UtcNow.Date.AddDays(1).AddHours(-8);//北京时间领先UTC 8个小时 //每日零点的正品会APP缓存 SimpleTrigger trigger = new SimpleTrigger("AppSetDealJob", "Jinher.AMP.BTP.Job", start, null, Jinher.JAP.Job.Engine.SimpleTrigger.RepeatIndefinitely, TimeSpan.FromHours(24)); trigger.Description = "AppSetDealJob触发器"; //把创建的任务和触发器注册到调度器中 scheduler.ScheduleJob(job, trigger); }
private void AddServiceOrderDealJob(IScheduler scheduler, System.Collections.IDictionary param) { JobDetail job = scheduler.GetJobDetail("ServiceOrderDealJob", "Jinher.AMP.BTP.Job"); job = new JobDetail("ServiceOrderDealJob", "Jinher.AMP.BTP.Job", typeof(ServiceOrderDealJob)); job.JobDataMap.PutAll(param); DateTime start = DateTime.UtcNow; //立即开始执行 每隔5分钟执行一次 SimpleTrigger trigger = new SimpleTrigger("ServiceOrderTrigger", "Jinher.AMP.BTP.Job", start, null, Jinher.JAP.Job.Engine.SimpleTrigger.RepeatIndefinitely, TimeSpan.FromMinutes(1)); trigger.Description = "ServiceOrderDealJob触发器"; scheduler.ScheduleJob(job, trigger); }
private void AddDownloadEInvoiceInfoJob(IScheduler scheduler, System.Collections.IDictionary param) { JobDetail job = scheduler.GetJobDetail("DownloadEInvoiceInfoJob", "Jinher.AMP.BTP.Job"); job = new JobDetail("DownloadEInvoiceInfoJob", "Jinher.AMP.BTP.Job", typeof(DownloadEInvoiceInfoJob)); job.JobDataMap.PutAll(param); DateTime start = DateTime.UtcNow; //立即开始执行 每隔1小时执行一次 SimpleTrigger trigger = new SimpleTrigger("DownloadEInvoiceInfoJob", "Jinher.AMP.BTP.Job", start, null, Jinher.JAP.Job.Engine.SimpleTrigger.RepeatIndefinitely, TimeSpan.FromHours(1)); trigger.Description = "DownloadEInvoiceInfoJob触发器"; scheduler.ScheduleJob(job, trigger); }
private void AddSendOrderInfoToYKBDMqJob(IScheduler scheduler, System.Collections.IDictionary param) { JobDetail job = scheduler.GetJobDetail("SendOrderInfoToYKBDMqJob", "Jinher.AMP.BTP.Job"); job = new JobDetail("SendOrderInfoToYKBDMqJob", "Jinher.AMP.BTP.Job", typeof(SendOrderInfoToYKBDMqJob)); job.JobDataMap.PutAll(param); DateTime start = DateTime.UtcNow; //每隔12小时执行一次 SimpleTrigger trigger = new SimpleTrigger("SendOrderInfoToYKBDMqTrigger", "Jinher.AMP.BTP.Job", start, null, Jinher.JAP.Job.Engine.SimpleTrigger.RepeatIndefinitely, TimeSpan.FromHours(12)); trigger.Description = "SendOrderInfoToYKBDMqJob触发器"; scheduler.ScheduleJob(job, trigger); }
private void StartTestScheduler() { IScheduler sched = GetTestScheduler(); sched.Start(); // construct job info JobDetail jobDetail = new JobDetail("myJob", null, typeof(sample.scheduler.core.ConsoleJob1)); // fire every hour Trigger trigger = TriggerUtils.MakeHourlyTrigger(); // start on the next even hour trigger.StartTimeUtc = TriggerUtils.GetEvenHourDate(DateTime.UtcNow); trigger.Name = "myTrigger"; sched.ScheduleJob(jobDetail, trigger); }
public List <JobDetail> ListJobs(string jobIdFilter) { if (string.IsNullOrEmpty(jobIdFilter)) { jobIdFilter = ".*"; } using (ILoggingOperation log = _logger.NormalOperation()) { return(log.Wrap <List <JobDetail> >(() => { List <JobDetail> result = new List <JobDetail>(); foreach (JobKey item in Global.Scheduler.GetJobKeys(GroupMatcher <JobKey> .GroupEquals(ServiceConstants.JobGroupName)) .Where(p => Regex.IsMatch(p.Name, jobIdFilter)) ) { IJobDetail detail = Global.Scheduler.GetJobDetail(item); IEnumerable <ITrigger> triggers = Global.Scheduler.GetTriggersOfJob(item); JobDetail jdet = new JobDetail() { JobId = item.Name, JobDataMap = detail.JobDataMap.ToDictionary(kv => kv.Key, kv => kv.Value.ToString()), Triggers = new List <TriggerDetail>(), Paused = triggers.Any(p => p.Key.Group == ServiceConstants.TriggerGroupName && Global.Scheduler.GetTriggerState(p.Key) == TriggerState.Paused) }; foreach (ITrigger trigger in triggers) { DateTimeOffset?nf = trigger.GetNextFireTimeUtc(); jdet.Triggers.Add(new TriggerDetail() { TriggerId = trigger.Key.ToString(), JobDataMap = trigger.JobDataMap.ToDictionary(kv => kv.Key, kv => kv.Value.ToString()), StartTime = trigger.StartTimeUtc.UtcDateTime, NextFireTime = nf.HasValue ? nf.Value.UtcDateTime : (DateTime?)null }); } result.Add(jdet); } return result; })); } }
private void LoadBatchQueue(DateTime nextRunFrom, DateTime nextRunTo) { ICommonHandler commonHandler = ServiceContainer.GetService <ICommonHandler>() as ICommonHandler; var lstAllQueue = commonHandler.GetTbs_BatchQueue(null, nextRunFrom, nextRunTo).OrderBy(q => q.NextRun).ThenBy(q => q.RunId).ToList(); foreach (var queueProxy in lstAllQueue) { var queue = CommonUtil.CloneObject <tbs_BatchQueue, tbs_BatchQueue>(queueProxy); JobDetail jobDetail = SequentialProcessJob.CreateJobDetail(queue, new QueueStatusUpdate(this.QueueStatusUpdate)); var scheduledQueue = _lstBatchQueue.Where(q => q.RunId == queue.RunId).FirstOrDefault(); if (scheduledQueue != null) { _lstBatchQueue.Remove(scheduledQueue); } if (queue.Status == "W") { Trigger trg = new SimpleTrigger(jobDetail.Name, null, queue.NextRun.ToUniversalTime(), null, 0, TimeSpan.Zero); if (_scheduler.GetJobDetail(jobDetail.Name, jobDetail.Group) != null) { _scheduler.DeleteJob(jobDetail.Name, jobDetail.Group); } _scheduler.ScheduleJob(jobDetail, trg); } _lstBatchQueue.Add(queue); } var lstCompleted = _lstBatchQueue.Where(q => q.Status == "C").ToList(); foreach (var queue in lstCompleted) { _lstBatchQueue.Remove(queue); } bsBatchQueue.ResetBindings(false); this.LastLoadedNextRun = nextRunTo; timLoadBatchQueue.Interval = (int)(nextRunTo.AddMinutes(-5) - DateTime.Now).TotalMilliseconds; timLoadBatchQueue.Enabled = true; }
/// <summary> /// Add the given trigger to the Scheduler, if it doesn't already exist. /// Overwrites the trigger in any case if "overwriteExistingJobs" is set. /// </summary> /// <param name="trigger">the trigger to add</param> /// <returns><code>true</code> if the trigger was actually added, <code>false</code> if it already existed before</returns> private bool AddTriggerToScheduler(Trigger trigger) { bool triggerExists = (GetScheduler().GetTrigger(trigger.Name, trigger.Group) != null); if (!triggerExists || this.overwriteExistingJobs) { // Check if the Trigger is aware of an associated JobDetail. if (trigger is IJobDetailAwareTrigger) { JobDetail jobDetail = ((IJobDetailAwareTrigger)trigger).JobDetail; // Automatically register the JobDetail too. if (!jobDetails.Contains(jobDetail) && AddJobToScheduler(jobDetail)) { jobDetails.Add(jobDetail); } } if (!triggerExists) { try { GetScheduler().ScheduleJob(trigger); } catch (ObjectAlreadyExistsException ex) { if (logger.IsDebugEnabled) { logger.Debug( "Unexpectedly found existing trigger, assumably due to cluster race condition: " + ex.Message + " - can safely be ignored"); } if (overwriteExistingJobs) { GetScheduler().RescheduleJob(trigger.Name, trigger.Group, trigger); } } } else { GetScheduler().RescheduleJob(trigger.Name, trigger.Group, trigger); } return(true); } else { return(false); } }
public void ExceptionJobUnscheduleFirinigTrigger() { sched.Start(); string jobName = "ExceptionPolicyUnscheduleFrinigTrigger"; string jobGroup = "ExceptionPolicyUnscheduleFrinigTriggerGroup"; JobDetail myDesc = new JobDetail(jobName, jobGroup, typeof(ExceptionJob)); myDesc.Durable = true; sched.AddJob(myDesc, false); string trigGroup = "ExceptionPolicyFrinigTriggerGroup"; Trigger trigger = new CronTrigger("trigName", trigGroup, "0/2 * * * * ?"); trigger.JobName = jobName; trigger.JobGroup = jobGroup; ExceptionJob.ThrowsException = true; ExceptionJob.LaunchCount = 0; ExceptionJob.Refire = false; ExceptionJob.UnscheduleFiringTrigger = true; ExceptionJob.UnscheduleAllTriggers = false; sched.ScheduleJob(trigger); Thread.Sleep(7 * 1000); sched.DeleteJob(jobName, jobGroup); Assert.AreEqual(1, ExceptionJob.LaunchCount, "The job shouldn't have been refired (UnscheduleFiringTrigger)"); ExceptionJob.LaunchCount = 0; ExceptionJob.UnscheduleFiringTrigger = true; ExceptionJob.UnscheduleAllTriggers = false; sched.AddJob(myDesc, false); trigger = new CronTrigger("trigName", trigGroup, "0/2 * * * * ?"); trigger.JobName = jobName; trigger.JobGroup = jobGroup; sched.ScheduleJob(trigger); trigger = new CronTrigger("trigName1", trigGroup, "0/3 * * * * ?"); trigger.JobName = jobName; trigger.JobGroup = jobGroup; sched.ScheduleJob(trigger); Thread.Sleep(7 * 1000); sched.DeleteJob(jobName, jobGroup); Assert.AreEqual(2, ExceptionJob.LaunchCount, "The job shouldn't have been refired(UnscheduleFiringTrigger)"); }
public string GetContentGenRecipesJson(string sContentUniqueId, string sContentHashCode) { JobDetail oJob = quartzScheduler.GetJobDetail(sContentUniqueId, ContentMonitorConstants.ContentMonitorGroupName); if (oJob != null) { try { return(ContentGenJob.ReadContentRecipesJson(sContentUniqueId, sContentHashCode)); } catch (Exception oEx) { throw new ApplicationException(string.Format(AppResource.ContentRecipesReadFailed, oEx.Message), oEx); } } return(""); }
public void TestMethodInvokingJobDetailFactoryObjectWithListenerNames() { TestMethodInvokingTask task = new TestMethodInvokingTask(); MethodInvokingJobDetailFactoryObject mijdfb = new MethodInvokingJobDetailFactoryObject(); String[] names = new String[] { "test1", "test2" }; mijdfb.Name = ("myJob1"); mijdfb.Group = (SchedulerConstants.DefaultGroup); mijdfb.TargetObject = (task); mijdfb.TargetMethod = ("doSomething"); mijdfb.JobListenerNames = (names); mijdfb.AfterPropertiesSet(); JobDetail jobDetail = (JobDetail)mijdfb.GetObject(); ArrayList result = new ArrayList(jobDetail.JobListenerNames); Assert.AreEqual(names, result); }
public void ChangeTaskDescription() { int id = 2;//Try to change the task with id JobDetail task = new JobDetail { Id = id, Day = unit.Calendar.Get(1), Project = unit.Projects.Get(1), Description = "Unit tests for TimeKeeper project" }; unit.Tasks.Update(task, id); int numberOfChanges = unit.Save(); Assert.AreEqual(1, numberOfChanges); Assert.AreEqual("Unit tests for TimeKeeper project", task.Description); }
public async Task InsertTask() { var controller = new TasksController(unit.Context); JobDetail task = new JobDetail { Day = unit.Calendar.Get(1), Project = unit.Projects.Get(1) }; var response = await controller.Post(task) as ObjectResult; var value = response.Value as JobDetailModel; Assert.AreEqual(200, response.StatusCode); Assert.AreEqual(98, value.Id);//Id of the new task will be 98 }
public static void CreateJob() { //每隔一段时间执行任务 IScheduler sched; ISchedulerFactory sf = new StdSchedulerFactory(); sched = sf.GetScheduler(); JobDetail job = new JobDetail("job1", "group1", typeof(IndexJob)); //IndexJob为实现了IJob接口的类 DateTime ts = TriggerUtils.GetNextGivenSecondDate(null, 59); //5秒后开始第一次运行 TimeSpan interval = TimeSpan.FromHours(3); //每隔30天执行一次 Trigger trigger = new SimpleTrigger("trigger1", "group1", "job1", "group1", ts, null, SimpleTrigger.RepeatIndefinitely, interval); //每若干小时运行一次,小时间隔由appsettings中的IndexIntervalHour参数指定 sched.AddJob(job, true); sched.ScheduleJob(trigger); sched.Start(); }
private void toolStripButtonAdd_Click(object sender, EventArgs e) { switch (_gridTypeEnumNow) { case ViewTypeEnum.JOB: var job = new JobDetail(null, _jobLogic); _refreshGrid = true; job.ShowDialog(); break; case ViewTypeEnum.TRIGGER: var trig = new TriggerDetail(null, Jobs, _triggerLogic); _refreshGrid = true; trig.ShowDialog(); break; } }
public async Task UploadFileSuccess() { //arrange JobDetail jobDetail = new JobDetail() { AWS_BATCH_JOB_ID = Guid.NewGuid().ToString(), SourceBucketName = "mjsaws-demo-s3", SourceKeyName = "green_tripdata_2018-01.csv" }; StorageHelper storageHelper = new StorageHelper(); //act var result = await storageHelper.StreamS3ObjectToString(jobDetail); //assert Assert.NotEqual(null, result); }
static void Main(string[] args) { IScheduler sched; ISchedulerFactory sf = new StdSchedulerFactory(); sched = sf.GetScheduler(); JobDetail job = new JobDetail("job1", "group1", typeof(IndexJob)); //IndexJob为实现了IJob接口的类 DateTime ts = TriggerUtils.GetNextGivenSecondDate(null, 5); //5秒后开始第一次运行 TimeSpan interval = TimeSpan.FromSeconds(5); //每隔1小时执行一次 Trigger trigger = new SimpleTrigger("trigger1", "group1", "job1", "group1", ts, null, SimpleTrigger.RepeatIndefinitely, interval); //每若干小时运行一次,小时间隔由appsettings中的IndexIntervalHour参数指定 sched.AddJob(job, true); sched.ScheduleJob(trigger); sched.Start(); Console.ReadKey(); }
public void TestRemoveJobListener() { string[] listenerNames = new string[] { "X", "A", "B" }; JobDetail jobDetail = new JobDetail(); for (int i = 0; i < listenerNames.Length; i++) { jobDetail.AddJobListener(listenerNames[i]); } // Make sure uniqueness is enforced for (int i = 0; i < listenerNames.Length; i++) { Assert.IsTrue(jobDetail.RemoveJobListener(listenerNames[i])); } }
public void Start() { // construct a scheduler factory ISchedulerFactory schedFact = new StdSchedulerFactory(); // get a scheduler IScheduler sched = schedFact.GetScheduler(); sched.JobFactory = _jobFactory; sched.Start(); // construct job info JobDetail jobDetail = new JobDetail("myJob", null, typeof(HelloJob)); // fire every hour Trigger trigger = TriggerUtils.MakeSecondlyTrigger(5); trigger.Name = "myTrigger"; sched.ScheduleJob(jobDetail, trigger); }
public async Task ChangeTaskWithWrongId() { var controller = new TasksController(unit.Context); int id = 140;//Try to change the task with id (doesn't exist) JobDetail task = new JobDetail { Id = id, Day = unit.Calendar.Get(1), Project = unit.Projects.Get(1), Hours = 7 }; var response = await controller.Put(id, task) as ObjectResult; Assert.AreEqual(404, response.StatusCode); }
public void Should_be_possible_to_schedule_a_job_to_3_seconds_from_now() { IScheduler scheduler = this.GetScheduler(); scheduler.Start(); JobDetail job = new JobDetail("Scheduler job", null, typeof(TestJob)); Trigger trigger = TriggerUtils.MakeSecondlyTrigger(3, 0); trigger.Name = "TriggerForTest"; trigger.StartTimeUtc = DateTime.UtcNow.AddSeconds(3); scheduler.ScheduleJob(job, trigger); Thread.Sleep(8000); // because the time of the job is 4 seconds Assert.IsTrue(this.jobExecution.Executions.Count() > 0); Assert.AreEqual(1, this.jobExecution.Executions.Count()); }
public async Task <IActionResult> Get(int id) { try { Logger.Info($"Try to get task with {id}"); JobDetail task = await Unit.Tasks.GetAsync(id); if (!resourceAccess.HasRight(GetUserClaims(), task)) { return(Unauthorized()); } return(Ok(task.Create())); } catch (Exception ex) { return(HandleException(ex)); } }
public string GetContentMonitoringJson(string sContentUniqueId) { JobDetail oJob = quartzScheduler.GetJobDetail(sContentUniqueId, ContentMonitorConstants.ContentMonitorGroupName); if (oJob != null) { try { string sContentDetailJson = (string)oJob.JobDataMap[ContentMonitorJobDataMapConstants.ContentDetail]; return(sContentDetailJson == null ? "" : sContentDetailJson); } catch (Exception oEx) { throw new ApplicationException(string.Format(AppResource.ContentDetailReadFailed, oEx.Message), oEx); } } return(""); }
private void ScheduleCronJob() { string jobName = JobName; string jobGroup = jobName + "Group"; string cronExpression = config != null ? config.Configuration : ""; var trigger = new CronTrigger(jobName, jobGroup, cronExpression) { StartTimeUtc = DateTime.UtcNow, MisfireInstruction = MisfireInstruction.CronTrigger.DoNothing }; var job = new JobDetail(jobName, typeof(TJob)); scheduler.ScheduleJob(job, trigger); log.InfoFormat("{0} scheduled with cron expression {1}", jobName, cronExpression); }
private void TriggerJobOfContentVersion <T>(string sJobName, string sGroupName, string sContentUniqueId, string sContentHashCode) { lock (quartzScheduler) { // Create a job of type T if none has existed if (null == quartzScheduler.GetJobDetail(sJobName, sGroupName)) { // Create a durable job of type T and add to the scheduler JobDetail oJob = new JobDetail(sJobName, sGroupName, typeof(T), false, true, false); quartzScheduler.AddJob(oJob, true); } // Create and initialize the trigger for the specific job request JobDataMap oJobDataMap = new JobDataMap(); oJobDataMap[GeneralJobDataMapConstants.ContentUniqueId] = sContentUniqueId; oJobDataMap[GeneralJobDataMapConstants.ContentHashCode] = sContentHashCode; quartzScheduler.TriggerJobWithVolatileTrigger(sJobName, sGroupName, oJobDataMap); } }
public void ChangeNonExistingTask() { //Try to change the task with id (doesn't exist) int id = 140; JobDetail task = new JobDetail { Id = id, Day = unit.Calendar.Get(75), Project = unit.Projects.Get(2) }; var ex = Assert.Throws <ArgumentException>(() => unit.Tasks.Update(task, id)); Assert.AreEqual(ex.Message, $"There is no object with id: {id} in the database"); int numberOfChanges = unit.Save(); Assert.AreEqual(0, numberOfChanges); }
public ActionResult Create([Bind(Include = "Id,Job_title,Job_desc,Image_Id,User_Id,Cat_Id,Creation_Date")] JobDetail jobDetail, HttpPostedFileBase Upload) { if (ModelState.IsValid) { string path = Path.Combine(Server.MapPath("~/Uploads"), Upload.FileName); Upload.SaveAs(path); jobDetail.Image_Id = Upload.FileName; jobDetail.User_Id = User.Identity.GetUserId(); jobDetail.Creation_Date = DateTime.Now; db.JobDetails.Add(jobDetail); db.SaveChanges(); return(RedirectToAction("Index")); } // ViewBag.User_Id = new SelectList(db.AspNetUsers, "Id", "Email", jobDetail.User_Id); ViewBag.Cat_Id = new SelectList(db.Categories, "Id", "Name", jobDetail.Cat_Id); return(View(jobDetail)); }
static void Main(string[] args) { ISchedulerFactory schedFact = new StdSchedulerFactory(); IScheduler scheduler = schedFact.GetScheduler(); IJobListener retryableJobListener = new RetryableJobListener(scheduler); scheduler.AddGlobalJobListener(retryableJobListener); scheduler.Start(); // construct job info JobDetail jobDetail = new JobDetail("DummyJob", null, typeof(DummyJob)); // fire only once Trigger trigger = TriggerUtils.MakeImmediateTrigger(0, TimeSpan.Zero); trigger.Name = "Chuck Norris"; // start scheduler.ScheduleJob(jobDetail, trigger); }
// GET: ManageBookings/Edit/5 public ActionResult Edit(int?id) { ViewBag.EmployeeList = new SelectList(GetEmployees(), "EmployeeFirstName", "EmployeeFirstName"); ViewBag.StatusList = new SelectList(GetStatusTables(), "BookingStatus", "BookingStatus"); if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } JobDetail jobCardDetail = db.JobDetails.Find(id); if (jobCardDetail == null) { return(HttpNotFound()); } ViewBag.BookingId = new SelectList(db.CustomersBookings, "BookingId", "CustomerName", jobCardDetail.BookingId); return(View(jobCardDetail)); }
private void ScheduleAllJobs() { List <JobItem> jobs = jobLoader.LoadJobs(); foreach (var jobItem in jobs) { logger.Debug("Scheduler Job: " + jobItem.Name); if (!jobItem.Enabled) { continue; } JobDetail jobDetail = BuildJobDetail(jobItem); Trigger trigger = BuildTrigger(jobItem); scheduler.ScheduleJob(jobDetail, trigger); } }
public ResultModel Insert(string userId, JobDetail obj) { JobDetail objt = new JobDetail(); LoadModel(obj, objt); try { DataContext.JobDetails.InsertOnSubmit(objt); DataContext.SubmitChanges(); } catch (Exception e) { Console.WriteLine(e); DataContext.SubmitChanges(); } return(ResultModel.SuccessResult()); }
public static void ScheduleZmanJob(string name, DateTime dateToStart, IScheduler scheduler, ReminderService reminderService, Account account) { DateTime date = GetNextZmanDateTime(dateToStart, reminderService.Location, reminderService.ZmanName, reminderService.SkipIfPassedRunBeforeZmanSeconds ? reminderService.AddSeconds : 0); var jobDetail = new JobDetail(name, null, GetJobType(reminderService.JobToRun)); jobDetail.JobDataMap["ReminderService"] = reminderService; jobDetail.JobDataMap["Account"] = account; jobDetail.JobDataMap["Location"] = reminderService.Location; var trigger = new SimpleTrigger(name, date.AddSeconds(reminderService.AddSeconds), date, 0, TimeSpan.Zero); scheduler.ScheduleJob(jobDetail, trigger); }
/// <summary> /// Gets the job detail. /// </summary> /// <param name="synchronizer">The synchronizer.</param> /// <returns>JobDetail.</returns> private JobDetail GetJobDetail(IProcessSynchronizer synchronizer) { var jobName = GetJobName(synchronizer); var jobDetail = Scheduler.GetJobDetail(jobName, QuartzGroupName); if (jobDetail != null && jobDetail.JobType != typeof(SyncProcessWorker)) { Scheduler.DeleteJob(jobName, QuartzGroupName); jobDetail = null; } if (jobDetail != null) return jobDetail; jobDetail = new JobDetail(jobName, QuartzGroupName, typeof(SyncProcessWorker), false, true, false); jobDetail.JobDataMap["processName"] = synchronizer.ProcessName; jobDetail.JobDataMap["syncProcessGuid"] = synchronizer.Guid; Scheduler.AddJob(jobDetail, true); return jobDetail; }
public List<JobDetail> GetJobDetailsInGroup(string group) { var groupMatcher = GroupMatcher<JobKey>.GroupContains(group); var jobKeys = scheduler.GetJobKeys(groupMatcher); List<JobDetail> jobList = new List<JobDetail>(); foreach (var jobKey in jobKeys) { var iJobDetail = scheduler.GetJobDetail(jobKey); JobDetail jd = new JobDetail(); jd.JobKey = iJobDetail.Key.Name; jd.Group = iJobDetail.Key.Group; jd.Type = iJobDetail.JobType.ToString(); jd.Description = iJobDetail.Description; jd.JobData = JobManagerUtility.GetJobDataMapSitecoreString(iJobDetail.JobDataMap); jobList.Add(jd); } return jobList; }
/// <summary> /// Inform the <see cref="IJobStore" /> that the scheduler has completed the /// firing of the given <see cref="Trigger" /> (and the execution its /// associated <see cref="IJob" />), and that the <see cref="JobDataMap" /> /// in the given <see cref="JobDetail" /> should be updated if the <see cref="IJob" /> /// is stateful. /// </summary> public virtual void TriggeredJobComplete(SchedulingContext ctxt, Trigger trigger, JobDetail jobDetail, SchedulerInstruction triggerInstCode) { lock (triggerLock) { string jobKey = JobWrapper.GetJobNameKey(jobDetail.Name, jobDetail.Group); JobWrapper jw = (JobWrapper) jobsByFQN[jobKey]; TriggerWrapper tw = (TriggerWrapper) triggersByFQN[TriggerWrapper.GetTriggerNameKey(trigger)]; // It's possible that the job is null if: // 1- it was deleted during execution // 2- RAMJobStore is being used only for volatile jobs / triggers // from the JDBC job store if (jw != null) { JobDetail jd = jw.jobDetail; if (jobDetail.Stateful) { JobDataMap newData = jobDetail.JobDataMap; if (newData != null) { newData = (JobDataMap)newData.Clone(); newData.ClearDirtyFlag(); } jd.JobDataMap = newData; blockedJobs.Remove(JobWrapper.GetJobNameKey(jd)); ArrayList trigs = GetTriggerWrappersForJob(jd.Name, jd.Group); foreach (TriggerWrapper ttw in trigs) { if (ttw.state == InternalTriggerState.Blocked) { ttw.state = InternalTriggerState.Waiting; timeTriggers.Add(ttw); } if (ttw.state == InternalTriggerState.PausedAndBlocked) { ttw.state = InternalTriggerState.Paused; } } signaler.SignalSchedulingChange(null); } } else { // even if it was deleted, there may be cleanup to do blockedJobs.Remove(JobWrapper.GetJobNameKey(jobDetail)); } // check for trigger deleted during execution... if (tw != null) { if (triggerInstCode == SchedulerInstruction.DeleteTrigger) { log.Debug("Deleting trigger"); NullableDateTime d = trigger.GetNextFireTimeUtc(); if (!d.HasValue) { // double check for possible reschedule within job // execution, which would cancel the need to delete... d = tw.Trigger.GetNextFireTimeUtc(); if (!d.HasValue) { RemoveTrigger(ctxt, trigger.Name, trigger.Group); } else { log.Debug("Deleting cancelled - trigger still active"); } } else { RemoveTrigger(ctxt, trigger.Name, trigger.Group); signaler.SignalSchedulingChange(null); } } else if (triggerInstCode == SchedulerInstruction.SetTriggerComplete) { tw.state = InternalTriggerState.Complete; timeTriggers.Remove(tw); signaler.SignalSchedulingChange(null); } else if (triggerInstCode == SchedulerInstruction.SetTriggerError) { Log.Info(string.Format(CultureInfo.InvariantCulture, "Trigger {0} set to ERROR state.", trigger.FullName)); tw.state = InternalTriggerState.Error; signaler.SignalSchedulingChange(null); } else if (triggerInstCode == SchedulerInstruction.SetAllJobTriggersError) { Log.Info(string.Format(CultureInfo.InvariantCulture, "All triggers of Job {0} set to ERROR state.", trigger.FullJobName)); SetAllTriggersOfJobToState(trigger.JobName, trigger.JobGroup, InternalTriggerState.Error); signaler.SignalSchedulingChange(null); } else if (triggerInstCode == SchedulerInstruction.SetAllJobTriggersComplete) { SetAllTriggersOfJobToState(trigger.JobName, trigger.JobGroup, InternalTriggerState.Complete); signaler.SignalSchedulingChange(null); } } } }
private void ProcessJobs(quartz data) { if (data.job == null) { // no jobs to process, file is empty return; } foreach (jobType jt in data.job) { JobSchedulingBundle jsb = new JobSchedulingBundle(); jobdetailType j = jt.jobdetail; Type jobType = Type.GetType(j.jobtype); if (jobType == null) { throw new SchedulerConfigException("Unknown job type " + j.jobtype); } JobDetail jd = new JobDetail(j.name, j.group, jobType, j.@volatile, j.durable, j.recover); jd.Description = j.description; if (j.joblistenerref != null && j.joblistenerref.Trim().Length > 0) { jd.AddJobListener(j.joblistenerref); } jsb.JobDetail = jd; // read job data map if (j.jobdatamap != null && j.jobdatamap.entry != null) { foreach (entryType entry in j.jobdatamap.entry) { jd.JobDataMap.Put(entry.key, entry.value); } } triggerType[] tArr = jt.trigger; if (tArr == null) { // set to empty tArr = new triggerType[0]; } foreach (triggerType t in tArr) { Trigger trigger; if (t.Item is cronType) { cronType c = (cronType) t.Item; DateTime startTime = (c.starttime == DateTime.MinValue ? DateTime.UtcNow : c.starttime); NullableDateTime endTime = (c.endtime == DateTime.MinValue ? null : (NullableDateTime)c.endtime); string jobName = c.jobname != null ? c.jobname : j.name; string jobGroup = c.jobgroup != null ? c.jobgroup : j.group; CronTrigger ct = new CronTrigger( c.name, c.group, jobName, jobGroup, startTime, endTime, c.cronexpression); if (c.timezone != null && c.timezone.Trim().Length > 0) { #if NET_35 ct.TimeZone = TimeZoneInfo.FindSystemTimeZoneById(c.timezone); #else throw new ArgumentException( "Specifying time zone for cron trigger is only supported in .NET 3.5 builds"); #endif } trigger = ct; } else if (t.Item is simpleType) { simpleType s = (simpleType) t.Item; DateTime startTime = (s.starttime == DateTime.MinValue ? DateTime.UtcNow : s.starttime); NullableDateTime endTime = (s.endtime == DateTime.MinValue ? null : (NullableDateTime)s.endtime); string jobName = s.jobname != null ? s.jobname : j.name; string jobGroup = s.jobgroup != null ? s.jobgroup : j.group; SimpleTrigger st = new SimpleTrigger( s.name, s.group, jobName, jobGroup, startTime, endTime, ParseSimpleTriggerRepeatCount(s.repeatcount), TimeSpan.FromMilliseconds(Convert.ToInt64(s.repeatinterval, CultureInfo.InvariantCulture))); trigger = st; } else { throw new ArgumentException("Unknown trigger type in XML"); } trigger.Description = t.Item.description; trigger.CalendarName = t.Item.calendarname; if (t.Item.misfireinstruction != null) { trigger.MisfireInstruction = ReadMisfireInstructionFromString(t.Item.misfireinstruction); } if (t.Item.jobdatamap != null && t.Item.jobdatamap.entry != null) { foreach (entryType entry in t.Item.jobdatamap.entry) { if (trigger.JobDataMap.Contains(entry.key)) { Log.Warn("Overriding key '" + entry.key + "' with another value in same trigger job data map"); } trigger.JobDataMap[entry.key] = entry.value; } } if (t.Item.triggerlistenerref != null && t.Item.triggerlistenerref.Trim().Length > 0) { trigger.AddTriggerListener(t.Item.triggerlistenerref); } jsb.Triggers.Add(trigger); } AddJobToSchedule(jsb); } }
/// <summary> /// Completes the trigger retry loop. /// </summary> /// <param name="trigger">The trigger.</param> /// <param name="jobDetail">The job detail.</param> /// <param name="instCode">The inst code.</param> /// <returns></returns> public virtual bool CompleteTriggerRetryLoop(Trigger trigger, JobDetail jobDetail, SchedulerInstruction instCode) { long count = 0; while (!shutdownRequested) { // FIXME: jhouse: note that there is no longer anthing that calls requestShutdown() try { Thread.Sleep(TimeSpan.FromSeconds(15)); // retry every 15 seconds (the db // connection must be failed) qs.NotifyJobStoreJobComplete(schdCtxt, trigger, jobDetail, instCode); return true; } catch (JobPersistenceException jpe) { if (count % 4 == 0) qs.NotifySchedulerListenersError( "An error occured while marking executed job complete (will continue attempts). job= '" + jobDetail.FullName + "'", jpe); } catch (ThreadInterruptedException) { } count++; } return false; }
/// <summary> /// Store the given <see cref="IJob" />. /// </summary> /// <param name="ctxt">The scheduling context.</param> /// <param name="newJob">The <see cref="IJob" /> to be stored.</param> /// <param name="replaceExisting">If <see langword="true" />, any <see cref="IJob" /> existing in the /// <see cref="IJobStore" /> with the same name and group should be /// over-written.</param> public virtual void StoreJob(SchedulingContext ctxt, JobDetail newJob, bool replaceExisting) { JobWrapper jw = new JobWrapper((JobDetail)newJob.Clone()); bool repl = false; if (jobsByFQN[jw.key] != null) { if (!replaceExisting) { throw new ObjectAlreadyExistsException(newJob); } repl = true; } lock (triggerLock) { if (!repl) { // get job group IDictionary grpMap = (Hashtable) jobsByGroup[newJob.Group]; if (grpMap == null) { grpMap = new Hashtable(100); jobsByGroup[newJob.Group] = grpMap; } // add to jobs by group grpMap[newJob.Name] = jw; // add to jobs by FQN map jobsByFQN[jw.key] = jw; } else { // update job detail JobWrapper orig = (JobWrapper) jobsByFQN[jw.key]; orig.jobDetail = jw.jobDetail; } } }
/// <summary> /// Calls the equivalent method on the 'proxied' <see cref="QuartzScheduler" />, /// passing the <see cref="SchedulingContext" /> associated with this /// instance. /// </summary> public virtual void AddJob(JobDetail jobDetail, bool replace) { sched.AddJob(schedCtxt, jobDetail, replace); }
internal JobWrapper(JobDetail jobDetail) { this.jobDetail = jobDetail; key = GetJobNameKey(jobDetail); }
/// <summary> /// Store the given <see cref="JobDetail" /> and <see cref="Trigger" />. /// </summary> /// <param name="ctxt">The scheduling context.</param> /// <param name="newJob">The <see cref="JobDetail" /> to be stored.</param> /// <param name="newTrigger">The <see cref="Trigger" /> to be stored.</param> public virtual void StoreJobAndTrigger(SchedulingContext ctxt, JobDetail newJob, Trigger newTrigger) { StoreJob(ctxt, newJob, false); StoreTrigger(ctxt, newTrigger, false); }
/// <summary> /// Gets the trigger. /// </summary> /// <param name="schedule">The schedule.</param> /// <param name="jobDetail">The job detail.</param> /// <returns>Trigger.</returns> private Trigger GetTrigger(ISchedule schedule, JobDetail jobDetail) { var startDate = schedule.StartDate.HasValue ? schedule.StartDate.Value : DateTime.Now; var triggerName = GetTriggerName(schedule); if (schedule.EndDate.HasValue && (startDate.ToUniversalTime() > schedule.EndDate.Value)) return null; var trigger = TriggerFactory.CreateTrigger(schedule); trigger.Name = triggerName; trigger.Group = QuartzGroupName; trigger.JobName = jobDetail.Name; trigger.JobGroup = jobDetail.Group; trigger.StartTimeUtc = startDate.ToUniversalTime(); trigger.EndTimeUtc = schedule.EndDate.HasValue ? schedule.EndDate.Value.ToUniversalTime() : (DateTime?)null; return trigger; }
public JobDetail GetJobDetails(string jobID) { Log.Info("Calling FindById on JobDetail Entity Service Repository with Job Id : " + jobID, this); var jobDetail = Sitecore.Data.Database.GetDatabase("master").GetItem(new ID(jobID)); if (jobDetail != null) { JobDetail jd = new JobDetail() { Id = jobDetail.ID.ToString(), Description = jobDetail["Description"], JobKey = jobDetail["Job Key"], Type = jobDetail["Type"], Group = jobDetail["Group"], JobData = jobDetail["Job Data Map"] }; return jd; } else { return null; } }
private TriggerBuilder GetTriggerBuilder(JobDetail jd, TriggerDetail td) { var trigger = TriggerBuilder.Create(); trigger.WithIdentity(td.TriggerKey, jd.Group); trigger.ForJob(jd.JobKey); trigger.WithPriority(td.Priority); trigger.StartAt(td.StartTime); if (td.EndTime != null && !td.EndTime.Equals(DateTime.MinValue)) trigger.EndAt(td.EndTime); switch (td.ScheduleTypeValue.ToLower()) { case "seconds": if (td.RepeatInterval > 0) { if (td.RepeatCount > 0) { trigger = trigger.WithSimpleSchedule(x => x .WithIntervalInSeconds(td.RepeatInterval) .WithRepeatCount(td.RepeatCount) ); } else { trigger = trigger.WithSimpleSchedule(x => x .WithIntervalInSeconds(td.RepeatInterval) .RepeatForever() ); } } else Log.Warn(String.Format("Job {0} was configured with {1} schedule but no Repeat Interval mentioned. Please configure the Repeat Interval correctly !!", jd.JobKey, td.ScheduleType), this); Diagnostics.Log.Info(String.Format("ScheduleType {0} and Schedule : {1})", td.ScheduleType, trigger.ToString()), this); break; case "minutes": if (td.RepeatInterval > 0) { if (td.RepeatCount > 0) { trigger = trigger.WithSimpleSchedule(x => x .WithIntervalInMinutes(td.RepeatInterval) .WithRepeatCount(td.RepeatCount) ); } else { trigger = trigger.WithSimpleSchedule(x => x .WithIntervalInMinutes(td.RepeatInterval) .RepeatForever() ); } } else Log.Warn(String.Format("Job {0} was configured with {1} schedule but no Repeat Interval mentioned. Please configure the Repeat Interval correctly !!", jd.JobKey, td.ScheduleType), this); Diagnostics.Log.Info(String.Format("ScheduleType {0} and Schedule : {1})", td.ScheduleType, trigger.ToString()), this); break; case "hours": if (td.RepeatInterval > 0) { if (td.RepeatCount > 0) { trigger = trigger.WithSimpleSchedule(x => x .WithIntervalInHours(td.RepeatInterval) .WithRepeatCount(td.RepeatCount) ); } else { trigger = trigger.WithSimpleSchedule(x => x .WithIntervalInHours(td.RepeatInterval) .RepeatForever() ); } } else Log.Warn(String.Format("Job {0} was configured with {1} schedule but no Repeat Interval mentioned. Please configure the Repeat Interval correctly !!", jd.JobKey, td.ScheduleType), this); Diagnostics.Log.Info(String.Format("ScheduleType {0} and Schedule : {1})", td.ScheduleType, trigger.ToString()), this); break; case "daily": trigger.WithSchedule(CronScheduleBuilder.DailyAtHourAndMinute(td.StartTime.Hour, td.StartTime.Minute)); break; case "weekly": //Convert Sitecore DaysOfWeeks property to System.DaysOfWeek which is understood by Quartz.net if (td.DaysOfWeeks != null && td.DaysOfWeeks.Count > 0) { System.DayOfWeek[] dayOfWeeks = new System.DayOfWeek[td.DaysOfWeeks.Count]; for (int i = 0; i < td.DaysOfWeeks.Count; i++) { dayOfWeeks[i] = (System.DayOfWeek)Enum.Parse(typeof(System.DayOfWeek), td.DaysOfWeeks[i].DayOfWeekValue.ToString()); } trigger.WithSchedule(CronScheduleBuilder.AtHourAndMinuteOnGivenDaysOfWeek(td.StartTime.Hour, td.StartTime.Minute, dayOfWeeks)); } else { Log.Warn(String.Format("Job {0} was configured with {1} schedule but \"Day of Weeks\" was not set correctly. Please configure the trigger correctly !!", jd.JobKey, td.ScheduleType), this); } break; case "monthly": if (td.DayOfMonth > 0) trigger.WithSchedule(CronScheduleBuilder.MonthlyOnDayAndHourAndMinute(td.DayOfMonth, td.StartTime.Hour, td.StartTime.Minute)); else Log.Warn(String.Format("Job {0} was configured with {1} schedule but \"Day of Month\" was not set correctly. Please configure the trigger correctly !!", jd.JobKey, td.ScheduleType), this); break; case "custom": if (!String.IsNullOrEmpty(td.CronExpression)) trigger.WithSchedule(CronScheduleBuilder.CronSchedule(new CronExpression(td.CronExpression))); else Log.Warn(String.Format("Job {0} was configured with {1} schedule but \"Cron Expression\" was not set correctly. Please configure the trigger correctly !!", jd.JobKey, td.ScheduleType), this); break; } return trigger; }
/// <summary> /// Vetoeds the job retry loop. /// </summary> /// <param name="trigger">The trigger.</param> /// <param name="jobDetail">The job detail.</param> /// <param name="instCode">The inst code.</param> /// <returns></returns> public bool VetoedJobRetryLoop(Trigger trigger, JobDetail jobDetail, SchedulerInstruction instCode) { while (!shutdownRequested) { try { Thread.Sleep(5 * 1000); // retry every 5 seconds (the db // connection must be failed) qs.NotifyJobStoreJobVetoed(schdCtxt, trigger, jobDetail, instCode); return true; } catch (JobPersistenceException jpe) { qs.NotifySchedulerListenersError( string.Format(CultureInfo.InvariantCulture, "An error occured while marking executed job vetoed. job= '{0}'", jobDetail.FullName), jpe); } catch (ThreadInterruptedException) { } } return false; }
/// <summary> /// Calls the equivalent method on the 'proxied' <see cref="QuartzScheduler" />, /// passing the <see cref="SchedulingContext" /> associated with this /// instance. /// </summary> public virtual DateTime ScheduleJob(JobDetail jobDetail, Trigger trigger) { try { return GetRemoteScheduler().ScheduleJob(schedCtxt, jobDetail, trigger); } catch (RemotingException re) { throw InvalidateHandleCreateException("Error communicating with remote scheduler.", re); } }
public List<TriggerDetail> GetTriggersForJob(JobDetail jobDetail) { Database masterDb = Factory.GetDatabase("master"); //Get the trigger definitions for this job string quartzJobTriggersQuery = "fast://" + GetJobDefinitionLocation() + "//*[@@parentid='" + jobDetail.Id + "']//*[@@templateid='" + Common.Constants.TriggerDetailTempalteID + "']"; Item[] quartzJobTriggers = masterDb.SelectItems(quartzJobTriggersQuery); List<TriggerDetail> lstTriggers = new List<TriggerDetail>(); if (quartzJobTriggers != null && quartzJobTriggers.Length > 0) { foreach (Item triggerItem in quartzJobTriggers) { TriggerDetail triggerDetail = new TriggerDetail(); triggerDetail.Id = triggerItem.ID.ToString(); triggerDetail.ParentItemId = jobDetail.Id; triggerDetail.TriggerKey = triggerItem["Trigger Key"]; if (!String.IsNullOrEmpty(triggerItem.Fields["Start Time"].Value)) { triggerDetail.StartTime = ((DateField)triggerItem.Fields["Start Time"]).DateTime; } if (!String.IsNullOrEmpty(triggerItem.Fields["End Time"].Value)) { triggerDetail.EndTime = ((DateField)triggerItem.Fields["End Time"]).DateTime; } if (!String.IsNullOrEmpty(triggerItem.Fields["Priority"].Value)) { triggerDetail.Priority = int.Parse(triggerItem.Fields["Priority"].Value); } if (!String.IsNullOrEmpty(triggerItem.Fields["Day of Month"].Value)) triggerDetail.DayOfMonth = int.Parse(triggerItem["Day of Month"]); //if (!String.IsNullOrEmpty(triggerItem.Fields["Repeat Every"].Value)) // triggerDetail.IntervalUnit = triggerItem["Repeat Every"]; if (!String.IsNullOrEmpty(triggerItem.Fields["Repeat Interval"].Value)) triggerDetail.RepeatInterval = int.Parse(triggerItem["Repeat Interval"]); if (!String.IsNullOrEmpty(triggerItem.Fields["Repeat Count"].Value)) triggerDetail.RepeatCount = int.Parse(triggerItem["Repeat Count"]); if (!String.IsNullOrEmpty(triggerItem.Fields["Schedule Type"].Value)) { triggerDetail.ScheduleType = triggerItem.Fields["Schedule Type"].Value; } if (!String.IsNullOrEmpty(triggerItem.Fields["Cron Expression"].Value)) triggerDetail.CronExpression = triggerItem["Cron Expression"]; lstTriggers.Add(triggerDetail); } //end for loop for triggers } //end if return lstTriggers; }
/// <summary> /// Calls the equivalent method on the 'proxied' <see cref="QuartzScheduler" />, /// passing the <see cref="SchedulingContext" /> associated with this /// instance. /// </summary> public virtual DateTime ScheduleJob(JobDetail jobDetail, Trigger trigger) { return sched.ScheduleJob(schedCtxt, jobDetail, trigger); }
/// <summary> /// Calls the equivalent method on the 'proxied' <see cref="QuartzScheduler" />, /// passing the <see cref="SchedulingContext" /> associated with this /// instance. /// </summary> public virtual void AddJob(JobDetail jobDetail, bool replace) { try { GetRemoteScheduler().AddJob(schedCtxt, jobDetail, replace); } catch (RemotingException re) { throw InvalidateHandleCreateException("Error communicating with remote scheduler.", re); } }
/// <summary> /// Called when the associated <see cref="IScheduler"/> is started, in order /// to let the plug-in know it can now make calls into the scheduler if it /// needs to. /// </summary> public virtual void Start() { try { if (jobFiles.Count > 0) { if (scanInterval > TimeSpan.Zero) { scheduler.Context.Put(JobInitializationPluginName + '_' + Name, this); } foreach (JobFile jobFile in jobFiles.Values) { if (scanInterval > TimeSpan.Zero) { String jobTriggerName = BuildJobTriggerName(jobFile.FileBasename); SimpleTrigger trig = new SimpleTrigger( jobTriggerName, JobInitializationPluginName, DateTime.UtcNow, null, SimpleTrigger.RepeatIndefinitely, scanInterval); trig.Volatile = true; JobDetail job = new JobDetail( jobTriggerName, JobInitializationPluginName, typeof(FileScanJob)); job.Volatile = true; job.JobDataMap.Put(FileScanJob.FileName, jobFile.FilePath); job.JobDataMap.Put(FileScanJob.FileScanListenerName, JobInitializationPluginName + '_' + Name); scheduler.ScheduleJob(job, trig); } ProcessFile(jobFile); } } } catch (SchedulerException se) { Log.Error("Error starting background-task for watching jobs file.", se); } finally { started = true; } }
internal JobWrapper(JobDetail jobDetail, string key) { this.jobDetail = jobDetail; this.key = key; }
public List<JobDetail> GetConfiguredJobs() { List<JobDetail> lstJobs = new List<JobDetail>(); //get a list of all Quartz Scheduler Items including JobDetails and Triggers string jobsDefinitionsQuery = "fast://" + GetJobDefinitionLocation() + "//*[@@templateid='" + Common.Constants.JobDetailTemplateID + "']"; try { Database masterDb = Factory.GetDatabase("master"); Item[] quartzJobs = masterDb.SelectItems(jobsDefinitionsQuery); #region Old Code //JobDetail jd = new JobDetail() //{ // JobKey = "myJob", // Group = "Group1", // Description = "Hello World Job", // Type = "Scheduler.HelloJob, Scheduler" //}; //var jobData = new Dictionary<string, Object>(); //jobData.Add("path",@"D:\Test" ); //jobData.Add("tablestoclean", "Log, ContentStatistics"); //jobData.Add("value", 2); //JobDataMap jdMap = new JobDataMap((IDictionary<string, Object>) jobData); //jd.JobData = jdMap; //List<TriggerDetail> lstTriggers = new List<TriggerDetail>(); /////TODO: Need to change this to set actual shedule //TriggerDetail td = new TriggerDetail() //{ // triggerKey = "Every10Seconds", // RepeatFrequency = 10, // IntervalUnit = RecurringInterval.Seconds, // Interval = 5, // StartTime = DateTime.Now //}; #endregion if (quartzJobs != null && quartzJobs.Length > 0) { foreach (Item jobItem in quartzJobs) { JobDetail jd = new JobDetail(); jd.Id = jobItem.ID.ToString(); jd.ItemName = jobItem.Name; jd.Type = jobItem["Type"]; jd.Description = jobItem["Description"]; jd.JobKey = jobItem["Job Key"]; jd.Group = jobItem["Group"]; jd.JobData = jobItem["Job Data Map"]; lstJobs.Add(jd); } //end for loop for jobs }//end if } catch(Exception ex) { Log.Error("Sitecore.QuartzScheuler: Error Occured in JobManager.GetConfiguredJobs : " + ex.Message + Environment.NewLine + ex.StackTrace, this); throw ex; } return lstJobs.OrderBy(x => x.Group).ThenBy(x => x.JobKey).ToList(); }
/// <summary> /// Initializes a new instance of the <see cref="TriggerFiredBundle"/> class. /// </summary> /// <param name="job">The job.</param> /// <param name="trigger">The trigger.</param> /// <param name="cal">The calendar.</param> /// <param name="jobIsRecovering">if set to <c>true</c> [job is recovering].</param> /// <param name="fireTimeUtc">The fire time.</param> /// <param name="scheduledFireTimeUtc">The scheduled fire time.</param> /// <param name="prevFireTimeUtc">The previous fire time.</param> /// <param name="nextFireTimeUtc">The next fire time.</param> public TriggerFiredBundle(JobDetail job, Trigger trigger, ICalendar cal, bool jobIsRecovering, NullableDateTime fireTimeUtc, NullableDateTime scheduledFireTimeUtc, NullableDateTime prevFireTimeUtc, NullableDateTime nextFireTimeUtc) { this.job = job; this.trigger = trigger; this.cal = cal; this.jobIsRecovering = jobIsRecovering; this.fireTimeUtc = DateTimeUtil.AssumeUniversalTime(fireTimeUtc); this.scheduledFireTimeUtc = DateTimeUtil.AssumeUniversalTime(scheduledFireTimeUtc); this.prevFireTimeUtc = DateTimeUtil.AssumeUniversalTime(prevFireTimeUtc); this.nextFireTimeUtc = DateTimeUtil.AssumeUniversalTime(nextFireTimeUtc); }
internal static string GetJobNameKey(JobDetail jobDetail) { return jobDetail.Group + "_$x$x$_" + jobDetail.Name; }