本文整理汇总了C#中ICalendar.IsTimeIncluded方法的典型用法代码示例。如果您正苦于以下问题:C# ICalendar.IsTimeIncluded方法的具体用法?C# ICalendar.IsTimeIncluded怎么用?C# ICalendar.IsTimeIncluded使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ICalendar
的用法示例。
在下文中一共展示了ICalendar.IsTimeIncluded方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: UpdateWithNewCalendar
/// <summary>
/// This method should not be used by the Quartz client.
/// <para>
/// The implementation should update the <see cref="ITrigger" />'s state
/// based on the given new version of the associated <see cref="ICalendar" />
/// (the state should be updated so that it's next fire time is appropriate
/// given the Calendar's new settings).
/// </para>
/// </summary>
/// <param name="calendar"> </param>
/// <param name="misfireThreshold"></param>
public override void UpdateWithNewCalendar(ICalendar calendar, TimeSpan misfireThreshold)
{
nextFireTimeUtc = GetFireTimeAfter(previousFireTimeUtc);
if (nextFireTimeUtc == null || calendar == null)
{
return;
}
DateTimeOffset now = SystemTime.UtcNow();
while (nextFireTimeUtc != null && !calendar.IsTimeIncluded(nextFireTimeUtc.Value))
{
nextFireTimeUtc = GetFireTimeAfter(nextFireTimeUtc);
if (nextFireTimeUtc == null)
{
break;
}
//avoid infinite loop
if (nextFireTimeUtc.Value.Year > YearToGiveupSchedulingAt)
{
nextFireTimeUtc = null;
}
if (nextFireTimeUtc != null && nextFireTimeUtc < now)
{
TimeSpan diff = now - nextFireTimeUtc.Value;
if (diff >= misfireThreshold)
{
nextFireTimeUtc = GetFireTimeAfter(nextFireTimeUtc);
}
}
}
}
示例2: Triggered
/// <summary>
/// This method should not be used by the Quartz client.
/// <para>
/// Called when the <see cref="IScheduler" /> has decided to 'fire'
/// the trigger (Execute the associated <see cref="IJob" />), in order to
/// give the <see cref="ITrigger" /> a chance to update itself for its next
/// triggering (if any).
/// </para>
/// </summary>
/// <seealso cref="JobExecutionException" />
public override void Triggered(ICalendar calendar)
{
timesTriggered++;
previousFireTimeUtc = nextFireTimeUtc;
nextFireTimeUtc = GetFireTimeAfter(nextFireTimeUtc);
while (nextFireTimeUtc != null && calendar != null
&& !calendar.IsTimeIncluded(nextFireTimeUtc.Value))
{
nextFireTimeUtc = GetFireTimeAfter(nextFireTimeUtc);
if (nextFireTimeUtc == null)
{
break;
}
//avoid infinite loop
if (nextFireTimeUtc.Value.Year > YearToGiveupSchedulingAt)
{
nextFireTimeUtc = null;
}
}
}
示例3: UpdateAfterMisfire
/// <summary>
/// Updates the <see cref="ICalendarIntervalTrigger" />'s state based on the
/// MisfireInstruction.XXX that was selected when the <see cref="ICalendarIntervalTrigger" />
/// was created.
/// </summary>
/// <remarks>
/// If the misfire instruction is set to <see cref="MisfireInstruction.SmartPolicy" />,
/// then the following scheme will be used:
/// <ul>
/// <li>The instruction will be interpreted as <see cref="MisfireInstruction.CalendarIntervalTrigger.FireOnceNow" /></li>
/// </ul>
/// </remarks>
public override void UpdateAfterMisfire(ICalendar cal)
{
int instr = MisfireInstruction;
if (instr == Quartz.MisfireInstruction.IgnoreMisfirePolicy)
{
return;
}
if (instr == Quartz.MisfireInstruction.SmartPolicy)
{
instr = Quartz.MisfireInstruction.CalendarIntervalTrigger.FireOnceNow;
}
if (instr == Quartz.MisfireInstruction.CalendarIntervalTrigger.DoNothing)
{
DateTimeOffset? newFireTime = GetFireTimeAfter(SystemTime.UtcNow());
while (newFireTime != null && cal != null && !cal.IsTimeIncluded(newFireTime.Value))
{
newFireTime = GetFireTimeAfter(newFireTime);
}
SetNextFireTimeUtc(newFireTime);
}
else if (instr == Quartz.MisfireInstruction.CalendarIntervalTrigger.FireOnceNow)
{
// fire once now...
SetNextFireTimeUtc(SystemTime.UtcNow());
// the new fire time afterward will magically preserve the original
// time of day for firing for day/week/month interval triggers,
// because of the way getFireTimeAfter() works - in its always restarting
// computation from the start time.
}
}
示例4: UpdateAfterMisfire
/// <summary>
/// Updates the <see cref="ISimpleTrigger" />'s state based on the
/// MisfireInstruction value that was selected when the <see cref="ISimpleTrigger" />
/// was created.
/// </summary>
/// <remarks>
/// If MisfireSmartPolicyEnabled is set to true,
/// then the following scheme will be used: <br />
/// <ul>
/// <li>If the Repeat Count is 0, then the instruction will
/// be interpreted as <see cref="MisfireInstruction.SimpleTrigger.FireNow" />.</li>
/// <li>If the Repeat Count is <see cref="RepeatIndefinitely" />, then
/// the instruction will be interpreted as <see cref="MisfireInstruction.SimpleTrigger.RescheduleNowWithRemainingRepeatCount" />.
/// <b>WARNING:</b> using MisfirePolicy.SimpleTrigger.RescheduleNowWithRemainingRepeatCount
/// with a trigger that has a non-null end-time may cause the trigger to
/// never fire again if the end-time arrived during the misfire time span.
/// </li>
/// <li>If the Repeat Count is > 0, then the instruction
/// will be interpreted as <see cref="MisfireInstruction.SimpleTrigger.RescheduleNowWithExistingRepeatCount" />.
/// </li>
/// </ul>
/// </remarks>
public override void UpdateAfterMisfire(ICalendar cal)
{
int instr = MisfireInstruction;
if (instr == Quartz.MisfireInstruction.SmartPolicy)
{
if (RepeatCount == 0)
{
instr = Quartz.MisfireInstruction.SimpleTrigger.FireNow;
}
else if (RepeatCount == RepeatIndefinitely)
{
instr = Quartz.MisfireInstruction.SimpleTrigger.RescheduleNextWithRemainingCount;
}
else
{
instr = Quartz.MisfireInstruction.SimpleTrigger.RescheduleNowWithExistingRepeatCount;
}
}
else if (instr == Quartz.MisfireInstruction.SimpleTrigger.FireNow && RepeatCount != 0)
{
instr = Quartz.MisfireInstruction.SimpleTrigger.RescheduleNowWithRemainingRepeatCount;
}
if (instr == Quartz.MisfireInstruction.SimpleTrigger.FireNow)
{
nextFireTimeUtc = SystemTime.UtcNow();
}
else if (instr == Quartz.MisfireInstruction.SimpleTrigger.RescheduleNextWithExistingCount)
{
DateTimeOffset? newFireTime = GetFireTimeAfter(SystemTime.UtcNow());
while (newFireTime.HasValue && cal != null && !cal.IsTimeIncluded(newFireTime.Value))
{
newFireTime = GetFireTimeAfter(newFireTime);
if (!newFireTime.HasValue)
{
break;
}
//avoid infinite loop
if (newFireTime.Value.Year > YearToGiveupSchedulingAt)
{
newFireTime = null;
}
}
nextFireTimeUtc = newFireTime;
}
else if (instr == Quartz.MisfireInstruction.SimpleTrigger.RescheduleNextWithRemainingCount)
{
DateTimeOffset? newFireTime = GetFireTimeAfter(SystemTime.UtcNow());
while (newFireTime.HasValue && cal != null && !cal.IsTimeIncluded(newFireTime.Value))
{
newFireTime = GetFireTimeAfter(newFireTime);
if (!newFireTime.HasValue)
{
break;
}
//avoid infinite loop
if (newFireTime.Value.Year > YearToGiveupSchedulingAt)
{
newFireTime = null;
}
}
if (newFireTime.HasValue)
{
int timesMissed = ComputeNumTimesFiredBetween(nextFireTimeUtc, newFireTime);
TimesTriggered = TimesTriggered + timesMissed;
}
nextFireTimeUtc = newFireTime;
}
else if (instr == Quartz.MisfireInstruction.SimpleTrigger.RescheduleNowWithExistingRepeatCount)
//.........这里部分代码省略.........
示例5: ComputeFirstFireTimeUtc
/// <summary>
/// This method should not be used by the Quartz client.
/// </summary>
/// <remarks>
/// <para>
/// Called by the scheduler at the time a <see cref="ITrigger" /> is first
/// added to the scheduler, in order to have the <see cref="ITrigger" />
/// compute its first fire time, based on any associated calendar.
/// </para>
///
/// <para>
/// After this method has been called, <see cref="ITrigger.GetNextFireTimeUtc" />
/// should return a valid answer.
/// </para>
/// </remarks>
/// <returns>
/// The first time at which the <see cref="ITrigger" /> will be fired
/// by the scheduler, which is also the same value <see cref="ITrigger.GetNextFireTimeUtc" />
/// will return (until after the first firing of the <see cref="ITrigger" />).
/// </returns>
public override DateTimeOffset? ComputeFirstFireTimeUtc(ICalendar calendar)
{
nextFireTimeUtc = StartTimeUtc;
while (nextFireTimeUtc != null && calendar != null
&& !calendar.IsTimeIncluded(nextFireTimeUtc.Value))
{
nextFireTimeUtc = GetFireTimeAfter(nextFireTimeUtc);
if (nextFireTimeUtc == null)
{
break;
}
//avoid infinite loop
if (nextFireTimeUtc.Value.Year > YearToGiveupSchedulingAt)
{
return null;
}
}
return nextFireTimeUtc;
}
示例6: UpdateAfterMisfire
/// <summary>
/// This method should not be used by the Quartz client.
/// <para>
/// To be implemented by the concrete classes that extend this class.
/// </para>
/// <para>
/// The implementation should update the <see cref="ITrigger" />'s state
/// based on the MISFIRE_INSTRUCTION_XXX that was selected when the <see cref="ITrigger" />
/// was created.
/// </para>
/// </summary>
/// <param name="cal"></param>
public override void UpdateAfterMisfire(ICalendar cal)
{
int instr = MisfireInstruction;
if (instr == Quartz.MisfireInstruction.SmartPolicy)
{
instr = Quartz.MisfireInstruction.CronTrigger.FireOnceNow;
}
if (instr == Quartz.MisfireInstruction.CronTrigger.DoNothing)
{
DateTimeOffset? newFireTime = GetFireTimeAfter(SystemTime.UtcNow());
while (newFireTime.HasValue && cal != null
&& !cal.IsTimeIncluded(newFireTime.Value))
{
newFireTime = GetFireTimeAfter(newFireTime);
}
SetNextFireTimeUtc(newFireTime);
}
else if (instr == Quartz.MisfireInstruction.CronTrigger.FireOnceNow)
{
SetNextFireTimeUtc(SystemTime.UtcNow());
}
}
示例7: ComputeFirstFireTimeUtc
/// <summary>
/// This method should not be used by the Quartz client.
/// </summary>
/// <remarks>
/// <para>
/// Called by the scheduler at the time a <see cref="ITrigger" /> is first
/// added to the scheduler, in order to have the <see cref="ITrigger" />
/// compute its first fire time, based on any associated calendar.
/// </para>
///
/// <para>
/// After this method has been called, <see cref="ITrigger.GetNextFireTimeUtc" />
/// should return a valid answer.
/// </para>
/// </remarks>
/// <returns>
/// The first time at which the <see cref="ITrigger" /> will be fired
/// by the scheduler, which is also the same value <see cref="ITrigger.GetNextFireTimeUtc" />
/// will return (until after the first firing of the <see cref="ITrigger" />).
/// </returns>
public override DateTimeOffset? ComputeFirstFireTimeUtc(ICalendar calendar)
{
DateTimeOffset startTime = TimeZoneUtil.ConvertTime(StartTimeUtc, TimeZone);
DateTimeOffset? startTimeOfDayDate = StartTimeOfDay.GetTimeOfDayForDate(startTime);
// If startTime is after the timeOfDay, then use starTime
if (startTime > startTimeOfDayDate)
{
nextFireTimeUtc = GetFireTimeAfter(startTime);
}
else
{
nextFireTimeUtc = AdvanceToNextDayOfWeek(startTimeOfDayDate.Value, false);
}
// Check calendar for date-time exclusion
while (nextFireTimeUtc != null && calendar != null
&& !calendar.IsTimeIncluded(nextFireTimeUtc.Value))
{
nextFireTimeUtc = GetFireTimeAfter(nextFireTimeUtc);
if (nextFireTimeUtc == null)
{
break;
}
//avoid infinite loop
if (nextFireTimeUtc.Value.Year > YearToGiveupSchedulingAt)
{
return null;
}
}
return nextFireTimeUtc;
}
示例8: Triggered
/// <summary>
/// Called when the <see cref="IScheduler" /> has decided to 'fire'
/// the trigger (Execute the associated <see cref="IJob" />), in order to
/// give the <see cref="ITrigger" /> a chance to update itself for its next
/// triggering (if any).
/// </summary>
/// <param name="cal"></param>
/// <seealso cref="JobExecutionException" />
public override void Triggered(ICalendar cal)
{
previousFireTimeUtc = nextFireTimeUtc;
nextFireTimeUtc = GetFireTimeAfter(nextFireTimeUtc);
while (nextFireTimeUtc.HasValue && cal != null
&& !cal.IsTimeIncluded(nextFireTimeUtc.Value))
{
nextFireTimeUtc = GetFireTimeAfter(nextFireTimeUtc);
}
}
示例9: ComputeFirstFireTimeUtc
/// <summary>
/// Called by the scheduler at the time a <see cref="ITrigger" /> is first
/// added to the scheduler, in order to have the <see cref="ITrigger" />
/// compute its first fire time, based on any associated calendar.
/// <para>
/// After this method has been called, <see cref="GetNextFireTimeUtc" />
/// should return a valid answer.
/// </para>
/// </summary>
/// <param name="cal"></param>
/// <returns>
/// the first time at which the <see cref="ITrigger" /> will be fired
/// by the scheduler, which is also the same value <see cref="GetNextFireTimeUtc" />
/// will return (until after the first firing of the <see cref="ITrigger" />).
/// </returns>
public override DateTimeOffset? ComputeFirstFireTimeUtc(ICalendar cal)
{
nextFireTimeUtc = GetFireTimeAfter(startTimeUtc.AddSeconds(-1));
while (nextFireTimeUtc.HasValue && cal != null && !cal.IsTimeIncluded(nextFireTimeUtc.Value))
{
nextFireTimeUtc = GetFireTimeAfter(nextFireTimeUtc);
}
return nextFireTimeUtc;
}
示例10: UpdateAfterMisfire
/// <summary>
/// Updates the <see cref="ItineraryTriggerImpl" />'s state based on the
/// MisfireInstruction value that was selected when the <see cref="ItineraryTriggerImpl" />
/// was created.
/// </summary>
public override void UpdateAfterMisfire(ICalendar cal)
{
var instr = MisfireInstruction;
if (instr == ItineraryTriggerMisfireInstruction.DoNothing) {
// Drop missed events. Resume schedule at the next event from from current time.
var newFireTime = GetFireTimeAfter(DateTime.UtcNow);
// Ensure event is in ICalendar.
while (newFireTime.HasValue && cal != null && !cal.IsTimeIncluded(newFireTime.Value)) {
newFireTime = GetFireTimeAfter(newFireTime);
}
SetNextFireTimeUtc(newFireTime);
}
else if (instr == ItineraryTriggerMisfireInstruction.FireOnceNow) {
// Drop missed events. Trigger event now, then resume schedule from current time.
SetNextFireTimeUtc(DateTime.UtcNow);
}
}
示例11: ComputeFirstFireTimeUtc
public override DateTimeOffset? ComputeFirstFireTimeUtc(ICalendar cal)
{
do {
if (!scheduleEnumerator.MoveNext()) {
nextEventTime = null;
break;
}
nextEventTime = scheduleEnumerator.Current.StartTime;
} while (cal != null && !cal.IsTimeIncluded(scheduleEnumerator.Current.StartTime));
return nextEventTime;
}
示例12: UpdateAfterMisfire
/// <summary>
/// Updates the <see cref="ItineraryTrigger" />'s state based on the
/// MisfireInstruction value that was selected when the <see cref="ItineraryTrigger" />
/// was created.
/// </summary>
public override void UpdateAfterMisfire(ICalendar cal)
{
var instr = MisfireInstruction;
if (instr == ItineraryTriggerMisfireInstruction.RescheduleNextWithExistingCount) {
// Drop missed events. Resume schedule at the next event from from current time.
var newFireTime = GetFireTimeAfter(DateTime.UtcNow);
// Ensure event is in ICalendar.
while (newFireTime.HasValue && cal != null && !cal.IsTimeIncluded(newFireTime.Value)) {
newFireTime = GetFireTimeAfter(newFireTime);
}
SetNextFireTime(newFireTime);
}
else if (instr == ItineraryTriggerMisfireInstruction.RescheduleNextWithRemainingCount) {
// Drop missed events. Resume schedule from current time.
// Track count of dropped events.
var rangeStart = DateTime.UtcNow;
var newFireTime = GetFireTimeAfter(rangeStart);
// Ensure event is in ICalendar.
while (newFireTime.HasValue && cal != null && !cal.IsTimeIncluded(newFireTime.Value)) {
newFireTime = GetFireTimeAfter(newFireTime);
}
// Tally missed events.
if (GetNextFireTimeUtc().HasValue) {
TriggerCount += schedule.GetRange(GetNextFireTimeUtc().Value, rangeStart)
.Where(e => cal == null || cal.IsTimeIncluded(e.StartTime))
.Count();
}
SetNextFireTime(newFireTime);
}
else if (instr == ItineraryTriggerMisfireInstruction.RescheduleNowWithExistingCount) {
// Drop missed events. Trigger event now, then resume schedule from current time.
SetNextFireTime(DateTime.UtcNow);
}
else if (instr == ItineraryTriggerMisfireInstruction.RescheduleNowWithRemainingCount) {
// Drop missed events. Resume schedule from current time.
// Track count of dropped events.
var newFireTime = DateTime.UtcNow;
// Tally missed events.
if (GetNextFireTimeUtc().HasValue) {
TriggerCount += schedule.GetRange(GetNextFireTimeUtc().Value, newFireTime)
.Where(e => cal == null || cal.IsTimeIncluded(e.StartTime))
.Count();
}
SetNextFireTime(newFireTime);
}
}