Exemple #1
0
        public override RecurrencePattern ConvertToRecurrencePattern()
        {
            RecurrencePattern pattern = new RecurrencePattern();

            pattern.Frequency      = RecurrenceFrequency.Yearly;
            pattern.DayOrdinal     = DayOfWeekIndexConverter.ConvertToDayOrdinal(DayOfWeekIndex);
            pattern.DaysOfWeekMask = DaysOfWeekStringConverter.ConvertToRecurrenceDay(DaysOfWeek);
            pattern.Month          = (RecurrenceMonth)Enum.Parse(typeof(RecurrenceMonth), Month.ToString());
            return(pattern);
        }
Exemple #2
0
        public override RecurrencePattern ConvertToRecurrencePattern()
        {
            RecurrencePattern pattern = new RecurrencePattern();

            pattern.Frequency      = RecurrenceFrequency.Monthly;
            pattern.DayOrdinal     = DayOfWeekIndexConverter.ConvertToDayOrdinal(DayOfWeekIndex);
            pattern.DaysOfWeekMask = DayOfWeekConverter.ConvertToRecurrenceDay(DaysOfWeek);
            pattern.Interval       = Interval;
            return(pattern);
        }
Exemple #3
0
        public static RecurrencePatternBaseType CreateFromSchedulerRecurrencePattern(RecurrencePattern schedulerPattern)
        {
            if (schedulerPattern.Frequency == RecurrenceFrequency.Daily)
            {
                if (schedulerPattern.DaysOfWeekMask == RecurrenceDay.EveryDay)
                {
                    DailyRecurrencePatternType pattern = new DailyRecurrencePatternType();
                    pattern.Interval = schedulerPattern.Interval;
                    return(pattern);
                }
                else
                {
                    WeeklyRecurrencePatternType pattern = new WeeklyRecurrencePatternType();
                    pattern.Interval   = 1;                   // Interval is ignored in this case.
                    pattern.DaysOfWeek = DaysOfWeekStringConverter.ConvertFromRecurrenceDay(schedulerPattern.DaysOfWeekMask, false);
                    return(pattern);
                }
            }

            if (schedulerPattern.Frequency == RecurrenceFrequency.Weekly)
            {
                WeeklyRecurrencePatternType pattern = new WeeklyRecurrencePatternType();
                pattern.Interval   = schedulerPattern.Interval;
                pattern.DaysOfWeek = DaysOfWeekStringConverter.ConvertFromRecurrenceDay(schedulerPattern.DaysOfWeekMask, false);
                return(pattern);
            }

            if (schedulerPattern.Frequency == RecurrenceFrequency.Monthly)
            {
                if (schedulerPattern.DayOfMonth > 0)
                {
                    AbsoluteMonthlyRecurrencePatternType pattern = new AbsoluteMonthlyRecurrencePatternType();
                    pattern.Interval   = schedulerPattern.Interval;
                    pattern.DayOfMonth = schedulerPattern.DayOfMonth;
                    return(pattern);
                }
                else
                {
                    RelativeMonthlyRecurrencePatternType pattern = new RelativeMonthlyRecurrencePatternType();
                    pattern.Interval       = schedulerPattern.Interval;
                    pattern.DayOfWeekIndex = DayOfWeekIndexConverter.ConvertFromDayOrdinal(schedulerPattern.DayOrdinal);
                    pattern.DaysOfWeek     = DayOfWeekConverter.ConvertFromRecurrenceDay(schedulerPattern.DaysOfWeekMask);
                    return(pattern);
                }
            }

            if (schedulerPattern.Frequency == RecurrenceFrequency.Yearly)
            {
                if (schedulerPattern.DayOfMonth > 0)
                {
                    AbsoluteYearlyRecurrencePatternType pattern = new AbsoluteYearlyRecurrencePatternType();
                    pattern.Month      = (MonthNamesType)Enum.Parse(typeof(MonthNamesType), schedulerPattern.Month.ToString());
                    pattern.DayOfMonth = schedulerPattern.DayOfMonth;
                    return(pattern);
                }
                else
                {
                    RelativeYearlyRecurrencePatternType pattern = new RelativeYearlyRecurrencePatternType();
                    pattern.Month          = (MonthNamesType)Enum.Parse(typeof(MonthNamesType), schedulerPattern.Month.ToString());
                    pattern.DayOfWeekIndex = DayOfWeekIndexConverter.ConvertFromDayOrdinal(schedulerPattern.DayOrdinal);
                    pattern.DaysOfWeek     = DaysOfWeekStringConverter.ConvertFromRecurrenceDay(schedulerPattern.DaysOfWeekMask, true);
                    return(pattern);
                }
            }

            return(null);
        }