示例#1
0
        public static void DeleteWorkingSetPartition(MailboxSession mailboxSession, string workingSetSourcePartitionInternal)
        {
            StoreObjectId storeObjectId = WorkingSetUtils.FindWorkingSetPartitionFolder(mailboxSession, workingSetSourcePartitionInternal);

            if (storeObjectId != null)
            {
                using (Folder folder = WorkingSetUtils.SafeBindToWorkingSetFolder(mailboxSession))
                {
                    AggregateOperationResult aggregateOperationResult = folder.DeleteObjects(DeleteItemFlags.HardDelete, new StoreId[]
                    {
                        storeObjectId
                    });
                    if (aggregateOperationResult.OperationResult != OperationResult.Succeeded)
                    {
                        throw new ObjectNotFoundException(new LocalizedString(string.Format("Delete partition failed, partition {0} is not found", workingSetSourcePartitionInternal)));
                    }
                    WorkingSet.PartitionsDeleted.Increment();
                    return;
                }
            }
            throw new ObjectNotFoundException(new LocalizedString(string.Format("Delete partition failed, partition {0} is not found", workingSetSourcePartitionInternal)));
        }
示例#2
0
        internal static StoreObjectId GetWorkingSetPartitionFolderId(MailboxSession mailboxSession, string workingSetSourcePartition, string workingSetSourcePartitionInternal)
        {
            StoreObjectId result;

            using (Folder folder = WorkingSetUtils.SafeBindToWorkingSetFolder(mailboxSession))
            {
                StoreObjectId storeObjectId = WorkingSetUtils.FindWorkingSetPartitionFolder(mailboxSession, workingSetSourcePartitionInternal);
                if (storeObjectId == null)
                {
                    using (Folder folder2 = Folder.Create(mailboxSession, folder.StoreObjectId, StoreObjectType.Folder, workingSetSourcePartition, CreateMode.CreateNew))
                    {
                        folder2[FolderSchema.WorkingSetSourcePartitionInternal] = workingSetSourcePartitionInternal;
                        folder2.Save();
                        folder2.Load();
                        storeObjectId = folder2.StoreObjectId;
                        WorkingSet.PartitionsCreated.Increment();
                    }
                }
                result = storeObjectId;
            }
            return(result);
        }