public ActionResult SWIGetReportDetail(string path) { try { SWIFolder folder = getParentFolder(path); if (folder.right == 0) { throw new Exception("Error: no right on this folder"); } string newPath = getFullPath(path); if (!System.IO.File.Exists(newPath)) { throw new Exception("Report path not found"); } Repository repository = Repository; Report report = Report.LoadFromFile(newPath, repository); SWIReportDetail result = new SWIReportDetail(); result.views = (from i in report.Views select new SWIView() { guid = i.GUID, name = i.Name, displayName = report.TranslateViewName(i.Name) }).ToArray(); result.outputs = (from i in report.Outputs select new SWIOutput() { guid = i.GUID, name = i.Name, displayName = report.TranslateOutputName(i.Name) }).ToArray(); return(Json(result)); } catch (Exception ex) { return(handleSWIException(ex)); } }
public ActionResult SWIGetReportDetail(string path) { try { SWIFolder folder = getParentFolder(path); if (folder.right == 0) { throw new Exception("Error: no right on this folder"); } string newPath = getFullPath(path); if (!System.IO.File.Exists(newPath)) { throw new Exception("Report path not found"); } Repository repository = Repository; Report report = Report.LoadFromFile(newPath, repository); SWIReportDetail result = new SWIReportDetail(); result.views = (from i in report.Views.Where(i => i.PublicExec && i.GUID != report.ViewGUID) select new SWIView() { guid = i.GUID, name = i.Name, displayName = report.TranslateViewName(i.Name) }).ToArray(); result.outputs = ((FolderRight)folder.right >= FolderRight.ExecuteReportOuput) ? (from i in report.Outputs.Where(j => j.PublicExec || (!j.PublicExec && j.UserName == WebUser.Name)) select new SWIOutput() { guid = i.GUID, name = i.Name, displayName = report.TranslateOutputName(i.Name) }).ToArray() : new SWIOutput[] { }; return(Json(result)); } catch (Exception ex) { return(HandleSWIException(ex)); } }
/// <summary> /// Returns the views and outputs of a report. /// </summary> public ActionResult SWIGetReportDetail(string path) { writeDebug("SWIGetReportDetail"); try { SWIFolder folder = getParentFolder(path); if (folder.right == 0) { throw new Exception("Error: no right on this folder"); } var file = getFileDetail(path); if (file.right == 0) { throw new Exception("Error: no right on this report or file"); } string newPath = getFullPath(path); if (!System.IO.File.Exists(newPath)) { throw new Exception("Report path not found"); } Repository repository = Repository; Report report = Report.LoadFromFile(newPath, repository, false); SWIReportDetail result = new SWIReportDetail(); result.views = (from i in report.Views.Where(i => i.WebExec && i.GUID != report.ViewGUID) select new SWIView() { guid = i.GUID, name = i.Name, displayname = report.TranslateViewName(i.Name) }).ToList(); result.outputs = ((FolderRight)folder.right >= FolderRight.ExecuteReportOuput) ? (from i in report.Outputs.Where(j => j.PublicExec || string.IsNullOrEmpty(j.UserName) || (!j.PublicExec && j.UserName == WebUser.Name)) select new SWIOutput() { guid = i.GUID, name = i.Name, displayname = report.TranslateOutputName(i.Name) }).ToList() : new List <SWIOutput>(); if (result.views.Count == 0 && result.outputs.Count == 0) { result.views = (from i in report.Views.Where(i => i.WebExec) select new SWIView() { guid = i.GUID, name = i.Name, displayname = report.TranslateViewName(i.Name) }).ToList(); } return(Json(result, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { return(HandleSWIException(ex)); } }