private void CopyItemsToTargetMailbox(string parentFolderId, IList <ItemInformation> items, ProgressRecord progressRecord) { List <ItemInformation> list = this.targetMailbox.CopyItems(parentFolderId, items); if (list != null && list.Count > 0) { foreach (ItemInformation itemInformation in list) { if (itemInformation.Error != null) { progressRecord.ReportItemError(itemInformation.Id, null, itemInformation.Error.ErrorType, itemInformation.Error.Message); } else { progressRecord.ReportItemExported(itemInformation.Id, itemInformation.Id.Id, null); } } } }
public void WriteDataBatch(List <ItemInformation> dataBatch) { List <ItemInformation> list = new List <ItemInformation>(Math.Min(dataBatch.Count, Constants.ReadWriteBatchSize)); string parentFolderId = null; string text = string.Empty; ProgressRecord progressRecord = new ProgressRecord(this.dataContext); try { foreach (ItemInformation itemInformation in dataBatch) { if (this.progressController.IsStopRequested) { break; } BaseFolderType parentFolder = this.targetFolderProvider.GetParentFolder(this.targetMailbox, itemInformation.Id.ParentFolder, this.includeDuplicates); if (parentFolder == null) { progressRecord.ReportItemError(itemInformation.Id, null, ExportErrorType.ParentFolderNotFound, string.Format("EDiscoveryError:E007:: Parent folder for this item is not found.", new object[0])); } else { parentFolderId = parentFolder.FolderId.Id; if (text == string.Empty) { text = parentFolder.FolderId.Id; } if (itemInformation.Error == null) { if (itemInformation.Id.IsDuplicate) { progressRecord.ReportItemExported(itemInformation.Id, null, null); } else { if (text != parentFolder.FolderId.Id || list.Count == Constants.ReadWriteBatchSize) { this.CopyItemsToTargetMailbox(text, list, progressRecord); text = parentFolder.FolderId.Id; list.Clear(); } list.Add(itemInformation); } } else { progressRecord.ReportItemError(itemInformation.Id, null, itemInformation.Error.ErrorType, itemInformation.Error.Message); } } } if (list.Count > 0) { this.CopyItemsToTargetMailbox(parentFolderId, list, progressRecord); list.Clear(); } } finally { this.timer.Stop(); if (progressRecord != null) { progressRecord.ReportDuration(this.timer.Elapsed); this.progressController.ReportProgress(progressRecord); } this.timer.Restart(); } }