Exemplo n.º 1
0
        private void CopyMessageBatch(List <MessageRec> messages, IFxProxyPool proxyPool)
        {
            MrsTracer.Provider.Function("MapiSourceMailbox.CopyMessageBatch({0} messages)", new object[]
            {
                messages.Count
            });
            byte[]            curFolderId = null;
            List <MessageRec> curBatch    = new List <MessageRec>();
            bool          exportCompleted = false;
            List <byte[]> list            = new List <byte[]>(messages.Count);

            foreach (MessageRec messageRec in messages)
            {
                list.Add(messageRec.EntryId);
            }
            ExecutionContext.Create(new DataContext[]
            {
                new OperationDataContext("LocalSourceMailbox.CopyMessageBatch", OperationType.None),
                new EntryIDsDataContext(list)
            }).Execute(delegate
            {
                try
                {
                    foreach (MessageRec messageRec2 in messages)
                    {
                        if (curFolderId != null && !CommonUtils.IsSameEntryId(curFolderId, messageRec2.FolderId))
                        {
                            this.FlushBatchToFolder(curBatch, proxyPool);
                            curFolderId = null;
                            curBatch.Clear();
                        }
                        curFolderId = messageRec2.FolderId;
                        curBatch.Add(messageRec2);
                    }
                    this.FlushBatchToFolder(curBatch, proxyPool);
                    exportCompleted = true;
                    proxyPool.Flush();
                }
                catch (LocalizedException)
                {
                    if (!exportCompleted)
                    {
                        MrsTracer.Provider.Debug("Flushing target proxy after receiving an exception.", new object[0]);
                        CommonUtils.CatchKnownExceptions(new Action(proxyPool.Flush), null);
                    }
                    throw;
                }
            });
        }
        void ISourceMailbox.ExportFolders(List <byte[]> folderIds, IFxProxyPool proxyPool, ExportFoldersDataToCopyFlags exportFoldersDataToCopyFlags, GetFolderRecFlags folderRecFlags, PropTag[] additionalFolderRecProps, CopyPropertiesFlags copyPropertiesFlags, PropTag[] excludeProps, AclFlags extendedAclFlags)
        {
            MrsTracer.ProxyClient.Function("StorageSourceMailbox.ExportFolders", new object[0]);
            base.VerifyMailboxConnection(VerifyMailboxConnectionFlags.None);
            bool exportCompleted = false;

            CommonUtils.ProcessKnownExceptions(delegate
            {
                foreach (byte[] folderEntryId in folderIds)
                {
                    this.ExportSingleFolder(proxyPool, folderEntryId, exportFoldersDataToCopyFlags, folderRecFlags, additionalFolderRecProps, copyPropertiesFlags, excludeProps, extendedAclFlags);
                }
                exportCompleted = true;
                proxyPool.Flush();
            }, delegate(Exception ex)
            {
                if (!exportCompleted)
                {
                    MrsTracer.Provider.Debug("Flushing target proxy after receiving an exception.", new object[0]);
                    CommonUtils.CatchKnownExceptions(new Action(proxyPool.Flush), null);
                }
                return(false);
            });
        }