/// <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          = StartTimeUtc.ToLocalTime();
            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);
        }
Beispiel #2
0
        public string BuildDescription()
        {
            StringBuilder sb = new StringBuilder();

            zBuildDescription(sb);
            sb.AppendFormat(" effective {0}", StartTimeUtc.ToLocalTime());
            if (EndTimeUtc.HasValue)
            {
                sb.AppendFormat(" until {0}", EndTimeUtc.Value.ToLocalTime());
            }
            return(sb.ToString());
        }
Beispiel #3
0
 protected override void zBuildDescription(StringBuilder sb)
 {
     if (RepeatsDailyOnInterval)
     {
         sb.AppendFormat("repeating {0} between {1} and {2}",
                         DescriptionUtils.GetIntervalDescription(DailyRepetitionInterval),
                         DailyRepetitionStartTimeUtc.ToLocalTime().ToLongTimeString(),
                         DailyRepetitionEndTimeUtc.ToLocalTime().ToLongTimeString());
     }
     else
     {
         sb.AppendFormat("at {0}", StartTimeUtc.ToLocalTime().ToLongTimeString());
     }
 }