当前位置: 首页>>代码示例>>C#>>正文


C# IScheduler.RescheduleJob方法代码示例

本文整理汇总了C#中IScheduler.RescheduleJob方法的典型用法代码示例。如果您正苦于以下问题:C# IScheduler.RescheduleJob方法的具体用法?C# IScheduler.RescheduleJob怎么用?C# IScheduler.RescheduleJob使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IScheduler的用法示例。


在下文中一共展示了IScheduler.RescheduleJob方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ScheduleTasks

 static async void ScheduleTasks(IScheduler scheduler)
 {
     using (var repo = new Repository())
     {
         var forms = (await repo.GetForms())
             .Where(t => t.TimeRemaining(repo) > TimeSpan.Zero)
             .ToList();
         foreach (var form in forms)
         {
             var job = JobBuilder.Create<FormBlockingJob>()
                 .WithIdentity($"Form{form.form_id}Job")
                 .UsingJobData("FormId", form.form_id)
                 .Build();
             var schedTime = new DateTimeOffset(form.DateExpired(repo));
             var trigger = TriggerBuilder.Create()
                 .WithIdentity($"Form{form.form_id}JobTrigger")
                 .StartAt(schedTime)
                 .ForJob($"Form{form.form_id}Job")
                 .Build();
             if (!scheduler.CheckExists(job.Key))
             {
                 scheduler.ScheduleJob(job, trigger);
                 _log.Info($"Scheduled block {form.name} at {trigger.StartTimeUtc}");
             }
             else
             {
                 scheduler.RescheduleJob(trigger.Key, trigger);
                 _log.Info($"Re-scheduled block {form.name} at {trigger.StartTimeUtc}");
             }
         }
     }
 }
开发者ID:superbatonchik,项目名称:EduFormManager,代码行数:32,代码来源:Program.cs

示例2: ScheduleJob

		/// <summary>
		/// Schedules a given job and trigger (both wrapped by a <see cref="JobSchedulingBundle" />).
		/// </summary>
		/// <param name="job">The job.</param>
		/// <param name="sched">The sched.</param>
		/// <param name="localOverWriteExistingJobs">if set to <c>true</c> [local over write existing jobs].</param>
		/// <exception cref="SchedulerException"> 
		/// if the Job or Trigger cannot be added to the Scheduler, or
		/// there is an internal Scheduler error.
		/// </exception>
		public virtual void ScheduleJob(JobSchedulingBundle job, IScheduler sched, bool localOverWriteExistingJobs)
		{
			if ((job != null) && job.Valid)
			{
				JobDetail detail = job.JobDetail;

				JobDetail dupeJ = sched.GetJobDetail(detail.Name, detail.Group);

				if ((dupeJ != null) && !localOverWriteExistingJobs)
				{
					Log.Info("Not overwriting existing job: " + dupeJ.FullName);
					return;
				}

				if (dupeJ != null)
				{
					Log.Info(string.Format(CultureInfo.InvariantCulture, "Replacing job: {0}", detail.FullName));
				}
				else
				{
					Log.Info(string.Format(CultureInfo.InvariantCulture, "Adding job: {0}", detail.FullName));
				}

				if (job.Triggers.Count == 0 && !job.JobDetail.Durable)
				{
					throw new SchedulerException("A Job defined without any triggers must be durable");
				}
				
				sched.AddJob(detail, true);

					
				foreach(Trigger trigger in job.Triggers)
				{
					Trigger dupeT = sched.GetTrigger(trigger.Name, trigger.Group);

					trigger.JobName = detail.Name;
					trigger.JobGroup = detail.Group;

					if (trigger.StartTimeUtc == DateTime.MinValue)
					{
						trigger.StartTimeUtc = DateTime.UtcNow;
					}

					if (dupeT != null)
					{
						Log.Debug(string.Format(CultureInfo.InvariantCulture, "Rescheduling job: {0} with updated trigger: {1}", detail.FullName, trigger.FullName));
						if (!dupeT.JobGroup.Equals(trigger.JobGroup) || !dupeT.JobName.Equals(trigger.JobName))
						{
							Log.Warn("Possibly duplicately named triggers in jobs xml file!");
						}
						sched.RescheduleJob(trigger.Name, trigger.Group, trigger);
					}
					else
					{
						Log.Debug(string.Format(CultureInfo.InvariantCulture, "Scheduling job: {0} with trigger: {1}", detail.FullName, trigger.FullName));
						sched.ScheduleJob(trigger);
					}
				}

				AddScheduledJob(job);
			}
		}
开发者ID:djvit-iteelabs,项目名称:Infosystem.Scraper,代码行数:72,代码来源:JobSchedulingDataProcessor.cs

示例3: RescheduleJob

        /// <summary>
        /// This method reschedules a job.
        /// </summary>
        /// <param name="qScheduler"></param>
        /// <param name="sJobName"></param>
        /// <param name="sJobGroup"></param>
        /// <param name="sCronExpression"></param>
        /// <param name="iPriority"></param>
        public void RescheduleJob(IScheduler qScheduler, string sJobName, string sJobGroup, string sCronExpression, int iPriority)
        {
            // Build new trigger
            var trigger = (ICronTrigger)TriggerBuilder.Create()
                .WithIdentity(sJobName, sJobGroup)
                .WithCronSchedule(sCronExpression)
                .WithPriority(iPriority)
                //.StartAt(StartAt.ToUniversalTime())
                .Build();

            qScheduler.RescheduleJob(new TriggerKey(sJobName, sJobGroup), trigger);
        }
开发者ID:Majestic3691,项目名称:HelloWorldQuartzDotNet,代码行数:20,代码来源:RFFCQuartzCommon.cs


注:本文中的IScheduler.RescheduleJob方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。