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;
     }
 }
示例#2
0
		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);
                    }
                }
            }
        }
示例#4
0
        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);
                    }
                }
            }
        }