public ActionResult GetFolderStructure() { ProjectRequestBase request = ApiRequestBase.ParseRequest <ProjectRequestBase>(this); if (!request.Validate(out Project p, out ApiResponseBase error)) { return(Json(error)); } GetFolderStructureResponse response = new GetFolderStructureResponse(); using (DB db = new DB(p.Name)) response.root = db.GetFolderStructure(); return(Json(response)); }
private void GetFolderStructureFinished(object sender, get_account_treeCompletedEventArgs e) { object[] state = (object[])e.UserState; RetrieveFolderStructureOptions retrieveOptions = (RetrieveFolderStructureOptions)state[1]; OperationFinished<GetFolderStructureResponse> getFolderStructureCompleted = (OperationFinished<GetFolderStructureResponse>)state[0]; GetFolderStructureResponse response; if (e.Error != null) { response = new GetFolderStructureResponse { Status = GetAccountTreeStatus.Failed, UserState = state[2], Error = e.Error }; } else { response = new GetFolderStructureResponse { Status = StatusMessageParser.ParseGetAccountTreeStatus(e.Result), UserState = state[2] }; if (response.Status == GetAccountTreeStatus.Successful) { byte[] folderInfoXml = null; string folderInfo = null; if (!retrieveOptions.Contains(RetrieveFolderStructureOptions.NoZip)) { folderInfoXml = Unzip(e.tree); } if (folderInfoXml != null) { folderInfo = Encoding.ASCII.GetString(folderInfoXml); } Folder folder = ParseFolderStructureXmlMessage(folderInfo); response.Folder = folder; } else if (response.Status == GetAccountTreeStatus.Unknown) { response.Error = new UnknownOperationStatusException(e.Result); } } getFolderStructureCompleted(response); }