コード例 #1
0
 private void ExportSingleFolder(IFxProxyPool proxyPool, byte[] folderEntryId, ExportFoldersDataToCopyFlags exportFoldersDataToCopyFlags, GetFolderRecFlags folderRecFlags, PropTag[] additionalFolderRecProps, CopyPropertiesFlags copyPropertiesFlags, PropTag[] excludePropertiesFromCopy, AclFlags extendedAclFlags)
 {
     ExecutionContext.Create(new DataContext[]
     {
         new OperationDataContext("StorageSourceMailbox.ExportSingleFolder", OperationType.None),
         new EntryIDsDataContext(folderEntryId),
         new SimpleValueDataContext("exportFoldersDataToCopyFlags", exportFoldersDataToCopyFlags),
         new SimpleValueDataContext("folderRecFlags", folderRecFlags),
         new PropTagsDataContext(additionalFolderRecProps),
         new SimpleValueDataContext("copyPropertiesFlags", copyPropertiesFlags),
         new PropTagsDataContext(excludePropertiesFromCopy),
         new SimpleValueDataContext("extendedAclFlags", extendedAclFlags)
     }).Execute(delegate
     {
         using (this.RHTracker.Start())
         {
             using (ISourceFolder folder = this.GetFolder <StorageSourceFolder>(folderEntryId))
             {
                 if (folder == null)
                 {
                     MrsTracer.Provider.Debug("Folder {0} is missing in source. Skipping.", new object[]
                     {
                         TraceUtils.DumpEntryId(folderEntryId)
                     });
                 }
                 else
                 {
                     using (IFolderProxy folderProxyForExportFolder = StorageSourceMailbox.GetFolderProxyForExportFolder(proxyPool, folder, exportFoldersDataToCopyFlags, folderRecFlags, additionalFolderRecProps))
                     {
                         if (extendedAclFlags != AclFlags.None)
                         {
                             this.ExportExtendedAcls(extendedAclFlags, folder, folderProxyForExportFolder);
                         }
                         using (FxProxyBudgetWrapper fxProxyBudgetWrapper = new FxProxyBudgetWrapper(folderProxyForExportFolder, false, new Func <IDisposable>(this.RHTracker.StartExclusive), new Action <uint>(this.RHTracker.Charge)))
                         {
                             if (exportFoldersDataToCopyFlags.HasFlag(ExportFoldersDataToCopyFlags.IncludeCopyToStream))
                             {
                                 folder.CopyTo(fxProxyBudgetWrapper, copyPropertiesFlags, excludePropertiesFromCopy);
                             }
                         }
                     }
                 }
             }
         }
     });
 }
