Ejemplo n.º 1
0
 public override IEnumerable<ScheduleEntry> BuildSchedule()
 {
     var list = new List<ScheduleEntry>();
     var weekStart = Duration.Start;
     while (weekStart <= Duration.End)
     {
         var weekStartDayIndex = (int)weekStart.DayOfWeek;
         for (var d = weekStartDayIndex; d < DaysInWeek; d++)
         {
             var dayOfWeek = Enum.GetValues(typeof(DayOfWeek)).GetValue(d);
             foreach (var scheduleDay in Days)
             {
                 if (scheduleDay.Day.Equals(dayOfWeek))
                 {
                     var daysPastWeekStart = d;
                     if (weekStartDayIndex > 0)
                         daysPastWeekStart -= weekStartDayIndex;
                     var entryDate = weekStart.AddDays(daysPastWeekStart);
                     if (entryDate <= Duration.End)
                     {
                         var entry = new ScheduleEntry
                         {
                             Date = weekStart.AddDays(daysPastWeekStart),
                             Time = scheduleDay.Time
                         };
                         list.Add(entry);
                     }
                 }
             }
         }
         weekStart = CalculateStartOfNextWeek(weekStart);
     }
     return list;
 }
Ejemplo n.º 2
0
        public override IEnumerable<ScheduleEntry> BuildSchedule()
        {
            var list = new List<ScheduleEntry>();
            var startDate = Duration.Start;
            while (startDate <= Duration.End)
            {
                //start with list of all dates in month starting with the Duration start date.
                List<DateTime> targetDates = GetRemainingDatesInMonth(startDate);

                //remove any past end of duration
                targetDates = FilterToDurationRange(targetDates);

                //apply filtering based on parameters (this order matters)
                targetDates = FilterToOrdinalWeek(targetDates);
                targetDates = FilterToDayOfWeek(targetDates);
                targetDates = FilterToOrdinalDay(targetDates);
                targetDates = FilterToOnlyWorkDays(targetDates);

                //create entries for what remains
                foreach (var date in targetDates)
                {
                    var entry = new ScheduleEntry
                    {
                        Date = date,
                        Time = Time
                    };
                    list.Add(entry);
                }

                startDate = CalculateFirstDateOfNextMonth(startDate);
            }
            return list;
        }
Ejemplo n.º 3
0
 public override IEnumerable<ScheduleEntry> BuildSchedule()
 {
     var list = new List<ScheduleEntry>();
     var entryDate = Duration.Start;
     while (entryDate <= Duration.End)
     {
         var entry = new ScheduleEntry
         {
              Date = entryDate,
              Time = Time
         };
         list.Add(entry);
         entryDate = entryDate.AddDays(Frequency);
     }
     return list;
 }