void IDestinationMailbox.CreateFolder(FolderRec sourceFolder, CreateFolderFlags createFolderFlags, out byte[] newFolderId) { MrsTracer.ProxyClient.Function("RemoteDestinationMailbox.CreateFolder(\"{0}\")", new object[] { sourceFolder.FolderName }); base.VerifyMailboxConnection(); if (!base.ServerVersion[8]) { if (sourceFolder.EntryId == null) { throw new UnsupportedRemoteServerVersionWithOperationPermanentException(base.MrsProxyClient.ServerName, base.ServerVersion.ToString(), "IDestinationMailbox_CreateFolder"); } base.MrsProxy.IDestinationMailbox_CreateFolder(base.Handle, sourceFolder, createFolderFlags.HasFlag(CreateFolderFlags.FailIfExists)); newFolderId = sourceFolder.EntryId; return; } else { if (!base.ServerVersion[50]) { base.MrsProxy.IDestinationMailbox_CreateFolder2(base.Handle, sourceFolder, createFolderFlags.HasFlag(CreateFolderFlags.FailIfExists), out newFolderId); return; } if (createFolderFlags.HasFlag(CreateFolderFlags.CreatePublicFolderDumpster) && !base.ServerVersion[49]) { throw new UnsupportedRemoteServerVersionWithOperationPermanentException(base.MrsProxyClient.ServerName, base.ServerVersion.ToString(), "IDestinationMailbox_CreateFolder with CanStoreCreatePFDumpster"); } base.MrsProxy.IDestinationMailbox_CreateFolder3(base.Handle, sourceFolder, (int)createFolderFlags, out newFolderId); return; } }
void IDestinationMailbox.CreateFolder(FolderRec sourceFolder, CreateFolderFlags createFolderFlags, out byte[] newFolderId) { byte[] newFolderIdInt = null; base.CreateContext("IDestinationMailbox.CreateFolder", new DataContext[] { new FolderRecDataContext(sourceFolder), new SimpleValueDataContext("CreateFolderFlags", createFolderFlags) }).Execute(delegate { ((IDestinationMailbox)this.WrappedObject).CreateFolder(sourceFolder, createFolderFlags, out newFolderIdInt); }, true); newFolderId = newFolderIdInt; }
protected override FolderRecWrapper CreateDestinationFolder(SyncContext syncContext, FolderRecWrapper srcFolderRec, FolderRecWrapper destParentRec) { CreateFolderFlags createFolderFlags = CreateFolderFlags.None; if (base.IsRoot && base.IsPublicFolderMigration && base.DestMailbox.IsCapabilitySupported(MRSProxyCapabilities.CanStoreCreatePFDumpster)) { createFolderFlags = CreateFolderFlags.CreatePublicFolderDumpster; } byte[] entryId; this.CreateFolder(PublicFolderMigrator.dummyEnumFolderContext, srcFolderRec, createFolderFlags, out entryId); FolderRecWrapper folderRecWrapper = syncContext.CreateTargetFolderRec(srcFolderRec); folderRecWrapper.FolderRec.EntryId = entryId; folderRecWrapper.FolderRec.ParentId = destParentRec.EntryId; List <PropValueData> list = new List <PropValueData>(folderRecWrapper.FolderRec.AdditionalProps); list.Add(new PropValueData(PropTag.ReplicaList, ReplicaListProperty.GetBytesFromStringArray(new string[] { this.GetContentMailboxGuid(srcFolderRec).ToString() }))); folderRecWrapper.FolderRec.AdditionalProps = list.ToArray(); return(folderRecWrapper); }
void IDestinationMailbox.CreateFolder(FolderRec sourceFolder, CreateFolderFlags createFolderFlags, out byte[] newFolderId) { MrsTracer.Provider.Function("PstDestinationMailbox.CreateFolder(\"{0}\")", new object[] { sourceFolder.FolderName }); newFolderId = null; uint nodeIdFromEntryId = PstMailbox.GetNodeIdFromEntryId(base.IPst.MessageStore.Guid, sourceFolder.ParentId); if (sourceFolder.EntryId != null) { uint nodeIdFromEntryId2 = PstMailbox.GetNodeIdFromEntryId(base.IPst.MessageStore.Guid, sourceFolder.EntryId); IFolder folder = base.IPst.ReadFolder(nodeIdFromEntryId2); if (folder != null) { if (createFolderFlags.HasFlag(CreateFolderFlags.FailIfExists)) { throw new UnableToReadPSTFolderPermanentException(nodeIdFromEntryId2); } if (nodeIdFromEntryId == folder.ParentId) { return; } } } IFolder folder2 = base.IPst.ReadFolder(nodeIdFromEntryId); if (folder2 == null) { throw new UnableToReadPSTFolderPermanentException(nodeIdFromEntryId); } using (PstFxFolder pstFxFolder = new PstFxFolder(this, folder2.AddFolder())) { pstFxFolder.PropertyBag.SetProperty(new PropertyValue(PropertyTag.DisplayName, sourceFolder.FolderName)); pstFxFolder.PropertyBag.SetProperty(new PropertyValue(PropertyTag.FolderType, (int)sourceFolder.FolderType)); newFolderId = PstMailbox.CreateEntryIdFromNodeId(base.IPst.MessageStore.Guid, pstFxFolder.IPstFolder.Id); } }
void IDestinationMailbox.CreateFolder(FolderRec sourceFolder, CreateFolderFlags createFolderFlags, out byte[] newFolderId) { MrsTracer.Provider.Function("MapiDestinationMailbox.CreateFolder(\"{0}\")", new object[] { sourceFolder.FolderName }); base.VerifyMailboxConnection(VerifyMailboxConnectionFlags.None); if (createFolderFlags.HasFlag(CreateFolderFlags.InternalAccess)) { throw new InternalAccessFolderCreationIsNotSupportedException(); } FolderRec folderRec = null; newFolderId = null; using (base.RHTracker.Start()) { if (!createFolderFlags.HasFlag(CreateFolderFlags.FailIfExists) && sourceFolder.EntryId != null) { OpenEntryFlags flags = OpenEntryFlags.DontThrowIfEntryIsMissing; using (MapiFolder mapiFolder = (MapiFolder)base.MapiStore.OpenEntry(sourceFolder.EntryId, flags)) { if (mapiFolder != null) { folderRec = FolderRec.Create(mapiFolder, null); newFolderId = folderRec.EntryId; } } } if (newFolderId == null) { OpenEntryFlags flags2 = OpenEntryFlags.DeferredErrors | OpenEntryFlags.Modify; using (MapiFolder mapiFolder2 = (MapiFolder)base.MapiStore.OpenEntry(sourceFolder.ParentId, flags2)) { using (MapiFolder mapiFolder3 = mapiFolder2.CreateFolder(sourceFolder.FolderName, null, false, sourceFolder.FolderType == FolderType.Search, sourceFolder.EntryId)) { newFolderId = mapiFolder3.GetProp(PropTag.EntryId).GetBytes(); } goto IL_160; } } if (!CommonUtils.IsSameEntryId(folderRec.ParentId, sourceFolder.ParentId)) { MrsTracer.Provider.Debug("Existing folder is under the wrong parent. Moving it.", new object[0]); ((IDestinationMailbox)this).MoveFolder(folderRec.EntryId, folderRec.ParentId, sourceFolder.ParentId); } IL_160: 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 (MapiDestinationFolder folder = base.GetFolder <MapiDestinationFolder>(newFolderId)) { ICSViewData[] icsViews = null; if (this.ServerVersion >= Server.E15MinVersion) { icsViews = sourceFolder.ICSViews; } folder.SetExtendedProps(promotedProperties, sourceFolder.Restrictions, sourceFolder.Views, icsViews); } } } }
public override void CreateFolder(FolderMap.EnumFolderContext context, FolderRecWrapper sourceFolderRecWrapper, CreateFolderFlags createFolderFlags, out byte[] newFolderEntryId) { if (sourceFolderRecWrapper.IsInternalAccess) { throw new InternalAccessFolderCreationIsNotSupportedException(); } newFolderEntryId = null; FolderMapping folderMapping = sourceFolderRecWrapper as FolderMapping; FolderHierarchy folderHierarchy = base.DestMailboxWrapper.FolderMap as FolderHierarchy; byte[] sessionSpecificEntryId = base.DestMailbox.GetSessionSpecificEntryId(folderMapping.EntryId); FolderMapping folderMapping2 = folderMapping.Parent as FolderMapping; bool isRoot = base.IsRoot; byte[] parentId; switch (folderMapping2.WKFType) { case WellKnownFolderType.Root: case WellKnownFolderType.NonIpmSubtree: case WellKnownFolderType.IpmSubtree: case WellKnownFolderType.EFormsRegistry: parentId = folderHierarchy.GetWellKnownFolder(folderMapping2.WKFType).EntryId; break; default: if (isRoot || this.ShouldCreateUnderParentInSecondary()) { parentId = base.DestMailbox.GetSessionSpecificEntryId(folderMapping.ParentId); } else { parentId = folderHierarchy.GetWellKnownFolder(WellKnownFolderType.IpmSubtree).EntryId; } break; } byte[] entryId = folderMapping.FolderRec.EntryId; byte[] parentId2 = folderMapping.FolderRec.ParentId; folderMapping.FolderRec.EntryId = sessionSpecificEntryId; folderMapping.FolderRec.ParentId = parentId; base.DestMailbox.CreateFolder(folderMapping.FolderRec, createFolderFlags, out newFolderEntryId); folderMapping.FolderRec.EntryId = entryId; folderMapping.FolderRec.ParentId = parentId2; List <PropValueData> list = new List <PropValueData>(2); Guid contentMailboxGuid = this.GetContentMailboxGuid(sourceFolderRecWrapper); StorePropertyDefinition replicaList = CoreFolderSchema.ReplicaList; byte[] bytesFromStringArray = ReplicaListProperty.GetBytesFromStringArray(new string[] { contentMailboxGuid.ToString() }); list.Add(new PropValueData(PropTag.ReplicaList, bytesFromStringArray)); using (IDestinationFolder folder = base.DestMailbox.GetFolder(sessionSpecificEntryId)) { if (folder == null) { MrsTracer.Service.Error("Something deleted destination folder from under us", new object[0]); throw new UnexpectedErrorPermanentException(-2147221238); } if (isRoot && !this.AssociatedDumpsterExists(folder)) { byte[] value = this.CreateAssociatedDumpsterFolder(folderMapping.FolderName, bytesFromStringArray, sessionSpecificEntryId); list.Add(new PropValueData(PropTag.IpmWasteBasketEntryId, value)); } folder.SetProps(list.ToArray()); } }
protected override void CatchupFolderHierarchy() { if (!this.PrimaryHierarchyMbxWrapper.Mailbox.IsConnected()) { this.PrimaryHierarchyMbxWrapper.Mailbox.Connect(MailboxConnectFlags.None); } FolderRecDataFlags folderRecDataFlags = FolderRecDataFlags.SearchCriteria; if (!base.CachedRequestJob.SkipFolderPromotedProperties) { folderRecDataFlags |= FolderRecDataFlags.PromotedProperties; } if (!base.CachedRequestJob.SkipFolderViews) { folderRecDataFlags |= FolderRecDataFlags.Views; } if (!base.CachedRequestJob.SkipFolderRestrictions) { folderRecDataFlags |= FolderRecDataFlags.Restrictions; } List <WellKnownFolder> list = this.folderMover.SourceMailbox.DiscoverWellKnownFolders(0); List <WellKnownFolder> destinationWellKnownFolders = this.folderMover.DestMailbox.DiscoverWellKnownFolders(0); foreach (byte[] array in this.foldersToMove) { using (IFolder folder = ((ISourceMailbox)this.PrimaryHierarchyMbxWrapper.Mailbox).GetFolder(array)) { using (IDestinationFolder folder2 = this.folderMover.DestMailbox.GetFolder(this.folderMover.DestMailbox.GetSessionSpecificEntryId(array))) { if (folder2 == null) { if (folder == null) { MrsTracer.Service.Debug("Folder {0} unavailable at both source and destination mailbox during catchup", new object[] { HexConverter.ByteArrayToHexString(array) }); } else { List <FolderRecWrapper> list2 = new List <FolderRecWrapper>(); byte[] entryId = array; for (;;) { using (ISourceFolder folder3 = this.folderMover.SourceMailbox.GetFolder(entryId)) { if (folder3 != null) { FolderRecWrapper folderRecWrapper = new FolderRecWrapper(folder3.GetFolderRec(null, GetFolderRecFlags.None)); if (folderRecWrapper.ParentId != null) { list2.Insert(0, folderRecWrapper); bool flag = false; foreach (WellKnownFolder wellKnownFolder in list) { if (CommonUtils.IsSameEntryId(wellKnownFolder.EntryId, folderRecWrapper.ParentId)) { flag = true; break; } } if (!flag) { entryId = folderRecWrapper.ParentId; continue; } } } } break; } foreach (FolderRecWrapper folderRecWrapper2 in list2) { byte[] entryId2 = folderRecWrapper2.FolderRec.EntryId; byte[] parentId = folderRecWrapper2.FolderRec.ParentId; byte[] sessionSpecificEntryId = this.folderMover.DestMailbox.GetSessionSpecificEntryId(entryId2); bool flag2 = false; byte[] destinationFolderIdFromSourceFolderId = AuxFolderMoveJob.GetDestinationFolderIdFromSourceFolderId(list, destinationWellKnownFolders, this.folderMover.DestMailbox, parentId, out flag2); using (IDestinationFolder folder4 = this.folderMover.DestMailbox.GetFolder(sessionSpecificEntryId)) { if (folder4 == null) { using (ISourceFolder folder5 = this.folderMover.SourceMailbox.GetFolder(entryId2)) { if (folder5 == null) { MrsTracer.Service.Warning("Source folder '{0}' {1} disappeared, skipping", new object[] { folderRecWrapper2.FolderName, folderRecWrapper2.EntryId }); break; } folderRecWrapper2.EnsureDataLoaded(folder5, folderRecDataFlags, this.folderMover); this.folderMover.TranslateFolderData(folderRecWrapper2); CreateFolderFlags createFolderFlags = CreateFolderFlags.None; folderRecWrapper2.FolderRec.EntryId = sessionSpecificEntryId; folderRecWrapper2.FolderRec.ParentId = destinationFolderIdFromSourceFolderId; byte[] array2; this.folderMover.CreateFolder(null, folderRecWrapper2, createFolderFlags, out array2); folderRecWrapper2.FolderRec.EntryId = entryId2; folderRecWrapper2.FolderRec.ParentId = parentId; } } } } } } } } } base.SyncStage = SyncStage.CreatingInitialSyncCheckpoint; base.OverallProgress = 15; base.TimeTracker.CurrentState = RequestState.CreatingInitialSyncCheckpoint; base.SaveState(SaveStateFlags.Regular, delegate(TransactionalRequestJob moveRequest) { moveRequest.RestartFromScratch = false; }); base.ScheduleWorkItem(new Action(base.CatchupFolders), WorkloadType.Unknown); }
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); } } } }