Exemplo n.º 1
0
 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);
     }
 }
Exemplo n.º 2
0
        // Token: 0x060019C5 RID: 6597 RVA: 0x0005BCD0 File Offset: 0x00059ED0
        private CalendarItem BindToItem(ItemId itemId)
        {
            StoreId id;

            try
            {
                id = StoreId.EwsIdToStoreObjectId(itemId.Id);
            }
            catch (InvalidIdMalformedException ex)
            {
                base.LogAndTraceError(string.Format("[GetCalendarItem] Invalid itemId '{0}' - exception: {1}", itemId.Id, UcwaConfigurationUtilities.BuildFailureLogString(ex)));
                return(null);
            }
            CalendarItem result = null;

            try
            {
                ExTraceGlobals.OnlineMeetingTracer.TraceInformation <string>(0, 0L, "[CreateOnlineMeeting.GetCalendarItem] Trying to bind to item with provided ItemId '{0}'", itemId.Id);
                result = CalendarItem.Bind(this.MailboxSession, id);
            }
            catch (ArgumentException ex2)
            {
                base.LogAndTraceError(string.Format("[GetCalendarItem] Unable to bind to item with provided ItemId '{0}'; Exception: {1}", itemId.Id, UcwaConfigurationUtilities.BuildFailureLogString(ex2)));
            }
            catch (ObjectNotFoundException ex3)
            {
                base.LogAndTraceError(string.Format("[GetCalendarItem] Unable to find item with provided ItemId '{0}'; Exception: {1}", itemId.Id, UcwaConfigurationUtilities.BuildFailureLogString(ex3)));
            }
            return(result);
        }
Exemplo n.º 3
0
        private Item BindToItemWithItemClass(StoreObjectId id, string itemClass, PropertyDefinition[] properties)
        {
            Item result;

            if (ObjectClass.IsReport(itemClass))
            {
                result = ReportMessage.Bind(this.mailboxSession, id, properties);
            }
            else if (ObjectClass.IsMessage(itemClass, false))
            {
                result = MessageItem.Bind(this.mailboxSession, id, properties);
            }
            else if (ObjectClass.IsPost(itemClass))
            {
                result = PostItem.Bind(this.mailboxSession, id, properties);
            }
            else if (ObjectClass.IsCalendarItem(itemClass))
            {
                result = CalendarItem.Bind(this.mailboxSession, id, properties);
            }
            else if (ObjectClass.IsMeetingRequest(itemClass))
            {
                result = MeetingRequest.Bind(this.mailboxSession, id, properties);
            }
            else if (ObjectClass.IsMeetingResponse(itemClass))
            {
                result = MeetingResponse.Bind(this.mailboxSession, id, properties);
            }
            else if (ObjectClass.IsMeetingCancellation(itemClass))
            {
                result = MeetingCancellation.Bind(this.mailboxSession, id, properties);
            }
            else if (ObjectClass.IsContact(itemClass))
            {
                result = Contact.Bind(this.mailboxSession, id, properties);
            }
            else if (ObjectClass.IsTask(itemClass))
            {
                Task task = Task.Bind(this.mailboxSession, id, true, properties);
                task.SuppressRecurrenceAdjustment = true;
                result = task;
            }
            else if (ObjectClass.IsDistributionList(itemClass))
            {
                result = DistributionList.Bind(this.mailboxSession, id, properties);
            }
            else if (ObjectClass.IsGenericMessage(itemClass))
            {
                result = MessageItem.Bind(this.mailboxSession, id, properties);
            }
            else
            {
                result = Item.Bind(this.mailboxSession, id, properties);
            }
            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);
 }
