Exemplo n.º 1
0
 /// <summary>
 /// Intended to be used internally by ConfigurationLoader
 /// </summary>
 /// <param name="paramsObj">Filled object with init params</param>
 public DailySchedule(ScheduleParams paramsObj)
 {
     if (paramsObj.OccursOnceAt.HasValue)
     {
         DailyInitOnce(ref _occursOnceAt, ref _type, paramsObj.OccursOnceAt,
                       paramsObj.Enabled, paramsObj.Description);
     }
     else
     {
         DailyInitRecurring(ref _interval, ref _intervalUnit, ref _startAt, ref _endAt, ref _type, ref SpanStart, ref SpanEnd,
                            paramsObj.IntervalUnit.Value, paramsObj.Interval.Value, paramsObj.StartAt, paramsObj.EndAt,
                            paramsObj.Enabled, paramsObj.Description);
     }
 }
Exemplo n.º 2
0
        private ScheduleParams ConvertToScheduleParamsObject(ScheduleConfig schConfig)
        {
            // ScheduleConfig is helper class, used to bind to section in IConfiguration
            // ScheduleParams holds checked, ready-to-use params in schedules constructors

            bool schModeOnce      = !string.IsNullOrWhiteSpace(schConfig.OccursOnceAt);
            bool schModeRecurring = !string.IsNullOrWhiteSpace(schConfig.IntervalUnit);

            if (schModeOnce && schModeRecurring)
            {
                throw new ArgumentException("You must choose only a single option, OccursOnceAt to fire single time of a day, or IntervalUnit for recurring event firing.");
            }

            if (!schModeOnce && !schModeRecurring)
            {
                throw new ArgumentException("You must choose a single option, OccursOnceAt or IntervalUnit (for recurring event firing).");
            }

            var paramsObj = new ScheduleParams();

            if (schModeOnce)
            {
                paramsObj.OccursOnceAt = new Time(schConfig.OccursOnceAt);
            }
            else if (schModeRecurring)
            {
                paramsObj.Interval     = schConfig.Interval;
                paramsObj.IntervalUnit = (DailyIntervalUnit)Enum.Parse(typeof(DailyIntervalUnit), ToTitleCase(schConfig.IntervalUnit));
                paramsObj.StartAt      = string.IsNullOrWhiteSpace(schConfig.StartAt) ? (Time?)null : new Time(schConfig.StartAt);
                paramsObj.EndAt        = string.IsNullOrWhiteSpace(schConfig.EndAt) ? (Time?)null : new Time(schConfig.EndAt);
            }

            paramsObj.Enabled     = schConfig.Enabled;
            paramsObj.Description = schConfig.Description;

            if (schConfig.DaysOfWeek != null)
            {
                paramsObj.DaysOfWeek = ConvertWeekDays(schConfig.DaysOfWeek);
            }

            if (schConfig.LaunchDays != null)
            {
                paramsObj.LaunchDays = schConfig.LaunchDays;
            }

            return(paramsObj);
        }
Exemplo n.º 3
0
 /// <summary>
 /// Intended to be used internally by ConfigurationLoader
 /// </summary>
 /// <param name="paramsObj">Filled object with init params</param>
 public WeeklySchedule(ScheduleParams paramsObj) : base(paramsObj)
 {
     InitWeeklySchedule(paramsObj.DaysOfWeek);
 }
Exemplo n.º 4
0
 /// <summary>
 /// Intended to be used internally by ConfigurationLoader
 /// </summary>
 /// <param name="paramsObj">Filled object with init params</param>
 public MonthlySchedule(ScheduleParams paramsObj) : base(paramsObj)
 {
     InitMonthlySchedule(paramsObj.LaunchDays);
 }