Example #1
0
        private void ApplyFolderChanges(SyncContext ctx, FolderChangesManifest folderChanges, FolderMapping fm, ISourceFolder srcFolder, IDestinationFolder destFolder)
        {
            int num  = 0;
            int num2 = 0;
            int num3 = 0;
            int num4 = 0;
            int num5 = 0;
            FolderContentsMapper folderContentsMapper = FolderContentsMapper.Create(fm, srcFolder, this.SourceHierarchy, destFolder, this.DestHierarchy, base.MRSJob.CachedRequestJob.ConflictResolutionOption ?? ConflictResolutionOption.KeepSourceItem, base.MRSJob.CachedRequestJob.AssociatedMessagesCopyOption ?? FAICopyOption.DoNotCopy, (base.MRSJob.CachedRequestJob.SyncProtocol == SyncProtocol.Imap) ? FolderContentsMapperFlags.ImapSync : FolderContentsMapperFlags.None);
            List <MessageRec>    list;

            byte[][] array;
            byte[][] array2;
            byte[][] array3;
            int      skipped;

            folderContentsMapper.ComputeIncrementalMapping(folderChanges, (base.SyncState == null) ? null : base.SyncState.BadItems, out list, out array, out array2, out array3, out skipped);
            this.CopyMessageBatch(folderContentsMapper, list, fm);
            destFolder.DeleteMessages(array);
            destFolder.SetReadFlagsOnMessages(SetReadFlags.None, array2);
            destFolder.SetReadFlagsOnMessages(SetReadFlags.ClearRead, array3);
            if (list != null)
            {
                foreach (MessageRec messageRec in list)
                {
                    if (messageRec.IsNew)
                    {
                        num++;
                    }
                    else
                    {
                        num2++;
                    }
                }
            }
            if (array != null)
            {
                num3 += array.Length;
            }
            if (array2 != null)
            {
                num4 += array2.Length;
            }
            if (array3 != null)
            {
                num5 += array3.Length;
            }
            ctx.CopyMessagesCount += new CopyMessagesCount(num, num2, num3, num4, num5, skipped);
        }
Example #2
0
        public void MergeFolderContentsPaged(FolderMapping folder, FolderContentsCrawler sourceFolderCrawler, IDestinationFolder destFolder, TimeSpan maxOperationDuration)
        {
            MrsTracer.Service.Function("MailboxMerger.MergeFolderContentsPaged({0})", new object[]
            {
                folder.FullFolderName
            });
            ISourceFolder wrappedObject = sourceFolderCrawler.WrappedObject;

            if (this.ContentRestriction != null)
            {
                wrappedObject.SetContentsRestriction(this.ContentRestriction);
            }
            FolderContentsMapper folderContentsMapper = FolderContentsMapper.Create(folder, wrappedObject, this.SourceHierarchy, destFolder, this.DestHierarchy, this.GetConflictResolutionOption(folder), base.MRSJob.CachedRequestJob.AssociatedMessagesCopyOption ?? FAICopyOption.DoNotCopy, (base.MRSJob.CachedRequestJob.SyncProtocol == SyncProtocol.Imap) ? FolderContentsMapperFlags.ImapSync : FolderContentsMapperFlags.None);
            DateTime             utcNow = DateTime.UtcNow;
            int               alreadyCopiedCount;
            ulong             alreadyCopiedSize;
            List <MessageRec> itemsToCopy;
            List <MessageRec> list;

            while (folderContentsMapper.ComputeMappingPaged(sourceFolderCrawler, (base.SyncState == null) ? null : base.SyncState.BadItems, out alreadyCopiedCount, out alreadyCopiedSize, out itemsToCopy, out list))
            {
                SyncProtocol syncProtocol = base.MRSJob.CachedRequestJob.SyncProtocol;
                foreach (MessageRec messageRec in list)
                {
                    destFolder.SetMessageProps(messageRec.EntryId, messageRec.AdditionalProps);
                }
                base.MailboxSizeTracker.TrackFolder(folder.EntryId, sourceFolderCrawler.TotalMessageCount, alreadyCopiedCount, alreadyCopiedSize);
                base.MRSJob.MessagesWritten     += base.MailboxSizeTracker.AlreadyCopiedCount;
                base.MRSJob.MessageSizeWritten  += base.MailboxSizeTracker.AlreadyCopiedSize;
                base.MRSJob.TotalMessages        = base.MailboxSizeTracker.MessageCount;
                base.MRSJob.TotalMessageByteSize = base.MailboxSizeTracker.TotalMessageSize;
                this.CopyMessageBatch(folderContentsMapper, itemsToCopy, folder);
                DateTime utcNow2 = DateTime.UtcNow;
                if (utcNow2 - utcNow >= maxOperationDuration)
                {
                    MrsTracer.Service.Debug("MergeFolderContentsPaged times out for assigned duration {0}. Start:{1}, End:{2}", new object[]
                    {
                        maxOperationDuration,
                        utcNow,
                        utcNow2
                    });
                    return;
                }
            }
        }
Example #3
0
        public void MergeFolderContents(FolderMapping fm, ISourceFolder srcFolder, IDestinationFolder destFolder)
        {
            MrsTracer.Service.Function("MailboxMerger.MergeFolderContents({0})", new object[]
            {
                fm.FullFolderName
            });
            if (this.ContentRestriction != null)
            {
                srcFolder.SetContentsRestriction(this.ContentRestriction);
            }
            FolderContentsMapper folderContentsMapper = FolderContentsMapper.Create(fm, srcFolder, this.SourceHierarchy, destFolder, this.DestHierarchy, this.GetConflictResolutionOption(fm), base.MRSJob.CachedRequestJob.AssociatedMessagesCopyOption ?? FAICopyOption.DoNotCopy, (base.MRSJob.CachedRequestJob.SyncProtocol == SyncProtocol.Imap) ? FolderContentsMapperFlags.ImapSync : FolderContentsMapperFlags.None);
            int               num;
            ulong             num2;
            List <MessageRec> list;
            List <MessageRec> list2;

            folderContentsMapper.ComputeMapping((base.SyncState == null) ? null : base.SyncState.BadItems, out num, out num2, out list, out list2);
            SyncProtocol syncProtocol = base.MRSJob.CachedRequestJob.SyncProtocol;

            foreach (MessageRec messageRec in list2)
            {
                destFolder.SetMessageProps(messageRec.EntryId, messageRec.AdditionalProps);
            }
            base.MailboxSizeTracker.TrackFolder(fm.EntryId, list, num, num2);
            int   num3;
            ulong num4;

            base.MailboxSizeTracker.GetFolderSize(fm.EntryId, out num3, out num4);
            base.Report.Append(MrsStrings.ReportFolderMergeStats(num3 - num, new ByteQuantifiedSize(num4 - num2).ToString(), num, new ByteQuantifiedSize(num2).ToString()));
            base.MRSJob.TotalMessages        = base.MailboxSizeTracker.MessageCount;
            base.MRSJob.TotalMessageByteSize = base.MailboxSizeTracker.TotalMessageSize;
            base.MRSJob.MessagesWritten      = base.MailboxSizeTracker.AlreadyCopiedCount;
            base.MRSJob.MessageSizeWritten   = base.MailboxSizeTracker.AlreadyCopiedSize;
            this.CopyMessageBatch(folderContentsMapper, list, fm);
            base.MailboxSizeTracker.TrackFolder(fm.EntryId, null, num3, num4);
        }