Class DailyTimeIntervalTriggerImpl
A concrete implementation of DailyTimeIntervalTrigger that is used to fire a IJobDetail based upon daily repeating time intervals.
[Serializable]
public class DailyTimeIntervalTriggerImpl : TriggerBase, IOperableTrigger, IMutableTrigger, IEquatable<TriggerBase>, IDailyTimeIntervalTrigger, ITrigger
- Inheritance
-
DailyTimeIntervalTriggerImpl
- Implements
- Inherited Members
Remarks
The trigger will fire every N (RepeatInterval ) seconds, minutes or hours (see RepeatInterval) during a given time window on specified days of the week.
For example#1, a trigger can be set to fire every 72 minutes between 8:00 and 11:00 everyday. It's fire times would be 8:00, 9:12, 10:24, then next day would repeat: 8:00, 9:12, 10:24 again.
For example#2, a trigger can be set to fire every 23 minutes between 9:20 and 16:47 Monday through Friday.
On each day, the starting fire time is reset to startTimeOfDay value, and then it will add repeatInterval value to it until the endTimeOfDay is reached. If you set daysOfWeek values, then fire time will only occur during those week days period. Again, remember this trigger will reset fire time each day with startTimeOfDay, regardless of your interval or endTimeOfDay!
The default values for fields if not set are: startTimeOfDay defaults to 00:00:00, the endTimeOfDay default to 23:59:59, and daysOfWeek is default to every day. The startTime default to current time-stamp now, while endTime has not value.
If startTime is before startTimeOfDay, then startTimeOfDay will be used and startTime has no affect other than to specify the first day of firing. Else if startTime is after startTimeOfDay, then the first fire time for that day will be the next interval after the startTime. For example, if you set startingTimeOfDay=9am, endingTimeOfDay=11am, interval=15 mins, and startTime=9:33am, then the next fire time will be 9:45pm. Note also that if you do not set startTime value, the trigger builder will default to current time, and current time maybe before or after the startTimeOfDay! So be aware how you set your startTime.
This trigger also supports a "repeatCount" feature to limit the number of times the trigger fires per day. Setting repeatCount=0 means the trigger will fire once per day at startTimeOfDay. Setting repeatCount=N means the trigger will fire N+1 times per day (the initial fire plus N repeats), then advance to the next valid day and repeat. Unlike SimpleTrigger which uses repeatCount as a global total, DailyTimeIntervalTrigger applies repeatCount per day. The default value of repeatCount is set to REPEAT_INDEFINITELY.
Constructors
DailyTimeIntervalTriggerImpl(TimeProvider?)
Create a IDailyTimeIntervalTrigger with no settings.
public DailyTimeIntervalTriggerImpl(TimeProvider? timeProvider = null)
Parameters
timeProviderTimeProviderTime provider instance to use, defaults to System
Remarks
Everything this trigger needs is a settable property, so the object-initializer form
new DailyTimeIntervalTriggerImpl { Key = ..., StartTimeOfDay = ..., EndTimeOfDay = ... }
replaces the constructor overloads that used to spell out each combination.
Fields
RepeatIndefinitely
Used to indicate the 'repeat count' of the trigger is indefinite. Or in other words, the trigger should repeat continually until the trigger's ending timestamp.
public const int RepeatIndefinitely = -1
Field Value
Properties
DaysOfWeek
The days of the week upon which to fire.
public IReadOnlyCollection<DayOfWeek> DaysOfWeek { get; set; }
Property Value
- IReadOnlyCollection<DayOfWeek>
A Set containing the integers representing the days of the week, per the values 0-6 as defined by DayOfWees.Sunday - DayOfWeek.Saturday.
EndTimeOfDay
The time of day to complete firing at the given interval. Defaults to 23:59:59.
public TimeOnly EndTimeOfDay { get; set; }
Property Value
Exceptions
- ArgumentException
The value carries precision finer than a whole second, or it comes before StartTimeOfDay.
EndTimeUtc
the time at which the IDailyTimeIntervalTrigger should quit repeating, rounded down to the whole second.
public override DateTimeOffset? EndTimeUtc { get; set; }
Property Value
Remarks
CronTriggerImpl's start
time does not: GetFireTimeAfter(DateTimeOffset?) counts whole seconds from the start of the day,
so a start time of 22:50:00.68 truncated to 74100 seconds after a 02:15 start-of-day
landed exactly on a 5-minute boundary and produced a first fire time of 22:50:00.000 —
before the trigger's own start.
FinalFireTimeUtc
Returns the final time at which the IDailyTimeIntervalTrigger will fire, if there is no end time set, null will be returned.
public override DateTimeOffset? FinalFireTimeUtc { get; }
Property Value
Remarks
Note that the return time may be in the past.
Unlike the other shipped trigger types this is the last instant at which the trigger may fire rather than a fire time its schedule produces: neither EndTimeUtc nor EndTimeOfDay has to land on a repeat of the interval. It is never past EndTimeUtc, which is where every trigger's firing stops.
HasMillisecondPrecision
Tells whether this Trigger instance can handle events in millisecond precision.
protected override bool HasMillisecondPrecision { get; }
Property Value
MayFireAgain
Determines whether or not the IDailyTimeIntervalTrigger will occur again.
public override bool MayFireAgain { get; }
Property Value
MisfireInstruction
What the scheduler does when this trigger misses a firing.
public DailyTimeIntervalTriggerMisfireInstruction MisfireInstruction { get; }
Property Value
- See Also
NextFireTimeUtc
Returns the next time at which the ITrigger is scheduled to fire. If the trigger will not fire again, null will be returned. Note that the time returned can possibly be in the past, if the time that was computed for the trigger to next fire has already arrived, but the scheduler has not yet been able to fire the trigger (which would likely be due to lack of resources e.g. threads).
public override DateTimeOffset? NextFireTimeUtc { get; set; }
Property Value
Remarks
The value returned is not guaranteed to be valid until after the ITrigger has been added to the scheduler.
PreviousFireTimeUtc
Returns the previous time at which the ICalendarIntervalTrigger fired. If the trigger has not yet fired, null will be returned.
public override DateTimeOffset? PreviousFireTimeUtc { get; set; }
Property Value
RepeatCount
Get the number of times per day this trigger should repeat. Setting to 0 means fire once per day; setting to N means fire N+1 times per day.
public int RepeatCount { get; set; }
Property Value
RepeatInterval
the time interval that will be added to the IDailyTimeIntervalTrigger's fire time (in the set repeat interval unit) in order to calculate the time of the next trigger repeat.
public int RepeatInterval { get; set; }
Property Value
RepeatIntervalUnit
the interval unit - the time unit on with the interval applies.
public IntervalUnit RepeatIntervalUnit { get; set; }
Property Value
Remarks
The repeat interval unit. The only intervals that are valid for this type of trigger are Second, Minute, and Hour.
StartTimeOfDay
The time of day to start firing at the given interval. Defaults to 00:00:00.
public TimeOnly StartTimeOfDay { get; set; }
Property Value
Exceptions
- ArgumentException
The value carries precision finer than a whole second, or it comes after EndTimeOfDay.
StartTimeUtc
The time at which the IDailyTimeIntervalTrigger should occur, rounded down to the whole second.
public override DateTimeOffset StartTimeUtc { get; set; }
Property Value
Remarks
CronTriggerImpl's start
time does not: GetFireTimeAfter(DateTimeOffset?) counts whole seconds from the start of the day,
so a start time of 22:50:00.68 truncated to 74100 seconds after a 02:15 start-of-day
landed exactly on a 5-minute boundary and produced a first fire time of 22:50:00.000 —
before the trigger's own start.
TimeZone
Gets the time zone within which time calculations related to this trigger will be performed.
public TimeZoneInfo TimeZone { get; set; }
Property Value
Remarks
If null, the system default TimeZone will be used.
TimesTriggered
the number of times the IDailyTimeIntervalTrigger has already fired.
public int TimesTriggered { get; set; }
Property Value
Methods
ComputeFirstFireTimeUtc(ICalendar?)
This method should not be used by the Quartz client.
public override DateTimeOffset? ComputeFirstFireTimeUtc(ICalendar? calendar)
Parameters
calendarICalendar
Returns
- DateTimeOffset?
The first time at which the ITrigger will be fired by the scheduler, which is also the same value NextFireTimeUtc will return (until after the first firing of the ITrigger).
Remarks
Called by the scheduler at the time a ITrigger is first added to the scheduler, in order to have the ITrigger compute its first fire time, based on any associated calendar.
After this method has been called, NextFireTimeUtc should return a valid answer.
GetFireTimeAfter(DateTimeOffset?)
Returns the next time at which the IDailyTimeIntervalTrigger will fire, after the given time. If the trigger will not fire after the given time, null will be returned.
public override DateTimeOffset? GetFireTimeAfter(DateTimeOffset? afterTime)
Parameters
afterTimeDateTimeOffset?
Returns
Remarks
A fire time that lands exactly on EndTimeUtc is one the trigger fires: the end time is the last instant at which a trigger may fire.
GetScheduleBuilder()
Get a IScheduleBuilder that is configured to produce a schedule identical to this trigger's schedule.
public override IScheduleBuilder GetScheduleBuilder()
Returns
RetryFired(ICalendar?)
This method should not be used by the Quartz client.
public override void RetryFired(ICalendar? calendar)
Parameters
calendarICalendarThe calendar the trigger observes, if any.
Remarks
Called by a job store when it is firing a retry rather than a scheduled occurrence — that is, when the trigger's next fire time is a retry instant ExecutionComplete(IJobExecutionContext, JobExecutionException?) put there. It advances NextFireTimeUtc past the retry to the occurrence the schedule actually calls for, applying the trigger's calendar exactly as Triggered(ICalendar?) does.
Unlike Triggered(ICalendar?) it touches no counter and does not move
PreviousFireTimeUtc: a retry is another attempt at an occurrence that has
already been counted, so it must not burn a repeat count or a recurrence rule's COUNT
slot, and it reports the original occurrence as its scheduled fire time.
- See Also
Triggered(ICalendar?)
Called when the scheduler has decided to 'fire' the trigger (execute the associated job), in order to give the trigger a chance to update itself for its next triggering (if any).
public override void Triggered(ICalendar? calendar)
Parameters
calendarICalendar
UpdateAfterMisfire(ICalendar?)
Updates the ICalendarIntervalTrigger's state based on the MisfireInstruction.XXX that was selected when the IDailyTimeIntervalTrigger was created.
public override void UpdateAfterMisfire(ICalendar? calendar)
Parameters
calendarICalendar
Remarks
If the misfire instruction is set to SmartPolicy, then the following scheme will be used:
- The instruction will be interpreted as FireAndProceed
UpdateWithNewCalendar(ICalendar, TimeSpan)
Moves the next fire time past whatever the calendar now excludes, so that a calendar added or changed after the trigger was stored takes effect on its next firing.
public override void UpdateWithNewCalendar(ICalendar calendar, TimeSpan misfireThreshold)
Parameters
calendarICalendarThe calendar the trigger is now to observe.
misfireThresholdTimeSpanHow far into the past a computed fire time may be before it counts as a misfire rather than as a firing that is merely late.
Validate()
Validates whether the properties of the IJobDetail are valid for submission into a IScheduler.
public override void Validate()
ValidateMisfireInstruction(int)
Whether the code is one of DailyTimeIntervalTriggerMisfireInstruction's values, or the family-agnostic "not set" and "smart policy".
protected override bool ValidateMisfireInstruction(int misfireInstruction)
Parameters
misfireInstructionintThe code being assigned.