Exemplo n.º 5
0
        public MeetingInquiryAction Process(CalendarVersionStoreGateway cvsGateway)
        {
            this.CheckDisposed("Process");
            VersionedId id;

            MeetingInquiryMessage.ExistingCalendarItemError existingCalendarItemError;
            byte[] providerLevelItemId;
            using (CalendarFolder calendarFolder = CalendarFolder.Bind(this.MailboxSession, DefaultFolderType.Calendar))
            {
                existingCalendarItemError = this.CheckExistingCalendarItem(calendarFolder, out id);
                providerLevelItemId       = calendarFolder.Id.ObjectId.ProviderLevelItemId;
            }
            switch (existingCalendarItemError)
            {
            case MeetingInquiryMessage.ExistingCalendarItemError.None:
                return(this.TryRepairMissingItem(cvsGateway, providerLevelItemId));

            case MeetingInquiryMessage.ExistingCalendarItemError.MeetingAlreadyExists:
                return(MeetingInquiryAction.MeetingAlreadyExists);

            case MeetingInquiryMessage.ExistingCalendarItemError.OccurrenceInquiry:
                using (CalendarItem calendarItem = CalendarItem.Bind(base.Session, id))
                {
                    MeetingInquiryMessage.OccurrenceInquiryError occurrenceInquiryError = this.CheckOccurrence(calendarItem);
                    switch (occurrenceInquiryError)
                    {
                    case MeetingInquiryMessage.OccurrenceInquiryError.None:
                        return(this.TryRepairMissingItem(cvsGateway, providerLevelItemId));

                    case MeetingInquiryMessage.OccurrenceInquiryError.InvalidOccurrence:
                    {
                        UpdateRumInfo rumInfo = UpdateRumInfo.CreateMasterInstance(this.GetRumAttendees(calendarItem), CalendarInconsistencyFlag.RecurrenceBlob);
                        calendarItem.SendUpdateRums(rumInfo, false);
                        return(MeetingInquiryAction.SendUpdateForMaster);
                    }

                    case MeetingInquiryMessage.OccurrenceInquiryError.ExistingOccurrence:
                        return(MeetingInquiryAction.ExistingOccurrence);

                    default:
                        throw new InvalidOperationException(string.Format("An invalid error code is returned: {0}.", occurrenceInquiryError));
                    }
                }
                break;
            }
            throw new InvalidOperationException(string.Format("An invalid error code is returned: {0}.", existingCalendarItemError));
        }
Exemplo n.º 6
0
 protected override Item Bind(MailboxSession mailboxSession, StoreId storeId)
 {
     return(CalendarItem.Bind(mailboxSession, storeId));
 }
 internal void Prepopulate(Folder folder)
 {
     if (folder == null)
     {
         throw new ArgumentNullException("folder");
     }
     this.prepopulate = true;
     if (this.CustomFilterState == null)
     {
         this.CustomFilterState = new Dictionary <ISyncItemId, DateTimeCustomSyncFilter.FilterState>();
     }
     using (QueryResult queryResult = folder.ItemQuery(ItemQueryType.None, null, null, new PropertyDefinition[]
     {
         ItemSchema.Id,
         CalendarItemInstanceSchema.EndTime,
         CalendarItemBaseSchema.CalendarItemType,
         StoreObjectSchema.ItemClass,
         ItemSchema.Subject,
         CalendarItemInstanceSchema.StartTime
     }))
     {
         bool flag = false;
         while (!flag)
         {
             object[][] rows = queryResult.GetRows(10000);
             flag = (rows.Length == 0);
             for (int i = 0; i < rows.Length; i++)
             {
                 StoreObjectId storeObjectId = null;
                 DateTimeCustomSyncFilter.FilterState filterState = null;
                 ISyncItemId key = null;
                 try
                 {
                     storeObjectId = ((VersionedId)rows[i][0]).ObjectId;
                     string itemClass = rows[i][3] as string;
                     key = MailboxSyncItemId.CreateForNewItem(storeObjectId);
                     if (!this.CustomFilterState.ContainsKey(key))
                     {
                         filterState = new DateTimeCustomSyncFilter.FilterState();
                         this.CustomFilterState[key] = filterState;
                     }
                     else
                     {
                         filterState = this.CustomFilterState[key];
                     }
                     if (!ObjectClass.IsCalendarItem(itemClass))
                     {
                         filterState.IsCalendarItem = false;
                     }
                     else
                     {
                         filterState.IsCalendarItem = true;
                         if (!(rows[i][2] is CalendarItemType))
                         {
                             filterState.IsCalendarItem = false;
                         }
                         else
                         {
                             filterState.IsRecurring = (CalendarItemType.RecurringMaster == (CalendarItemType)rows[i][2]);
                             if (filterState.IsRecurring)
                             {
                                 using (CalendarItem calendarItem = CalendarItem.Bind(folder.Session, storeObjectId))
                                 {
                                     if (calendarItem.Recurrence != null)
                                     {
                                         if (calendarItem.Recurrence.Range is NoEndRecurrenceRange)
                                         {
                                             filterState.DoesRecurrenceEnd = false;
                                         }
                                         else
                                         {
                                             filterState.DoesRecurrenceEnd = true;
                                             OccurrenceInfo lastOccurrence = calendarItem.Recurrence.GetLastOccurrence();
                                             filterState.EndTime = lastOccurrence.EndTime;
                                         }
                                     }
                                     else
                                     {
                                         filterState.IsCalendarItem = false;
                                     }
                                     goto IL_1E6;
                                 }
                             }
                             if (!(rows[i][1] is ExDateTime))
                             {
                                 filterState.IsCalendarItem = false;
                             }
                             else
                             {
                                 filterState.EndTime = (ExDateTime)rows[i][1];
                             }
                             IL_1E6 :;
                         }
                     }
                 }
                 catch (Exception ex)
                 {
                     if (ex is ObjectNotFoundException)
                     {
                         this.CustomFilterState.Remove(key);
                     }
                     else
                     {
                         if (!SyncCommand.IsItemSyncTolerableException(ex))
                         {
                             throw;
                         }
                         string     text       = "Unknown";
                         ExDateTime exDateTime = ExDateTime.MinValue;
                         try
                         {
                             text       = (rows[i][4] as string);
                             exDateTime = (ExDateTime)rows[i][5];
                         }
                         catch
                         {
                         }
                         AirSyncUtility.ExceptionToStringHelper exceptionToStringHelper = new AirSyncUtility.ExceptionToStringHelper(ex);
                         AirSyncDiagnostics.TraceDebug(ExTraceGlobals.RequestsTracer, this, "Exception was caught in Prepopulate. Item id=\"{0}\", subject=\"{1}\", meetingTime={2}\r\n{3}\r\nIgnoring exception and proceeding to next item.", new object[]
                         {
                             (storeObjectId != null) ? storeObjectId : "null",
                             text,
                             exDateTime,
                             exceptionToStringHelper
                         });
                         if (filterState != null)
                         {
                             filterState.IsCalendarItem = false;
                         }
                     }
                 }
             }
         }
     }
 }
