private RecurrencePattern CreateMonthlyRecurrence(Recurrence icalRecurrence, ExDateTime start, CalendarType calendarType) { RecurrencePattern result = null; if (icalRecurrence.ByDayList == null && icalRecurrence.BySetPosition == null) { int dayOfMonth = (icalRecurrence.ByMonthDay != null) ? icalRecurrence.ByMonthDay[0] : start.Day; result = new MonthlyRecurrencePattern(dayOfMonth, icalRecurrence.Interval, calendarType); } else if (icalRecurrence.ByDayList != null && icalRecurrence.ByMonthDay == null) { DaysOfWeek daysOfWeek = VItemBase.DaysOfWeekFromByDayList(icalRecurrence.ByDayList, start); int occurrenceNumber = icalRecurrence.ByDayList[0].OccurrenceNumber; RecurrenceOrderType?recurrenceOrderType = null; if (icalRecurrence.BySetPosition != null) { if (occurrenceNumber == 0 && icalRecurrence.BySetPosition[0] >= -1 && icalRecurrence.BySetPosition[0] <= 4 && icalRecurrence.BySetPosition[0] != 0) { recurrenceOrderType = new RecurrenceOrderType?((RecurrenceOrderType)icalRecurrence.BySetPosition[0]); } } else if (occurrenceNumber != 0) { recurrenceOrderType = new RecurrenceOrderType?((RecurrenceOrderType)occurrenceNumber); } if (recurrenceOrderType != null) { result = new MonthlyThRecurrencePattern(daysOfWeek, recurrenceOrderType.Value, icalRecurrence.Interval, calendarType); } } return(result); }
public override bool Equals(RecurrencePattern value, bool ignoreCalendarTypeAndIsLeapMonth) { if (!(value is MonthlyThRecurrencePattern)) { return(false); } MonthlyThRecurrencePattern monthlyThRecurrencePattern = (MonthlyThRecurrencePattern)value; return(monthlyThRecurrencePattern.DaysOfWeek == this.daysOfWeek && monthlyThRecurrencePattern.Order == this.order && (ignoreCalendarTypeAndIsLeapMonth || monthlyThRecurrencePattern.calendarType == this.calendarType) && base.Equals(value, ignoreCalendarTypeAndIsLeapMonth)); }
internal override LocalizedString When() { if (Recurrence.IsGregorianCompatible(this.CalendarType)) { if (base.RecurrenceInterval == 1) { if (base.RecurrenceObjectType == RecurrenceObjectType.CalendarRecurrence) { return(ClientStrings.CalendarWhenMonthlyThEveryMonth(MonthlyThRecurrencePattern.OrderAsString(this.Order), new LocalizedDaysOfWeek(this.DaysOfWeek))); } return(ClientStrings.TaskWhenMonthlyThEveryMonth(MonthlyThRecurrencePattern.OrderAsString(this.Order), new LocalizedDaysOfWeek(this.DaysOfWeek))); } else if (base.RecurrenceInterval == 2) { if (base.RecurrenceObjectType == RecurrenceObjectType.CalendarRecurrence) { return(ClientStrings.CalendarWhenMonthlyThEveryOtherMonth(MonthlyThRecurrencePattern.OrderAsString(this.Order), new LocalizedDaysOfWeek(this.DaysOfWeek))); } return(ClientStrings.TaskWhenMonthlyThEveryOtherMonth(MonthlyThRecurrencePattern.OrderAsString(this.Order), new LocalizedDaysOfWeek(this.DaysOfWeek))); } else { if (base.RecurrenceObjectType == RecurrenceObjectType.CalendarRecurrence) { return(ClientStrings.CalendarWhenMonthlyThEveryNMonths(MonthlyThRecurrencePattern.OrderAsString(this.Order), new LocalizedDaysOfWeek(this.DaysOfWeek), base.RecurrenceInterval)); } return(ClientStrings.TaskWhenMonthlyThEveryNMonths(MonthlyThRecurrencePattern.OrderAsString(this.Order), new LocalizedDaysOfWeek(this.DaysOfWeek), base.RecurrenceInterval)); } } else if (base.RecurrenceInterval == 1) { if (base.RecurrenceObjectType == RecurrenceObjectType.CalendarRecurrence) { return(ClientStrings.AlternateCalendarWhenMonthlyThEveryMonth(Recurrence.GetCalendarName(this.CalendarType), MonthlyThRecurrencePattern.OrderAsString(this.Order), new LocalizedDaysOfWeek(this.DaysOfWeek))); } return(ClientStrings.AlternateCalendarTaskWhenMonthlyThEveryMonth(Recurrence.GetCalendarName(this.CalendarType), MonthlyThRecurrencePattern.OrderAsString(this.Order), new LocalizedDaysOfWeek(this.DaysOfWeek))); } else if (base.RecurrenceInterval == 2) { if (base.RecurrenceObjectType == RecurrenceObjectType.CalendarRecurrence) { return(ClientStrings.AlternateCalendarWhenMonthlyThEveryOtherMonth(Recurrence.GetCalendarName(this.CalendarType), MonthlyThRecurrencePattern.OrderAsString(this.Order), new LocalizedDaysOfWeek(this.DaysOfWeek))); } return(ClientStrings.AlternateCalendarTaskWhenMonthlyThEveryOtherMonth(Recurrence.GetCalendarName(this.CalendarType), MonthlyThRecurrencePattern.OrderAsString(this.Order), new LocalizedDaysOfWeek(this.DaysOfWeek))); } else { if (base.RecurrenceObjectType == RecurrenceObjectType.CalendarRecurrence) { return(ClientStrings.AlternateCalendarWhenMonthlyThEveryNMonths(Recurrence.GetCalendarName(this.CalendarType), MonthlyThRecurrencePattern.OrderAsString(this.Order), new LocalizedDaysOfWeek(this.DaysOfWeek), base.RecurrenceInterval)); } return(ClientStrings.AlternateCalendarTaskWhenMonthlyThEveryNMonths(Recurrence.GetCalendarName(this.CalendarType), MonthlyThRecurrencePattern.OrderAsString(this.Order), new LocalizedDaysOfWeek(this.DaysOfWeek), base.RecurrenceInterval)); } }
internal override LocalizedString When() { LocalizedString result; if (Recurrence.IsGregorianCompatible(this.CalendarType)) { if (base.RecurrenceObjectType == RecurrenceObjectType.CalendarRecurrence) { result = ClientStrings.CalendarWhenYearlyTh(MonthlyThRecurrencePattern.OrderAsString(this.Order), new LocalizedDaysOfWeek(this.DaysOfWeek), new LocalizedMonth(this.Month)); } else { result = ClientStrings.TaskWhenYearlyTh(MonthlyThRecurrencePattern.OrderAsString(this.Order), new LocalizedDaysOfWeek(this.DaysOfWeek), new LocalizedMonth(this.Month)); } } else if (this.IsLeapMonth) { if (base.RecurrenceObjectType == RecurrenceObjectType.CalendarRecurrence) { result = ClientStrings.AlternateCalendarWhenYearlyThLeap(Recurrence.GetCalendarName(this.CalendarType), MonthlyThRecurrencePattern.OrderAsString(this.Order), new LocalizedDaysOfWeek(this.DaysOfWeek), this.Month); } else { result = ClientStrings.AlternateCalendarTaskWhenYearlyThLeap(Recurrence.GetCalendarName(this.CalendarType), MonthlyThRecurrencePattern.OrderAsString(this.Order), new LocalizedDaysOfWeek(this.DaysOfWeek), this.Month); } } else if (base.RecurrenceObjectType == RecurrenceObjectType.CalendarRecurrence) { result = ClientStrings.AlternateCalendarWhenYearlyTh(Recurrence.GetCalendarName(this.CalendarType), MonthlyThRecurrencePattern.OrderAsString(this.Order), new LocalizedDaysOfWeek(this.DaysOfWeek), this.Month); } else { result = ClientStrings.AlternateCalendarTaskWhenYearlyTh(Recurrence.GetCalendarName(this.CalendarType), MonthlyThRecurrencePattern.OrderAsString(this.Order), new LocalizedDaysOfWeek(this.DaysOfWeek), this.Month); } return(result); }
private void SetPatternSpecificProperties(RecurrencePattern pattern) { if (pattern is DailyRecurrencePattern) { DailyRecurrencePattern dailyRecurrencePattern = (DailyRecurrencePattern)pattern; this.Group = RecurrenceGroup.Daily; this.Type = RecurrenceTypeInBlob.Minute; this.Period = dailyRecurrencePattern.RecurrenceInterval * 24 * 60; return; } if (pattern is WeeklyRecurrencePattern) { WeeklyRecurrencePattern weeklyRecurrencePattern = (WeeklyRecurrencePattern)pattern; this.Group = RecurrenceGroup.Weekly; this.Type = RecurrenceTypeInBlob.Week; this.Period = weeklyRecurrencePattern.RecurrenceInterval; this.DayMask = weeklyRecurrencePattern.DaysOfWeek; this.FirstDayOfWeek = (int)((WeeklyRecurrencePattern)pattern).FirstDayOfWeek; return; } if (pattern is MonthlyRecurrencePattern) { MonthlyRecurrencePattern monthlyRecurrencePattern = (MonthlyRecurrencePattern)pattern; this.Group = RecurrenceGroup.Monthly; this.Type = ((monthlyRecurrencePattern.CalendarType == CalendarType.Hijri) ? RecurrenceTypeInBlob.HjMonth : RecurrenceTypeInBlob.Month); this.Period = monthlyRecurrencePattern.RecurrenceInterval; this.DayOfMonth = monthlyRecurrencePattern.DayOfMonth; return; } if (pattern is YearlyRecurrencePattern) { YearlyRecurrencePattern yearlyRecurrencePattern = (YearlyRecurrencePattern)pattern; this.Group = RecurrenceGroup.Yearly; this.Type = ((yearlyRecurrencePattern.CalendarType == CalendarType.Hijri) ? RecurrenceTypeInBlob.HjMonth : RecurrenceTypeInBlob.Month); this.DayOfMonth = yearlyRecurrencePattern.DayOfMonth; this.Period = 12; return; } if (pattern is MonthlyThRecurrencePattern) { MonthlyThRecurrencePattern monthlyThRecurrencePattern = (MonthlyThRecurrencePattern)pattern; this.Group = RecurrenceGroup.Monthly; this.Type = ((monthlyThRecurrencePattern.CalendarType == CalendarType.Hijri) ? RecurrenceTypeInBlob.HjMonthNth : RecurrenceTypeInBlob.MonthNth); this.DayMask = monthlyThRecurrencePattern.DaysOfWeek; this.NthOccurrence = monthlyThRecurrencePattern.Order; this.Period = monthlyThRecurrencePattern.RecurrenceInterval; return; } if (pattern is YearlyThRecurrencePattern) { YearlyThRecurrencePattern yearlyThRecurrencePattern = (YearlyThRecurrencePattern)pattern; this.Group = RecurrenceGroup.Yearly; this.Type = ((yearlyThRecurrencePattern.CalendarType == CalendarType.Hijri) ? RecurrenceTypeInBlob.HjMonthNth : RecurrenceTypeInBlob.MonthNth); this.DayMask = yearlyThRecurrencePattern.DaysOfWeek; this.NthOccurrence = yearlyThRecurrencePattern.Order; this.MonthOfYear = yearlyThRecurrencePattern.Month; this.Period = 12; return; } if (pattern is DailyRegeneratingPattern) { DailyRegeneratingPattern dailyRegeneratingPattern = (DailyRegeneratingPattern)pattern; this.Type = RecurrenceTypeInBlob.Minute; this.Group = RecurrenceGroup.Daily; this.Period = dailyRegeneratingPattern.RecurrenceInterval * 24 * 60; return; } if (pattern is WeeklyRegeneratingPattern) { WeeklyRegeneratingPattern weeklyRegeneratingPattern = (WeeklyRegeneratingPattern)pattern; this.Type = RecurrenceTypeInBlob.Minute; this.Group = RecurrenceGroup.Weekly; this.DayMask = DaysOfWeek.Monday; this.Period = weeklyRegeneratingPattern.RecurrenceInterval * 7 * 24 * 60; return; } if (pattern is MonthlyRegeneratingPattern) { MonthlyRegeneratingPattern monthlyRegeneratingPattern = (MonthlyRegeneratingPattern)pattern; this.Type = RecurrenceTypeInBlob.MonthNth; this.Group = RecurrenceGroup.Monthly; this.DayMask = DaysOfWeek.Monday; this.NthOccurrence = (RecurrenceOrderType)0; this.Period = monthlyRegeneratingPattern.RecurrenceInterval; return; } if (pattern is YearlyRegeneratingPattern) { YearlyRegeneratingPattern yearlyRegeneratingPattern = (YearlyRegeneratingPattern)pattern; this.Type = RecurrenceTypeInBlob.Month; this.Group = RecurrenceGroup.Yearly; this.DayOfMonth = 1; this.Period = 12 * yearlyRegeneratingPattern.RecurrenceInterval; } }
protected Recurrence ICalRecurrenceFromXsoRecurrence(Recurrence xsoRecurrence) { Recurrence recurrence = new Recurrence(); RecurrencePattern pattern = xsoRecurrence.Pattern; RecurrenceRange range = xsoRecurrence.Range; if (pattern is DailyRecurrencePattern) { recurrence.Frequency = Frequency.Daily; } else if (pattern is WeeklyRecurrencePattern) { recurrence.Frequency = Frequency.Weekly; WeeklyRecurrencePattern weeklyRecurrencePattern = (WeeklyRecurrencePattern)pattern; recurrence.ByDayList = VItemBase.ByDayListFromDaysOfWeek(weeklyRecurrencePattern.DaysOfWeek); recurrence.WorkWeekStart = weeklyRecurrencePattern.FirstDayOfWeek; } else if (pattern is MonthlyRecurrencePattern) { recurrence.Frequency = Frequency.Monthly; MonthlyRecurrencePattern monthlyRecurrencePattern = (MonthlyRecurrencePattern)pattern; recurrence.ByMonthDay = new int[] { monthlyRecurrencePattern.DayOfMonth }; } else if (pattern is MonthlyThRecurrencePattern) { recurrence.Frequency = Frequency.Monthly; MonthlyThRecurrencePattern monthlyThRecurrencePattern = (MonthlyThRecurrencePattern)pattern; recurrence.ByDayList = VItemBase.ByDayListFromDaysOfWeek(monthlyThRecurrencePattern.DaysOfWeek); int order = (int)monthlyThRecurrencePattern.Order; if (recurrence.ByDayList.Length == 1) { recurrence.ByDayList[0].OccurrenceNumber = order; } else { recurrence.BySetPosition = new int[] { order }; } } else if (pattern is YearlyRecurrencePattern) { recurrence.Frequency = Frequency.Yearly; YearlyRecurrencePattern yearlyRecurrencePattern = (YearlyRecurrencePattern)pattern; recurrence.ByMonth = new int[] { yearlyRecurrencePattern.Month }; recurrence.ByMonthDay = new int[] { yearlyRecurrencePattern.DayOfMonth }; } else if (pattern is YearlyThRecurrencePattern) { recurrence.Frequency = Frequency.Yearly; YearlyThRecurrencePattern yearlyThRecurrencePattern = (YearlyThRecurrencePattern)pattern; recurrence.ByMonth = new int[] { yearlyThRecurrencePattern.Month }; recurrence.ByDayList = VItemBase.ByDayListFromDaysOfWeek(yearlyThRecurrencePattern.DaysOfWeek); int order2 = (int)yearlyThRecurrencePattern.Order; if (recurrence.ByDayList.Length == 1) { recurrence.ByDayList[0].OccurrenceNumber = order2; } else { recurrence.BySetPosition = new int[] { order2 }; } } IntervalRecurrencePattern intervalRecurrencePattern = pattern as IntervalRecurrencePattern; if (intervalRecurrencePattern != null) { recurrence.Interval = intervalRecurrencePattern.RecurrenceInterval; } else { recurrence.Interval = 1; } if (range is EndDateRecurrenceRange) { EndDateRecurrenceRange endDateRecurrenceRange = (EndDateRecurrenceRange)range; recurrence.UntilDateTime = (DateTime)(endDateRecurrenceRange.EndDate + xsoRecurrence.StartOffset).ToUtc(); } else if (range is NumberedRecurrenceRange) { NumberedRecurrenceRange numberedRecurrenceRange = (NumberedRecurrenceRange)range; recurrence.Count = numberedRecurrenceRange.NumberOfOccurrences; } return(recurrence); }