// Token: 0x06001218 RID: 4632 RVA: 0x0006247C File Offset: 0x0006067C private static RecurrenceRange CreateRecurrenceRange(ExDateTime startDate, RecurrenceData recurrenceData) { RecurrenceRange recurrenceRange = null; try { if (recurrenceData.HasOccurences()) { recurrenceRange = new NumberedRecurrenceRange(); ((NumberedRecurrenceRange)recurrenceRange).NumberOfOccurrences = (int)recurrenceData.Occurrences; } else if (recurrenceData.HasUntil()) { recurrenceRange = new EndDateRecurrenceRange(); ((EndDateRecurrenceRange)recurrenceRange).EndDate = recurrenceData.Until; } else { recurrenceRange = new NoEndRecurrenceRange(); } recurrenceRange.StartDate = startDate; } catch (ArgumentException ex) { throw new ConversionException(ex.Message); } return(recurrenceRange); }
// Token: 0x06001007 RID: 4103 RVA: 0x0005B17C File Offset: 0x0005937C protected override void InternalCopyFrom(IProperty srcProperty) { INestedProperty nestedProperty = srcProperty as INestedProperty; if (nestedProperty == null) { throw new UnexpectedTypeException("INestedProperty", srcProperty); } RecurrenceData recurrenceData = nestedProperty.NestedData as RecurrenceData; if (recurrenceData == null) { throw new UnexpectedTypeException("RecurrenceData", nestedProperty.NestedData); } if (srcProperty.State != PropertyState.Modified) { return; } base.XmlNode = base.XmlParentNode.OwnerDocument.CreateElement(base.AirSyncTagNames[0], base.Namespace); for (int i = 0; i < recurrenceData.Keys.Length; i++) { string text = recurrenceData.SubProperties[recurrenceData.Keys[i]] as string; if (text == null && recurrenceData.Keys[i] == "Type") { throw new ConversionException("Type of Recurrence has to be specified"); } if (text != null) { base.AppendChildNode(recurrenceData.Keys[i], text); } } base.XmlParentNode.AppendChild(base.XmlNode); }
// Token: 0x06001216 RID: 4630 RVA: 0x00062240 File Offset: 0x00060440 public override void CopyFrom(IProperty srcProperty) { if (base.EntityPropertyDefinition.Setter == null) { throw new ConversionException("Unable to set data of type " + base.EntityPropertyDefinition.Type.FullName); } INestedProperty nestedProperty = srcProperty as INestedProperty; if (nestedProperty == null) { throw new UnexpectedTypeException("INestedProperty", srcProperty); } RecurrenceData recurrenceData = nestedProperty.NestedData as RecurrenceData; if (recurrenceData == null) { throw new UnexpectedTypeException("RecurrenceData", nestedProperty.NestedData); } recurrenceData.Validate(); PatternedRecurrence patternedRecurrence = new PatternedRecurrence(); patternedRecurrence.Pattern = EntityRecurrenceProperty.CreateRecurrencePattern(recurrenceData); patternedRecurrence.Range = EntityRecurrenceProperty.CreateRecurrenceRange(base.CalendaringEvent.Start, recurrenceData); base.EntityPropertyDefinition.Setter(base.Item, patternedRecurrence); }
// Token: 0x06001219 RID: 4633 RVA: 0x000624FC File Offset: 0x000606FC private static void PopulateRecurrencePattern(RecurrenceData recurrenceData, RecurrencePattern pattern) { recurrenceData.Interval = (ushort)pattern.Interval; DailyRecurrencePattern dailyRecurrencePattern = pattern as DailyRecurrencePattern; if (dailyRecurrencePattern != null) { recurrenceData.Type = RecurrenceData.RecurrenceType.Daily; return; } WeeklyRecurrencePattern weeklyRecurrencePattern = pattern as WeeklyRecurrencePattern; if (weeklyRecurrencePattern != null) { recurrenceData.Type = RecurrenceData.RecurrenceType.Weekly; recurrenceData.DaysOfWeek = weeklyRecurrencePattern.DaysOfWeek; return; } AbsoluteMonthlyRecurrencePattern absoluteMonthlyRecurrencePattern = pattern as AbsoluteMonthlyRecurrencePattern; if (absoluteMonthlyRecurrencePattern != null) { recurrenceData.Type = RecurrenceData.RecurrenceType.Monthly; recurrenceData.DayOfMonth = (byte)absoluteMonthlyRecurrencePattern.DayOfMonth; return; } RelativeMonthlyRecurrencePattern relativeMonthlyRecurrencePattern = pattern as RelativeMonthlyRecurrencePattern; if (relativeMonthlyRecurrencePattern != null) { recurrenceData.Type = RecurrenceData.RecurrenceType.MonthlyTh; recurrenceData.WeekIndex = relativeMonthlyRecurrencePattern.Index; recurrenceData.DaysOfWeek = relativeMonthlyRecurrencePattern.DaysOfWeek; return; } AbsoluteYearlyRecurrencePattern absoluteYearlyRecurrencePattern = pattern as AbsoluteYearlyRecurrencePattern; if (absoluteYearlyRecurrencePattern != null) { recurrenceData.Type = RecurrenceData.RecurrenceType.Yearly; recurrenceData.DayOfMonth = (byte)absoluteYearlyRecurrencePattern.DayOfMonth; recurrenceData.MonthOfYear = (byte)absoluteYearlyRecurrencePattern.Month; return; } RelativeYearlyRecurrencePattern relativeYearlyRecurrencePattern = pattern as RelativeYearlyRecurrencePattern; if (relativeYearlyRecurrencePattern != null) { recurrenceData.Type = RecurrenceData.RecurrenceType.YearlyTh; recurrenceData.WeekIndex = relativeYearlyRecurrencePattern.Index; recurrenceData.DaysOfWeek = relativeYearlyRecurrencePattern.DaysOfWeek; recurrenceData.MonthOfYear = (byte)relativeYearlyRecurrencePattern.Month; return; } throw new ConversionException("Unexpected Recurrence Pattern"); }
// Token: 0x06001217 RID: 4631 RVA: 0x000622F8 File Offset: 0x000604F8 private static RecurrencePattern CreateRecurrencePattern(RecurrenceData recurrenceData) { RecurrencePattern recurrencePattern; switch (recurrenceData.Type) { case RecurrenceData.RecurrenceType.Daily: if (recurrenceData.SubProperties["DayOfWeek"] != null) { recurrencePattern = new WeeklyRecurrencePattern(); ((WeeklyRecurrencePattern)recurrencePattern).DaysOfWeek = recurrenceData.DaysOfWeek; goto IL_15E; } recurrencePattern = new DailyRecurrencePattern(); goto IL_15E; case RecurrenceData.RecurrenceType.Weekly: recurrencePattern = new WeeklyRecurrencePattern(); ((WeeklyRecurrencePattern)recurrencePattern).DaysOfWeek = recurrenceData.DaysOfWeek; goto IL_15E; case RecurrenceData.RecurrenceType.Monthly: recurrencePattern = new AbsoluteMonthlyRecurrencePattern(); ((AbsoluteMonthlyRecurrencePattern)recurrencePattern).DayOfMonth = (int)recurrenceData.DayOfMonth; goto IL_15E; case RecurrenceData.RecurrenceType.MonthlyTh: recurrencePattern = new RelativeMonthlyRecurrencePattern(); ((RelativeMonthlyRecurrencePattern)recurrencePattern).DaysOfWeek = recurrenceData.DaysOfWeek; ((RelativeMonthlyRecurrencePattern)recurrencePattern).Index = recurrenceData.WeekIndex; goto IL_15E; case RecurrenceData.RecurrenceType.Yearly: recurrencePattern = new AbsoluteYearlyRecurrencePattern(); ((AbsoluteYearlyRecurrencePattern)recurrencePattern).DayOfMonth = (int)recurrenceData.DayOfMonth; ((AbsoluteYearlyRecurrencePattern)recurrencePattern).Month = (int)recurrenceData.MonthOfYear; goto IL_15E; case RecurrenceData.RecurrenceType.YearlyTh: recurrencePattern = new RelativeYearlyRecurrencePattern(); ((RelativeYearlyRecurrencePattern)recurrencePattern).DaysOfWeek = recurrenceData.DaysOfWeek; ((RelativeYearlyRecurrencePattern)recurrencePattern).Index = recurrenceData.WeekIndex; ((RelativeYearlyRecurrencePattern)recurrencePattern).Month = (int)recurrenceData.MonthOfYear; goto IL_15E; } throw new ConversionException(string.Format(CultureInfo.InvariantCulture, "Unexpected recurrence type {0}, should have been caught in a higher validation layer", new object[] { recurrenceData.Type })); IL_15E: recurrencePattern.Interval = (int)(recurrenceData.HasInterval() ? recurrenceData.Interval : 1); return(recurrencePattern); }
// Token: 0x0600121A RID: 4634 RVA: 0x00062608 File Offset: 0x00060808 private static void PopulateRecurrenceRange(RecurrenceData recurrenceData, RecurrenceRange range) { EndDateRecurrenceRange endDateRecurrenceRange = range as EndDateRecurrenceRange; NumberedRecurrenceRange numberedRecurrenceRange = range as NumberedRecurrenceRange; if (endDateRecurrenceRange != null) { recurrenceData.Until = endDateRecurrenceRange.EndDate; return; } if (numberedRecurrenceRange != null) { recurrenceData.Occurrences = (ushort)numberedRecurrenceRange.NumberOfOccurrences; } }
public string ToString(List <Event> Events) { StringBuilder builder = new StringBuilder(); builder.AppendLine("BEGIN:VEVENT"); builder.AppendLine("SUMMARY:" + CleanText(Title)); builder.AppendLine("DTSTAMP:" + Created.ToString("yyyyMMddTHHmmssZ")); builder.AppendLine("DESCRIPTION:" + CleanText(Description)); builder.AppendLine("LOCATION:" + CleanText(Location)); builder.AppendLine("CATEGORIES:" + CleanText(Category)); builder.AppendLine("UID:" + UID); builder.AppendLine("STATUS:CONFIRMED"); builder.AppendLine("LAST-MODIFIED:" + LastModified.ToString("yyyyMMddTHHmmssZ")); if (AllDayEvent) { builder.AppendLine("DTSTART;VALUE=DATE:" + EventDate.ToString("yyyyMMdd")); double days = Math.Round(((Double)Duration / (double)(60 * 60 * 24))); builder.AppendLine("DTEND;VALUE=DATE:" + EventDate.AddDays(days).ToString("yyyyMMdd")); } else { builder.AppendLine("DTSTART:" + EventDate.ToString("yyyyMMddTHHmmssZ")); builder.AppendLine("DTEND:" + EventDate.AddSeconds(Duration).ToString("yyyyMMddTHHmmssZ")); } IEnumerable <Event> deletedEvents = Events.Where(e => e.MasterSeriesItemID == ID && e.EventType == EventType.Deleted); foreach (Event deletedEvent in deletedEvents) { if (AllDayEvent) { builder.AppendLine("EXDATE;VALUE=DATE:" + deletedEvent.RecurrenceID.ToString("yyyyMMdd")); } else { builder.AppendLine("EXDATE:" + deletedEvent.RecurrenceID.ToString("yyyyMMddTHHmmssZ")); } } if (RecurrenceID != DateTime.MinValue && EventType == EventType.Exception) // Event is exception to recurring item { if (AllDayEvent) { builder.AppendLine("RECURRENCE-ID;VALUE=DATE:" + RecurrenceID.ToString("yyyyMMdd")); } else { builder.AppendLine("RECURRENCE-ID:" + RecurrenceID.ToString("yyyyMMddTHHmmssZ")); } } else if (Recurrence && !RecurrenceData.Contains("V3RecurrencePattern")) { RecurrenceHelper recurrenceHelper = new RecurrenceHelper(); builder.AppendLine(recurrenceHelper.BuildRecurrence(RecurrenceData, EndDate)); } if (EventType == CalendarModel.EventType.Exception) { List <Event> exceptions = Events.Where(e => e.MasterSeriesItemID == MasterSeriesItemID).OrderBy(e => e.Created).ToList <Event>(); builder.AppendLine("SEQUENCE:" + (exceptions.IndexOf(this) + 1)); } else { builder.AppendLine("SEQUENCE:0"); } builder.AppendLine("BEGIN:VALARM"); builder.AppendLine("ACTION:DISPLAY"); builder.AppendLine("TRIGGER:-PT10M"); builder.AppendLine("DESCRIPTION:Reminder"); builder.AppendLine("END:VALARM"); builder.AppendLine("END:VEVENT"); return(builder.ToString()); }
protected override void InternalCopyFrom(IProperty srcProperty) { INestedProperty nestedProperty = srcProperty as INestedProperty; if (nestedProperty == null) { throw new UnexpectedTypeException("INestedProperty", srcProperty); } MeetingRequestData meetingRequestData = nestedProperty.NestedData as MeetingRequestData; if (meetingRequestData == null) { throw new UnexpectedTypeException("MeetingRequestData", nestedProperty.NestedData); } if (PropertyState.Modified != srcProperty.State) { return; } base.XmlNode = base.XmlParentNode.OwnerDocument.CreateElement(base.AirSyncTagNames[0], base.Namespace); string[] keysForVersion = MeetingRequestData.GetKeysForVersion(this.protocolVersion); for (int i = 0; i < keysForVersion.Length; i++) { object obj = meetingRequestData.SubProperties[keysForVersion[i]]; string text = obj as string; if (text != null) { base.AppendChildNode(base.XmlNode, keysForVersion[i], text, MeetingRequestData.GetEmailNamespaceForKey(i)); } else { RecurrenceData recurrenceData = obj as RecurrenceData; if (recurrenceData != null) { if (!(recurrenceData.SubProperties["Type"] is string)) { throw new ConversionException("Type of Recurrence has to be specified"); } XmlNode xmlNode = base.XmlParentNode.OwnerDocument.CreateElement(MeetingRequestData.Tags.Recurrences.ToString(), base.Namespace); XmlNode xmlNode2 = base.XmlParentNode.OwnerDocument.CreateElement("Recurrence", base.Namespace); for (int j = 0; j < recurrenceData.Keys.Length; j++) { string text2 = recurrenceData.SubProperties[recurrenceData.Keys[j]] as string; if (text2 != null) { base.AppendChildNode(xmlNode2, recurrenceData.Keys[j], text2, RecurrenceData.GetEmailNamespaceForKey(j)); } } xmlNode.AppendChild(xmlNode2); base.XmlNode.AppendChild(xmlNode); } else { EnhancedLocationData enhancedLocationData = obj as EnhancedLocationData; if (enhancedLocationData != null && this.protocolVersion >= 160) { XmlNode xmlNode3 = base.XmlParentNode.OwnerDocument.CreateElement("Location", "AirSyncBase:"); base.AppendToXmlNode(xmlNode3, enhancedLocationData, "AirSyncBase:"); base.XmlNode.AppendChild(xmlNode3); } } } } base.XmlParentNode.AppendChild(base.XmlNode); }
public static void Populate(RecurrenceData recurrenceData, StoreObject item) { CalendarItem calendarItem = item as CalendarItem; Task task = item as Task; Recurrence recurrence; if (calendarItem != null) { recurrence = calendarItem.Recurrence; } else { if (task == null) { throw new UnexpectedTypeException("Task", item); } recurrence = task.Recurrence; } if (recurrence == null) { throw new ArgumentNullException("recurrence"); } if (recurrenceData == null) { throw new ArgumentNullException("recurrenceData"); } RecurrencePattern pattern = recurrence.Pattern; RecurrenceRange range = recurrence.Range; DailyRecurrencePattern dailyRecurrencePattern; WeeklyRecurrencePattern weeklyRecurrencePattern; MonthlyRecurrencePattern monthlyRecurrencePattern; YearlyRecurrencePattern yearlyRecurrencePattern; MonthlyThRecurrencePattern monthlyThRecurrencePattern; YearlyThRecurrencePattern yearlyThRecurrencePattern; DailyRegeneratingPattern dailyRegeneratingPattern; WeeklyRegeneratingPattern weeklyRegeneratingPattern; MonthlyRegeneratingPattern monthlyRegeneratingPattern; if ((dailyRecurrencePattern = (pattern as DailyRecurrencePattern)) != null) { recurrenceData.Type = RecurrenceData.RecurrenceType.Daily; recurrenceData.Regenerate = false; recurrenceData.Interval = (ushort)dailyRecurrencePattern.RecurrenceInterval; } else if ((weeklyRecurrencePattern = (pattern as WeeklyRecurrencePattern)) != null) { recurrenceData.Type = RecurrenceData.RecurrenceType.Weekly; recurrenceData.Regenerate = false; recurrenceData.Interval = (ushort)weeklyRecurrencePattern.RecurrenceInterval; recurrenceData.DayOfWeek = (byte)weeklyRecurrencePattern.DaysOfWeek; if (recurrenceData.ProtocolVersion >= 141) { recurrenceData.FirstDayOfWeek = weeklyRecurrencePattern.FirstDayOfWeek; } } else if ((monthlyRecurrencePattern = (pattern as MonthlyRecurrencePattern)) != null) { recurrenceData.Type = RecurrenceData.RecurrenceType.Monthly; recurrenceData.Regenerate = false; recurrenceData.Interval = (ushort)monthlyRecurrencePattern.RecurrenceInterval; recurrenceData.DayOfMonth = (byte)monthlyRecurrencePattern.DayOfMonth; if (recurrenceData.ProtocolVersion >= 140) { recurrenceData.CalendarType = monthlyRecurrencePattern.CalendarType; } } else if ((yearlyRecurrencePattern = (pattern as YearlyRecurrencePattern)) != null) { recurrenceData.Type = RecurrenceData.RecurrenceType.Yearly; recurrenceData.Regenerate = false; recurrenceData.Interval = 1; recurrenceData.DayOfMonth = (byte)yearlyRecurrencePattern.DayOfMonth; recurrenceData.MonthOfYear = (byte)yearlyRecurrencePattern.Month; if (recurrenceData.ProtocolVersion >= 140) { recurrenceData.CalendarType = yearlyRecurrencePattern.CalendarType; recurrenceData.IsLeapMonth = yearlyRecurrencePattern.IsLeapMonth; } } else if ((monthlyThRecurrencePattern = (pattern as MonthlyThRecurrencePattern)) != null) { recurrenceData.Type = RecurrenceData.RecurrenceType.MonthlyTh; recurrenceData.Regenerate = false; recurrenceData.Interval = (ushort)monthlyThRecurrencePattern.RecurrenceInterval; recurrenceData.WeekOfMonth = (byte)((monthlyThRecurrencePattern.Order == RecurrenceOrderType.Last) ? ((RecurrenceOrderType)5) : monthlyThRecurrencePattern.Order); recurrenceData.DayOfWeek = (byte)monthlyThRecurrencePattern.DaysOfWeek; if (recurrenceData.ProtocolVersion >= 140) { recurrenceData.CalendarType = monthlyThRecurrencePattern.CalendarType; } } else if ((yearlyThRecurrencePattern = (pattern as YearlyThRecurrencePattern)) != null) { recurrenceData.Type = RecurrenceData.RecurrenceType.YearlyTh; recurrenceData.Regenerate = false; recurrenceData.Interval = 1; recurrenceData.WeekOfMonth = (byte)((yearlyThRecurrencePattern.Order == RecurrenceOrderType.Last) ? ((RecurrenceOrderType)5) : yearlyThRecurrencePattern.Order); recurrenceData.DayOfWeek = (byte)yearlyThRecurrencePattern.DaysOfWeek; recurrenceData.MonthOfYear = (byte)yearlyThRecurrencePattern.Month; if (recurrenceData.ProtocolVersion >= 140) { recurrenceData.CalendarType = yearlyThRecurrencePattern.CalendarType; recurrenceData.IsLeapMonth = yearlyThRecurrencePattern.IsLeapMonth; } } else if ((dailyRegeneratingPattern = (pattern as DailyRegeneratingPattern)) != null) { recurrenceData.Type = RecurrenceData.RecurrenceType.Daily; recurrenceData.Regenerate = true; recurrenceData.Interval = (ushort)dailyRegeneratingPattern.RecurrenceInterval; } else if ((weeklyRegeneratingPattern = (pattern as WeeklyRegeneratingPattern)) != null) { recurrenceData.Type = RecurrenceData.RecurrenceType.Weekly; recurrenceData.Regenerate = true; recurrenceData.Interval = (ushort)weeklyRegeneratingPattern.RecurrenceInterval; } else if ((monthlyRegeneratingPattern = (pattern as MonthlyRegeneratingPattern)) != null) { recurrenceData.Type = RecurrenceData.RecurrenceType.Monthly; recurrenceData.Regenerate = true; recurrenceData.Interval = (ushort)monthlyRegeneratingPattern.RecurrenceInterval; if (recurrenceData.ProtocolVersion >= 140) { recurrenceData.CalendarType = monthlyRegeneratingPattern.CalendarType; } } else { YearlyRegeneratingPattern yearlyRegeneratingPattern; if ((yearlyRegeneratingPattern = (pattern as YearlyRegeneratingPattern)) == null) { throw new ConversionException("Unexpected Recurrence Pattern"); } recurrenceData.Type = RecurrenceData.RecurrenceType.Yearly; recurrenceData.Regenerate = true; recurrenceData.Interval = (ushort)yearlyRegeneratingPattern.RecurrenceInterval; if (recurrenceData.ProtocolVersion >= 140) { recurrenceData.CalendarType = yearlyRegeneratingPattern.CalendarType; recurrenceData.IsLeapMonth = false; } } if (task != null) { object obj = task.TryGetProperty(TaskSchema.IsOneOff); if (obj != null && obj is bool) { recurrenceData.DeadOccur = (bool)obj; } else { recurrenceData.DeadOccur = false; } recurrenceData.Start = range.StartDate; } EndDateRecurrenceRange endDateRecurrenceRange; if ((endDateRecurrenceRange = (range as EndDateRecurrenceRange)) == null) { NumberedRecurrenceRange numberedRecurrenceRange; if ((numberedRecurrenceRange = (range as NumberedRecurrenceRange)) != null) { recurrenceData.Occurrences = (ushort)numberedRecurrenceRange.NumberOfOccurrences; } return; } if (calendarItem != null) { ExDateTime exDateTime = endDateRecurrenceRange.EndDate; exDateTime += calendarItem.Recurrence.StartOffset; ExDateTime until = ExTimeZone.UtcTimeZone.ConvertDateTime(exDateTime); recurrenceData.Until = until; return; } recurrenceData.Until = endDateRecurrenceRange.EndDate; }
private static RecurrencePattern CreateRecurrencePattern(TypeOfRecurrence recurrenceType, RecurrenceData recurrenceData, Recurrence oldRecurrence) { ushort recurrenceInterval = 1; RecurrenceData.RecurrenceType type = recurrenceData.Type; if (recurrenceData.HasInterval()) { recurrenceInterval = recurrenceData.Interval; } if (recurrenceData.HasWeekOfMonth()) { recurrenceData.WeekOfMonth = ((recurrenceData.WeekOfMonth == 5) ? byte.MaxValue : recurrenceData.WeekOfMonth); } if (recurrenceType == TypeOfRecurrence.Calendar || (recurrenceType == TypeOfRecurrence.Task && !recurrenceData.Regenerate)) { switch (type) { case RecurrenceData.RecurrenceType.Daily: if (recurrenceData.SubProperties["DayOfMonth"] != null || recurrenceData.SubProperties["WeekOfMonth"] != null || recurrenceData.SubProperties["MonthOfYear"] != null || recurrenceData.SubProperties["CalendarType"] != null || recurrenceData.SubProperties["IsLeapMonth"] != null) { throw new ConversionException(string.Format(CultureInfo.InvariantCulture, "DayOfMonth, WeekOfMonth, MonthOfYear, CalendarType, IsLeapMonth is not expected with recurrence type {0}", new object[] { type.ToString() })); } if (recurrenceData.SubProperties["DayOfWeek"] != null) { return(new WeeklyRecurrencePattern((DaysOfWeek)recurrenceData.DayOfWeek, (int)recurrenceInterval)); } return(new DailyRecurrencePattern((int)recurrenceInterval)); case RecurrenceData.RecurrenceType.Weekly: { if (recurrenceData.SubProperties["DayOfMonth"] != null || recurrenceData.SubProperties["WeekOfMonth"] != null || recurrenceData.SubProperties["MonthOfYear"] != null || recurrenceData.SubProperties["CalendarType"] != null || recurrenceData.SubProperties["IsLeapMonth"] != null) { throw new ConversionException(string.Format(CultureInfo.InvariantCulture, "DayOfMonth, WeekOfMonth, MonthOfYear, CalendarType, IsLeapMonth is not expected with recurrence type {0}", new object[] { type.ToString() })); } if (recurrenceData.SubProperties["DayOfWeek"] == null) { throw new ConversionException(string.Format(CultureInfo.InvariantCulture, "DayOfWeek is expected with recurrence type {0}", new object[] { type.ToString() })); } WeeklyRecurrencePattern weeklyRecurrencePattern = (oldRecurrence != null) ? (oldRecurrence.Pattern as WeeklyRecurrencePattern) : null; return(new WeeklyRecurrencePattern((DaysOfWeek)recurrenceData.DayOfWeek, (int)recurrenceInterval, (recurrenceData.ProtocolVersion < 141 && weeklyRecurrencePattern != null) ? weeklyRecurrencePattern.FirstDayOfWeek : recurrenceData.FirstDayOfWeek)); } case RecurrenceData.RecurrenceType.Monthly: if (recurrenceData.SubProperties["DayOfWeek"] != null || recurrenceData.SubProperties["WeekOfMonth"] != null || recurrenceData.SubProperties["MonthOfYear"] != null || recurrenceData.SubProperties["IsLeapMonth"] != null) { throw new ConversionException(string.Format(CultureInfo.InvariantCulture, "DayOfWeek, WeekOfMonth, MonthOfYear, IsLeapMonth is not expected with recurrence type {0}", new object[] { type.ToString() })); } if (recurrenceData.SubProperties["DayOfMonth"] == null) { throw new ConversionException(string.Format(CultureInfo.InvariantCulture, "DayOfMonth is expected with recurrence type {0}", new object[] { type.ToString() })); } return(new MonthlyRecurrencePattern((int)recurrenceData.DayOfMonth, (int)recurrenceInterval, recurrenceData.CalendarType)); case RecurrenceData.RecurrenceType.MonthlyTh: { if (recurrenceData.SubProperties["DayOfMonth"] != null || recurrenceData.SubProperties["MonthOfYear"] != null || recurrenceData.SubProperties["IsLeapMonth"] != null) { throw new ConversionException(string.Format(CultureInfo.InvariantCulture, "DayOfMonth, MonthOfYear, IsLeapMonth is not expected with recurrence type {0}", new object[] { type.ToString() })); } if (recurrenceData.SubProperties["WeekOfMonth"] == null || recurrenceData.SubProperties["DayOfWeek"] == null) { throw new ConversionException(string.Format(CultureInfo.InvariantCulture, "WeekOfMonth, DayOfWeek is expected with recurrence type {0}", new object[] { type.ToString() })); } RecurrenceOrderType recurrenceOrderType = (recurrenceData.WeekOfMonth == byte.MaxValue) ? RecurrenceOrderType.Last : ((RecurrenceOrderType)recurrenceData.WeekOfMonth); if (!EnumValidator.IsValidValue <RecurrenceOrderType>(recurrenceOrderType)) { throw new ConversionException(string.Format(CultureInfo.InvariantCulture, "WeekOfMonth value {0} is invalid", new object[] { recurrenceOrderType.ToString() })); } return(new MonthlyThRecurrencePattern((DaysOfWeek)recurrenceData.DayOfWeek, recurrenceOrderType, (int)recurrenceInterval, recurrenceData.CalendarType)); } case RecurrenceData.RecurrenceType.Yearly: if (recurrenceData.SubProperties["DayOfWeek"] != null || recurrenceData.SubProperties["WeekOfMonth"] != null) { throw new ConversionException(string.Format(CultureInfo.InvariantCulture, "DayOfWeek, WeekOfMonth is not expected with recurrence type {0}", new object[] { type.ToString() })); } if (recurrenceData.SubProperties["DayOfMonth"] == null || recurrenceData.SubProperties["MonthOfYear"] == null) { throw new ConversionException(string.Format(CultureInfo.InvariantCulture, "DayOfMonth, MonthOfYear is expected with recurrence type {0}", new object[] { type.ToString() })); } return(new YearlyRecurrencePattern((int)recurrenceData.DayOfMonth, (int)recurrenceData.MonthOfYear, recurrenceData.IsLeapMonth, recurrenceData.CalendarType)); case RecurrenceData.RecurrenceType.YearlyTh: { if (recurrenceData.SubProperties["DayOfMonth"] != null) { throw new ConversionException(string.Format(CultureInfo.InvariantCulture, "DayOfMonth is not expected with recurrence type {0}", new object[] { type.ToString() })); } if (recurrenceData.SubProperties["WeekOfMonth"] == null || recurrenceData.SubProperties["DayOfWeek"] == null || recurrenceData.SubProperties["MonthOfYear"] == null) { throw new ConversionException(string.Format(CultureInfo.InvariantCulture, "WeekOfMonth, DayOfWeek, MonthOfYear is expected with recurrence type {0}", new object[] { type.ToString() })); } RecurrenceOrderType recurrenceOrderType = (recurrenceData.WeekOfMonth == byte.MaxValue) ? RecurrenceOrderType.Last : ((RecurrenceOrderType)recurrenceData.WeekOfMonth); if (!EnumValidator.IsValidValue <RecurrenceOrderType>(recurrenceOrderType)) { throw new ConversionException(string.Format(CultureInfo.InvariantCulture, "WeekOfMonth value {0} is invalid", new object[] { recurrenceOrderType.ToString() })); } return(new YearlyThRecurrencePattern((DaysOfWeek)recurrenceData.DayOfWeek, recurrenceOrderType, (int)recurrenceData.MonthOfYear, recurrenceData.IsLeapMonth, recurrenceData.CalendarType)); } } throw new ConversionException("Unexpected recurrence type, should have been caught in a higher validation layer"); } switch (type) { case RecurrenceData.RecurrenceType.Daily: if (recurrenceData.SubProperties["DayOfWeek"] != null || recurrenceData.SubProperties["DayOfMonth"] != null || recurrenceData.SubProperties["WeekOfMonth"] != null || recurrenceData.SubProperties["MonthOfYear"] != null || recurrenceData.SubProperties["CalendarType"] != null || recurrenceData.SubProperties["IsLeapMonth"] != null) { throw new ConversionException(string.Format(CultureInfo.InvariantCulture, "DayOfWeek, DayOfMonth, WeekOfMonth, MonthOfYear, CalendarType, IsLeapMonth is not expected with recurrence type {0}", new object[] { type.ToString() })); } return(new DailyRegeneratingPattern((int)recurrenceInterval)); case RecurrenceData.RecurrenceType.Weekly: if (recurrenceData.SubProperties["DayOfWeek"] != null || recurrenceData.SubProperties["DayOfMonth"] != null || recurrenceData.SubProperties["WeekOfMonth"] != null || recurrenceData.SubProperties["MonthOfYear"] != null || recurrenceData.SubProperties["CalendarType"] != null || recurrenceData.SubProperties["IsLeapMonth"] != null) { throw new ConversionException(string.Format(CultureInfo.InvariantCulture, "DayOfWeek, DayOfMonth, WeekOfMonth, MonthOfYear, CalendarType, IsLeapMonth is not expected with recurrence type {0}", new object[] { type.ToString() })); } return(new WeeklyRegeneratingPattern((int)recurrenceInterval)); case RecurrenceData.RecurrenceType.Monthly: if (recurrenceData.SubProperties["DayOfWeek"] != null || recurrenceData.SubProperties["DayOfMonth"] != null || recurrenceData.SubProperties["WeekOfMonth"] != null || recurrenceData.SubProperties["MonthOfYear"] != null || recurrenceData.SubProperties["IsLeapMonth"] != null) { throw new ConversionException(string.Format(CultureInfo.InvariantCulture, "DayOfWeek, DayOfMonth, WeekOfMonth, MonthOfYear, IsLeapMonth is not expected with recurrence type {0}", new object[] { type.ToString() })); } return(new MonthlyRegeneratingPattern((int)recurrenceInterval, recurrenceData.CalendarType)); case RecurrenceData.RecurrenceType.Yearly: if (recurrenceData.SubProperties["DayOfWeek"] != null || recurrenceData.SubProperties["DayOfMonth"] != null || recurrenceData.SubProperties["WeekOfMonth"] != null || recurrenceData.SubProperties["MonthOfYear"] != null) { throw new ConversionException(string.Format(CultureInfo.InvariantCulture, "DayOfWeek, DayOfMonth, WeekOfMonth, MonthOfYear is not expected with recurrence type {0}", new object[] { type.ToString() })); } return(new YearlyRegeneratingPattern((int)recurrenceInterval, recurrenceData.CalendarType)); } throw new ConversionException("Unexpected recurrence type '" + type + "', should have been caught in a higher validation layer"); }
protected override void InternalCopyFromModified(IProperty srcProperty) { CalendarItem calendarItem = null; Task task = null; if (this.recurrenceType == TypeOfRecurrence.Calendar) { calendarItem = (base.XsoItem as CalendarItem); if (calendarItem == null) { throw new UnexpectedTypeException("CalendarItem", base.XsoItem); } if (!calendarItem.IsOrganizer()) { AirSyncDiagnostics.TraceInfo(ExTraceGlobals.CommonTracer, null, "InternalCopyFromModified::Skip Recurrence change in case of attendee."); return; } } else if (this.recurrenceType == TypeOfRecurrence.Task) { task = (base.XsoItem as Task); if (task == null) { throw new UnexpectedTypeException("Task", base.XsoItem); } } INestedProperty nestedProperty = srcProperty as INestedProperty; if (nestedProperty == null) { throw new UnexpectedTypeException("INestedProperty", srcProperty); } RecurrenceData recurrenceData = nestedProperty.NestedData as RecurrenceData; if (recurrenceData == null) { throw new UnexpectedTypeException("RecurrenceData", nestedProperty.NestedData); } Recurrence recurrence = (this.recurrenceType == TypeOfRecurrence.Calendar) ? calendarItem.Recurrence : task.Recurrence; RecurrencePattern recurrencePattern = XsoRecurrenceProperty.CreateRecurrencePattern(this.recurrenceType, recurrenceData, recurrence); ExDateTime startDate = ExDateTime.MinValue; ExDateTime endDate = ExDateTime.MinValue; if (this.recurrenceType == TypeOfRecurrence.Calendar) { ExDateTime startTime = calendarItem.StartTime; ExTimeZone exTimeZoneFromItem = TimeZoneHelper.GetExTimeZoneFromItem(calendarItem); startDate = exTimeZoneFromItem.ConvertDateTime(startTime); if (recurrenceData.HasUntil()) { ExDateTime until = recurrenceData.Until; endDate = exTimeZoneFromItem.ConvertDateTime(until); } } else if (this.recurrenceType == TypeOfRecurrence.Task) { startDate = recurrenceData.Start; if (recurrenceData.HasUntil()) { endDate = recurrenceData.Until; } } RecurrenceRange range; try { if (recurrenceData.HasOccurences()) { range = new NumberedRecurrenceRange(startDate, (int)recurrenceData.Occurrences); } else if (recurrenceData.HasUntil()) { range = new EndDateRecurrenceRange(startDate, endDate); } else { range = new NoEndRecurrenceRange(startDate); } } catch (ArgumentException ex) { throw new ConversionException(ex.Message); } bool ignoreCalendarTypeAndIsLeapMonth = recurrenceData.ProtocolVersion < 140; if (recurrence != null && recurrence.Pattern != null && recurrence.Pattern.Equals(recurrencePattern, ignoreCalendarTypeAndIsLeapMonth)) { recurrencePattern = recurrence.Pattern; } try { if (this.recurrenceType == TypeOfRecurrence.Calendar) { ExTimeZone exTimeZoneFromItem2 = TimeZoneHelper.GetExTimeZoneFromItem(calendarItem); try { calendarItem.Recurrence = new Recurrence(recurrencePattern, range, exTimeZoneFromItem2, null); goto IL_295; } catch (ArgumentOutOfRangeException) { if (recurrenceData.CalendarType == CalendarType.Default) { recurrenceData.CalendarType = CalendarType.Gregorian; AirSyncDiagnostics.TraceInfo(ExTraceGlobals.CommonTracer, null, "Replace calendar recurrence calendar type with Gregorian."); recurrencePattern = XsoRecurrenceProperty.CreateRecurrencePattern(this.recurrenceType, recurrenceData, recurrence); calendarItem.Recurrence = new Recurrence(recurrencePattern, range, exTimeZoneFromItem2, null); goto IL_295; } throw; } } try { task.Recurrence = new Recurrence(recurrencePattern, range); } catch (ArgumentOutOfRangeException) { if (recurrenceData.CalendarType != CalendarType.Default) { throw; } recurrenceData.CalendarType = CalendarType.Gregorian; AirSyncDiagnostics.TraceInfo(ExTraceGlobals.CommonTracer, null, "Replace task recurrence calendar type with Gregorian."); recurrencePattern = XsoRecurrenceProperty.CreateRecurrencePattern(this.recurrenceType, recurrenceData, recurrence); task.Recurrence = new Recurrence(recurrencePattern, range); } task[TaskSchema.IsOneOff] = recurrenceData.DeadOccur; IL_295 :; } catch (NotSupportedException ex2) { throw new ConversionException(ex2.Message); } }