internal static bool CancelCalendarItem(UserContext userContext, CalendarItemBase calendarItemBase, EditCalendarItemHelper.CancelRangeType cancelRange, ExDateTime cancelFromDateTime, out InfobarMessage infobarMessage) { bool result = true; infobarMessage = null; CalendarItem calendarItem = calendarItemBase as CalendarItem; try { if (calendarItem == null) { StoreObjectId masterStoreObjectId = CalendarUtilities.GetMasterStoreObjectId(calendarItemBase); calendarItem = Utilities.GetItem <CalendarItem>(userContext, masterStoreObjectId, new PropertyDefinition[0]); if (calendarItem != null) { calendarItem.OpenAsReadWrite(); } } if (cancelRange == EditCalendarItemHelper.CancelRangeType.Occurrence || cancelRange == EditCalendarItemHelper.CancelRangeType.None) { EditCalendarItemHelper.CancelCalendarItem(userContext, calendarItemBase); } else if (cancelRange == EditCalendarItemHelper.CancelRangeType.All) { EditCalendarItemHelper.CancelCalendarItem(userContext, calendarItem); } else if (cancelRange == EditCalendarItemHelper.CancelRangeType.FromDate) { int cancelRecurrenceCount = CalendarItemUtilities.GetCancelRecurrenceCount(calendarItem, cancelFromDateTime); if (cancelRecurrenceCount == 0) { EditCalendarItemHelper.CancelCalendarItem(userContext, calendarItem); } else if (cancelRecurrenceCount > 0) { calendarItem.Recurrence = new Recurrence(calendarItem.Recurrence.Pattern, new EndDateRecurrenceRange(calendarItem.Recurrence.Range.StartDate, cancelFromDateTime.IncrementDays(-1))); if (calendarItem.IsMeeting && calendarItem.MeetingRequestWasSent) { result = CalendarUtilities.SendMeetingMessages(userContext, calendarItem, true, out infobarMessage); } else { result = CalendarUtilities.SaveCalendarItem(calendarItem, userContext, out infobarMessage); } } } } finally { if (calendarItem != null && calendarItem != calendarItemBase) { calendarItem.Dispose(); } } return(result); }
protected internal override CalendarItemOccurrence RecoverDeletedOccurrence() { if (this.possibleDeletedOccurrenceId != null) { MailboxSession calendarMailboxSession = MeetingMessage.GetCalendarMailboxSession(this); for (int i = 0; i < 2; i++) { CalendarItem calendarItem = CalendarItem.Bind(calendarMailboxSession, StoreObjectId.FromProviderSpecificId(this.possibleDeletedOccurrenceId.ProviderLevelItemId, StoreObjectType.CalendarItem)); try { calendarItem.OpenAsReadWrite(); if (calendarItem.Recurrence != null) { InternalRecurrence internalRecurrence = (InternalRecurrence)calendarItem.Recurrence; ExDateTime occurrenceId = ((OccurrenceStoreObjectId)this.possibleDeletedOccurrenceId).OccurrenceId; if (internalRecurrence.IsValidOccurrenceId(occurrenceId)) { if (internalRecurrence.IsOccurrenceDeleted(occurrenceId)) { base.LocationIdentifierHelperInstance.SetLocationIdentifier(39541U, LastChangeAction.RecoverDeletedOccurance); calendarItem.RecoverDeletedOccurrence(this.possibleDeletedOccurrenceId); if (calendarItem.Save(SaveMode.ResolveConflicts).SaveStatus == SaveResult.IrresolvableConflict) { goto IL_136; } } CalendarItemOccurrence calendarItemOccurrence = CalendarItemOccurrence.Bind(calendarMailboxSession, this.possibleDeletedOccurrenceId, MeetingMessageSchema.Instance.AutoloadProperties); calendarItemOccurrence.OpenAsReadWrite(); ExTraceGlobals.MeetingMessageTracer.Information <GlobalObjectId>((long)this.GetHashCode(), "Storage.MeetingMessage.RecoverDeletedOccurrence: GOID={0}; occurrence recovered.", this.GlobalObjectId); return(calendarItemOccurrence); } ExTraceGlobals.MeetingMessageTracer.Information <GlobalObjectId>((long)this.GetHashCode(), "Storage.MeetingMessage.RecoverDeletedOccurrence: GOID={0}; occurrence id is invalid.", this.GlobalObjectId); return(null); } } catch (OccurrenceNotFoundException) { ExTraceGlobals.MeetingMessageTracer.Information <GlobalObjectId>((long)this.GetHashCode(), "Storage.MeetingMessage.RecoverDeletedOccurrence: GOID={0}; occurrence not found.", this.GlobalObjectId); return(null); } finally { calendarItem.Dispose(); } IL_136 :; } } ExTraceGlobals.MeetingMessageTracer.Information <GlobalObjectId>((long)this.GetHashCode(), "Storage.MeetingMessage.RecoverDeletedOccurrence: GOID={0}; occurrence not recovered.", this.GlobalObjectId); return(null); }