protected override void InternalSetToDefault(IProperty srcProperty) { if (this.recurrenceType != TypeOfRecurrence.Calendar) { if (this.recurrenceType == TypeOfRecurrence.Task) { Task task = base.XsoItem as Task; if (task == null) { throw new UnexpectedTypeException("Task", base.XsoItem); } task.Recurrence = null; } return; } CalendarItem calendarItem = base.XsoItem as CalendarItem; if (calendarItem == null) { throw new UnexpectedTypeException("CalendarItem", base.XsoItem); } if (calendarItem.IsOrganizer()) { calendarItem.Recurrence = null; base.XsoItem[CalendarItemBaseSchema.TimeZone] = TimeZoneHelper.GetPromotedTimeZoneFromItem(calendarItem).LocalizableDisplayName.ToString(); return; } AirSyncDiagnostics.TraceInfo(ExTraceGlobals.CommonTracer, null, "Skip Recurrence change in case of attendee."); }
public void ChangeEndRecurrence() { OwaStoreObjectId owaStoreObjectId = (OwaStoreObjectId)base.GetParameter("Id"); string changeKey = (string)base.GetParameter("CK"); ExDateTime endRange = (ExDateTime)base.GetParameter("ET"); CalendarItem calendarItem = null; try { calendarItem = Utilities.GetItem <CalendarItem>(base.UserContext, owaStoreObjectId, changeKey, new PropertyDefinition[] { CalendarItemBaseSchema.IsMeeting, CalendarItemBaseSchema.MeetingRequestWasSent, StoreObjectSchema.EffectiveRights }); if (!ItemUtility.UserCanEditItem(calendarItem) || Utilities.IsItemInExternalSharedInFolder(base.UserContext, calendarItem)) { this.Writer.Write("<div id=divOp _sOp=\"np\"></div>"); } else { int num = MeetingUtilities.CancelRecurrence(calendarItem, endRange); if (num != -2147483648) { if (calendarItem.IsMeeting && calendarItem.MeetingRequestWasSent && calendarItem.IsOrganizer()) { base.ResponseContentType = OwaEventContentType.Html; this.Writer.Write("<div id=divOp _sOp=er></div>"); } else if (0 < num) { EndDateRecurrenceRange range = new EndDateRecurrenceRange(calendarItem.Recurrence.Range.StartDate, endRange.IncrementDays(-1)); calendarItem.Recurrence = new Recurrence(calendarItem.Recurrence.Pattern, range); Utilities.SaveItem(calendarItem); this.RenderPayload(new OwaStoreObjectId[] { (OwaStoreObjectId)base.GetParameter("fId") }); } else { calendarItem.DeleteMeeting(DeleteItemFlags.MoveToDeletedItems); this.RenderPayload(new OwaStoreObjectId[] { (OwaStoreObjectId)base.GetParameter("fId") }); } } } } finally { if (calendarItem != null) { calendarItem.Dispose(); calendarItem = null; } } }
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); } }