Class DailyTimeIntervalScheduleBuilder
- Namespace
- Quartz
- Assembly
- Quartz.dll
A IScheduleBuilder implementation that build schedule for DailyTimeIntervalTrigger.
public sealed class DailyTimeIntervalScheduleBuilder : IScheduleBuilder
- Inheritance
-
DailyTimeIntervalScheduleBuilder
- Implements
- Inherited Members
Remarks
This builder provide an extra convenient method for you to set the trigger's EndTimeOfDay. You may use either endingDailyAt() or EndingDailyAfterCount() to set the value. The later will auto calculate your EndTimeOfDay by using the interval, IntervalUnit and StartTimeOfDay to perform the calculation.
When using EndingDailyAfterCount(), you should note that it is used to calculating EndTimeOfDay. So if your startTime on the first day is already pass by a time that would not add up to the count you expected, until the next day comes. Remember that DailyTimeIntervalTrigger will use StartTimeOfDay and endTimeOfDay as fresh per each day!
Quartz provides a builder-style API for constructing scheduling-related entities via a Domain-Specific Language (DSL). The DSL can best be utilized through the usage of static imports of the methods on the classes TriggerBuilder, JobBuilder, DateBuilder, JobKey, TriggerKey and the various IScheduleBuilder implementations.
Client code can then use the DSL to write code such as this:
IJobDetail job = JobBuilder.Create<MyJob>()
.WithIdentity("myJob")
.Build();
ITrigger trigger = TriggerBuilder.Create()
.WithIdentity("myTrigger", "myTriggerGroup")
.WithDailyTimeIntervalSchedule(x =>
x.WithInterval(15, IntervalUnit.Minute)
.StartingDailyAt(new TimeOnly(8, 0)))
.Build();
await scheduler.ScheduleJob(job, trigger);
Methods
Build()
Build the actual Trigger -- NOT intended to be invoked by end users, but will rather be invoked by a TriggerBuilder which this ScheduleBuilder is given to.
public IMutableTrigger Build()
Returns
Create()
Create a DailyTimeIntervalScheduleBuilder
public static DailyTimeIntervalScheduleBuilder Create()
Returns
- DailyTimeIntervalScheduleBuilder
The new DailyTimeIntervalScheduleBuilder
Remarks
The clock EndingDailyAfterCount(int) computes against comes from the TriggerBuilder<TJob> that builds the trigger, so a scheduler configured with a custom TimeProvider is honored without handing one to this builder.
EndingDailyAfterCount(int)
End the daily window after the given number of firings: the EndTimeOfDay is calculated from the count, the interval and the StartTimeOfDay.
public DailyTimeIntervalScheduleBuilder EndingDailyAfterCount(int count)
Parameters
countintthe number of firings per day (>= 1).
Returns
- DailyTimeIntervalScheduleBuilder
the updated DailyTimeIntervalScheduleBuilder
Remarks
The calculation is deferred to Build(), so it sees the schedule's final start time, interval and time zone regardless of the order the builder was configured in, and it runs against the clock of the TriggerBuilder<TJob> that builds the trigger. A count too large for the daily window is therefore reported by Build(), not by this call.
EndingDailyAt(TimeOnly)
The time of day for this trigger to end firing each day. Defaults to 23:59:59.
public DailyTimeIntervalScheduleBuilder EndingDailyAt(TimeOnly timeOfDay)
Parameters
timeOfDayTimeOnlythe time of day, with one-second resolution.
Returns
- DailyTimeIntervalScheduleBuilder
the updated DailyTimeIntervalScheduleBuilder
Exceptions
- ArgumentException
timeOfDaycarries precision finer than a whole second.
InTimeZone(TimeZoneInfo?)
TimeZone in which to base the schedule.
public DailyTimeIntervalScheduleBuilder InTimeZone(TimeZoneInfo? timeZone)
Parameters
timeZoneTimeZoneInfothe time-zone for the schedule; null means the system's local time zone.
Returns
- DailyTimeIntervalScheduleBuilder
the updated DailyTimeIntervalScheduleBuilder
- See Also
OnDaysOfTheWeek(params IReadOnlyCollection<DayOfWeek>)
Set the trigger to fire on the given days of the week.
public DailyTimeIntervalScheduleBuilder OnDaysOfTheWeek(params IReadOnlyCollection<DayOfWeek> onDaysOfWeek)
Parameters
onDaysOfWeekIReadOnlyCollection<DayOfWeek>the days of the week to fire on; pass them as separate arguments or as any collection.
Returns
- DailyTimeIntervalScheduleBuilder
the updated DailyTimeIntervalScheduleBuilder
OnEveryDay()
Set the trigger to fire on all days of the week.
public DailyTimeIntervalScheduleBuilder OnEveryDay()
Returns
- DailyTimeIntervalScheduleBuilder
the updated DailyTimeIntervalScheduleBuilder
OnMondayThroughFriday()
Set the trigger to fire on the days from Monday through Friday.
public DailyTimeIntervalScheduleBuilder OnMondayThroughFriday()
Returns
- DailyTimeIntervalScheduleBuilder
the updated DailyTimeIntervalScheduleBuilder
OnSaturdayAndSunday()
Set the trigger to fire on the days Saturday and Sunday.
public DailyTimeIntervalScheduleBuilder OnSaturdayAndSunday()
Returns
- DailyTimeIntervalScheduleBuilder
the updated DailyTimeIntervalScheduleBuilder
StartingDailyAt(TimeOnly)
The time of day for this trigger to start firing each day. Defaults to 00:00:00.
public DailyTimeIntervalScheduleBuilder StartingDailyAt(TimeOnly timeOfDay)
Parameters
timeOfDayTimeOnlythe time of day, with one-second resolution.
Returns
- DailyTimeIntervalScheduleBuilder
the updated DailyTimeIntervalScheduleBuilder
Exceptions
- ArgumentException
timeOfDaycarries precision finer than a whole second.
WithInterval(int, IntervalUnit)
Specify the time unit and interval for the Trigger to be produced.
public DailyTimeIntervalScheduleBuilder WithInterval(int interval, IntervalUnit unit)
Parameters
intervalintthe interval at which the trigger should repeat.
unitIntervalUnitthe time unit (IntervalUnit) of the interval.
Returns
- DailyTimeIntervalScheduleBuilder
the updated CalendarIntervalScheduleBuilder
- See Also
WithMisfireInstruction(DailyTimeIntervalTriggerMisfireInstruction)
Say what the trigger should do when it misses a firing.
public DailyTimeIntervalScheduleBuilder WithMisfireInstruction(DailyTimeIntervalTriggerMisfireInstruction instruction)
Parameters
instructionDailyTimeIntervalTriggerMisfireInstructionthe policy to apply; defaults to SmartPolicy.
Returns
- DailyTimeIntervalScheduleBuilder
the updated DailyTimeIntervalScheduleBuilder
- See Also
WithRepeatCount(int)
Set the number of times per day for interval to repeat.
public DailyTimeIntervalScheduleBuilder WithRepeatCount(int repeatCount)
Parameters
repeatCountint
Returns
Remarks
Note: total fires per day = 1 (at startTimeOfDay) + repeatCount. The trigger resets each day and repeats on subsequent valid days.