public override void EnforceLevelOfDetails(MailboxSession mailboxSession, StoreId itemId, LevelOfDetails levelOfDetails) { using (CalendarItem calendarItem = CalendarItem.Bind(mailboxSession, itemId)) { this.EnforceLevelOfDetailsOnItem(calendarItem, levelOfDetails); if (calendarItem.Recurrence != null) { IList <OccurrenceInfo> modifiedOccurrences = calendarItem.Recurrence.GetModifiedOccurrences(); ItemSynchronizer.Tracer.TraceDebug <CalendarItemSynchronizer, int, StoreId>((long)this.GetHashCode(), "{0}: Found {1} modified occurrences for item {2}.", this, modifiedOccurrences.Count, itemId); foreach (OccurrenceInfo occurrenceInfo in modifiedOccurrences) { ExDateTime originalStartTime = occurrenceInfo.OriginalStartTime; if (!calendarItem.Recurrence.IsOccurrenceDeleted(originalStartTime) && calendarItem.Recurrence.IsValidOccurrenceId(originalStartTime)) { using (CalendarItemOccurrence calendarItemOccurrence = calendarItem.OpenOccurrenceByOriginalStartTime(originalStartTime, new PropertyDefinition[0])) { this.EnforceLevelOfDetailsOnItem(calendarItemOccurrence, levelOfDetails); calendarItemOccurrence.Save(SaveMode.NoConflictResolution); continue; } } ItemSynchronizer.Tracer.TraceDebug <CalendarItemSynchronizer, ExDateTime>((long)this.GetHashCode(), "{0}: Exception {1} is deleted or invalid. Skipping enforcement of level of details.", this, originalStartTime); } } calendarItem.Save(SaveMode.NoConflictResolution); } }
// Token: 0x06001566 RID: 5478 RVA: 0x0007DE58 File Offset: 0x0007C058 protected CalendarItemBase GetCalendarItemBaseToReplyOrForward(CalendarItem item) { ExDateTime occurrence = this.Occurrence; CalendarItemBase result = null; if (occurrence == ExDateTime.MinValue) { result = item; } else { if (item.Recurrence == null) { AirSyncDiagnostics.TraceError <string, ExDateTime>(ExTraceGlobals.RequestsTracer, this, "Failed to get occurrence of calendar item with subject: \"{0}\" with Start Time: {1}", item.Subject, occurrence); base.ProtocolLogger.SetValue(ProtocolLoggerData.Error, "NoRecurrenceInCalendar"); throw new AirSyncPermanentException(HttpStatusCode.InternalServerError, StatusCode.NoRecurrenceInCalendar, null, false); } try { CalendarItemOccurrence calendarItemOccurrence = item.OpenOccurrenceByOriginalStartTime(occurrence, null); if (!item.IsMeeting) { calendarItemOccurrence.MakeModifiedOccurrence(); } result = calendarItemOccurrence; } catch (OccurrenceNotFoundException innerException) { AirSyncDiagnostics.TraceError <string, ExDateTime>(ExTraceGlobals.RequestsTracer, this, "OccurrenceNotFoundException getting occurrence of calendar item with subject: \"{0}\" with Start Time: {1}", item.Subject, occurrence); base.ProtocolLogger.SetValue(ProtocolLoggerData.Error, "NoInstanceInCalendar"); throw new AirSyncPermanentException(HttpStatusCode.InternalServerError, StatusCode.NoRecurrenceInCalendar, innerException, false); } } return(result); }
public bool SendRums(RumInfo info, bool copyToSentItems, CalendarItemBase item, ref Dictionary <GlobalObjectId, List <Attendee> > organizerRumsSent) { bool result = false; if (info == null) { throw new ArgumentNullException("info"); } if (item == null) { throw new ArgumentNullException("item"); } if (organizerRumsSent == null) { throw new ArgumentNullException("organizerRumsSent"); } if (info.IsOccurrenceRum) { if (item is CalendarItemOccurrence) { ExDateTime originalStartTime = ((CalendarItemOccurrence)item).OriginalStartTime; result = this.SendRumsBase(info, copyToSentItems, item, ref organizerRumsSent); } else { if (!(item is CalendarItem)) { throw new ArgumentException("The calendar item's type is unrecognized.", "item"); } CalendarItem calendarItem = (CalendarItem)item; using (CalendarItemBase calendarItemBase = calendarItem.OpenOccurrenceByOriginalStartTime(info.OccurrenceOriginalStartTime.Value, new PropertyDefinition[0])) { calendarItemBase.OpenAsReadWrite(); result = this.SendRumsBase(info, copyToSentItems, calendarItemBase, ref organizerRumsSent); } item.Load(); } } else { result = this.SendRumsBase(info, copyToSentItems, item, ref organizerRumsSent); } return(result); }
public IEnumerator <ExceptionInstance> GetEnumerator() { CalendarItem calItem = base.XsoItem as CalendarItem; if (calItem.Recurrence == null) { base.State = PropertyState.SetToDefault; } else { ExDateTime[] deletedExceptions = calItem.Recurrence.GetDeletedOccurrences(); for (int idx = 0; idx < deletedExceptions.Length; idx++) { yield return(new ExceptionInstance(ExTimeZone.UtcTimeZone.ConvertDateTime(deletedExceptions[idx]), 1)); } XsoDataObject mailboxDataObject = null; OccurrenceInfo[] modifiedExceptions = (OccurrenceInfo[])calItem.Recurrence.GetModifiedOccurrences(); for (int idx2 = 0; idx2 < modifiedExceptions.Length; idx2++) { if (mailboxDataObject == null) { mailboxDataObject = this.schemaState.GetInnerXsoDataObject(); } ExceptionInstance instance = new ExceptionInstance(ExTimeZone.UtcTimeZone.ConvertDateTime(modifiedExceptions[idx2].OriginalStartTime), 0); using (CalendarItemOccurrence mailboxOccurrence = calItem.OpenOccurrenceByOriginalStartTime(modifiedExceptions[idx2].OriginalStartTime, mailboxDataObject.GetPrefetchProperties())) { if (mailboxOccurrence == null) { throw new ConversionException("Could not look up the modified item by itemId"); } mailboxDataObject.Bind(mailboxOccurrence); instance.ModifiedException = mailboxDataObject; yield return(instance); mailboxDataObject.Unbind(); } } } yield break; }
private bool HandleModifiedExceptions(ExchangeService exchangeService, ItemIdType[] itemsToGet, Dictionary <string, OccurrenceInfoType> modifiedOccurrencesTable, CalendarItem localItem) { IEnumerable <ItemType> item; try { item = exchangeService.GetItem(itemsToGet, StoreObjectType.CalendarFolder); } catch (UnexpectedRemoteDataException ex) { AppointmentTranslator.Tracer.TraceError <AppointmentTranslator, UnexpectedRemoteDataException>((long)this.GetHashCode(), "{0}: Failed to get any exception item. Exception = {1}.", this, ex); if (ex.Items == null) { throw; } bool flag = false; int num = 0; foreach (ResponseMessageType responseMessageType in ex.Items) { if (responseMessageType == null) { throw; } if (this.IsReponseErrorRetryable(responseMessageType.ResponseCode)) { flag = true; break; } if (responseMessageType.ResponseCode == ResponseCodeType.ErrorInvalidOperation) { num++; } else if (responseMessageType.ResponseCode != ResponseCodeType.ErrorCorruptData && responseMessageType.ResponseCode != ResponseCodeType.ErrorItemNotFound) { throw; } } if (flag) { throw new FailedCommunicationException(ex); } if (num > 0 && num != ex.Items.Length) { throw; } return(false); } bool result = false; foreach (ItemType itemType in item) { CalendarItemType calendarItemType = itemType as CalendarItemType; OccurrenceInfoType occurrenceInfoType; if (calendarItemType == null) { AppointmentTranslator.Tracer.TraceError <AppointmentTranslator>((long)this.GetHashCode(), "{0}: Non-appointment exception item", this); } else if (!modifiedOccurrencesTable.TryGetValue(calendarItemType.ItemId.Id, out occurrenceInfoType)) { AppointmentTranslator.Tracer.TraceError <AppointmentTranslator, string>((long)this.GetHashCode(), "{0}: Unexpected exception item: {1}", this, calendarItemType.ItemId.Id); } else { ExDateTime exDateTime = (ExDateTime)this.NormalizeDateToUtc(occurrenceInfoType.OriginalStart); AppointmentTranslator.Tracer.TraceDebug <AppointmentTranslator, string, ExDateTime>((long)this.GetHashCode(), "{0}: Processing exception {1} originalStartTime {2}", this, calendarItemType.ItemId.Id, exDateTime); try { using (CalendarItemOccurrence calendarItemOccurrence = localItem.OpenOccurrenceByOriginalStartTime(exDateTime, new PropertyDefinition[0])) { AppointmentTranslator.Tracer.TraceDebug <AppointmentTranslator, string, ExDateTime>((long)this.GetHashCode(), "{0}: Copying exception properties {1} originalStartTime {2}", this, calendarItemType.ItemId.Id, exDateTime); this.CopyCalendarProperties(calendarItemOccurrence, calendarItemType); AppointmentTranslator.Tracer.TraceDebug <AppointmentTranslator, string, ExDateTime>((long)this.GetHashCode(), "{0}: Saving exception item {1} originalStartTime {2}", this, calendarItemType.ItemId.Id, exDateTime); calendarItemOccurrence.Save(SaveMode.NoConflictResolution); result = true; } } catch (CorruptDataException arg) { AppointmentTranslator.Tracer.TraceDebug <AppointmentTranslator, ExDateTime, CorruptDataException>((long)this.GetHashCode(), "{0}: Got a corrupt data exception during Save for item with originalStartTime {1}, Exception = {2}", this, exDateTime, arg); } catch (VirusException arg2) { AppointmentTranslator.Tracer.TraceDebug <AppointmentTranslator, ExDateTime, VirusException>((long)this.GetHashCode(), "{0}: Got a virus detected exception during Save for item with originalStartTime {1}, Exception = {2}", this, exDateTime, arg2); } catch (RecurrenceException arg3) { AppointmentTranslator.Tracer.TraceDebug <AppointmentTranslator, ExDateTime, RecurrenceException>((long)this.GetHashCode(), "{0}: Got a recurrence exception during Save for item with originalStartTime {1}, Exception = {2}", this, exDateTime, arg3); } catch (OccurrenceNotFoundException arg4) { AppointmentTranslator.Tracer.TraceDebug <AppointmentTranslator, ExDateTime, OccurrenceNotFoundException>((long)this.GetHashCode(), "{0}: Got an OccurrenceNotFoundException exception during Save for item with originalStartTime {1}, Exception = {2}", this, exDateTime, arg4); } } } return(result); }
// Token: 0x06000CE8 RID: 3304 RVA: 0x00045858 File Offset: 0x00043A58 private StoreObjectId GetOccurenceId(StoreObjectId mailboxRequestId, ExDateTime instanceId) { Item item = null; CalendarItemOccurrence calendarItemOccurrence = null; StoreObjectId result; try { try { item = Item.Bind(base.MailboxSession, mailboxRequestId, null); } catch (ObjectNotFoundException) { throw new AirSyncPermanentException(HttpStatusCode.BadRequest, StatusCode.Sync_ProtocolVersionMismatch, null, false) { ErrorStringForProtocolLogger = "GetOccurenceId+ItemNotFound" }; } CalendarItem calendarItem = item as CalendarItem; if (calendarItem == null) { AirSyncDiagnostics.TraceError(ExTraceGlobals.RequestsTracer, this, "GetOccurenceId bound to a non-calendar item, return item itself"); result = mailboxRequestId; } else { if (calendarItem.Recurrence == null) { throw new AirSyncPermanentException(HttpStatusCode.BadRequest, StatusCode.NoRecurrenceInCalendar, null, false) { ErrorStringForProtocolLogger = "NoRecurrenceInCalendar" }; } if (!calendarItem.IsMeeting) { throw new AirSyncPermanentException(HttpStatusCode.BadRequest, StatusCode.Sync_ProtocolVersionMismatch, null, false) { ErrorStringForProtocolLogger = "NotAMeeting" }; } try { try { calendarItemOccurrence = calendarItem.OpenOccurrenceByOriginalStartTime(instanceId, null); } catch (OccurrenceNotFoundException) { calendarItemOccurrence = null; } if (calendarItemOccurrence == null) { throw new AirSyncPermanentException(HttpStatusCode.BadRequest, StatusCode.Sync_ProtocolVersionMismatch, null, false) { ErrorStringForProtocolLogger = "NotAnOccurence" }; } result = calendarItemOccurrence.Id.ObjectId; } catch (ObjectNotFoundException) { throw new AirSyncPermanentException(HttpStatusCode.BadRequest, StatusCode.Sync_ProtocolVersionMismatch, null, false) { ErrorStringForProtocolLogger = "ObjectNotFound" }; } } } finally { if (calendarItemOccurrence != null) { calendarItemOccurrence.Dispose(); } if (item != null) { item.Dispose(); } } return(result); }
protected override void InternalCopyFromModified(IProperty srcProperty) { CalendarItem calendarItem = base.XsoItem as CalendarItem; IExceptionsProperty exceptionsProperty = srcProperty as IExceptionsProperty; XsoDataObject xsoDataObject = null; foreach (ExceptionInstance exceptionInstance in exceptionsProperty) { ExDateTime exDateTime = ExTimeZone.UtcTimeZone.ConvertDateTime(exceptionInstance.ExceptionStartTime); ExDateTime exDateTime2 = calendarItem.ExTimeZone.ConvertDateTime(exDateTime); if (exceptionInstance.Deleted == 1) { if (calendarItem.Id == null) { calendarItem.Save(SaveMode.ResolveConflicts); calendarItem.Load(); } try { this.ValidateCalendarItem(calendarItem); calendarItem.DeleteOccurrenceByOriginalStartTime(exDateTime2); continue; } catch (OccurrenceNotFoundException) { AirSyncDiagnostics.TraceDebug <ExDateTime>(ExTraceGlobals.XsoTracer, this, "Exception with OriginalStartTime: {0} already deleted.", exDateTime2); continue; } } if (xsoDataObject == null) { xsoDataObject = this.schemaState.GetInnerXsoDataObject(); } CalendarItemOccurrence calendarItemOccurrence = null; try { if (calendarItem.Id != null) { this.ValidateCalendarItem(calendarItem); calendarItemOccurrence = calendarItem.OpenOccurrenceByOriginalStartTime(exDateTime2, xsoDataObject.GetPrefetchProperties()); } else { AirSyncDiagnostics.TraceDebug(ExTraceGlobals.XsoTracer, this, "New calendar recurrence item added with exceptions. Extra save (RPC to store) needed for this"); calendarItem.Save(SaveMode.ResolveConflicts); calendarItem.Load(); this.ValidateCalendarItem(calendarItem); calendarItemOccurrence = calendarItem.OpenOccurrenceByOriginalStartTime(exDateTime2, xsoDataObject.GetPrefetchProperties()); } if (calendarItemOccurrence == null) { throw new ConversionException("Could not open the Calendar Occurrence using the Original StartTime"); } calendarItemOccurrence.OpenAsReadWrite(); try { xsoDataObject.Bind(calendarItemOccurrence); xsoDataObject.CopyFrom(exceptionInstance.ModifiedException); } finally { xsoDataObject.Unbind(); } calendarItemOccurrence.Save(SaveMode.NoConflictResolution); } finally { if (calendarItemOccurrence != null) { calendarItemOccurrence.Dispose(); } } } }