public ActionResult SWIGetFolders(string path) { try { if (WebUser == null || !WebUser.IsAuthenticated) throw new Exception("Error: user is not authenticated"); if (string.IsNullOrEmpty(path)) throw new Exception("Error: path must be supplied"); var folder = new SWIFolder() { path = path, name = Repository.TranslateFolderName(path) }; fillFolder(folder); return Json(folder); } catch (Exception ex) { return Json(new { error = ex.Message }); } }
void fillFolder(SWIFolder folder) { List<SWIFolder> subFolders = new List<SWIFolder>(); string folderPath = Repository.ReportsFolder + (folder.path == null ? "\\" : folder.path); foreach (string subFolder in Directory.GetDirectories(folderPath)) { SecurityFolder securityFolder = WebUser.FindSecurityFolder(subFolder); if (securityFolder == null && !WebUser.IsParentSecurityFolder(subFolder)) continue; var subFolderPath = folderPath = subFolder.Substring(Repository.ReportsFolder.Length); var sub = new SWIFolder() { path = subFolderPath, name = Repository.TranslateFolderName(subFolder) }; fillFolder(sub); subFolders.Add(sub); } folder.folders = subFolders.ToArray(); }