public void InitializeFolderMap(StoreId targetRootId, string[] targetSubfolders) { StoreId defaultFolderId = this.sourceMailbox.GetDefaultFolderId(DefaultFolderType.Root); StoreId defaultFolderId2 = this.sourceMailbox.GetDefaultFolderId(DefaultFolderType.RecoverableItemsRoot); FolderNode folderNode2; if (this.targetMailbox != null) { FolderNode folderNode = new FolderNode(null, targetRootId, null, null); folderNode2 = folderNode; foreach (string displayName in targetSubfolders) { FolderNode folderNode3 = new FolderNode(null, null, displayName, folderNode2); folderNode2 = folderNode3; } } else { folderNode2 = new FolderNode(defaultFolderId, null, Strings.PrimaryMailbox, null); } FolderNode folderNode4 = folderNode2; folderNode4.SourceFolderId = defaultFolderId; this.folderNodeMap = new Dictionary <StoreId, FolderNode>(); this.folderNodeMap.Add(folderNode4.SourceFolderId, folderNode4); string displayName2 = null; if (this.searchWorker.SearchDumpster || this.searchWorker.IncludeUnsearchableItems) { string[] uniqueFolderName = this.GetUniqueFolderName(this.sourceMailbox, defaultFolderId, new string[] { Strings.RecoverableItems, Strings.Unsearchable }); displayName2 = uniqueFolderName[0]; string text = uniqueFolderName[1]; } if (this.searchWorker.SearchDumpster && defaultFolderId2 != null) { this.folderNodeMap.Add(defaultFolderId2, new FolderNode(defaultFolderId2, null, displayName2, folderNode4)); } }
private StoreId CreateTargetFolder(MailboxSession targetMailbox, FolderNode folderNode) { Stack <FolderNode> stack = new Stack <FolderNode>(); FolderNode folderNode2 = folderNode; while (folderNode2.TargetFolderId == null) { stack.Push(folderNode2); folderNode2 = folderNode2.Parent; } FolderNode folderNode3 = folderNode2; while (stack.Count > 0) { bool sourceBasedFolder = folderNode.SourceFolderId != null; folderNode2 = stack.Pop(); folderNode2.TargetFolderId = this.CreateFolder(targetMailbox, folderNode3.TargetFolderId, folderNode2.DisplayName, sourceBasedFolder); folderNode3 = folderNode2; } return(folderNode.TargetFolderId); }
internal FolderNode(StoreId sourceFolderId, StoreId targetFolderId, string displayName, FolderNode parent) : this(sourceFolderId, targetFolderId, displayName, false, parent) { }
internal FolderNode(StoreId sourceFolderId, StoreId targetFolderId, string displayName, bool isSoftDeleted, FolderNode parent) { this.SourceFolderId = sourceFolderId; this.TargetFolderId = targetFolderId; this.DisplayName = displayName; this.Parent = parent; this.IsSoftDeleted = isSoftDeleted; }
public override void PerformBatchOperation(object[][] batchedItemBuffer, int fetchedItemCount, StoreId currentFolderId, MailboxSession sourceMailbox, MailboxSession targetMailbox, Dictionary <StoreId, FolderNode> folderNodeMap, SearchResultProcessor processor) { processor.CheckTargetMailboxAvailableSpace(); StoreId[] array = new StoreId[fetchedItemCount]; for (int i = 0; i < fetchedItemCount; i++) { array[i] = (StoreId)batchedItemBuffer[i][0]; } FolderNode folderNode = folderNodeMap[currentFolderId]; using (Folder folder = Folder.Bind(sourceMailbox, currentFolderId)) { processor.BackOffFromSourceStore(); processor.BackOffFromTargetStore(); try { GroupOperationResult groupOperationResult = null; lock (targetMailbox) { if (processor.IsAborted()) { return; } if (folderNode.TargetFolderId == null) { this.CreateTargetFolder(targetMailbox, folderNode); } groupOperationResult = folder.CopyItems(targetMailbox, folderNode.TargetFolderId, false, array); } if (groupOperationResult.OperationResult != OperationResult.Succeeded) { SearchMailboxAction.Tracer.TraceError <OperationResult, LocalizedException>((long)this.GetHashCode(), "DeleteItems operation failed with operation result: {0} and exception: {1}", groupOperationResult.OperationResult, groupOperationResult.Exception); if (groupOperationResult.Exception.GetType() == typeof(MapiExceptionPartialCompletion) || groupOperationResult.Exception.GetType() == typeof(PartialCompletionException)) { StoragePermanentException e = new StoragePermanentException(Strings.CopyItemsFailed, groupOperationResult.Exception); processor.ReportActionException(e); } else { SearchMailboxException e2 = new SearchMailboxException(Strings.CopyItemsFailed, groupOperationResult.Exception); processor.ReportActionException(e2); } } else { SearchMailboxAction.Tracer.TraceDebug <int, string>((long)this.GetHashCode(), "SearchMailboxWoker progressed with {0} message deletes on mailbox {1}", array.Length, processor.GetSourceUserName()); } } catch (ArgumentException ex) { SearchMailboxAction.Tracer.TraceError <ArgumentException>((long)this.GetHashCode(), "CopyItems operation failed due to item validation failed, exception: {0}", ex); SearchMailboxException e3 = new SearchMailboxException(Strings.CopyItemsFailed, ex); processor.ReportActionException(e3); } catch (MapiExceptionPartialCompletion mapiExceptionPartialCompletion) { SearchMailboxAction.Tracer.TraceError <MapiExceptionPartialCompletion>((long)this.GetHashCode(), "CopyItems operation failed due to insufficient space in target mailbox, exception: {0}", mapiExceptionPartialCompletion); StoragePermanentException e4 = new StoragePermanentException(Strings.CopyItemsFailed, mapiExceptionPartialCompletion); processor.ReportActionException(e4); } catch (PartialCompletionException ex2) { SearchMailboxAction.Tracer.TraceError <PartialCompletionException>((long)this.GetHashCode(), "CopyItems operation failed due to insufficient space in target mailbox, exception: {0}", ex2); StoragePermanentException e5 = new StoragePermanentException(Strings.CopyItemsFailed, ex2); processor.ReportActionException(e5); } } }