本文整理汇总了C#中ITrigger.GetNextFireTimeUtc方法的典型用法代码示例。如果您正苦于以下问题:C# ITrigger.GetNextFireTimeUtc方法的具体用法?C# ITrigger.GetNextFireTimeUtc怎么用?C# ITrigger.GetNextFireTimeUtc使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ITrigger
的用法示例。
在下文中一共展示了ITrigger.GetNextFireTimeUtc方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TriggerModel
public TriggerModel(ITrigger trigger)
{
TriggerGroupName = trigger.Key.Group;
TriggerName = trigger.Key.Name;
StartTime = trigger.StartTimeUtc;
EndTime = trigger.EndTimeUtc;
FinalFireTime = trigger.FinalFireTimeUtc;
Priority = trigger.Priority;
Description = trigger.Description;
JobDataMap = trigger.JobDataMap;
NextFireTime = trigger.GetNextFireTimeUtc();
}
示例2: ScheduleJob
/// <summary>
/// Schedule the given <see cref="ITrigger" /> with the
/// <see cref="IJob" /> identified by the <see cref="ITrigger" />'s settings.
/// </summary>
public virtual DateTimeOffset ScheduleJob(ITrigger trigger)
{
ValidateState();
if (trigger == null)
{
throw new SchedulerException("Trigger cannot be null");
}
IOperableTrigger trig = (IOperableTrigger) trigger;
trig.Validate();
ICalendar cal = null;
if (trigger.CalendarName != null)
{
cal = resources.JobStore.RetrieveCalendar(trigger.CalendarName);
if (cal == null)
{
throw new SchedulerException(string.Format(CultureInfo.InvariantCulture, "Calendar not found: {0}", trigger.CalendarName));
}
}
DateTimeOffset? ft = trig.ComputeFirstFireTimeUtc(cal);
if (!ft.HasValue)
{
var message = string.Format("Based on configured schedule, the given trigger '{0}' will never fire.", trigger.Key);
throw new SchedulerException(message);
}
resources.JobStore.StoreTrigger(trig, false);
NotifySchedulerThread(trigger.GetNextFireTimeUtc());
NotifySchedulerListenersScheduled(trigger);
return ft.Value;
}
示例3: RescheduleJob
/// <summary>
/// Remove (delete) the <see cref="ITrigger" /> with the
/// given name, and store the new given one - which must be associated
/// with the same job.
/// </summary>
/// <param name="triggerKey">the key of the trigger</param>
/// <param name="newTrigger">The new <see cref="ITrigger" /> to be stored.</param>
/// <returns>
/// <see langword="null" /> if a <see cref="ITrigger" /> with the given
/// name and group was not found and removed from the store, otherwise
/// the first fire time of the newly scheduled trigger.
/// </returns>
public virtual DateTimeOffset? RescheduleJob(TriggerKey triggerKey, ITrigger newTrigger)
{
ValidateState();
if (triggerKey == null)
{
throw new ArgumentException("triggerKey cannot be null");
}
if (newTrigger == null)
{
throw new ArgumentException("newTrigger cannot be null");
}
var trigger = (IOperableTrigger) newTrigger;
ITrigger oldTrigger = GetTrigger(triggerKey);
if (oldTrigger == null)
{
return null;
}
trigger.JobKey = oldTrigger.JobKey;
trigger.Validate();
ICalendar cal = null;
if (newTrigger.CalendarName != null)
{
cal = resources.JobStore.RetrieveCalendar(newTrigger.CalendarName);
}
DateTimeOffset? ft = trigger.ComputeFirstFireTimeUtc(cal);
if (!ft.HasValue)
{
var message = string.Format("Based on configured schedule, the given trigger '{0}' will never fire.", trigger.Key);
throw new SchedulerException(message);
}
if (resources.JobStore.ReplaceTrigger(triggerKey, trigger))
{
NotifySchedulerThread(newTrigger.GetNextFireTimeUtc());
NotifySchedulerListenersUnscheduled(triggerKey);
NotifySchedulerListenersScheduled(newTrigger);
}
else
{
return null;
}
return ft;
}
示例4: TriggerComplete
/// <summary>
/// Called by the <see cref="IScheduler" /> when a <see cref="ITrigger" />
/// has fired, it's associated <see cref="IJobDetail" />
/// has been executed, and it's <see cref="IOperableTrigger.Triggered" /> method has been
/// called.
/// </summary>
/// <param name="trigger">The <see cref="ITrigger" /> that was fired.</param>
/// <param name="context">The <see cref="IJobExecutionContext" /> that was passed to the
/// <see cref="IJob" />'s <see cref="IJob.Execute" /> method.</param>
/// <param name="triggerInstructionCode">The result of the call on the <see cref="IOperableTrigger" />'s <see cref="IOperableTrigger.Triggered" /> method.</param>
public virtual void TriggerComplete(ITrigger trigger, IJobExecutionContext context, SchedulerInstruction triggerInstructionCode)
{
string instrCode = "UNKNOWN";
if (triggerInstructionCode == SchedulerInstruction.DeleteTrigger)
{
instrCode = "DELETE TRIGGER";
}
else if (triggerInstructionCode == SchedulerInstruction.NoInstruction)
{
instrCode = "DO NOTHING";
}
else if (triggerInstructionCode == SchedulerInstruction.ReExecuteJob)
{
instrCode = "RE-EXECUTE JOB";
}
else if (triggerInstructionCode ==SchedulerInstruction.SetAllJobTriggersComplete)
{
instrCode = "SET ALL OF JOB'S TRIGGERS COMPLETE";
}
else if (triggerInstructionCode == SchedulerInstruction.SetTriggerComplete)
{
instrCode = "SET THIS TRIGGER COMPLETE";
}
object[] args =
new object[]
{
trigger.Key.Name, trigger.Key.Group, trigger.GetPreviousFireTimeUtc(), trigger.GetNextFireTimeUtc(), SystemTime.UtcNow(),
context.JobDetail.Key.Name, context.JobDetail.Key.Group, context.RefireCount, triggerInstructionCode, instrCode
};
}
示例5: TriggerMisfired
/// <summary>
/// Called by the <see cref="IScheduler" /> when a <see cref="ITrigger" />
/// has misfired.
/// <para>
/// Consideration should be given to how much time is spent in this method,
/// as it will affect all triggers that are misfiring. If you have lots
/// of triggers misfiring at once, it could be an issue it this method
/// does a lot.
/// </para>
/// </summary>
/// <param name="trigger">The <see cref="ITrigger" /> that has misfired.</param>
public virtual void TriggerMisfired(ITrigger trigger)
{
object[] args =
new object[]
{
trigger.Key.Name, trigger.Key.Group, trigger.GetPreviousFireTimeUtc(), trigger.GetNextFireTimeUtc(), SystemTime.UtcNow(),
trigger.JobKey.Name, trigger.JobKey.Group
};
}
示例6: TriggerFired
/// <summary>
/// Called by the <see cref="IScheduler" /> when a <see cref="ITrigger" />
/// has fired, and it's associated <see cref="IJobDetail" />
/// is about to be executed.
/// <para>
/// It is called before the <see cref="VetoJobExecution" /> method of this
/// interface.
/// </para>
/// </summary>
/// <param name="trigger">The <see cref="ITrigger" /> that has fired.</param>
/// <param name="context">The <see cref="IJobExecutionContext" /> that will be passed to the <see cref="IJob" />'s <see cref="IJob.Execute" /> method.</param>
public virtual void TriggerFired(ITrigger trigger, IJobExecutionContext context)
{
object[] args =
new object[]
{
trigger.Key.Name, trigger.Key.Group, trigger.GetPreviousFireTimeUtc(), trigger.GetNextFireTimeUtc(), SystemTime.UtcNow(),
context.JobDetail.Key.Name, context.JobDetail.Key.Group, context.RefireCount
};
}
示例7: TriggerMisfired
/// <summary>
/// Called by the <see cref="IScheduler" /> when a <see cref="ITrigger" />
/// has misfired.
/// <p>
/// Consideration should be given to how much time is spent in this method,
/// as it will affect all triggers that are misfiring. If you have lots
/// of triggers misfiring at once, it could be an issue it this method
/// does a lot.
/// </p>
/// </summary>
/// <param name="trigger">The <see cref="ITrigger" /> that has misfired.</param>
public virtual void TriggerMisfired(ITrigger trigger)
{
if (!Log.IsInfoEnabled)
{
return;
}
object[] args =
new object[]
{
trigger.Key.Name, trigger.Key.Group, trigger.GetPreviousFireTimeUtc(), trigger.GetNextFireTimeUtc(), SystemTime.UtcNow(),
trigger.JobKey.Name, trigger.JobKey.Group
};
Log.Info(String.Format(CultureInfo.InvariantCulture, TriggerMisfiredMessage, args));
}
示例8: TriggerFired
/// <summary>
/// Called by the <see cref="IScheduler" /> when a <see cref="ITrigger" />
/// has fired, and it's associated <see cref="IJobDetail" />
/// is about to be executed.
/// <p>
/// It is called before the <see cref="VetoJobExecution" /> method of this
/// interface.
/// </p>
/// </summary>
/// <param name="trigger">The <see cref="ITrigger" /> that has fired.</param>
/// <param name="context">The <see cref="IJobExecutionContext" /> that will be passed to the <see cref="IJob" />'s <see cref="IJob.Execute" /> method.</param>
public virtual void TriggerFired(ITrigger trigger, IJobExecutionContext context)
{
if (!Log.IsInfoEnabled)
{
return;
}
object[] args =
new object[]
{
trigger.Key.Name, trigger.Key.Group, trigger.GetPreviousFireTimeUtc(), trigger.GetNextFireTimeUtc(), SystemTime.UtcNow(),
context.JobDetail.Key.Name, context.JobDetail.Key.Group, context.RefireCount
};
Log.Info(String.Format(CultureInfo.InvariantCulture, TriggerFiredMessage, args));
}
示例9: GetTriggerData
private static TriggerData GetTriggerData(IScheduler scheduler, ITrigger trigger)
{
return new TriggerData(trigger.Key.Name, GetTriggerStatus(trigger, scheduler))
{
GroupName = trigger.Key.Group,
StartDate = trigger.StartTimeUtc.DateTime,
EndDate = trigger.EndTimeUtc.ToDateTime(),
NextFireDate = trigger.GetNextFireTimeUtc().ToDateTime(),
PreviousFireDate = trigger.GetPreviousFireTimeUtc().ToDateTime(),
TriggerType = TriggerTypeExtractor.GetFor(trigger)
};
}
示例10: UpdateTriggerState
/// <summary>
/// update trigger state
/// if the group the trigger is in or the group the trigger's job is in are paused, then we need to check whether its job is in the blocked group, if it's then set its state to PausedBlocked, else set it to blocked.
/// else set the trigger to the normal state (waiting), conver the nextfiretime into UTC milliseconds, so it could be stored as score in the sorted set.
/// </summary>
/// <param name="trigger">ITrigger</param>
private void UpdateTriggerState(ITrigger trigger)
{
var triggerPausedResult =
this.Db.SetContains(this.RedisJobStoreSchema.PausedTriggerGroupsSetKey(),
this.RedisJobStoreSchema.TriggerGroupSetKey(trigger.Key.Group));
var jobPausedResult = this.Db.SetContains(this.RedisJobStoreSchema.PausedJobGroupsSetKey(),
this.RedisJobStoreSchema.JobGroupSetKey(trigger.JobKey.Group));
if (triggerPausedResult || jobPausedResult)
{
double nextFireTime = trigger.GetNextFireTimeUtc().HasValue
? trigger.GetNextFireTimeUtc().Value.DateTime.ToUnixTimeMilliSeconds() : -1;
var jobHashKey = this.RedisJobStoreSchema.JobHashKey(trigger.JobKey);
if (this.Db.SetContains(this.RedisJobStoreSchema.BlockedJobsSet(), jobHashKey))
{
this.SetTriggerState(RedisTriggerState.PausedBlocked,
nextFireTime, this.RedisJobStoreSchema.TriggerHashkey(trigger.Key));
}
else
{
this.SetTriggerState(RedisTriggerState.Paused,
nextFireTime, this.RedisJobStoreSchema.TriggerHashkey(trigger.Key));
}
}
else if (trigger.GetNextFireTimeUtc().HasValue)
{
this.SetTriggerState(RedisTriggerState.Waiting,
trigger.GetNextFireTimeUtc().Value.DateTime.ToUnixTimeMilliSeconds(), this.RedisJobStoreSchema.TriggerHashkey(trigger.Key));
}
}
示例11: RescheduleJob
/// <summary>
/// Remove (delete) the <see cref="ITrigger" /> with the
/// given name, and store the new given one - which must be associated
/// with the same job.
/// </summary>
/// <param name="triggerKey">the key of the trigger</param>
/// <param name="newTrigger">The new <see cref="ITrigger" /> to be stored.</param>
/// <returns>
/// <see langword="null" /> if a <see cref="ITrigger" /> with the given
/// name and group was not found and removed from the store, otherwise
/// the first fire time of the newly scheduled trigger.
/// </returns>
public virtual async Task<DateTimeOffset?> RescheduleJob(TriggerKey triggerKey, ITrigger newTrigger)
{
ValidateState();
if (triggerKey == null)
{
throw new ArgumentException("triggerKey cannot be null");
}
if (newTrigger == null)
{
throw new ArgumentException("newTrigger cannot be null");
}
var trigger = (IOperableTrigger) newTrigger;
ITrigger oldTrigger = await GetTrigger(triggerKey).ConfigureAwait(false);
if (oldTrigger == null)
{
return null;
}
trigger.JobKey = oldTrigger.JobKey;
trigger.Validate();
ICalendar cal = null;
if (newTrigger.CalendarName != null)
{
cal = await resources.JobStore.RetrieveCalendar(newTrigger.CalendarName).ConfigureAwait(false);
}
DateTimeOffset? ft;
if (trigger.GetNextFireTimeUtc() != null)
{
// use a cloned trigger so that we don't lose possible forcefully set next fire time
var clonedTrigger = (IOperableTrigger) trigger.Clone();
ft = clonedTrigger.ComputeFirstFireTimeUtc(cal);
}
else
{
ft = trigger.ComputeFirstFireTimeUtc(cal);
}
if (!ft.HasValue)
{
var message = $"Based on configured schedule, the given trigger '{trigger.Key}' will never fire.";
throw new SchedulerException(message);
}
if (await resources.JobStore.ReplaceTrigger(triggerKey, trigger).ConfigureAwait(false))
{
NotifySchedulerThread(newTrigger.GetNextFireTimeUtc());
await NotifySchedulerListenersUnscheduled(triggerKey).ConfigureAwait(false);
await NotifySchedulerListenersScheduled(newTrigger).ConfigureAwait(false);
}
else
{
return null;
}
return ft;
}
示例12: ScheduleJob
/// <summary>
/// Schedule the given <see cref="ITrigger" /> with the
/// <see cref="IJob" /> identified by the <see cref="ITrigger" />'s settings.
/// </summary>
public virtual async Task<DateTimeOffset> ScheduleJob(ITrigger trigger)
{
ValidateState();
if (trigger == null)
{
throw new SchedulerException("Trigger cannot be null");
}
IOperableTrigger trig = (IOperableTrigger) trigger;
trig.Validate();
ICalendar cal = null;
if (trigger.CalendarName != null)
{
cal = await resources.JobStore.RetrieveCalendar(trigger.CalendarName).ConfigureAwait(false);
if (cal == null)
{
throw new SchedulerException($"Calendar not found: {trigger.CalendarName}");
}
}
DateTimeOffset? ft = trig.ComputeFirstFireTimeUtc(cal);
if (!ft.HasValue)
{
var message = $"Based on configured schedule, the given trigger '{trigger.Key}' will never fire.";
throw new SchedulerException(message);
}
await resources.JobStore.StoreTrigger(trig, false).ConfigureAwait(false);
NotifySchedulerThread(trigger.GetNextFireTimeUtc());
await NotifySchedulerListenersScheduled(trigger).ConfigureAwait(false);
return ft.Value;
}
示例13: RescheduleJob
/// <summary>
/// Remove (delete) the <see cref="ITrigger" /> with the
/// given name, and store the new given one - which must be associated
/// with the same job.
/// </summary>
/// <param name="triggerKey">the key of the trigger</param>
/// <param name="newTrigger">The new <see cref="ITrigger" /> to be stored.</param>
/// <returns>
/// <see langword="null" /> if a <see cref="ITrigger" /> with the given
/// name and group was not found and removed from the store, otherwise
/// the first fire time of the newly scheduled trigger.
/// </returns>
public virtual DateTimeOffset? RescheduleJob(TriggerKey triggerKey, ITrigger newTrigger)
{
ValidateState();
IOperableTrigger trig = (IOperableTrigger) newTrigger;
trig.Validate();
ICalendar cal = null;
if (newTrigger.CalendarName != null)
{
cal = resources.JobStore.RetrieveCalendar(newTrigger.CalendarName);
}
DateTimeOffset? ft = trig.ComputeFirstFireTimeUtc(cal);
if (!ft.HasValue)
{
throw new SchedulerException("Based on configured schedule, the given trigger will never fire.");
}
if (resources.JobStore.ReplaceTrigger(triggerKey, trig))
{
NotifySchedulerThread(newTrigger.GetNextFireTimeUtc());
NotifySchedulerListenersUnscheduled(triggerKey);
NotifySchedulerListenersScheduled(newTrigger);
}
else
{
return null;
}
return ft;
}