public JsonResult GetFolderChildren(String ParentId = "", Int32 Depth = 1, bool includeParent = false) { ////If we are requesting the root node then return an empty list. This should only happen on systems with 0 folders. if (ParentId == ROOTNODE) { return(Result(new List <JSTreeData>(), null, JsonRequestBehavior.AllowGet)); } Guid?rootNodeId = String.IsNullOrWhiteSpace(ParentId) ? null : new Guid?(new Guid(ParentId)); var clientV2 = SvcBldr.FolderV2(); var foldRecursionArgs = new FolderRecursionArgs { ParentId = rootNodeId, Depth = Depth }; var srChildren = clientV2.GetChildren(foldRecursionArgs); if (srChildren.Error != null) { return(Result(null, srChildren.Error)); } var children = srChildren.Result; var subNodes = JSTreeFormat.ConvertToJSTreeFormat(children); if (rootNodeId == null) // Is the Root Folder { var rootNode = new JSTreeData("Folders"); rootNode.children = subNodes; return(Result(rootNode, srChildren.Error, JsonRequestBehavior.AllowGet)); } else { if (includeParent) { var srRoot = clientV2.Get(rootNodeId.Value); if (srRoot.Error != null) { return(Result(null, srRoot.Error, JsonRequestBehavior.AllowGet)); } if (srRoot.Result != null) { var rootNode = new JSTreeData(srRoot.Result.Title); rootNode.children = subNodes; rootNode.attr.Id = rootNodeId.ToString(); return(Result(rootNode, srChildren.Error, JsonRequestBehavior.AllowGet)); } else { return(Result(null, ExceptionsML.GetExceptionML(new Exception(Constants.i18n("parentFolderNotFound"))), JsonRequestBehavior.AllowGet)); } } else { return(Result(subNodes, srChildren.Error, JsonRequestBehavior.AllowGet)); } } }
private ServiceReturn GetFolderDocumentsByPath(string folderPath, int start, int count, string sortColumn) { // Remove trailing / so only folder name is passed if (folderPath.LastIndexOf('/') == folderPath.Length - 1) { folderPath = folderPath.Remove(folderPath.LastIndexOf('/')); } ServiceReturn result = new ServiceReturn(); ExceptionsML bizEx = null; if (count == 0) { count = 1000; } var folderClient = SvcBldr.FolderV2(); // If the folder is the root, get all children if (folderPath == Constants.i18n("folders")) { // if the root, pass in an empty path (null works too) folderPath = string.Empty; } else { // If the folder is below the root remove the root from the path string[] foldBelowRoot = folderPath.Split('/'); var len = foldBelowRoot.Length; folderPath = string.Join("/", foldBelowRoot, 1, len - 1); } var sr = folderClient.SearchByPath(new SearchByPathPackage { EntityPath = folderPath, Count = count, SortColumn = sortColumn, Start = start }); if (sr.Error != null) { result.BizEx = bizEx; return(result); } if (sr.Result == null) { result.BizEx = new ExceptionsML() { Message = Constants.i18n("folderDoesNotExist") }; return(result); } result.Result = sr.Result; return(result); }
public JsonResult RemoveItems(Guid[] inboxIds, Guid[] folderIds) { var srDelete = new SR <Boolean>(); srDelete.Error = null; if (inboxIds != null && inboxIds.Length > 0) { var inbox = SvcBldr.InboxV2(); srDelete = inbox.Delete(new InboxDeletePackage { DeleteDocuments = false, InboxIds = inboxIds }); } if (srDelete.Error == null && folderIds != null && folderIds.Length > 0) { var folder = SvcBldr.FolderV2(); srDelete = folder.Delete(new FolderDeletePackage { DeleteDocuments = false, FolderIds = folderIds }); } return(Result(null, srDelete.Error)); }
public JsonResult DeleteItems(Guid[] documentIds, Guid[] inboxIds, Guid[] folderIds, bool overrideErrors = false) { ExceptionsML bizEx = null; var options = SvcBldr.Options; if (overrideErrors) { SvcBldr.Options = ServiceRequestOptions.OverrideErrors; } if (inboxIds != null && inboxIds.Length != 0) { var inbox = SvcBldr.InboxV2(); var r = inbox.Delete(new InboxDeletePackage { DeleteDocuments = true, InboxIds = inboxIds }); if (r.Error != null) { if (r.Error.Type == new OverridableException().GetType().ToString()) { if (bizEx == null) { bizEx = r.Error; } else { bizEx.Message += r.Error.Message; } } else { return(Result(null, r.Error)); } } } if (folderIds != null && folderIds.Length != 0) { var folder = SvcBldr.FolderV2(); var r = folder.Delete(new FolderDeletePackage { DeleteDocuments = true, FolderIds = folderIds }); if (r.Error != null) { if (r.Error.Type == new OverridableException().GetType().ToString()) { if (bizEx == null) { bizEx = r.Error; } else { bizEx.Message += r.Error.Message; } } else { return(Result(null, r.Error)); } } } if (bizEx != null) { bizEx.Message += Environment.NewLine + Constants.i18n("continueYesNo"); return(Result(null, bizEx)); } if (documentIds != null && documentIds.Length != 0) { var client = SvcBldr.DocumentV2(); var r = client.SoftDelete(documentIds); if (r.Error != null) { return(Result(null, r.Error)); } } SvcBldr.Options = ServiceRequestOptions.NotSet; return(Result(null, null)); }