Exemplo n.º 8
0
        internal static List <MeetingData> GetMeetingsInRange(MailboxSession session, UserObject mailboxUser, CalendarFolder calendarFolder, ExDateTime rangeStart, ExDateTime rangeEnd, string locationToFilterWith, string subjectToFilterWith, List <MeetingValidationResult> results)
        {
            object[][]         array   = null;
            List <MeetingData> list    = new List <MeetingData>();
            HashSet <StoreId>  hashSet = new HashSet <StoreId>();

            if (results == null)
            {
                return(list);
            }
            array = CalendarQuery.GetRecurringMasters(calendarFolder, CalendarQuery.CalendarQueryProps);
            foreach (object[] array3 in array)
            {
                if (!ObjectClass.IsCalendarItemSeries((string)array3[29]))
                {
                    string text;
                    if (!CalendarQuery.ArePropertiesValid(array3, out text))
                    {
                        StoreId     storeId     = (StoreId)array3[0];
                        MeetingData meetingData = MeetingData.CreateInstance(mailboxUser, storeId);
                        results.Add(new MeetingValidationResult(rangeStart, rangeEnd, mailboxUser, meetingData, false, text));
                    }
                    else
                    {
                        string location = (string)array3[8];
                        string text2    = (string)array3[9];
                        if (CalendarQuery.ShouldContinueLocationSubjectFilters(locationToFilterWith, subjectToFilterWith, location, text2))
                        {
                            StoreId storeId = (StoreId)array3[0];
                            bool    flag    = (bool)array3[3];
                            if (flag)
                            {
                                CalendarItem calendarItem = null;
                                string       empty        = string.Empty;
                                try
                                {
                                    calendarItem = CalendarItem.Bind(session, storeId, CalendarQuery.CalendarQueryProps);
                                    if (calendarItem.Recurrence != null)
                                    {
                                        IList <OccurrenceInfo> modifiedOccurrences = calendarItem.Recurrence.GetModifiedOccurrences();
                                        foreach (OccurrenceInfo occurrenceInfo in modifiedOccurrences)
                                        {
                                            StoreId versionedId = occurrenceInfo.VersionedId;
                                            hashSet.Add(versionedId);
                                        }
                                        OccurrenceInfo firstOccurrence;
                                        OccurrenceInfo occurrenceInfo2;
                                        try
                                        {
                                            firstOccurrence = calendarItem.Recurrence.GetFirstOccurrence();
                                            if (calendarItem.Recurrence.Range is NoEndRecurrenceRange)
                                            {
                                                occurrenceInfo2 = null;
                                            }
                                            else
                                            {
                                                occurrenceInfo2 = calendarItem.Recurrence.GetLastOccurrence();
                                            }
                                        }
                                        catch (RecurrenceHasNoOccurrenceException)
                                        {
                                            goto IL_350;
                                        }
                                        catch (InvalidOperationException)
                                        {
                                            MeetingData meetingData2 = MeetingData.CreateInstance(mailboxUser, storeId);
                                            results.Add(new MeetingValidationResult(rangeStart, rangeEnd, mailboxUser, meetingData2, false, string.Format("GetMeetingsInRange: InvalidOperationException: no end occurence, Subject=\"{0}\"", text2)));
                                            goto IL_350;
                                        }
                                        if ((occurrenceInfo2 == null || !(occurrenceInfo2.StartTime < rangeStart)) && !(firstOccurrence.EndTime >= rangeEnd))
                                        {
                                            QueryResultPropertyBag queryResultPropertyBag = new QueryResultPropertyBag(session, CalendarQuery.CalendarQueryProps);
                                            queryResultPropertyBag.SetQueryResultRow(array3);
                                            MeetingData item = MeetingData.CreateInstance(mailboxUser, calendarItem);
                                            list.Add(item);
                                            foreach (OccurrenceInfo occurrenceInfo3 in modifiedOccurrences)
                                            {
                                                if (!(occurrenceInfo3.StartTime > rangeEnd) && !(occurrenceInfo3.StartTime < rangeStart))
                                                {
                                                    MeetingData item2 = MeetingData.CreateInstance(mailboxUser, occurrenceInfo3.VersionedId, calendarItem.GlobalObjectId, CalendarItemType.Exception);
                                                    list.Add(item2);
                                                }
                                            }
                                        }
                                    }
                                }
                                catch (RecurrenceFormatException exception)
                                {
                                    MeetingData item3 = MeetingData.CreateInstance(mailboxUser, storeId, null, exception);
                                    list.Add(item3);
                                }
                                catch (ObjectNotFoundException exception2)
                                {
                                    MeetingData meetingData3 = MeetingData.CreateInstance(mailboxUser, storeId, null, exception2);
                                    list.Add(meetingData3);
                                    results.Add(new MeetingValidationResult(rangeStart, rangeEnd, mailboxUser, meetingData3, false, string.Format("GetMeetingsInRange: ObjectNotFoundException - could not find this meeting, Subject=\"{0}\"", text2)));
                                }
                                catch (CorruptDataException arg)
                                {
                                    text = string.Format("GetMeetingsInRange: Subject=\"{0}\", CorruptDataException: {1}", text2, arg);
                                    MeetingValidationResult mvresultWithMoreCalItemData = CalendarQuery.GetMVResultWithMoreCalItemData(session, mailboxUser, storeId, text, text2, rangeStart, rangeEnd);
                                    results.Add(mvresultWithMoreCalItemData);
                                }
                                catch (ArgumentException exception3)
                                {
                                    MeetingData meetingData4 = MeetingData.CreateInstance(mailboxUser, storeId, null, exception3);
                                    list.Add(meetingData4);
                                    results.Add(new MeetingValidationResult(rangeStart, rangeEnd, mailboxUser, meetingData4, false, string.Format("GetMeetingsInRange: ArgumentException - could not bind this meeting, Subject=\"{0}\"", text2)));
                                }
                                catch (AccessDeniedException arg2)
                                {
                                    MeetingData meetingData5 = MeetingData.CreateInstance(mailboxUser, storeId);
                                    results.Add(new MeetingValidationResult(rangeStart, rangeEnd, mailboxUser, meetingData5, false, string.Format("GetMeetingsInRange:  AccessDeniedException: {0}", arg2)));
                                }
                                finally
                                {
                                    if (calendarItem != null)
                                    {
                                        calendarItem.Dispose();
                                    }
                                }
                            }
                        }
                    }
                }
                IL_350 :;
            }
            try
            {
                array = calendarFolder.GetCalendarView(rangeStart, rangeEnd, CalendarQuery.CalendarQueryProps);
            }
            catch (Exception arg3)
            {
                MeetingData meetingData6 = MeetingData.CreateInstance(mailboxUser, null);
                results.Add(new MeetingValidationResult(rangeStart, rangeEnd, mailboxUser, meetingData6, false, string.Format("GetMeetingsInRange:  Exception: {0}", arg3)));
                return(list);
            }
            foreach (object[] array5 in array)
            {
                if (!ObjectClass.IsCalendarItemSeries((string)array5[29]))
                {
                    string errorDescription;
                    if (!CalendarQuery.ArePropertiesValid(array5, out errorDescription))
                    {
                        StoreId     storeId2     = (StoreId)array5[0];
                        MeetingData meetingData7 = MeetingData.CreateInstance(mailboxUser, storeId2);
                        results.Add(new MeetingValidationResult(rangeStart, rangeEnd, mailboxUser, meetingData7, false, errorDescription));
                    }
                    else
                    {
                        string location2 = (string)array5[8];
                        string subject   = (string)array5[9];
                        if (CalendarQuery.ShouldContinueLocationSubjectFilters(locationToFilterWith, subjectToFilterWith, location2, subject))
                        {
                            StoreId storeId2 = (StoreId)array5[0];
                            bool    flag2    = (bool)array5[3];
                            if (flag2)
                            {
                                byte[]         array6 = (byte[])array5[1];
                                GlobalObjectId globalObjectId;
                                try
                                {
                                    globalObjectId = new GlobalObjectId(array6);
                                }
                                catch (CorruptDataException arg4)
                                {
                                    MeetingData meetingData8 = MeetingData.CreateInstance(mailboxUser, storeId2);
                                    results.Add(new MeetingValidationResult(rangeStart, rangeEnd, mailboxUser, meetingData8, false, string.Format("GetMeetingsInRange: CorruptDataException: The Global Object ID is invalid ({0}). Error: {1}", GlobalObjectId.ByteArrayToHexString(array6), arg4)));
                                    goto IL_54A;
                                }
                                int value = (int)array5[30];
                                CalendarItemType calendarItemType = (CalendarItemType)array5[5];
                                if (calendarItemType == CalendarItemType.Single)
                                {
                                    int         appointmentSequenceNumber = (int)array5[15];
                                    ExDateTime  lastModifiedTime          = (ExDateTime)array5[14];
                                    ExDateTime  ownerCriticalChangeTime   = (ExDateTime)array5[17];
                                    int         documentId = (int)array5[33];
                                    MeetingData item4      = MeetingData.CreateInstance(mailboxUser, storeId2, globalObjectId, appointmentSequenceNumber, lastModifiedTime, ownerCriticalChangeTime, CalendarItemType.Single, subject, new int?(value), documentId);
                                    list.Add(item4);
                                }
                                else if (calendarItemType == CalendarItemType.Exception)
                                {
                                    if (!hashSet.Contains(storeId2))
                                    {
                                        MeetingData item5 = MeetingData.CreateInstance(mailboxUser, storeId2, globalObjectId, CalendarItemType.Exception);
                                        list.Add(item5);
                                    }
                                }
                                else if (calendarItemType == CalendarItemType.Occurrence)
                                {
                                    MeetingData item6 = MeetingData.CreateInstance(mailboxUser, storeId2, globalObjectId, CalendarItemType.Occurrence);
                                    list.Add(item6);
                                }
                            }
                        }
                    }
                }
                IL_54A :;
            }
            return(list);
        }
