public JsonResult DumpItems(CatalogJobParameter catalog, RestoreAdminUserInfo restoreAdminUserInfo, LoadedTreeItem selectedItem, string notificationAddress, ExportType exportType) { var password = RSAUtil.AsymmetricDecrypt(restoreAdminUserInfo.Password); IRestoreServiceEx restore = RestoreFactory.Instance.NewRestoreServiceEx(restoreAdminUserInfo.UserAddress, password, string.Empty, restoreAdminUserInfo.Organization); restore.CurrentRestoreCatalogJob = catalog; restore.Destination = RestoreFactory.Instance.NewDumpDestination(); restore.Destination.ExportType = exportType; restore.Destination.SetOtherInformation(notificationAddress); restore.Restore(selectedItem); return Json(new { IsSuccess = true }); }
public JsonResult UpdateMails(CatalogJobParameter catalogJob, string folderId, int pageIndex, int pageCount) { var dataAccess = RestoreFactory.Instance.NewDataAccessForQuery(); dataAccess.CatalogJob = catalogJob; List<IItemData> items = dataAccess.GetChildItems(folderId, pageIndex, pageCount); int startIndex = pageIndex * pageCount; int endIndex = startIndex + pageCount; List<Item> result = new List<Item>(pageCount); int index = 0; while (startIndex < endIndex && index < items.Count) { var mailItem = items[index++]; var item = new Item() { Id = mailItem.ItemId, ChildCount = 0, ItemType = ItemTypeStr.Item, DisplayName = mailItem.DisplayName, OtherInformation = mailItem }; result.Add(item); startIndex++; } int totalCount = -1; if (pageIndex == 0) { totalCount = dataAccess.GetChildItemsCount(folderId); } return Json(new { Mails = result, TotalCount = totalCount }); }
public JsonResult UpdateFolders(CatalogJobParameter catalogJob, string mailAddress) { var dataAccess = RestoreFactory.Instance.NewDataAccessForQuery(); dataAccess.CatalogJob = catalogJob; var allFolder = dataAccess.GetAllFoldersInMailboxes(mailAddress); var tree = TreeNode.CreateTree(allFolder); List<Item> result = new List<Item>(); Stack<Item> stacks = new Stack<Item>(); int oldDepth = -1; TreeNode.DepthFirstTraverseTree(tree, (currentNode, depth, inChildrenIndex) => { Item item = null; if (currentNode.Folder == null) { item = new Item(); } else { item = new Item() { Id = currentNode.Folder.FolderId, DisplayName = ((IItemBase)currentNode.Folder).DisplayName, ChildCount = currentNode.Folder.ChildFolderCount + currentNode.Folder.ChildItemCount, ItemType = ItemTypeStr.Folder, OtherInformation = currentNode.Folder }; } if (oldDepth <= depth) { stacks.Push(item); } else { LinkedList<Item> childItems = new LinkedList<Item>(); var stackCount = stacks.Count; for (int i = 0; i < inChildrenIndex; i++) { childItems.AddFirst(stacks.Pop()); } item.Container = childItems.ToList(); stacks.Push(item); } oldDepth = depth; }); var rootItem = stacks.Pop(); return Json(new { CatalogTime = catalogJob.StartTime, Details = rootItem.Container }); }
public JsonResult UpdateMailboxes(CatalogJobParameter catalogJob) { var dataAccess = RestoreFactory.Instance.NewDataAccessForQuery(); dataAccess.CatalogJob = catalogJob; var allMailboxes = dataAccess.GetAllMailbox(); List<Item> infos = new List<Item>(allMailboxes.Count); foreach (var mailbox in allMailboxes) { infos.Add(new Item() { Id = mailbox.RootFolderId, DisplayName = mailbox.DisplayName, ChildCount = mailbox.ChildFolderCount, ItemType = ItemTypeStr.Mailbox, OtherInformation = mailbox }); } return Json(new { Details = infos, CatalogTime = catalogJob.StartTime }); }
public JsonResult RestoreItemsToOrg(CatalogJobParameter catalog, RestoreAdminUserInfo restoreAdminUserInfo, RestoreDestination destination, LoadedTreeItem selectedItem) { var password = RSAUtil.AsymmetricDecrypt(restoreAdminUserInfo.Password); IRestoreServiceEx restore = RestoreFactory.Instance.NewRestoreServiceEx(restoreAdminUserInfo.UserAddress, password, string.Empty, restoreAdminUserInfo.Organization); restore.CurrentRestoreCatalogJob = catalog; var context = ((RestoreServiceEx)restore).ServiceContext; var dataAccess = RestoreFactory.Instance.NewCatalogDataAccessInternal(); restore.Destination = RestoreFactory.Instance.NewRestoreDestinationOrgEx(restore.ServiceContext.Argument, dataAccess); restore.Destination.SetOtherInformation(destination.FolderPath); restore.Restore(selectedItem); return Json(new { IsSuccess = true }); }