예제 #1
0
        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 });
        }
예제 #2
0
 public FilterBySelectedTree(LoadedTreeItem orgSelectItems)
 {
     _orgSelectedItems = orgSelectItems;
     _orgSelectedItemUtils = new LoadedTreeItemUtil(orgSelectItems);
 }
예제 #3
0
        public LoadedTreeItemUtil(LoadedTreeItem item)
        {
            Item = item;

            List<LoadedTreeItemUtil> children = CreateChildren(item.LoadedChildren);
            Id2Children = new Dictionary<string, LoadedTreeItemUtil>(children.Count);
            Display2Children = new Dictionary<string, LoadedTreeItemUtil>(children.Count);

            foreach(var child in children)
            {
                Id2Children[child.Item.Id] = child;
                Display2Children[child.Item.DisplayName] = child;
            }
        }
예제 #4
0
 private void RestoreUnloadedChildren(LoadedTreeItem item,
     List<IMailboxData> childMailboxes,
     List<IFolderData> childFolders,
     List<IItemData> childMailItems,
     IRestoreDestinationEx restoreDestination,
     Stack<IItemBase> dealItemStack)
 {
     switch (item.ItemKind)
     {
         case ItemKind.Organization:
             RestoreUnLoadedMailbox(childMailboxes, restoreDestination, dealItemStack);
             break;
         case ItemKind.Mailbox:
             RestoreUnLoadedFolders(childFolders, restoreDestination, dealItemStack);
             break;
         case ItemKind.Folder:
             RestoreUnLoadedFolders(childFolders, restoreDestination, dealItemStack);
             RestoreUnLoadedItems(childMailItems, restoreDestination, dealItemStack);
             break;
         case ItemKind.Item:
             throw new ArgumentException();
         default:
             throw new NotSupportedException();
     }
 }
예제 #5
0
 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 });
 }
예제 #6
0
        private void GetUnloadedChild(LoadedTreeItem item, out List<IMailboxData> childMailboxes, out List<IFolderData> childFolders, out List<IItemData> childMailItems)
        {
            childMailboxes = null;
            childFolders = null;
            childMailItems = null;

            List<string> loadedMailChildrenIds = new List<string>();
            List<string> loadedFolderChildrenIds = new List<string>();
            List<string> loadedItemChildrenIds = new List<string>();

            if(item.LoadedChildrenCount > 0)
                foreach (var loadChildItem in item.LoadedChildren)
                {
                    switch (loadChildItem.ItemKind)
                    {
                        case ItemKind.Organization:
                            throw new NotSupportedException("no this type child.");
                        case ItemKind.Mailbox:
                            loadedMailChildrenIds.Add(loadChildItem.Id);
                            break;
                        case ItemKind.Folder:
                            loadedFolderChildrenIds.Add(loadChildItem.Id);
                            break;
                        case ItemKind.Item:
                            loadedItemChildrenIds.Add(loadChildItem.Id);
                            break;
                        default:
                            throw new NotSupportedException(string.Format("Don't support the type {0}", item.ItemType));
                    }
                }

            switch (item.ItemKind)
            {
                case ItemKind.Organization:
                    childMailboxes = DataAccess.GetAllMailbox(loadedMailChildrenIds);
                    break;
                case ItemKind.Mailbox:
                    childFolders = DataAccess.GetAllChildFolder(item.Id, loadedFolderChildrenIds);
                    break;
                case ItemKind.Folder:
                    childFolders = DataAccess.GetAllChildFolder(item.Id, loadedFolderChildrenIds);
                    childMailItems = DataAccess.GetAllChildItems(item.Id, loadedItemChildrenIds);
                    break;
                case ItemKind.Item:
                    throw new NotSupportedException("unload mail items need deal with in unload folder.");
                default:
                    throw new NotSupportedException(string.Format("Don't support the type {0}", item.ItemType));
            }
        }