Exemplo n.º 9
0
        private MeetingInquiryAction TryReviveMeeting(CalendarItemBase deletedVersion)
        {
            bool flag = false;

            if (this.GlobalObjectId.IsCleanGlobalObjectId)
            {
                using (CalendarItemBase calendarItemBase = (CalendarItemBase)Microsoft.Exchange.Data.Storage.Item.CloneItem(base.Session, this.MailboxSession.GetDefaultFolderId(DefaultFolderType.Calendar), deletedVersion, false, true, null))
                {
                    calendarItemBase.LocationIdentifierHelperInstance.SetLocationIdentifier(43287U, LastChangeAction.Resurrect);
                    calendarItemBase.Save(SaveMode.NoConflictResolution);
                    flag = true;
                    goto IL_207;
                }
            }
            using (CalendarFolder calendarFolder = CalendarFolder.Bind(this.MailboxSession, DefaultFolderType.Calendar))
            {
                StoreId calendarItemId = calendarFolder.GetCalendarItemId(this.GlobalObjectId.CleanGlobalObjectIdBytes);
                if (calendarItemId != null)
                {
                    using (CalendarItem calendarItem = CalendarItem.Bind(this.MailboxSession, calendarItemId))
                    {
                        if (calendarItem.CalendarItemType == CalendarItemType.RecurringMaster)
                        {
                            try
                            {
                                calendarItem.RecoverDeletedOccurrenceByDateId(this.GlobalObjectId.Date);
                                calendarItem.LocationIdentifierHelperInstance.SetLocationIdentifier(59671U, LastChangeAction.Resurrect);
                                ConflictResolutionResult conflictResolutionResult = calendarItem.Save(SaveMode.ResolveConflicts);
                                if (conflictResolutionResult.SaveStatus == SaveResult.IrresolvableConflict)
                                {
                                    ExTraceGlobals.MeetingMessageTracer.TraceError <string, GlobalObjectId>((long)this.GetHashCode(), "Storage.MeetingInquiryMessage::ReviveDeletedVersionIfNoCancellation for Mailbox {0} and GOID {1} hit a save conflict.", this.MailboxSession.DisplayName, this.GlobalObjectId);
                                    throw new SaveConflictException(ServerStrings.ExSaveFailedBecauseOfConflicts(base.InternalObjectId), conflictResolutionResult);
                                }
                                flag = true;
                            }
                            catch (OccurrenceNotFoundException)
                            {
                                ExTraceGlobals.MeetingMessageTracer.TraceError <string, GlobalObjectId, ExDateTime>((long)this.GetHashCode(), "Storage.MeetingInquiryMessage::ReviveDeletedVersionIfNoCancellation for Mailbox {0} and GOID {1}. There's no occurrence on {2}", this.MailboxSession.DisplayName, this.GlobalObjectId, this.GlobalObjectId.Date);
                            }
                            catch (ObjectValidationException ex)
                            {
                                if (ex.Errors.Count != 1 || (!(ex.Errors[0].Constraint is OrganizerPropertiesConstraint) && !(ex.Errors[0].Constraint is CalendarOriginatorIdConstraint)))
                                {
                                    throw;
                                }
                                ExTraceGlobals.MeetingMessageTracer.TraceError <string, GlobalObjectId, string>((long)this.GetHashCode(), "Storage.MeetingInquiryMessage::ReviveDeletedVersionIfNoCancellation for Mailbox {0} and GOID {1}. Object validation failed : {2}", this.MailboxSession.DisplayName, this.GlobalObjectId, ex.Message);
                            }
                        }
                        goto IL_1FB;
                    }
                }
                ExTraceGlobals.MeetingMessageTracer.TraceError <string, byte[]>((long)this.GetHashCode(), "Storage.MeetingInquiryMessage::ReviveDeletedVersionIfNoCancellation for Mailbox {0}. Couldn't find calendar item with CGOID {1}", this.MailboxSession.DisplayName, this.GlobalObjectId.CleanGlobalObjectIdBytes);
                IL_1FB :;
            }
            IL_207 :
            if (!flag)
            {
                return(MeetingInquiryAction.FailedToRevive);
            }
            return(MeetingInquiryAction.ReviveMeeting);
        }
