/// <summary>
        /// Get a <see cref="IScheduleBuilder" /> that is configured to produce a
        /// schedule identical to this trigger's schedule.
        /// </summary>
        /// <returns></returns>
        /// <see cref="TriggerBuilder"/>
        public override IScheduleBuilder GetScheduleBuilder()
        {
            DailyTimeIntervalScheduleBuilder cb = DailyTimeIntervalScheduleBuilder.Create()
                                                  .WithInterval(RepeatInterval, RepeatIntervalUnit)
                                                  .OnDaysOfTheWeek(DaysOfWeek)
                                                  .StartingDailyAt(StartTimeOfDay)
                                                  .EndingDailyAt(EndTimeOfDay);

            switch (MisfireInstruction)
            {
            case Quartz.MisfireInstruction.DailyTimeIntervalTrigger.DoNothing:
                cb.WithMisfireHandlingInstructionDoNothing();
                break;

            case Quartz.MisfireInstruction.DailyTimeIntervalTrigger.FireOnceNow:
                cb.WithMisfireHandlingInstructionFireAndProceed();
                break;
            }

            return(cb);
        }
Exemplo n.º 2
0
        private static DailyTimeIntervalScheduleBuilder zCreateDailyTimeIntervalSchedule(DailyRepeatableSchedule schedule)
        {
            DailyTimeIntervalScheduleBuilder sb = DailyTimeIntervalScheduleBuilder.Create();

            switch (schedule.MissedScheduleMode)
            {
            case MissedScheduleMode.RunImmediately:
                sb = sb.WithMisfireHandlingInstructionFireAndProceed();
                break;

            case MissedScheduleMode.RunAtNextScheduledTime:
                sb = sb.WithMisfireHandlingInstructionDoNothing();
                break;

            default:
                throw new NotImplementedException();
            }
            if (schedule.RepeatsDailyOnInterval)
            {
                sb = sb.StartingDailyAt(TimeOfDay.HourMinuteAndSecondOfDay(
                                            schedule.DailyRepetitionStartTimeUtc.Hour,
                                            schedule.DailyRepetitionStartTimeUtc.Minute,
                                            schedule.DailyRepetitionStartTimeUtc.Second))
                     .WithIntervalInSeconds((int)schedule.DailyRepetitionInterval.TotalSeconds)
                     .EndingDailyAt(TimeOfDay.HourMinuteAndSecondOfDay(
                                        schedule.DailyRepetitionEndTimeUtc.Hour,
                                        schedule.DailyRepetitionEndTimeUtc.Minute,
                                        schedule.DailyRepetitionEndTimeUtc.Second));
            }
            else
            {
                sb = sb.StartingDailyAt(TimeOfDay.HourMinuteAndSecondOfDay(
                                            schedule.StartTimeUtc.Hour,
                                            schedule.StartTimeUtc.Minute,
                                            schedule.StartTimeUtc.Second))
                     .WithIntervalInHours(24);
            }
            return(sb);
        }