// Token: 0x06000464 RID: 1124 RVA: 0x0001F97C File Offset: 0x0001DB7C internal static Dictionary <StoreObjectId, FolderTuple> QueryFolderHierarchy(MailboxSession mailboxSession) { Dictionary <StoreObjectId, FolderTuple> dictionary = new Dictionary <StoreObjectId, FolderTuple>(); if (mailboxSession == null) { return(dictionary); } FolderHelper.Tracer.TraceDebug <IExchangePrincipal, bool>((long)mailboxSession.GetHashCode(), "{0}: QueryFolderHierarchy: Archive mailbox: {1}.", mailboxSession.MailboxOwner, mailboxSession.MailboxOwner.MailboxInfo.IsArchive); StoreObjectId defaultFolderId = mailboxSession.GetDefaultFolderId(DefaultFolderType.Root); dictionary[defaultFolderId] = new FolderTuple(defaultFolderId, defaultFolderId, string.Empty, new object[10], true); using (Folder folder = Folder.Bind(mailboxSession, defaultFolderId)) { using (QueryResult queryResult = folder.FolderQuery(FolderQueryFlags.DeepTraversal, null, null, FolderHelper.DataColumns)) { for (;;) { object[][] rows = queryResult.GetRows(100); if (rows.Length <= 0) { break; } for (int i = 0; i < rows.Length; i++) { if (rows[i][0] is VersionedId && rows[i][1] is StoreObjectId) { StoreObjectId objectId = (rows[i][0] as VersionedId).ObjectId; StoreObjectId storeObjectId = rows[i][1] as StoreObjectId; dictionary[objectId] = new FolderTuple(objectId, storeObjectId, (string)rows[i][2], rows[i]); FolderHelper.Tracer.TraceDebug((long)mailboxSession.GetHashCode(), "{0}: QueryFolderHierarchy: Added folder '{1}' to the folderMap. FolderId: '{2}'. ParentId: '{3}'.", new object[] { mailboxSession.MailboxOwner, (string)rows[i][2], objectId.ToHexEntryId(), storeObjectId.ToHexEntryId() }); } } } } } return(dictionary); }
protected override IEnumerable <T> InternalFindPaged <T>(QueryFilter filter, ObjectId rootId, bool deepSearch, SortBy sortBy, int pageSize) { if (sortBy != null) { throw new NotSupportedException("sortBy"); } if (rootId != null && !(rootId is PublicFolderId)) { throw new NotSupportedException("rootId: " + rootId.GetType().FullName); } if (!typeof(PublicFolder).GetTypeInfo().IsAssignableFrom(typeof(T).GetTypeInfo())) { throw new NotSupportedException("FindPaged: " + typeof(T).FullName); } if (filter == null) { filter = PublicFolderDataProvider.nonHiddenFilter; } else { filter = new AndFilter(new QueryFilter[] { filter, PublicFolderDataProvider.nonHiddenFilter }); } Dictionary <StoreObjectId, MapiFolderPath> knownFolderPathsCache = new Dictionary <StoreObjectId, MapiFolderPath>(); knownFolderPathsCache.Add(this.PublicFolderSession.GetPublicFolderRootId(), MapiFolderPath.IpmSubtreeRoot); knownFolderPathsCache.Add(this.PublicFolderSession.GetIpmSubtreeFolderId(), MapiFolderPath.IpmSubtreeRoot); knownFolderPathsCache.Add(this.PublicFolderSession.GetNonIpmSubtreeFolderId(), MapiFolderPath.NonIpmSubtreeRoot); StoreObjectId xsoRootIdentity; MapiFolderPath xsoRootFolderPath; if (rootId == null) { xsoRootIdentity = this.PublicFolderSession.GetIpmSubtreeFolderId(); xsoRootFolderPath = MapiFolderPath.IpmSubtreeRoot; } else { PublicFolderId publicFolderId = (PublicFolderId)rootId; if (publicFolderId.StoreObjectId == null) { StoreObjectId storeObjectId = this.ResolveStoreObjectIdFromFolderPath(publicFolderId.MapiFolderPath); if (storeObjectId == null) { yield break; } xsoRootIdentity = storeObjectId; } else { xsoRootIdentity = publicFolderId.StoreObjectId; } xsoRootFolderPath = publicFolderId.MapiFolderPath; } PublicFolder rootFolder = new PublicFolder(); PropertyDefinition[] xsoProperties = rootFolder.Schema.AllDependentXsoProperties; Folder xsoFolder = Folder.Bind(this.PublicFolderSession, xsoRootIdentity, xsoProperties); rootFolder.LoadDataFromXso(this.PublicFolderSession.MailboxPrincipal.ObjectId, xsoFolder); rootFolder.SetDefaultFolderType(DefaultFolderType.None); rootFolder.OrganizationId = this.PublicFolderSession.OrganizationId; StoreObjectId receoverableItemsDeletionFolderId = PublicFolderCOWSession.GetRecoverableItemsDeletionsFolderId(xsoFolder); rootFolder.DumpsterEntryId = ((receoverableItemsDeletionFolderId != null) ? receoverableItemsDeletionFolderId.ToHexEntryId() : null); if (null == xsoRootFolderPath) { xsoRootFolderPath = MailboxFolderDataProvider.CalculateMailboxFolderPath(this.PublicFolderSession, rootFolder.InternalFolderIdentity.ObjectId, rootFolder.InternalParentFolderIdentity, rootFolder.Name, knownFolderPathsCache); } else if (!knownFolderPathsCache.ContainsKey(rootFolder.InternalFolderIdentity.ObjectId)) { knownFolderPathsCache.Add(rootFolder.InternalFolderIdentity.ObjectId, xsoRootFolderPath); } rootFolder.FolderPath = xsoRootFolderPath; if (deepSearch) { yield return((T)((object)rootFolder)); } QueryResult queryResults = xsoFolder.FolderQuery(deepSearch ? FolderQueryFlags.DeepTraversal : FolderQueryFlags.None, filter, null, new PropertyDefinition[] { FolderSchema.Id }); for (;;) { object[][] folderRows = queryResults.GetRows((pageSize == 0) ? 1000 : pageSize); if (folderRows.Length <= 0) { break; } foreach (object[] row in folderRows) { PublicFolder onePublicFolder = new PublicFolder(); using (Folder oneXsoFolder = Folder.Bind(this.PublicFolderSession, ((VersionedId)row[0]).ObjectId, xsoProperties)) { onePublicFolder.LoadDataFromXso(this.PublicFolderSession.MailboxPrincipal.ObjectId, oneXsoFolder); onePublicFolder.SetDefaultFolderType(DefaultFolderType.None); onePublicFolder.OrganizationId = this.PublicFolderSession.OrganizationId; receoverableItemsDeletionFolderId = PublicFolderCOWSession.GetRecoverableItemsDeletionsFolderId(oneXsoFolder); onePublicFolder.DumpsterEntryId = ((receoverableItemsDeletionFolderId != null) ? receoverableItemsDeletionFolderId.ToHexEntryId() : null); onePublicFolder.FolderPath = MailboxFolderDataProvider.CalculateMailboxFolderPath(this.PublicFolderSession, onePublicFolder.InternalFolderIdentity.ObjectId, onePublicFolder.InternalParentFolderIdentity, onePublicFolder.Name, knownFolderPathsCache); yield return((T)((object)onePublicFolder)); } } } yield break; }
// Token: 0x06000602 RID: 1538 RVA: 0x0002DDFC File Offset: 0x0002BFFC private bool CollectItemsInFolder(DefaultFolderType folderToCollect) { HoldCleanupEnforcer.Tracer.TraceDebug <HoldCleanupEnforcer, DefaultFolderType>((long)this.GetHashCode(), "{0}: CollectItemsInFolder: folderToCollect={1}.", this, folderToCollect); StoreObjectId defaultFolderId = base.MailboxDataForTags.MailboxSession.GetDefaultFolderId(folderToCollect); if (defaultFolderId == null) { HoldCleanupEnforcer.Tracer.TraceDebug <HoldCleanupEnforcer, DefaultFolderType>((long)this.GetHashCode(), "{0}: {1} folder is null", this, folderToCollect); return(true); } using (Folder folder = Folder.Bind(base.MailboxDataForTags.MailboxSession, defaultFolderId)) { int num = base.FolderItemTypeCount(folder, ItemQueryType.None); if (num <= 0) { HoldCleanupEnforcer.Tracer.TraceDebug <HoldCleanupEnforcer, DefaultFolderType, string>((long)this.GetHashCode(), "{0}: {1} [{2}] folder is empty", this, folderToCollect, defaultFolderId.ToHexEntryId()); return(true); } QueryFilter queryFilter = null; if (base.MailboxDataForTags.HoldCleanupFolderType == folderToCollect && !string.IsNullOrEmpty(base.MailboxDataForTags.HoldCleanupInternetMessageId)) { queryFilter = new ComparisonFilter(ComparisonOperator.GreaterThanOrEqual, ItemSchema.InternetMessageId, base.MailboxDataForTags.HoldCleanupInternetMessageId); } else { this.SetWatermark(folderToCollect, string.Empty); } base.SysCleanupSubAssistant.ThrottleStoreCall(); using (QueryResult queryResult = folder.ItemQuery(ItemQueryType.None, null, HoldCleanupEnforcer.Sort, HoldCleanupEnforcer.PropertyColumns)) { StoreId storeId = null; string text = null; Item item = null; bool flag = false; ICollection <PropertyDefinition> collection = null; try { if (queryFilter != null) { queryResult.SeekToCondition(SeekReference.OriginBeginning, queryFilter); } object[][] rows; while ((rows = queryResult.GetRows(100)).Length > 0) { foreach (object[] array2 in rows) { VersionedId value = array2.GetValue(HoldCleanupEnforcer.PropertyIndex.ItemId); string text2 = (array2[3] is string) ? array2.GetValue(HoldCleanupEnforcer.PropertyIndex.ItemClass) : null; string text3 = (array2[2] is string) ? array2.GetValue(HoldCleanupEnforcer.PropertyIndex.InternetMessageId) : null; int value2 = array2.GetValue(HoldCleanupEnforcer.PropertyIndex.Size); if (string.IsNullOrEmpty(text3)) { HoldCleanupEnforcer.Tracer.TraceDebug <HoldCleanupEnforcer, VersionedId, string>((long)this.GetHashCode(), "{0}: Skipping item {1} of class {2} due to missing InternetMessageId", this, value, text2); base.MailboxDataForTags.StatisticsLogEntry.NumberOfItemsSkippedByHoldCleanupEnforcer += 1L; } else { if (text3 == text) { if (collection == null) { if (string.IsNullOrEmpty(text2)) { HoldCleanupEnforcer.Tracer.TraceDebug <HoldCleanupEnforcer, VersionedId>((long)this.GetHashCode(), "{0}: Skipping item {1} due to missing ItemClass", this, value); base.MailboxDataForTags.StatisticsLogEntry.NumberOfItemsSkippedByHoldCleanupEnforcer += 1L; goto IL_349; } collection = this.GetLegalTrackingProperties(text2); } base.SysCleanupSubAssistant.ThrottleStoreCall(); if (item == null) { item = Item.Bind(base.MailboxDataForTags.MailboxSession, storeId, collection); } using (Item item2 = Item.Bind(base.MailboxDataForTags.MailboxSession, value, collection)) { if (this.AreItemsLegallyEqual(collection, item, item2)) { HoldCleanupEnforcer.Tracer.TraceInformation(49376, (long)this.GetHashCode(), "{0}: Item {1} of class {2} is a duplicate of {3}, it will be deleted.", new object[] { this, value, text2, storeId }); base.MailboxDataForTags.StatisticsLogEntry.NumberOfItemsDeterminedDuplicateByHoldCleanupEnforcer += 1L; base.MailboxDataForTags.StatisticsLogEntry.SizeOfItemsDeterminedDuplicateByHoldCleanupEnforcer += (long)value2; if (!this.logOnly) { base.TagExpirationExecutor.AddToDoomedHardDeleteList(new ItemData(value, value2), true); } } else { storeId = value; item.Dispose(); item = null; } goto IL_330; } goto IL_310; } goto IL_310; IL_330: base.MailboxDataForTags.StatisticsLogEntry.NumberOfItemsAnalyzedByHoldCleanupEnforcer += 1L; goto IL_349; IL_310: text = text3; storeId = value; flag = true; if (item != null) { item.Dispose(); item = null; } if (collection != null) { collection = null; goto IL_330; } goto IL_330; } IL_349 :; } if (!base.MailboxDataForTags.StatisticsLogEntry.IsOnDemandJob && base.MailboxDataForTags.StatisticsLogEntry.NumberOfItemsAnalyzedByHoldCleanupEnforcer >= (long)this.batchSizeForELC) { this.SetWatermark(folderToCollect, text); return(false); } if (flag && !string.IsNullOrEmpty(text)) { this.SetWatermark(folderToCollect, text); flag = false; } } } finally { if (item != null) { item.Dispose(); } } } } return(true); }
private bool TryFetchFavoritePublicFolder(object[] row, int folderTreeDataSectionValue, out IFavoritePublicFolder favoritePublicFolder, out bool shouldContinue) { favoritePublicFolder = null; shouldContinue = true; StoreId storeId = FavoritePublicFoldersManager.InternalGetItemPropertyOrDefault <StoreId>(row, null, FavoritePublicFoldersManager.FavoriteFolderEntryPropertyIndex.Id); if (storeId == null) { FavoritePublicFoldersManager.Tracer.TraceError((long)this.GetHashCode(), "TryFetchFavoritePublicFolder: detected item with null id"); return(false); } FavoritePublicFoldersManager.Tracer.TraceDebug <string>((long)this.GetHashCode(), "TryFetchFavoritePublicFolder: processing item '{0}'", storeId.ToBase64String()); string text = FavoritePublicFoldersManager.InternalGetItemPropertyOrDefault <string>(row, string.Empty, FavoritePublicFoldersManager.FavoriteFolderEntryPropertyIndex.ItemClass); if (!ObjectClass.IsFolderTreeData(text)) { shouldContinue = false; FavoritePublicFoldersManager.Tracer.TraceDebug <string>((long)this.GetHashCode(), "TryFetchFavoritePublicFolder: not the expected item class '{0}', stopping enumeration", text); return(false); } int num = FavoritePublicFoldersManager.InternalGetItemPropertyOrDefault <int>(row, -1, FavoritePublicFoldersManager.FavoriteFolderEntryPropertyIndex.GroupSection); if (folderTreeDataSectionValue != num) { FavoritePublicFoldersManager.Tracer.TraceDebug <int, int>((long)this.GetHashCode(), "TryFetchFavoritePublicFolder: not the expected group section (expected '{0}', actual '{1}'), skipping", folderTreeDataSectionValue, num); return(false); } int num2 = FavoritePublicFoldersManager.InternalGetItemPropertyOrDefault <int>(row, -1, FavoritePublicFoldersManager.FavoriteFolderEntryPropertyIndex.Type); if (num2 != 0 && num2 != 2 && num2 != 1) { FavoritePublicFoldersManager.Tracer.TraceDebug <int>((long)this.GetHashCode(), "TryFetchFavoritePublicFolder: not the expected folder type '{0}', skipping", num2); return(false); } byte[] array = FavoritePublicFoldersManager.InternalGetItemPropertyOrDefault <byte[]>(row, null, FavoritePublicFoldersManager.FavoriteFolderEntryPropertyIndex.NodeEntryId); if (array == null) { FavoritePublicFoldersManager.Tracer.TraceError((long)this.GetHashCode(), "TryFetchFavoritePublicFolder: folderEntryId was null"); return(false); } StoreObjectId storeObjectId = null; try { storeObjectId = StoreObjectId.FromProviderSpecificId(array); if (!storeObjectId.IsPublicFolderType()) { FavoritePublicFoldersManager.Tracer.TraceDebug <string>((long)this.GetHashCode(), "TryFetchFavoritePublicFolder: folderStoreObjectId is not of the expected type (actual '{0}'), skipping", (storeObjectId == null) ? "null" : storeObjectId.ToHexEntryId()); return(false); } storeObjectId = StoreObjectId.FromLegacyFavoritePublicFolderId(storeObjectId); } catch (CorruptDataException arg) { FavoritePublicFoldersManager.Tracer.TraceError <CorruptDataException, string>((long)this.GetHashCode(), "GetFavorites: Exception {0} encountered trying to retrieve navigation node entry ID for folder entry id {1}", arg, (array == null) ? "null" : Convert.ToBase64String(array)); return(false); } string displayName = FavoritePublicFoldersManager.InternalGetItemPropertyOrDefault <string>(row, string.Empty, FavoritePublicFoldersManager.FavoriteFolderEntryPropertyIndex.Subject); favoritePublicFolder = new FavoritePublicFolder(storeObjectId, displayName); return(true); }