Exemplo n.º 10
0
        // Token: 0x060010EE RID: 4334 RVA: 0x00046958 File Offset: 0x00044B58
        private int AddNewOrChangedItems(StoreId id, IList <SyncCalendarItemType> updatedItemsList, IList <SyncCalendarItemType> recurrenceMastersWithInstances, IList <SyncCalendarItemType> recurrenceMastersWithoutInstances, IDictionary <StoreId, SyncCalendarItemType> unchangedRecurrenceMastersWithInstances, IList <StoreId> deletedItemsList, HashSet <StoreId> syncItemsHashSet, IList <KeyValuePair <StoreId, LocalizedException> > caughtExceptions)
        {
            int addedItems = 0;

            try
            {
                GrayException.MapAndReportGrayExceptions(delegate()
                {
                    using (CalendarItem calendarItem = CalendarItem.Bind(this.session, id, new PropertyDefinition[]
                    {
                        CalendarItemInstanceSchema.StartWallClock,
                        CalendarItemInstanceSchema.EndWallClock
                    }))
                    {
                        string uid;
                        try
                        {
                            uid = new GlobalObjectId(calendarItem).Uid;
                        }
                        catch (Exception arg)
                        {
                            ExTraceGlobals.SyncCalendarTracer.TraceWarning <StoreId, Exception>((long)this.GetHashCode(), "Skipping the corrupt recurring calendar GlobalObjectId (Id: '{0}'). {1}", id, arg);
                            uid = null;
                        }
                        SyncCalendarItemType typedItem = this.GetTypedItem(calendarItem.Id, uid, calendarItem.CalendarItemType, calendarItem.StartTime, calendarItem.StartWallClock, calendarItem.EndTime, calendarItem.EndWallClock);
                        if (calendarItem.CalendarItemType == CalendarItemType.RecurringMaster)
                        {
                            if (calendarItem.Recurrence == null)
                            {
                                ExTraceGlobals.SyncCalendarTracer.TraceWarning <StoreId>((long)this.GetHashCode(), "Skipping the corrupt recurring calendar item with no recurrence (Id: '{0}').", id);
                            }
                            else
                            {
                                IList <OccurrenceInfo> occurrenceInfoList = calendarItem.Recurrence.GetOccurrenceInfoList(this.windowStart, this.windowEnd);
                                if (occurrenceInfoList.Count != 0)
                                {
                                    addedItems += this.AddSyncItem(typedItem, recurrenceMastersWithInstances, syncItemsHashSet, unchangedRecurrenceMastersWithInstances, false);
                                    using (IEnumerator <OccurrenceInfo> enumerator = occurrenceInfoList.GetEnumerator())
                                    {
                                        while (enumerator.MoveNext())
                                        {
                                            OccurrenceInfo occurrenceInfo = enumerator.Current;
                                            CalendarItemType type;
                                            ExDateTime startWallClock;
                                            ExDateTime endWallClock;
                                            if (occurrenceInfo is ExceptionInfo)
                                            {
                                                type           = CalendarItemType.Exception;
                                                startWallClock = ExDateTime.MinValue;
                                                endWallClock   = ExDateTime.MinValue;
                                            }
                                            else
                                            {
                                                type           = CalendarItemType.Occurrence;
                                                startWallClock = calendarItem.StartWallClock.TimeZone.ConvertDateTime(occurrenceInfo.StartTime);
                                                endWallClock   = calendarItem.EndWallClock.TimeZone.ConvertDateTime(occurrenceInfo.EndTime);
                                            }
                                            SyncCalendarItemType typedItem2 = this.GetTypedItem(occurrenceInfo.VersionedId, uid, type, occurrenceInfo.StartTime, startWallClock, occurrenceInfo.EndTime, endWallClock);
                                            addedItems += this.AddSyncItem(typedItem2, updatedItemsList, syncItemsHashSet, unchangedRecurrenceMastersWithInstances, false);
                                        }
                                        goto IL_2D1;
                                    }
                                }
                                addedItems += this.AddSyncItem(typedItem, recurrenceMastersWithoutInstances, syncItemsHashSet, unchangedRecurrenceMastersWithInstances, false);
                            }
                        }
                        else
                        {
                            bool flag = this.windowStart <calendarItem.EndTime && this.windowEnd> calendarItem.StartTime;
                            if (flag)
                            {
                                addedItems += this.AddSyncItem(typedItem, updatedItemsList, syncItemsHashSet, unchangedRecurrenceMastersWithInstances, false);
                            }
                            else
                            {
                                addedItems += this.AddDeletedItem(id, syncItemsHashSet, deletedItemsList);
                            }
                        }
                        IL_2D1:;
                    }
                }, new GrayException.IsGrayExceptionDelegate(GrayException.IsSystemGrayException));
            }
            catch (LocalizedException ex)
            {
                ExTraceGlobals.SyncCalendarTracer.TraceWarning <string, LocalizedException>((long)this.GetHashCode(), "XsoSyncCalendar.AddNewOrChangedItems: Exception thrown while processing item {0}: {1}", id.ToBase64String(), ex);
                caughtExceptions.Add(new KeyValuePair <StoreId, LocalizedException>(id, ex));
            }
            return(addedItems);
        }