예제 #7
0
        private void CheckLoadedTreeItem(LoadedTreeItem item, out bool isLoadUnloadChildren, out bool isEnd)
        {
            var itemStatus = (SelectedItemStatus)item.Status;
            var isLoadedAllChild = item.LoadedChildrenCount == item.TotalChildCount;
            var isAllLoadedChildSelected = item.LoadedChildrenCount == item.SelectedChildCount;
            var isNoLoadedChildSelected = item.SelectedChildCount == 0;
            var itemUnloadStatus = (SelectedItemStatus)item.UnloadedChildrenStatus;

            if (itemUnloadStatus == SelectedItemStatus.Indeterminate)
                throw new ArgumentException("unload status must not be indeterminate.");

            isLoadUnloadChildren = false;
            isEnd = false;

            if (item.CanSelect == 0)
            {
                isEnd = true;
                return;
            }

            switch (itemStatus)
            {
                case SelectedItemStatus.Selected:

                    // loaded
                    if (!isAllLoadedChildSelected)
                        throw new ArgumentException("when item status is selected status, all loaded item need select. please check code.");

                    // unloaded
                    else if (!isLoadedAllChild && itemUnloadStatus != SelectedItemStatus.Selected)
                        throw new ArgumentException("when item status is selected status, unloaded status must be selected. please check code.");

                    else if (isLoadedAllChild)
                    {
                        // all load select items.
                    }
                    else
                    {
                        isLoadUnloadChildren = true;
                        // load selected item + unload items.
                    }
                    break;
                case SelectedItemStatus.Indeterminate:

                    if (isLoadedAllChild)
                    {
                        if (isAllLoadedChildSelected)
                        {
                            throw new ArgumentException("when item status is indeterminate and all child is loaded, only part of items select.");
                        }

                        // all load select items.
                    }
                    else
                    {
                        if (itemUnloadStatus == SelectedItemStatus.UnSelected)
                            isLoadUnloadChildren = false;
                        else if (itemUnloadStatus == SelectedItemStatus.Selected)
                            isLoadUnloadChildren = true;
                        else
                            throw new ArgumentException("when item status is indeterminate and part child is loaded, the unload status must be selected.");

                    }
                    break;
                case SelectedItemStatus.UnSelected:
                    if (!isNoLoadedChildSelected)
                        throw new ArgumentException("when item status is unselected, all loaded item must not select.");
                    else if (itemUnloadStatus != SelectedItemStatus.UnSelected)
                        throw new ArgumentException("when item status is unselected, all unloaded item must not select.");
                    else
                        isEnd = true;
                    break;
                default:
                    throw new NotSupportedException(string.Format("Don't support the selecte statuls {0}", item.Status));
            }
        }
예제 #8
0
        public void RestoreSelectItem(LoadedTreeItem item, IRestoreDestinationEx restoreDestination, Stack<IItemBase> dealItemStack)
        {
            bool isEnd = false;
            bool isLoadUnloadChildren = false;

            CheckLoadedTreeItem(item, out isLoadUnloadChildren, out isEnd);
            if (isEnd)
                return;

            List<IMailboxData> childMailboxes = null;
            List<IFolderData> childFolders = null;
            List<IItemData> childMailItems = null;
            if (isLoadUnloadChildren)
            {
                GetUnloadedChild(item, out childMailboxes, out childFolders, out childMailItems);
            }

            dealItemStack.Push(item);
            // deal self.
            if (item.Status == (byte)SelectedItemStatus.Selected)
            {
                switch (item.ItemKind)
                {
                    case ItemKind.Organization:
                        RestoreOrganizationToDestination(CurrentRestoreCatalogJob.Organization, restoreDestination, dealItemStack);
                        break;
                    case ItemKind.Mailbox:
                        RestoreMailboxToDestination(item.DisplayName, restoreDestination, dealItemStack);
                        break;
                    case ItemKind.Folder:
                        RestoreFolderToDestination(item.DisplayName, restoreDestination, dealItemStack);
                        break;
                    case ItemKind.Item:
                        RestoreItemToDestination(item.Id, item.DisplayName, restoreDestination, dealItemStack);
                        break;
                }
            }

            // deal loaded children.
            if (item.LoadedChildren != null)
            {
                foreach (var loadChildItem in item.LoadedChildren)
                    RestoreSelectItem(loadChildItem, restoreDestination, dealItemStack);
            }

            // deal unloaded children.
            if (isLoadUnloadChildren)
                RestoreUnloadedChildren(item, childMailboxes, childFolders, childMailItems, restoreDestination, dealItemStack);

            dealItemStack.Pop();
        }
예제 #9
0
 public void Restore(LoadedTreeItem item)
 {
     RestoreStart();
     item.DisplayName = CurrentRestoreCatalogJob.Organization;
     Stack<IItemBase> stacks = new Stack<IItemBase>(8);
     RestoreSelectItem(item, Destination, stacks);
     RestoreEnd();
 }
예제 #10
0
 //public IServiceContext GetServiceContext()
 //{
 //    return ServiceContext.ContextInstance;
 //}
 public IFilterItem NewFilterItemBySelectTree(LoadedTreeItem orgSelectItem)
 {
     return (IFilterItem)CreateType<IFilterItem>(DataProtectImplAssembly, orgSelectItem);
 }