FolderChangesManifest ISourceFolder.EnumerateChanges(EnumerateContentChangesFlags flags, int maxChanges) { if (!base.Folder.IsContentAvailable) { return(new FolderChangesManifest(base.FolderId)); } SyncContentsManifestState syncState = ((MapiSourceMailbox)base.Mailbox).SyncState[base.FolderId]; bool flag = maxChanges != 0; if (!flag || flags.HasFlag(EnumerateContentChangesFlags.FirstPage)) { MapiStore mapiStore = base.Mailbox.MapiStore; int[] array = new int[4]; array[0] = 8; if (mapiStore.IsVersionGreaterOrEqualThan(array)) { this.contentChangesFetcher = new ManifestContentChangesFetcher(this, base.Folder, base.Mailbox, flag); } else { this.contentChangesFetcher = new TitaniumContentChangesFetcher(this, base.Folder, base.Mailbox); } } return(this.contentChangesFetcher.EnumerateContentChanges(syncState, flags, maxChanges)); }
private void ConfigureMapiManifest(SyncContentsManifestState syncState, FolderChangesManifest changes, EnumerateContentChangesFlags flags, int maxChanges) { if (this.isPagedEnumeration && !flags.HasFlag(EnumerateContentChangesFlags.FirstPage)) { this.callback.InitializeNextPage(changes, maxChanges); return; } this.callback = new ManifestContentsCallback(this.folder.GetFolderId(), this.isPagedEnumeration); this.callback.InitializeNextPage(changes, maxChanges); ManifestConfigFlags manifestConfigFlags = ManifestConfigFlags.Associated | ManifestConfigFlags.Normal | ManifestConfigFlags.OrderByDeliveryTime; if (flags.HasFlag(EnumerateContentChangesFlags.Catchup)) { manifestConfigFlags |= ManifestConfigFlags.Catchup; } Restriction restriction = ((this.mailbox.Options & MailboxOptions.IgnoreExtendedRuleFAIs) != MailboxOptions.None) ? ContentChangesFetcherUtils.ExcludeAllRulesRestriction : ContentChangesFetcherUtils.ExcludeV40RulesRestriction; using (this.mailbox.RHTracker.Start()) { this.mapiManifest = this.mapiFolder.CreateExportManifest(); } using (MemoryStream memoryStream = (syncState.Data != null) ? new MemoryStream(syncState.Data) : null) { using (this.mailbox.RHTracker.Start()) { this.mapiManifest.Configure(manifestConfigFlags, restriction, memoryStream, this.callback, new PropTag[0]); } } }
FolderChangesManifest ISourceFolder.EnumerateChanges(EnumerateContentChangesFlags flags, int maxChanges) { FolderChangesManifest folderChangesManifest = new FolderChangesManifest(base.FolderId); folderChangesManifest.ChangedMessages = new List <MessageRec>(); folderChangesManifest.ReadMessages = new List <byte[]>(); folderChangesManifest.UnreadMessages = new List <byte[]>(); SyncContentsManifestState syncContentsManifestState = base.Mailbox.SyncState[base.FolderId]; PopFolderState lastSyncedState; if (syncContentsManifestState.Data != null) { lastSyncedState = PopFolderState.Deserialize(syncContentsManifestState.Data); } else { lastSyncedState = PopFolderState.CreateNew(); } List <MessageRec> messages = base.EnumerateMessagesOnPopConnection(maxChanges); PopFolderState popFolderState = PopFolderState.Create(messages); this.EnumerateIncrementalChanges(popFolderState, lastSyncedState, folderChangesManifest, messages); syncContentsManifestState.Data = popFolderState.Serialize(); return(folderChangesManifest); }
List <MessageRec> ISourceFolder.EnumerateMessagesPaged(int maxPageSize) { if (!base.Folder.IsSelectable) { return(null); } SyncContentsManifestState syncContentsManifestState = base.Mailbox.SyncState[base.FolderId]; ImapFolderState imapFolderState = (syncContentsManifestState.Data != null) ? ImapFolderState.Deserialize(syncContentsManifestState.Data) : ImapFolderState.CreateNew(base.Folder); if (this.nextSeqNumCrawl == null) { this.nextSeqNumCrawl = new int?((imapFolderState.SeqNumCrawl == int.MaxValue) ? (base.Folder.NumberOfMessages ?? 0) : imapFolderState.SeqNumCrawl); } else { imapFolderState.SeqNumCrawl = this.nextSeqNumCrawl.Value; syncContentsManifestState.Data = imapFolderState.Serialize(); } if (this.nextSeqNumCrawl == 0) { return(null); } int num = Math.Max(1, (this.nextSeqNumCrawl - maxPageSize + 1).Value); List <MessageRec> result = base.EnumerateMessages(FetchMessagesFlags.IncludeExtendedData, new int?(this.nextSeqNumCrawl.Value), new int?(num)); this.nextSeqNumCrawl = new int?(Math.Max(0, num - 1)); return(result); }
internal EasFolderSyncState GetPersistedSyncState(SyncContentsManifestState syncBlob) { if (syncBlob.Data != null) { return(EasFolderSyncState.Deserialize(syncBlob.Data)); } return(new EasFolderSyncState { SyncKey = "0", CrawlerSyncKey = "0" }); }
List <MessageRec> ISourceFolder.EnumerateMessagesPaged(int maxPageSize) { SyncContentsManifestState syncContentsManifestState = base.Mailbox.SyncState[base.EntryId]; EasFolderSyncState persistedSyncState = base.Mailbox.GetPersistedSyncState(syncContentsManifestState); if (string.IsNullOrEmpty(this.nextEnumerateKey)) { this.nextEnumerateKey = persistedSyncState.CrawlerSyncKey; } else { persistedSyncState.CrawlerSyncKey = this.nextEnumerateKey; persistedSyncState.CrawlerDeletions.AddRange(this.pendingDeletes); syncContentsManifestState.Data = persistedSyncState.Serialize(); } EasSyncOptions options = new EasSyncOptions { SyncKey = this.nextEnumerateKey, RecentOnly = false, MaxNumberOfMessage = maxPageSize }; EasSyncResult easSyncResult = base.SyncMessages(base.Mailbox.CrawlerConnectionWrapper, options); if (this.estimatedItemCount == 0) { options.SyncKey = easSyncResult.SyncKeyRequested; this.estimatedItemCount = base.GetItemEstimate(base.Mailbox.CrawlerConnectionWrapper, options); } if (easSyncResult.MessageRecs.Count == 0) { return(null); } this.nextEnumerateKey = easSyncResult.NewSyncKey; List <MessageRec> list = new List <MessageRec>(easSyncResult.MessageRecs.Count); foreach (MessageRec messageRec in easSyncResult.MessageRecs) { if (persistedSyncState.ChangesSynced == null || !(messageRec.CreationTimestamp < persistedSyncState.ChangesSynced.Value) || !(messageRec.CreationTimestamp > persistedSyncState.ChangesSynced.Value - EasRequestGenerator.RecentSyncTimeSpan)) { if (EasSourceFolder.FindMessageCategory(messageRec) == EasMessageCategory.Delete) { this.pendingDeletes.Add(EasMailbox.GetStringId(messageRec.EntryId)); } else { list.Add(messageRec); } } } return(list); }
public SyncContentsManifestState this[byte[] folderKey] { get { SyncContentsManifestState syncContentsManifestState; if (!this.folderData.TryGetValue(folderKey, out syncContentsManifestState)) { syncContentsManifestState = new SyncContentsManifestState(); syncContentsManifestState.FolderId = folderKey; this.folderData.Add(folderKey, syncContentsManifestState); } return(syncContentsManifestState); } }
private byte[] CreateCalendarEvent(byte[] calendarEventId, byte[] folderEntryId, Event theEvent, IList <Event> exceptionalEvents, IList <string> deletedOccurrences) { SyncContentsManifestState syncContentsManifestState = this.SyncState[folderEntryId]; EasFolderSyncState persistedSyncState = base.GetPersistedSyncState(syncContentsManifestState); string newSyncKey = null; byte[] result = this.CreateItem(calendarEventId, folderEntryId, (string itemClientId, string syncKey, string serverId) => this.EasConnectionWrapper.CreateCalendarEvent(itemClientId, syncKey, out newSyncKey, serverId, theEvent, exceptionalEvents, deletedOccurrences, this.EasAuthenticationParameters.UserSmtpAddress)); if (newSyncKey != null) { persistedSyncState.SyncKey = newSyncKey; syncContentsManifestState.Data = persistedSyncState.Serialize(); } return(result); }
FolderChangesManifest ISourceFolder.EnumerateChanges(EnumerateContentChangesFlags flags, int maxChanges) { MrsTracer.Provider.Function("StorageSourceFolder.EnumerateChanges({0}, 0x{1:x}, {2})", new object[] { base.DisplayNameForTracing, (int)flags, maxChanges }); SyncContentsManifestState syncState = ((StorageSourceMailbox)base.Mailbox).SyncState[base.FolderId]; bool flag = maxChanges != 0; if (!flag || flags.HasFlag(EnumerateContentChangesFlags.FirstPage)) { this.contentChangesFetcher = new ManifestContentChangesFetcher(this, this.MapiFolder, base.Mailbox, flag); } return(this.contentChangesFetcher.EnumerateContentChanges(syncState, flags, maxChanges)); }
FolderChangesManifest IContentChangesFetcher.EnumerateContentChanges(SyncContentsManifestState syncState, EnumerateContentChangesFlags flags, int maxChanges) { FolderChangesManifest folderChangesManifest = this.EnumerateChanges(syncState, flags, maxChanges); if (MrsTracer.Provider.IsEnabled(TraceType.DebugTrace)) { int num; int num2; int num3; folderChangesManifest.GetMessageCounts(out num, out num2, out num3); MrsTracer.Provider.Debug("Discovered {0} new, {1} changed, {2} deleted, {3} read, {4} unread.", new object[] { num, num2, num3, folderChangesManifest.ReadMessages.Count, folderChangesManifest.UnreadMessages.Count }); } return(folderChangesManifest); }
private FolderChangesManifest EnumerateChanges(SyncContentsManifestState syncState, EnumerateContentChangesFlags flags, int maxChanges) { FolderChangesManifest folderChangesManifest = new FolderChangesManifest(this.folder.GetFolderId()); if (this.folder.GetFolderRec(null, GetFolderRecFlags.None).FolderType == FolderType.Search) { return(folderChangesManifest); } this.ConfigureMapiManifest(syncState, folderChangesManifest, flags, maxChanges); ManifestStatus manifestStatus; do { manifestStatus = this.mapiManifest.Synchronize(); }while (manifestStatus != ManifestStatus.Done && manifestStatus != ManifestStatus.Yielded); using (MemoryStream memoryStream = new MemoryStream()) { this.mapiManifest.GetState(memoryStream); syncState.Data = memoryStream.ToArray(); } return(folderChangesManifest); }
FolderChangesManifest ISourceFolder.EnumerateChanges(EnumerateContentChangesFlags flags, int maxChanges) { FolderChangesManifest folderChangesManifest = base.CreateInitializedChangesManifest(); SyncContentsManifestState syncContentsManifestState = base.Mailbox.SyncState[base.EntryId]; EasFolderSyncState persistedSyncState = base.Mailbox.GetPersistedSyncState(syncContentsManifestState); string syncKey = persistedSyncState.SyncKey; EasSyncOptions options = new EasSyncOptions { SyncKey = syncKey, RecentOnly = true, MaxNumberOfMessage = 512 }; EasSyncResult easSyncResult = base.SyncMessages(base.Mailbox.EasConnectionWrapper, options); List <MessageRec> messageRecs = easSyncResult.MessageRecs; this.EnumerateIncrementalChanges(folderChangesManifest, messageRecs); this.MergePendingDeletes(folderChangesManifest, persistedSyncState.CrawlerDeletions); persistedSyncState.SyncKey = easSyncResult.NewSyncKey; persistedSyncState.ChangesSynced = new DateTime?(DateTime.UtcNow); persistedSyncState.CrawlerDeletions.Clear(); syncContentsManifestState.Data = persistedSyncState.Serialize(); return(folderChangesManifest); }
List <MessageRec> ISourceFolder.EnumerateMessagesPaged(int maxPageSize) { SyncContentsManifestState syncContentsManifestState = base.Mailbox.SyncState[base.FolderId]; PopFolderState popFolderState = (syncContentsManifestState.Data != null) ? PopFolderState.Deserialize(syncContentsManifestState.Data) : PopFolderState.CreateNew(); foreach (string item in this.crawlerCopiedMessages.Values) { popFolderState.MessageList.Add(item); this.crawlerCopiedMessages.Remove(item); } syncContentsManifestState.Data = popFolderState.Serialize(); List <MessageRec> list = base.EnumerateMessagesOnPopConnection(0); List <MessageRec> list2 = new List <MessageRec>(); foreach (MessageRec messageRec in list) { string item2 = PopEntryId.ParseUid(messageRec.EntryId); if (!popFolderState.MessageList.Contains(item2)) { list2.Add(messageRec); if (list2.Count == maxPageSize) { break; } } } if (list2.Count == 0) { return(null); } foreach (MessageRec messageRec2 in list2) { string item3 = PopEntryId.ParseUid(messageRec2.EntryId); this.crawlerCopiedMessages.Add(item3); } return(list2); }
FolderChangesManifest ISourceFolder.EnumerateChanges(EnumerateContentChangesFlags flags, int maxChanges) { FolderChangesManifest folderChangesManifest = new FolderChangesManifest(base.FolderId); folderChangesManifest.ChangedMessages = new List <MessageRec>(); folderChangesManifest.ReadMessages = new List <byte[]>(); folderChangesManifest.UnreadMessages = new List <byte[]>(); if (!base.Folder.IsSelectable) { return(folderChangesManifest); } SyncContentsManifestState syncContentsManifestState = base.Mailbox.SyncState[base.FolderId]; ImapFolderState imapFolderState; if (syncContentsManifestState.Data != null) { imapFolderState = ImapFolderState.Deserialize(syncContentsManifestState.Data); if (imapFolderState.UidValidity != base.Folder.UidValidity) { syncContentsManifestState.Data = ImapFolderState.CreateNew(base.Folder).Serialize(); this.nextSeqNumCrawl = null; folderChangesManifest.FolderRecoverySync = true; return(folderChangesManifest); } } else { imapFolderState = ImapFolderState.CreateNew(base.Folder); } List <MessageRec> messages = base.EnumerateMessages(FetchMessagesFlags.None, null, null); ImapFolderState imapFolderState2 = ImapFolderState.Create(messages, imapFolderState.SeqNumCrawl, base.Folder.UidNext, base.Folder.UidValidity); this.EnumerateIncrementalChanges(imapFolderState2, imapFolderState, folderChangesManifest, messages); syncContentsManifestState.Data = imapFolderState2.Serialize(); return(folderChangesManifest); }
FolderChangesManifest IContentChangesFetcher.EnumerateContentChanges(SyncContentsManifestState syncState, EnumerateContentChangesFlags enumerateFlags, int maxChanges) { FolderChangesManifest folderChangesManifest = new FolderChangesManifest(this.folder.GetFolderId()); bool flag = enumerateFlags.HasFlag(EnumerateContentChangesFlags.Catchup); ManifestContentsCallback manifestContentsCallback = new ManifestContentsCallback(this.folder.GetFolderId(), false); manifestContentsCallback.InitializeNextPage(folderChangesManifest, maxChanges); SyncConfigFlags syncConfigFlags = SyncConfigFlags.ReadState | SyncConfigFlags.Associated | SyncConfigFlags.Normal | SyncConfigFlags.OnlySpecifiedProps; if (flag) { syncConfigFlags |= SyncConfigFlags.Catchup; } PropTag[] propsInclude = new PropTag[] { PropTag.EntryId, PropTag.MessageSize }; MapiSynchronizer mapiSynchronizer; using (this.mailbox.RHTracker.Start()) { mapiSynchronizer = this.mapiFolder.CreateContentsSynchronizer(); } using (MapiManifestCollector mapiManifestCollector = new MapiManifestCollector(this.mapiFolder, manifestContentsCallback)) { using (mapiSynchronizer) { using (MemoryStream memoryStream = new MemoryStream()) { if (syncState.Data != null) { memoryStream.Write(syncState.Data, 0, syncState.Data.Length); memoryStream.Position = 0L; } Restriction restriction = ((this.mailbox.Options & MailboxOptions.IgnoreExtendedRuleFAIs) != MailboxOptions.None) ? ContentChangesFetcherUtils.ExcludeAllRulesRestriction : ContentChangesFetcherUtils.ExcludeV40RulesRestriction; using (this.mailbox.RHTracker.Start()) { mapiSynchronizer.Config(memoryStream, syncConfigFlags, mapiManifestCollector, restriction, propsInclude, null); while (mapiSynchronizer.Synchronize() != 0) { } } syncState.Data = memoryStream.ToArray(); } } } if (!flag && MrsTracer.Provider.IsEnabled(TraceType.DebugTrace)) { int num; int num2; int num3; folderChangesManifest.GetMessageCounts(out num, out num2, out num3); MrsTracer.Provider.Debug("Discovered {0} new, {1} changed, {2} deleted, {3} read, {4} unread.", new object[] { num, num2, num3, folderChangesManifest.ReadMessages.Count, folderChangesManifest.UnreadMessages.Count }); } return(folderChangesManifest); }
List <MessageRec> IFolder.EnumerateMessages(EnumerateMessagesFlags emFlags, PropTag[] additionalPtagsToLoad) { List <MessageRec> result = new List <MessageRec>(); if (!this.Folder.IsContentAvailable) { return(result); } ContentsTableFlags[] array = new ContentsTableFlags[] { ContentsTableFlags.None, ContentsTableFlags.Associated, ContentsTableFlags.ShowSoftDeletes, ContentsTableFlags.ShowSoftDeletes | ContentsTableFlags.Associated }; ContentsTableFlags[] array2 = new ContentsTableFlags[] { ContentsTableFlags.None, ContentsTableFlags.Associated }; ContentsTableFlags[] array3 = (this.Folder.MapiStore.VersionMajor < 15) ? array : array2; for (int i = 0; i < array3.Length; i++) { ContentsTableFlags flags = ContentsTableFlags.DeferredErrors | array3[i]; bool doingFAI = (flags & ContentsTableFlags.Associated) != ContentsTableFlags.None; bool doingDeletes = (flags & ContentsTableFlags.ShowSoftDeletes) != ContentsTableFlags.None; if ((emFlags & ((!doingDeletes || 2 != 0) ? EnumerateMessagesFlags.RegularMessages : ((EnumerateMessagesFlags)0))) != (EnumerateMessagesFlags)0) { List <PropTag> pta = new List <PropTag>(5); int idxEntryId = -1; int idxCreationTime = -1; int idxMessageClass = -1; int idxRuleMsgVersion = -1; int idxMessageSize = -1; idxEntryId = pta.Count; pta.Add(PropTag.EntryId); if ((emFlags & EnumerateMessagesFlags.IncludeExtendedData) != (EnumerateMessagesFlags)0) { idxMessageSize = pta.Count; pta.Add(PropTag.MessageSize); idxCreationTime = pta.Count; pta.Add(PropTag.CreationTime); } if (doingFAI) { idxMessageClass = pta.Count; pta.Add(PropTag.MessageClass); idxRuleMsgVersion = pta.Count; pta.Add(PropTag.RuleMsgVersion); } int idxExtraPtags = pta.Count; if (additionalPtagsToLoad != null) { pta.AddRange(additionalPtagsToLoad); } MrsTracer.Provider.Debug("MapiFolder.GetContentsTable({0})", new object[] { flags }); ExecutionContext.Create(new DataContext[] { new OperationDataContext("MapiFolder.GetContentsTable", OperationType.None), new SimpleValueDataContext("Flags", flags) }).Execute(delegate { int lcidValue = (!doingFAI && this.contentsRestriction != null) ? this.contentsRestriction.LCID : 0; MapiTable contentsTable; using (this.Mailbox.RHTracker.Start()) { contentsTable = this.Folder.GetContentsTable(flags); } using (contentsTable) { using (new SortLCIDContext(this.Folder.MapiStore, lcidValue)) { Restriction restriction = null; if (!doingFAI && this.contentsRestriction != null) { restriction = DataConverter <RestrictionConverter, Restriction, RestrictionData> .GetNative(this.contentsRestriction); } MapiUtils.InitQueryAllRows(contentsTable, restriction, pta); for (;;) { PropValue[][] array4; using (this.Mailbox.RHTracker.Start()) { array4 = contentsTable.QueryRows(1000); } if (array4.GetLength(0) == 0) { break; } MrsTracer.Provider.Debug("QueryRows returned {0} items.", new object[] { array4.Length }); PropValue[][] array5 = array4; int j = 0; while (j < array5.Length) { PropValue[] array6 = array5[j]; if (!doingFAI) { goto IL_1F9; } string @string = array6[idxMessageClass].GetString(); if ((this.Mailbox.Options & MailboxOptions.IgnoreExtendedRuleFAIs) != MailboxOptions.None) { if (!StringComparer.OrdinalIgnoreCase.Equals(@string, "IPM.Rule.Message") && !StringComparer.OrdinalIgnoreCase.Equals(@string, "IPM.Rule.Version2.Message")) { if (!StringComparer.OrdinalIgnoreCase.Equals(@string, "IPM.ExtendedRule.Message")) { goto IL_1F9; } } } else if (!StringComparer.OrdinalIgnoreCase.Equals(@string, "IPM.Rule.Message") || array6[idxRuleMsgVersion].GetInt(0) != 1) { goto IL_1F9; } IL_423: j++; continue; IL_1F9: DateTime dateTime = (idxCreationTime != -1) ? MapiUtils.GetDateTimeOrDefault(array6[idxCreationTime]) : DateTime.MinValue; byte[] bytes = array6[idxEntryId].GetBytes(); if (emFlags.HasFlag(EnumerateMessagesFlags.SkipICSMidSetMissing) && bytes != null && this.Mailbox.SupportsSavingSyncState) { SyncContentsManifestState syncContentsManifestState = this.Mailbox.SyncState[this.FolderId]; if (syncContentsManifestState != null && !syncContentsManifestState.IdSetGivenContainsEntryId(bytes)) { MrsTracer.Provider.Debug("entry id {0} with creation time {1} not found in given items.", new object[] { TraceUtils.DumpEntryId(bytes), dateTime }); goto IL_423; } } List <PropValueData> list = null; if (additionalPtagsToLoad != null && additionalPtagsToLoad.Length > 0) { list = new List <PropValueData>(); for (int k = idxExtraPtags; k < array6.Length; k++) { list.Add(DataConverter <PropValueConverter, PropValue, PropValueData> .GetData(array6[k])); } } if ((emFlags & EnumerateMessagesFlags.ReturnLongTermIDs) == EnumerateMessagesFlags.ReturnLongTermIDs && bytes != null) { if (list == null) { list = new List <PropValueData>(); } list.Add(new PropValueData(PropTag.LTID, this.Mailbox.MapiStore.GlobalIdFromId(this.Mailbox.MapiStore.GetMidFromMessageEntryId(bytes)))); } MsgRecFlags msgRecFlags = doingFAI ? MsgRecFlags.Associated : MsgRecFlags.None; if (doingDeletes) { msgRecFlags |= MsgRecFlags.Deleted; } MessageRec item = new MessageRec(bytes, this.FolderId, dateTime, (idxMessageSize != -1) ? array6[idxMessageSize].GetInt(1000) : 1000, msgRecFlags, (list == null) ? null : list.ToArray()); result.Add(item); goto IL_423; } } } } }); } } MrsTracer.Provider.Debug("MapiFolder.EnumerateMessages returns {0} items.", new object[] { result.Count }); return(result); }
List <MessageRec> IFolder.EnumerateMessages(EnumerateMessagesFlags emFlags, PropTag[] additionalPtagsToLoad) { MrsTracer.Provider.Function("StorageFolder.EnumerateMessages: {0}", new object[] { this.DisplayNameForTracing }); List <MessageRec> result = new List <MessageRec>(); ItemQueryType[] array = new ItemQueryType[] { ItemQueryType.None, ItemQueryType.Associated }; for (int i = 0; i < array.Length; i++) { ItemQueryType flags = array[i]; bool doingFAI = (flags & ItemQueryType.Associated) != ItemQueryType.None; bool doingDeletes = (flags & ItemQueryType.SoftDeleted) != ItemQueryType.None; if ((emFlags & ((!doingDeletes || 2 != 0) ? EnumerateMessagesFlags.RegularMessages : ((EnumerateMessagesFlags)0))) != (EnumerateMessagesFlags)0) { List <NativeStorePropertyDefinition> dataColumns = new List <NativeStorePropertyDefinition>(5); int idxEntryId = -1; int idxCreationTime = -1; int idxMessageClass = -1; int idxRuleMsgVersion = -1; int idxMessageSize = -1; idxEntryId = dataColumns.Count; dataColumns.Add(this.Mailbox.ConvertPropTagsToDefinitions(new PropTag[] { PropTag.EntryId })[0]); if ((emFlags & EnumerateMessagesFlags.IncludeExtendedData) != (EnumerateMessagesFlags)0) { idxMessageSize = dataColumns.Count; dataColumns.Add(this.Mailbox.ConvertPropTagsToDefinitions(new PropTag[] { PropTag.MessageSize })[0]); idxCreationTime = dataColumns.Count; dataColumns.Add(this.Mailbox.ConvertPropTagsToDefinitions(new PropTag[] { PropTag.CreationTime })[0]); } if (doingFAI) { idxMessageClass = dataColumns.Count; dataColumns.Add(this.Mailbox.ConvertPropTagsToDefinitions(new PropTag[] { PropTag.MessageClass })[0]); idxRuleMsgVersion = dataColumns.Count; dataColumns.Add(this.Mailbox.ConvertPropTagsToDefinitions(new PropTag[] { PropTag.RuleMsgVersion })[0]); } int idxExtraPtags = dataColumns.Count; if (additionalPtagsToLoad != null) { dataColumns.AddRange(this.Mailbox.ConvertPropTagsToDefinitions(additionalPtagsToLoad)); } MrsTracer.Provider.Debug("StorageFolder.GetContentsTable({0})", new object[] { flags }); ExecutionContext.Create(new DataContext[] { new OperationDataContext("StorageFolder.EnumerateMessages", OperationType.None), new SimpleValueDataContext("Flags", flags) }).Execute(delegate { QueryFilter queryFilter = null; if (this.contentsRestriction != null) { queryFilter = this.contentsRestriction.GetQueryFilter(this.Mailbox.StoreSession); } using (QueryResult queryResult = this.CoreFolder.QueryExecutor.ItemQuery(flags, queryFilter, null, dataColumns.ToArray())) { MrsTracer.Provider.Debug("StorageFolder.EnumerateMessages: ItemQuery returned {0} items.", new object[] { queryResult.EstimatedRowCount }); object[][] rows; do { using (this.Mailbox.RHTracker.Start()) { rows = queryResult.GetRows(1000); } object[][] array2 = rows; int j = 0; while (j < array2.Length) { object[] array3 = array2[j]; if (!doingFAI) { goto IL_197; } string x = (string)array3[idxMessageClass]; if ((this.Mailbox.Options & MailboxOptions.IgnoreExtendedRuleFAIs) != MailboxOptions.None) { if (!StringComparer.OrdinalIgnoreCase.Equals(x, "IPM.Rule.Message") && !StringComparer.OrdinalIgnoreCase.Equals(x, "IPM.Rule.Version2.Message")) { if (!StringComparer.OrdinalIgnoreCase.Equals(x, "IPM.ExtendedRule.Message")) { goto IL_197; } } } else if (!StringComparer.OrdinalIgnoreCase.Equals(x, "IPM.Rule.Message") || !(array3[idxRuleMsgVersion] as short? == 1)) { goto IL_197; } IL_3E6: j++; continue; IL_197: DateTime dateTime = DateTime.MinValue; if (idxCreationTime != -1) { object obj = array3[idxCreationTime]; if (obj is ExDateTime) { dateTime = (DateTime)((ExDateTime)obj); } } byte[] entryId = (byte[])array3[idxEntryId]; if (emFlags.HasFlag(EnumerateMessagesFlags.SkipICSMidSetMissing) && this.Mailbox.SupportsSavingSyncState) { SyncContentsManifestState syncContentsManifestState = this.Mailbox.SyncState[this.FolderId]; if (syncContentsManifestState != null && !syncContentsManifestState.IdSetGivenContainsEntryId(entryId)) { MrsTracer.Provider.Debug("entry id {0} with creation time {1} not found in given items.", new object[] { TraceUtils.DumpEntryId(entryId), dateTime }); goto IL_3E6; } } List <PropValueData> list = null; if (additionalPtagsToLoad != null && additionalPtagsToLoad.Length > 0) { list = new List <PropValueData>(); for (int k = idxExtraPtags; k < array3.Length; k++) { list.Add(new PropValueData(additionalPtagsToLoad[k - idxExtraPtags], array3[k])); } } int messageSize = 1000; if (idxMessageSize != -1) { object obj2 = array3[idxMessageSize]; if (obj2 is int) { messageSize = (int)obj2; } } if (emFlags.HasFlag(EnumerateMessagesFlags.ReturnLongTermIDs)) { if (list == null) { list = new List <PropValueData>(); } list.Add(new PropValueData(PropTag.LTID, this.Mailbox.StoreSession.IdConverter.GetLongTermIdFromId(this.Mailbox.StoreSession.IdConverter.GetMidFromMessageId(StoreObjectId.FromProviderSpecificId(entryId))))); } MsgRecFlags msgRecFlags = doingFAI ? MsgRecFlags.Associated : MsgRecFlags.None; if (doingDeletes) { msgRecFlags |= MsgRecFlags.Deleted; } MessageRec item = new MessageRec(entryId, this.FolderId, dateTime, messageSize, msgRecFlags, (list == null) ? null : list.ToArray()); result.Add(item); goto IL_3E6; } }while (rows.Length > 0); } }); } } MrsTracer.Provider.Debug("StorageFolder.EnumerateMessages returns {0} items.", new object[] { result.Count }); return(result); }