示例#1
0
        public BasicSchedule SaveSchedule()
        {
            BasicSchedule schedule = null;

            if (IsOnce)
            {
                schedule = new BasicSchedule();
            }
            else if (IsEveryDay)
            {
                schedule = new DayRepeatSchedule();
                var daySchedule = schedule as DayRepeatSchedule;
                daySchedule.RepeatPerDays = EveryDayIntervalDays;
            }
            else if (IsEveryWeek)
            {
                schedule = new WeekRepeatSchedule();
                var weekSchedule = schedule as WeekRepeatSchedule;
                weekSchedule.RepeatPerWeeks = EveryWeekIntervalWeeks;
                weekSchedule.RepeatWeekDays = EveryWeekWeekDays.Select(wd => wd.DayOfWeek).ToArray();
            }
            else if (IsEveryMonth)
            {
                schedule = new MonthRepeatSchedule();
                var monthSchedule = schedule as MonthRepeatSchedule;
                monthSchedule.Months = EveryMonthMonths.Select(wm => wm.Month).ToArray();

                if (EveryMonthDaySchedule)
                {
                    monthSchedule.Days = EveryMonthDays.Select(md => md.Day).ToArray();
                }
                else if (EveryMonthWeekSchedule)
                {
                    monthSchedule.WeekOrders = EveryMonthWeeks.Select(ww => ww.WeekNumber).ToArray();
                    monthSchedule.WeekDays   = EveryMonthWeekDays.Select(wd => wd.DayOfWeek).ToArray();
                }
            }


            schedule.BeginTime = StartAtDate;

            if (RepeatSchedule)
            {
                schedule.RepeatPeriod = RepeatPeriod;

                if (RepeatUntil)
                {
                    schedule.RepeatUntil = RepeatUntilTime;
                }
            }

            if (HasEndTime)
            {
                schedule.EndTime = EndTime;
            }

            schedule.Enabled = IsEnabled;
            return(schedule);
        }
示例#2
0
        public BasicSchedule SaveSchedule()
        {
            BasicSchedule schedule = null;

            if (rbOneTime.Checked)
            {
                schedule = new BasicSchedule();
            }
            else if (rbPerDay.Checked)
            {
                schedule = new DayRepeatSchedule();
                var daySchedule = schedule as DayRepeatSchedule;
                daySchedule.RepeatPerDays = getRepeatPerDays();
            }
            else if (rbPerWeek.Checked)
            {
                schedule = new WeekRepeatSchedule();
                var weekSchedule = schedule as WeekRepeatSchedule;
                weekSchedule.RepeatPerWeeks = getRepeatPerWeeks();
                weekSchedule.RepeatWeekDays = getRepeatWeekDays();
            }
            else if (rbPerMonth.Checked)
            {
                schedule = new MonthRepeatSchedule();
                var monthSchedule = schedule as MonthRepeatSchedule;
                monthSchedule.Months = (from i in clbMonth.CheckedIndices.Cast <int>()
                                        where i > 0
                                        select i).ToArray();

                if (rbDays.Checked)
                {
                    monthSchedule.Days = (from i in clbDays.CheckedIndices.Cast <int>()
                                          where i > 0
                                          select i).ToArray();
                }
                else if (rbOn.Checked)
                {
                    monthSchedule.WeekOrders = (from i in clbOrder.CheckedIndices.Cast <int>()
                                                where i > 0
                                                select i).ToArray();
                    monthSchedule.WeekDays = (from i in clbWeeks.CheckedIndices.Cast <int>()
                                              where i > 0
                                              select(DayOfWeek)(i - 1)).ToArray();
                }
            }


            schedule.BeginTime = getBeginTime();

            if (cbRepeat.Checked)
            {
                schedule.RepeatPeriod = getRepeatPeriod();

                if (cbRepeatUntil.Checked)
                {
                    schedule.RepeatUntil = getRepeatUntil();
                }
            }

            if (cbUntil.Checked)
            {
                schedule.EndTime = getEndTime();
            }

            schedule.Enabled = getEnabled();
            return(schedule);
        }