Пример #1
0
 public static ObjectId RedactFolderId(ObjectId folderId, out string raw, out string redacted)
 {
     raw      = null;
     redacted = null;
     if (folderId is MailboxFolderId)
     {
         MailboxFolderId mailboxFolderId = (MailboxFolderId)folderId;
         folderId = new MailboxFolderId(SuppressingPiiData.Redact(mailboxFolderId.MailboxOwnerId, out raw, out redacted), mailboxFolderId.StoreObjectIdValue, mailboxFolderId.MailboxFolderPath);
     }
     if (folderId is Microsoft.Exchange.Data.Storage.Management.PublicFolderId)
     {
         Microsoft.Exchange.Data.Storage.Management.PublicFolderId publicFolderId = (Microsoft.Exchange.Data.Storage.Management.PublicFolderId)folderId;
         folderId = new Microsoft.Exchange.Data.Storage.Management.PublicFolderId(publicFolderId.OrganizationId, publicFolderId.StoreObjectId, SuppressingPiiData.Redact(publicFolderId.MapiFolderPath, out raw, out redacted));
     }
     return(folderId);
 }
        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;
        }