Exemplo n.º 1
0
        protected override bool OnVisitDay(Day day, CalendarPeriodCollectorContext context)
        {
            if (context.Scope != CalendarPeriodCollectorContext.CollectType.Hour)
            {
                return(true); // continue
            }

            if (Filter.CollectingHours.Count == 0 && Filter.CollectingDayHours.Count == 0)
            {
                foreach (Hour hour in day.GetHours())
                {
                    if (IsMatchingHour(hour, context) && CheckLimits(hour))
                    {
                        Periods.Add(hour);
                    }
                }
            }
            else
            {
                if (IsMatchingDay(day, context))
                {
                    List <HourRange> collectingHours = new List <HourRange>(Filter.CollectingHours);
                    foreach (DayHourRange collectingDayHour in Filter.CollectingDayHours)
                    {
                        if (collectingDayHour.Day == day.DayOfWeek)
                        {
                            collectingHours.Add(collectingDayHour);
                        }
                    }
                    foreach (HourRange collectingHour in collectingHours)
                    {
                        DateTime          start = collectingHour.Start.ToDateTime(day.Start);
                        DateTime          end   = collectingHour.End.ToDateTime(day.Start);
                        CalendarTimeRange hours = new CalendarTimeRange(start, end, day.Calendar);
                        if (CheckExcludePeriods(hours) && CheckLimits(hours))
                        {
                            Periods.Add(hours);
                        }
                    }
                }
            }

            return(false); // abort
        }
Exemplo n.º 2
0
 private bool HasSameData(CalendarTimeRange comp)
 {
     return(Calendar.Equals(comp.Calendar));
 }