private void ExecuteSyncStateOperation(Action <StoreSession, CoreFolder> operation) { using (base.RHTracker.Start()) { if (base.IsPublicFolderMove || base.IsPublicFolderMailboxRestore) { PublicFolderSession publicFolderSession = this.GetPublicFolderSession(); using (CoreFolder coreFolder = CoreFolder.Bind(publicFolderSession, publicFolderSession.GetTombstonesRootFolderId())) { operation(publicFolderSession, coreFolder); goto IL_A9; } } MailboxSession mailboxSession = null; bool flag = false; try { if (base.UseHomeMDB) { mailboxSession = this.GetMailboxSession(); } else { mailboxSession = this.OpenSystemMailbox(); flag = true; } using (CoreFolder coreFolder2 = CoreFolder.Create(mailboxSession, mailboxSession.GetDefaultFolderId(DefaultFolderType.Configuration), false, "MailboxReplicationService SyncStates", CreateMode.OpenIfExists)) { coreFolder2.Save(SaveMode.FailOnAnyConflict); operation(mailboxSession, coreFolder2); } } finally { if (flag && mailboxSession != null) { mailboxSession.Dispose(); } } IL_A9 :; } }
void IDestinationMailbox.CreateFolder(FolderRec sourceFolder, CreateFolderFlags createFolderFlags, out byte[] newFolderId) { MrsTracer.Provider.Function("StorageDestinationMailbox.CreateFolder(\"{0}\")", new object[] { sourceFolder.FolderName }); base.VerifyMailboxConnection(VerifyMailboxConnectionFlags.None); FolderRec folderRec = null; newFolderId = null; bool isSearchFolder = sourceFolder.FolderType == FolderType.Search; string text = sourceFolder.FolderName; if (string.IsNullOrWhiteSpace(text)) { text = Guid.NewGuid().ToString(); } using (base.RHTracker.Start()) { if (sourceFolder.EntryId != null) { using (StorageDestinationFolder folder = base.GetFolder <StorageDestinationFolder>(sourceFolder.EntryId)) { if (folder != null) { MrsTracer.Provider.Debug("Source folder '{0}' already exists in destination.", new object[] { sourceFolder.FolderName }); if (createFolderFlags.HasFlag(CreateFolderFlags.FailIfExists)) { throw new FolderAlreadyExistsException(sourceFolder.FolderName); } folderRec = ((IFolder)folder).GetFolderRec(null, GetFolderRecFlags.None); newFolderId = folderRec.EntryId; } } } if (newFolderId == null) { CreateMode createMode = CreateMode.OverrideFolderCreationBlock; if (createFolderFlags.HasFlag(CreateFolderFlags.CreatePublicFolderDumpster)) { createMode |= CreateMode.CreatePublicFolderDumpster; } using (CoreFolder coreFolder = createFolderFlags.HasFlag(CreateFolderFlags.InternalAccess) ? CoreFolder.CreateSecure(base.StoreSession, base.GetFolderId(sourceFolder.ParentId), isSearchFolder, text, createMode) : CoreFolder.Create(base.StoreSession, base.GetFolderId(sourceFolder.ParentId), isSearchFolder, text, createMode)) { if (sourceFolder.EntryId != null) { coreFolder.PropertyBag[StoreObjectSchema.EntryId] = sourceFolder.EntryId; } string value; if (!string.IsNullOrEmpty(sourceFolder.FolderClass) && StorageDestinationMailbox.folderClassMap.TryGetValue(sourceFolder.FolderClass, out value)) { coreFolder.PropertyBag[StoreObjectSchema.ContainerClass] = value; } coreFolder.Save(SaveMode.FailOnAnyConflict); coreFolder.PropertyBag.Load(FolderSchema.Instance.AutoloadProperties); newFolderId = coreFolder.Id.ObjectId.ProviderLevelItemId; goto IL_225; } } if (!CommonUtils.IsSameEntryId(folderRec.ParentId, sourceFolder.ParentId)) { MrsTracer.Common.Debug("Existing folder is under the wrong parent. Moving it.", new object[0]); ((IDestinationMailbox)this).MoveFolder(sourceFolder.EntryId, folderRec.ParentId, sourceFolder.ParentId); } IL_225: PropTag[] promotedProperties = sourceFolder.GetPromotedProperties(); if ((promotedProperties != null && promotedProperties.Length > 0) || (sourceFolder.Restrictions != null && sourceFolder.Restrictions.Length > 0) || (sourceFolder.Views != null && sourceFolder.Views.Length > 0) || (sourceFolder.ICSViews != null && sourceFolder.ICSViews.Length > 0)) { using (StorageDestinationFolder folder2 = base.GetFolder <StorageDestinationFolder>(sourceFolder.EntryId)) { folder2.SetExtendedProps(promotedProperties, sourceFolder.Restrictions, sourceFolder.Views, sourceFolder.ICSViews); } } } }