Exemplo n.º 11
0
        // Token: 0x060010EC RID: 4332 RVA: 0x000462C8 File Offset: 0x000444C8
        private CalendarViewQueryResumptionPoint DoQuerySync(HashSet <StoreId> syncItemsHashSet, List <SyncCalendarItemType> updatedItemsList, List <SyncCalendarItemType> recurrenceMastersWithInstances, Dictionary <StoreId, SyncCalendarItemType> unchangedRecurrenceMastersWithInstances, ExDateTime queryWindowStart, ExDateTime queryWindowEnd, int maxCount, IList <KeyValuePair <StoreId, LocalizedException> > caughtExceptions, out int addedItems)
        {
            ExTraceGlobals.SyncCalendarTracer.TraceDebug((long)this.GetHashCode(), "XsoSyncCalendar.DoQuerySync: Start");
            int localAddedItems = 0;
            CalendarViewBatchingStrategy calendarViewBatchingStrategy = (this.syncState.QueryResumptionPoint == null) ? CalendarViewBatchingStrategy.CreateNewBatchingInstance(maxCount) : CalendarViewBatchingStrategy.CreateResumingInstance(maxCount, this.syncState.QueryResumptionPoint);

            using (CalendarFolder calendarFolder = CalendarFolder.Bind(this.session, this.folderId))
            {
                PropertyDefinition[] xsoRequiredProperties = this.getPropertiesToFetchDelegate(calendarFolder);
                object[][]           syncView = calendarFolder.GetSyncView(queryWindowStart, queryWindowEnd, calendarViewBatchingStrategy, xsoRequiredProperties, false);
                object[][]           array    = syncView;
                for (int i = 0; i < array.Length; i++)
                {
                    object[] itemRow = array[i];
                    try
                    {
                        GrayException.MapAndReportGrayExceptions(delegate()
                        {
                            ExDateTime t;
                            SyncCalendarItemType typedItem = this.GetTypedItem(xsoRequiredProperties, itemRow, out t);
                            if (typedItem.CalendarItemType != CalendarItemType.RecurringMaster)
                            {
                                if (this.windowStart == queryWindowStart || t >= queryWindowStart)
                                {
                                    localAddedItems += this.AddSyncItem(typedItem, updatedItemsList, syncItemsHashSet, unchangedRecurrenceMastersWithInstances, false);
                                }
                                return;
                            }
                            bool flag = false;
                            if (this.windowStart == queryWindowStart)
                            {
                                flag = true;
                            }
                            else
                            {
                                using (CalendarItem calendarItem = CalendarItem.Bind(this.session, typedItem.ItemId))
                                {
                                    IList <OccurrenceInfo> occurrenceInfoList = calendarItem.Recurrence.GetOccurrenceInfoList(this.windowStart, queryWindowStart);
                                    flag = (occurrenceInfoList.Count == 0);
                                }
                            }
                            if (flag)
                            {
                                localAddedItems += this.AddSyncItem(typedItem, recurrenceMastersWithInstances, syncItemsHashSet, unchangedRecurrenceMastersWithInstances, false);
                                return;
                            }
                            localAddedItems += this.AddSyncItem(typedItem, null, syncItemsHashSet, unchangedRecurrenceMastersWithInstances, true);
                        }, new GrayException.IsGrayExceptionDelegate(GrayException.IsSystemGrayException));
                    }
                    catch (LocalizedException ex)
                    {
                        StoreId storeId = (StoreId)itemRow[0];
                        ExTraceGlobals.SyncCalendarTracer.TraceWarning <string, LocalizedException>((long)this.GetHashCode(), "XsoSyncCalendar.DoQuerySync: Exception thrown while processing item {0}: {1}", storeId.ToBase64String(), ex);
                        caughtExceptions.Add(new KeyValuePair <StoreId, LocalizedException>(storeId, ex));
                    }
                }
            }
            ExTraceGlobals.SyncCalendarTracer.TraceDebug((long)this.GetHashCode(), "XsoSyncCalendar.DoQuerySync: End");
            addedItems = localAddedItems;
            return(calendarViewBatchingStrategy.ResumptionPoint);
        }
 public CalendarItem GetMaster()
 {
     this.CheckDisposed("GetMaster");
     return(CalendarItem.Bind(base.Session, this.MasterId));
 }
