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; } } }
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); }