コード例 #2
0
        MailboxInformation IMailboxReplicationService.GetMailboxInformation4(string requestJobXml, Guid primaryMailboxGuid, Guid physicalMailboxGuid, byte[] partitionHint, Guid targetMdbGuid, string targetMdbName, string remoteHostName, string remoteOrgName, string remoteDCName, string username, string password, string domain)
        {
            MailboxInformation info = null;

            this.ForwardKnownExceptions(delegate
            {
                TenantPartitionHint partitionHint2 = (partitionHint != null) ? TenantPartitionHint.FromPersistablePartitionHint(partitionHint) : null;
                bool flag = string.IsNullOrEmpty(targetMdbName) && targetMdbGuid == Guid.Empty;
                NetworkCredential networkCredential = (!string.IsNullOrEmpty(username)) ? new NetworkCredential(username, password, domain) : null;
                MailboxType mbxType;
                IMailbox mailbox;
                if (string.IsNullOrEmpty(remoteHostName))
                {
                    if (!string.IsNullOrEmpty(remoteDCName))
                    {
                        if (flag)
                        {
                            mbxType = MailboxType.SourceMailbox;
                            mailbox = new MapiSourceMailbox(LocalMailboxFlags.Move);
                        }
                        else
                        {
                            mbxType = MailboxType.DestMailboxIntraOrg;
                            mailbox = new MapiDestinationMailbox(LocalMailboxFlags.None);
                        }
                        mailbox.ConfigADConnection(remoteDCName, remoteDCName, networkCredential);
                    }
                    else
                    {
                        ProxyServerSettings proxyServerSettings;
                        if (targetMdbGuid != Guid.Empty)
                        {
                            proxyServerSettings = CommonUtils.MapDatabaseToProxyServer(targetMdbGuid);
                        }
                        else
                        {
                            proxyServerSettings = CommonUtils.MapMailboxToProxyServer(new Guid?(physicalMailboxGuid), new Guid?(primaryMailboxGuid), partitionHint);
                        }
                        if (flag)
                        {
                            if (proxyServerSettings.Scenario == ProxyScenarios.LocalMdbAndProxy)
                            {
                                mailbox = new StorageSourceMailbox(LocalMailboxFlags.Move);
                            }
                            else
                            {
                                mailbox = new RemoteSourceMailbox(proxyServerSettings.Fqdn, null, null, ProxyControlFlags.DoNotApplyProxyThrottling, null, false, LocalMailboxFlags.Move);
                            }
                            mbxType = MailboxType.SourceMailbox;
                        }
                        else
                        {
                            if (proxyServerSettings.Scenario == ProxyScenarios.LocalMdbAndProxy)
                            {
                                mailbox = new StorageDestinationMailbox(LocalMailboxFlags.Move);
                            }
                            else
                            {
                                mailbox = new RemoteDestinationMailbox(proxyServerSettings.Fqdn, null, null, ProxyControlFlags.DoNotApplyProxyThrottling, null, false, LocalMailboxFlags.Move);
                            }
                            mbxType = MailboxType.DestMailboxIntraOrg;
                        }
                    }
                }
                else
                {
                    ProxyControlFlags proxyControlFlags = ProxyControlFlags.DoNotApplyProxyThrottling;
                    RequestJobXML requestJobXML         = XMLSerializableBase.Deserialize <RequestJobXML>(requestJobXml, true);
                    if (requestJobXML != null)
                    {
                        using (TransactionalRequestJob transactionalRequestJob = new TransactionalRequestJob(requestJobXML))
                        {
                            transactionalRequestJob.IsFake = true;
                            proxyControlFlags |= transactionalRequestJob.GetProxyControlFlags();
                        }
                    }
                    if (flag)
                    {
                        mailbox = new RemoteSourceMailbox(remoteHostName, remoteOrgName, networkCredential, proxyControlFlags, null, true, LocalMailboxFlags.Move);
                        mbxType = MailboxType.SourceMailbox;
                    }
                    else
                    {
                        mailbox = new RemoteDestinationMailbox(remoteHostName, remoteOrgName, networkCredential, proxyControlFlags, null, true, LocalMailboxFlags.Move);
                        mbxType = MailboxType.DestMailboxCrossOrg;
                    }
                }
                using (mailbox)
                {
                    mailbox.Config(null, primaryMailboxGuid, physicalMailboxGuid, partitionHint2, targetMdbGuid, mbxType, null);
                    if (!string.IsNullOrEmpty(targetMdbName))
                    {
                        mailbox.ConfigMDBByName(targetMdbName);
                    }
                    mailbox.Connect(MailboxConnectFlags.None);
                    using (SettingsContextBase.ActivateContext(mailbox as ISettingsContextProvider))
                    {
                        info          = mailbox.GetMailboxInformation();
                        ADUser aduser = mailbox.GetADUser();
                        if (!this.clientVersion[2] && aduser.HasSeparatedArchive)
                        {
                            throw new UnsupportedClientVersionPermanentException(this.clientVersion.ComputerName, this.clientVersion.ToString(), "ArchiveSeparation");
                        }
                        info.UserDataXML       = ConfigurableObjectXML.Serialize <ADUser>(aduser);
                        info.ServerInformation = mailbox.GetMailboxServerInformation();
                        mailbox.Disconnect();
                    }
                }
            }, null);
            return(info);
        }