Exemplo n.º 13
0
        // Token: 0x0600095D RID: 2397 RVA: 0x0003ED90 File Offset: 0x0003CF90
        public static IList <CalendarInfo> Load(ExDateTime creationRequestTime, ExTimeZone timeZoneAdjustment, MailboxSession session, StoreObjectId calFldrId, StorageWorkingHours workingHours, ExDateTime actualizationTime, ExDateTime endTime)
        {
            StoreObjectId defaultFolderId = session.GetDefaultFolderId(DefaultFolderType.Reminders);

            if (defaultFolderId == null)
            {
                ExTraceGlobals.AssistantTracer.TraceDebug <IExchangePrincipal, string>((long)typeof(ReminderLoader).GetHashCode(), "cannot open reminder folder for user {0}, Time {1}", session.MailboxOwner, ExDateTime.GetNow(timeZoneAdjustment).ToLongTimeString());
                return(new CalendarInfo[0]);
            }
            List <CalendarInfo> list          = new List <CalendarInfo>();
            StoreObjectId       storeObjectId = calFldrId;

            if (calFldrId.IsFolderId && StoreObjectType.Folder != calFldrId.ObjectType)
            {
                storeObjectId = calFldrId.Clone();
                storeObjectId.UpdateItemType(StoreObjectType.Folder);
            }
            QueryFilter queryFilter = new AndFilter(new QueryFilter[]
            {
                new ComparisonFilter(ComparisonOperator.GreaterThanOrEqual, ItemSchema.ReminderNextTime, actualizationTime),
                new ComparisonFilter(ComparisonOperator.LessThan, ItemSchema.ReminderNextTime, endTime),
                new ComparisonFilter(ComparisonOperator.Equal, ItemSchema.ReminderIsSet, true),
                new ComparisonFilter(ComparisonOperator.Equal, StoreObjectSchema.ParentItemId, storeObjectId)
            });

            SortBy[] sortColumns = new SortBy[]
            {
                new SortBy(ItemSchema.ReminderNextTime, SortOrder.Ascending)
            };
            new Interval <ExDateTime>(actualizationTime, false, endTime, true);
            using (SearchFolder searchFolder = SearchFolder.Bind(session, defaultFolderId))
            {
                using (QueryResult queryResult = searchFolder.ItemQuery(ItemQueryType.None, queryFilter, sortColumns, CalendarInfo.InterestedProperties))
                {
                    ExDateTime exDateTime = ExDateTime.MinValue;
                    foreach (object[] propVals in queryResult.GetRows(100))
                    {
                        CalendarInfo calendarInfo = CalendarInfo.FromInterestedProperties(creationRequestTime, timeZoneAdjustment, session, true, propVals);
                        if (CalendarItemType.RecurringMaster == calendarInfo.CalendarItemType)
                        {
                            using (CalendarItem calendarItem = CalendarItem.Bind(session, calendarInfo.CalendarItemIdentity))
                            {
                                using (CalendarItemOccurrence calendarItemOccurrence = (CalendarItemOccurrence)calendarItem.Reminder.GetPertinentItem(actualizationTime))
                                {
                                    if (calendarItemOccurrence != null)
                                    {
                                        calendarInfo = CalendarInfo.FromCalendarItemBase(creationRequestTime, timeZoneAdjustment, calendarItemOccurrence);
                                    }
                                }
                            }
                        }
                        if (!(calendarInfo.ReminderTime < actualizationTime) && calendarInfo.IsInteresting(CalendarNotificationType.Reminder) && (workingHours == null || Utils.InWorkingHours(calendarInfo.StartTime, calendarInfo.EndTime, workingHours)))
                        {
                            if (ExDateTime.MinValue == exDateTime)
                            {
                                exDateTime = calendarInfo.ReminderTime;
                            }
                            else if (calendarInfo.ReminderTime > exDateTime)
                            {
                                break;
                            }
                            list.Add(calendarInfo);
                        }
                    }
                }
            }
            return(list.AsReadOnly());
        }