コード例 #1
0
        public IEnumerable <FillLevelReading> GenerateFillLevelReadings(TaskGeneratorConfig taskGeneratorConfig)
        {
            if (!taskGeneratorConfig.Repeat)
            {
                return(new[]
                {
                    CreateFillLevelReading(taskGeneratorConfig.Begin, taskGeneratorConfig.End, taskGeneratorConfig.IsAllDay, taskGeneratorConfig.Container, taskGeneratorConfig.ResponsibleSubject,
                                           taskGeneratorConfig.Series)
                });
            }

            IEnumerable <DateTime> dates;

            switch (taskGeneratorConfig.Cycle)
            {
            case 0:
            {
                dates = GenerateDailyRecurrence(taskGeneratorConfig.Begin, taskGeneratorConfig.RecurrenceInterval, taskGeneratorConfig.EndsWithDate, taskGeneratorConfig.RepeatUntilDate,
                                                taskGeneratorConfig.NumberOfRecurrences);
                break;
            }

            case 1:
            {
                dates = GenerateWeeklyRecurrence(taskGeneratorConfig.Begin, taskGeneratorConfig.RecurrenceInterval, taskGeneratorConfig.EndsWithDate, taskGeneratorConfig.RepeatUntilDate,
                                                 taskGeneratorConfig.NumberOfRecurrences, taskGeneratorConfig.WeekDays);
                break;
            }

            case 2:
            {
                dates = GenerateMonthlyRecurrence(taskGeneratorConfig.Begin, taskGeneratorConfig.RecurrenceInterval, taskGeneratorConfig.EndsWithDate, taskGeneratorConfig.RepeatUntilDate,
                                                  taskGeneratorConfig.NumberOfRecurrences, taskGeneratorConfig.IsWeekdayRecurrence);
                break;
            }

            case 3:
            {
                dates = GenerateYearlyRecurrence(taskGeneratorConfig.Begin, taskGeneratorConfig.RecurrenceInterval, taskGeneratorConfig.EndsWithDate, taskGeneratorConfig.RepeatUntilDate,
                                                 taskGeneratorConfig.NumberOfRecurrences);
                break;
            }

            default:
                throw new InvalidOperationException();
            }

            var range = taskGeneratorConfig.End.Subtract(taskGeneratorConfig.Begin);

            return
                (dates.Select(
                     date => CreateFillLevelReading(date, date.Add(range), taskGeneratorConfig.IsAllDay, taskGeneratorConfig.Container, taskGeneratorConfig.ResponsibleSubject, taskGeneratorConfig.Series)));
        }
コード例 #2
0
        public IEnumerable <FillLevelReading> GenerateFillLevelReadings(WasteContainer container, ResponsibleSubject responsibleSubject, Series series, DayOfWeek[] weekDays)
        {
            var taskGeneratorConfig = new TaskGeneratorConfig();

            taskGeneratorConfig.Container          = container;
            taskGeneratorConfig.Series             = series;
            taskGeneratorConfig.ResponsibleSubject = responsibleSubject;
            taskGeneratorConfig.WeekDays           = weekDays;

            taskGeneratorConfig.Begin               = series.Begin;
            taskGeneratorConfig.End                 = series.End;
            taskGeneratorConfig.Repeat              = series.Repeat;
            taskGeneratorConfig.RecurrenceInterval  = series.RecurrenceInterval;
            taskGeneratorConfig.EndsWithDate        = series.EndsWithDate;
            taskGeneratorConfig.RepeatUntilDate     = series.RepeatUntilDate;
            taskGeneratorConfig.NumberOfRecurrences = series.NumberOfRecurrences;
            taskGeneratorConfig.IsWeekdayRecurrence = series.IsWeekdayRecurrence;
            taskGeneratorConfig.IsAllDay            = series.IsAllDay;
            taskGeneratorConfig.Cycle               = series.Cycle;

            return(GenerateFillLevelReadings(taskGeneratorConfig));
        }