private byte[] CreateAssociatedDumpsterFolder(string sourceFolderName, byte[] replicaListValue, byte[] destinationFolderEntryId) { FolderHierarchy folderHierarchy = base.DestMailboxWrapper.FolderMap as FolderHierarchy; FolderRec folderRec = new FolderRec(); folderRec.ParentId = folderHierarchy.GetWellKnownFolder(WellKnownFolderType.PublicFolderDumpsterRoot).EntryId; folderRec.FolderName = PublicFolderCOWSession.GenerateUniqueFolderName(sourceFolderName); folderRec.FolderType = FolderType.Generic; byte[] array; base.DestMailbox.CreateFolder(folderRec, CreateFolderFlags.FailIfExists, out array); using (IDestinationFolder folder = base.DestMailbox.GetFolder(array)) { folder.SetProps(new PropValueData[] { new PropValueData(PropTag.ReplicaList, replicaListValue), new PropValueData(PropTag.IpmWasteBasketEntryId, destinationFolderEntryId), new PropValueData(PropTag.TimeInServer, 64) }); } return(array); }
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; }
public IEnumerable <T> FindPaged <T>(QueryFilter filter, ObjectId rootId, bool deepSearch, SortBy sortBy, int pageSize) where T : IConfigurable, new() { base.CheckDisposed(); if (!typeof(PublicFolderStatistics).GetTypeInfo().IsAssignableFrom(typeof(T).GetTypeInfo())) { throw new NotSupportedException("FindPaged: " + typeof(T).FullName); } IEnumerable <PublicFolder> publicFolders = this.publicFolderDataProvider.FindPaged <PublicFolder>(filter, rootId, deepSearch, sortBy, pageSize); foreach (PublicFolder publicFolder in publicFolders) { PublicFolderSession contentSession = null; if (this.mailboxGuid == Guid.Empty) { contentSession = this.PublicFolderDataProvider.PublicFolderSessionCache.GetPublicFolderSession(publicFolder.InternalFolderIdentity.ObjectId); } else { contentSession = this.PublicFolderDataProvider.PublicFolderSessionCache.GetPublicFolderSession(this.mailboxGuid); } using (Folder contentFolder = Folder.Bind(contentSession, publicFolder.InternalFolderIdentity, PublicFolderStatisticsDataProvider.contentFolderProperties)) { PublicFolderStatistics publicFolderStatistics = new PublicFolderStatistics(); publicFolderStatistics.LoadDataFromXso(contentSession.MailboxPrincipal.ObjectId, contentFolder); uint ownerCount = 0U; uint contactCount = 0U; PermissionSet folderPermissionSet = contentFolder.GetPermissionSet(); foreach (Permission permission in folderPermissionSet) { if (permission.IsFolderContact) { contactCount += 1U; } if (permission.IsFolderOwner) { ownerCount += 1U; } } publicFolderStatistics.OwnerCount = ownerCount; publicFolderStatistics.ContactCount = contactCount; StoreObjectId dumpsterId = PublicFolderCOWSession.GetRecoverableItemsDeletionsFolderId((CoreFolder)contentFolder.CoreObject); checked { if (dumpsterId != null) { try { using (CoreFolder coreFolder = CoreFolder.Bind(contentSession, dumpsterId, PublicFolderStatisticsDataProvider.dumpsterProperties)) { publicFolderStatistics.DeletedItemCount = (uint)((int)coreFolder.PropertyBag[FolderSchema.ItemCount]); publicFolderStatistics.TotalDeletedItemSize = ByteQuantifiedSize.FromBytes((ulong)((long)coreFolder.PropertyBag[FolderSchema.ExtendedSize])); } } catch (ObjectNotFoundException) { } } yield return((T)((object)publicFolderStatistics)); } } } yield break; }