Beispiel #1
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);
        }
		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;
		}