Quartz.Impl.Triggers.DailyTimeIntervalTriggerImpl.Validate C# (CSharp) Method

Validate() public method

Validates whether the properties of the IJobDetail are valid for submission into a IScheduler.
public Validate ( ) : void
return void
        public override void Validate()
        {
            base.Validate();

            if (repeatIntervalUnit != IntervalUnit.Second && repeatIntervalUnit != IntervalUnit.Minute && repeatIntervalUnit != IntervalUnit.Hour)
            {
                throw new SchedulerException("Invalid repeat IntervalUnit (must be Second, Minute or Hour).");
            }
            if (repeatInterval < 1)
            {
                throw new SchedulerException("Repeat Interval cannot be zero.");
            }

            // Ensure interval does not exceed 24 hours
            const long SecondsInHour = 24 * 60 * 60L;
            if (repeatIntervalUnit == IntervalUnit.Second && repeatInterval > SecondsInHour)
            {
                throw new SchedulerException("repeatInterval can not exceed 24 hours (" + SecondsInHour + " seconds). Given " + repeatInterval);
            }
            if (repeatIntervalUnit == IntervalUnit.Minute && repeatInterval > SecondsInHour / 60L)
            {
                throw new SchedulerException("repeatInterval can not exceed 24 hours (" + SecondsInHour / 60L + " minutes). Given " + repeatInterval);
            }
            if (repeatIntervalUnit == IntervalUnit.Hour && repeatInterval > 24)
            {
                throw new SchedulerException("repeatInterval can not exceed 24 hours. Given " + repeatInterval + " hours.");
            }

            // Ensure timeOfDay is in order.
            if (EndTimeOfDay != null && EndTimeOfDay.Before(StartTimeOfDay))
            {
                throw new SchedulerException("StartTimeOfDay " + startTimeOfDay + " should not come after endTimeOfDay " + endTimeOfDay);
            }
        }

Usage Example

 public void TestValidateTimeOfDayOrder()
 {
     var trigger = new DailyTimeIntervalTriggerImpl
     {
         StartTimeOfDay = new TimeOfDay(12, 0, 0),
         EndTimeOfDay = new TimeOfDay(8, 0, 0)
     };
     try
     {
         trigger.Validate();
         Assert.Fail("Trigger should be invalidate when time of day is not in order.");
     }
     catch (SchedulerException)
     {
         // expected.
     }
 }
All Usage Examples Of Quartz.Impl.Triggers.DailyTimeIntervalTriggerImpl::Validate