Esempio n. 1
0
        public TemporalExpressionUnion Create(ISchedule schedule)
        {
            if (schedule.WeekInterval == WeekInterval.None)
            {
                throw new ArgumentException("WeekInterval must be set for schedules with a monthly frequency.");
            }

            if (schedule.DayInterval == DayInterval.None)
            {
                throw new ArgumentException("DayInterval must be set for schedules with a monthly frequency.");
            }

            var union           = new TemporalExpressionUnion();
            var weeklyIntervals = union.GetFlags(schedule.WeekInterval);

            foreach (var weeklyInterval in weeklyIntervals)
            {
                var daysOfWeek = union.GetFlags(schedule.DayInterval);
                foreach (var dayOfWeek in daysOfWeek)
                {
                    var dayInMonth = new ScheduleDayInMonth((DayInterval)dayOfWeek, (WeekInterval)weeklyInterval);
                    union.Add(dayInMonth);
                }
            }

            return(union);
        }
Esempio n. 2
0
        private static TemporalExpressionUnion GetObservedHolidays()
        {
            var observedHolidays = new TemporalExpressionUnion();

            observedHolidays.Add(new ScheduleFixedHoliday(7, 4));
            observedHolidays.Add(new ScheduleFloatingHoliday(MonthOfYear.Sep, DayOfWeek.Monday, WeekInterval.First));
            return(observedHolidays);
        }
Esempio n. 3
0
        public TemporalExpressionUnion Create(ISchedule schedule)
        {
            var union      = new TemporalExpressionUnion();
            var dayOfMonth = new ScheduleDayOfMonth(schedule.DayOfMonth);

            union.Add(dayOfMonth);
            return(union);
        }
        public TemporalExpressionUnion Create(ISchedule schedule)
        {
            var union = new TemporalExpressionUnion();

            foreach (DayInterval day in Enum.GetValues(typeof(DayInterval)))
            {
                union.Add(new ScheduleDayOfWeek(day));
            }

            return(union);
        }
        private static TemporalExpressionUnion GetEasterHolidays(int startYear, int endYear)
        {
            Debug.Assert(endYear >= startYear);
            var list  = Easter.GetEasterSundays(startYear, endYear);
            var union = new TemporalExpressionUnion();

            foreach (var date in list)
            {
                union.Add(new ScheduleDate(date));
            }
            return(union);
        }
        public TemporalExpressionUnion Create(ISchedule schedule)
        {
            if (schedule.Annual == null)
            {
                throw new ArgumentException("ScheduleAnnual must be set for schedules with an annual frequency.");
            }

            var annual = schedule.Annual;
            var union  = new TemporalExpressionUnion();

            union.Add(annual);
            return(union);
        }
Esempio n. 7
0
        /// <summary>
        /// Given a schedule with a quarterly frequency build out a union of temporal expressions
        /// to describe schedules that include day(s), week(s), and month(s) within a quarter.
        /// For example:
        ///
        /// (1) last Fri of the last week of the last month in the 1st and 3rd quarters.
        /// (2) first Mon of every week of the first month in every quarter.
        /// </summary>
        /// <returns></returns>
        public TemporalExpressionUnion Create(ISchedule schedule)
        {
            if (schedule.QuarterInterval == QuarterInterval.None)
            {
                throw new ArgumentException("QuarterInterval must be set for schedules with a quarterly frequency.");
            }

            if (schedule.MonthOfQuarterInterval == MonthOfQuarterInterval.None)
            {
                throw new ArgumentException("MonthOfQuarterInterval must be set for schedules with a quarterly frequency.");
            }

            if (schedule.WeekInterval == WeekInterval.None)
            {
                throw new ArgumentException("WeekInterval must be set for schedules with a quarterly frequency.");
            }

            if (schedule.DayInterval == DayInterval.None)
            {
                throw new ArgumentException("DayInterval must be set for schedules with a quarterly frequency.");
            }

            var union = new TemporalExpressionUnion();
            var quarterlyIntervals = union.GetFlags(schedule.QuarterInterval);

            foreach (var quarter in quarterlyIntervals)
            {
                var monthOfQuarterIntervals = union.GetFlags(schedule.MonthOfQuarterInterval);
                foreach (var monthOfQuarter in monthOfQuarterIntervals)
                {
                    var weeklyIntervals = union.GetFlags(schedule.WeekInterval);
                    foreach (var week in weeklyIntervals)
                    {
                        var daysOfWeek = union.GetFlags(schedule.DayInterval);
                        foreach (var day in daysOfWeek)
                        {
                            var dayInQuarter = new ScheduleDayInQuarter(
                                (DayInterval)day,
                                (WeekInterval)week,
                                (QuarterInterval)quarter,
                                (MonthOfQuarterInterval)monthOfQuarter
                                );

                            union.Add(dayInQuarter);
                        }
                    }
                }
            }

            return(union);
        }
Esempio n. 8
0
        private static TemporalExpressionUnion GetHolidays()
        {
            var union = new TemporalExpressionUnion();
            var independenceDayUnitedStates = new ScheduleFixedHoliday(7, 4);
            var laborDayUnitedStates        = new ScheduleFloatingHoliday(MonthOfYear.Sep, DayOfWeek.Monday, WeekInterval.First);
            var christmasDay = new ScheduleFixedHoliday(12, 25);
            var ludwigWittgensteinBirthday = new ScheduleFixedHoliday(4, 26);

            union.Add(independenceDayUnitedStates);
            union.Add(laborDayUnitedStates);
            union.Add(christmasDay);
            union.Add(ludwigWittgensteinBirthday);

            return(union);
        }
        public TemporalExpressionUnion Create(ISchedule schedule)
        {
            if (schedule.DayInterval == DayInterval.None)
            {
                throw new ArgumentException("DayInterval must be set for schedules with a weekly frequency.");
            }

            var union      = new TemporalExpressionUnion();
            var daysOfWeek = union.GetFlags(schedule.DayInterval);

            foreach (var day in daysOfWeek)
            {
                var dayOfWeek = new ScheduleDayOfWeek((DayInterval)day);
                union.Add(dayOfWeek);
            }

            return(union);
        }
Esempio n. 10
0
 public void SetExcludedDates(TemporalExpressionUnion union)
 {
     ExcludedDates = union;
 }
Esempio n. 11
0
 public ScheduleBuilder Excluding(TemporalExpressionUnion excludedDates)
 {
     Schedule.SetExcludedDates(excludedDates);
     return(this);
 }