public ActionResult InitExecuteReportViewOutput(string report) { try { if (!CheckAuthentication()) { return(Content(_loginContent)); } string filePath = Repository.ReportsFolder + report; if (System.IO.File.Exists(filePath)) { SecurityFolder securityFolder = WebUser.FindSecurityFolder(Path.GetDirectoryName(filePath)); if (securityFolder == null) { throw new Exception("Error: this folder is not published"); } if (securityFolder.PublicationType != PublicationType.ExecuteOutput) { throw new Exception("Error: outputs cannot be executed"); } Repository repository = Repository; Report reportToExecute = Report.LoadFromFile(filePath, repository); reportToExecute.WebExecutionGUID = Guid.NewGuid().ToString(); reportToExecute.SecurityContext = WebUser; return(Content(RenderRazorViewToString("ExecuteViewOutput", reportToExecute))); } } catch (Exception ex) { return(HandleException(ex)); } return(Content(string.Format("Error: Report file not found.\r\n{0}", report))); }
SWIFolder getFolder(string path) { checkSWIAuthentication(); path = FileHelper.ConvertOSFilePath(path); if (string.IsNullOrEmpty(path)) { throw new Exception("Error: path must be supplied"); } if (path.Contains(".." + Path.DirectorySeparatorChar.ToString())) { throw new Exception("Error: invalid path"); } SWIFolder result = new SWIFolder(); result.path = path; result.right = 0; result.sql = WebUser.SqlModel; result.SetFullPath(getFullPath(path)); if (result.IsPersonal) { //Personal if (WebUser.PersonalFolderRight == PersonalFolderRight.None) { throw new Exception("Error: this user has no personal folder"); } result.SetManageFlag(true, true, result.FinalPath == ""); result.expand = false; string prefix = Repository.GetPersonalFolderName(WebUser); result.name = (result.FinalPath == "" ? prefix : Path.GetFileName(result.FinalPath)); result.fullname = prefix + (result.FinalPath == "" ? Path.DirectorySeparatorChar.ToString() : "") + result.FinalPath; result.right = (int)FolderRight.Edit; result.files = (WebUser.PersonalFolderRight == PersonalFolderRight.Files); } else { result.name = (result.FinalPath == Path.DirectorySeparatorChar.ToString() ? Translate("Reports") : Repository.TranslateFolderName(path)); result.fullname = Translate("Reports") + Repository.TranslateFolderPath(result.FinalPath); SecurityFolder securityFolder = WebUser.FindSecurityFolder(path); if (securityFolder != null) { result.SetManageFlag(securityFolder.UseSubFolders, securityFolder.ManageFolder, securityFolder.IsDefined); result.expand = securityFolder.ExpandSubFolders; result.right = (int)securityFolder.FolderRight; result.files = securityFolder.FilesOnly; } } return(result); }
SWIFolder getFolder(string path) { checkSWIAuthentication(); if (string.IsNullOrEmpty(path)) { throw new Exception("Error: path must be supplied"); } if (path.Contains("..\\")) { throw new Exception("Error: invalid path"); } SWIFolder result = new SWIFolder(); result.path = path; result.right = 0; result.SetFullPath(getFullPath(path)); if (result.IsPersonal) { //Personal if (!WebUser.HasPersonalFolder) { throw new Exception("Error: this user has no personal folder"); } result.SetManageFlag(true, true, result.Path == ""); result.expand = false; string prefix = Repository.GetPersonalFolderName(WebUser); result.name = (result.Path == "" ? prefix : Path.GetFileName(result.Path)); result.fullname = prefix + (result.Path == "" ? "\\" : "") + result.Path; result.right = (int)FolderRight.Edit; } else { result.name = (result.Path == "\\" ? Repository.TranslateWeb("Reports") : Repository.TranslateFolderName(path)); result.fullname = Repository.TranslateWeb("Reports") + Repository.TranslateFolderPath(result.Path); SecurityFolder securityFolder = WebUser.FindSecurityFolder(path); if (securityFolder != null) { result.SetManageFlag(securityFolder.UseSubFolders, securityFolder.ManageFolder, securityFolder.IsDefined); result.expand = securityFolder.ExpandSubFolders; result.right = (int)securityFolder.FolderRight; } } return(result); }
public ActionResult ViewFile(string path) { try { if (!CheckAuthentication()) { return(Content(_loginContent)); } string tempFolder = Path.Combine(Path.Combine(Request.PhysicalApplicationPath, "temp")); FileHelper.PurgeTempDirectory(tempFolder); string filePath = Repository.ReportsFolder + path; if (System.IO.File.Exists(filePath)) { SecurityFolder securityFolder = WebUser.FindSecurityFolder(Path.GetDirectoryName(filePath)); if (securityFolder == null) { throw new Exception("Error: this folder is not published"); } filePath = Report.CopySealFile(filePath, tempFolder); int index = Request.Url.OriginalString.ToLower().IndexOf("viewfile"); if (index == -1) { throw new Exception("Invalid URL"); } string url = Request.Url.OriginalString.Substring(0, index) + "temp/" + Path.GetFileName(filePath); return(Redirect(url)); } } catch (Exception ex) { return(HandleException(ex)); } return(Content(string.Format("Error: File not found.\r\n{0}", path))); }
public ActionResult InitExecuteReport(string path, string viewGUID, string outputGUID) { try { if (!CheckAuthentication()) { return(Content(_loginContent)); } string filePath = Repository.ReportsFolder + path; if (System.IO.File.Exists(filePath)) { SecurityFolder securityFolder = WebUser.FindSecurityFolder(Path.GetDirectoryName(filePath)); if (securityFolder == null) { throw new Exception("Error: this folder is not published"); } if (!string.IsNullOrEmpty(outputGUID) || !string.IsNullOrEmpty(viewGUID)) { if (securityFolder.PublicationType != PublicationType.ExecuteOutput) { throw new Exception("Error: outputs cannot be executed"); } } Repository repository = Repository.CreateFast(); Report reportToExecute = Report.LoadFromFile(filePath, repository); reportToExecute.WebExecutionGUID = Guid.NewGuid().ToString(); reportToExecute.ExecutionContext = ReportExecutionContext.WebReport; reportToExecute.SecurityContext = WebUser; reportToExecute.CurrentViewGUID = reportToExecute.ViewGUID; //execute to output if (!string.IsNullOrEmpty(outputGUID)) { reportToExecute.OutputToExecute = reportToExecute.Outputs.FirstOrDefault(i => i.GUID == outputGUID); reportToExecute.ExecutionContext = ReportExecutionContext.WebOutput; if (reportToExecute.OutputToExecute != null) { reportToExecute.CurrentViewGUID = reportToExecute.OutputToExecute.ViewGUID; } } //execute with custom view if (!string.IsNullOrEmpty(viewGUID)) { reportToExecute.CurrentViewGUID = viewGUID; } ReportExecution execution = new ReportExecution() { Report = reportToExecute }; Session[reportToExecute.WebExecutionGUID] = execution; int index = Request.Url.OriginalString.ToLower().IndexOf("initexecutereport"); if (index == -1) { throw new Exception("Invalid URL"); } reportToExecute.WebUrl = Request.Url.OriginalString.Substring(0, index); repository.WebPublishFolder = Path.Combine(Request.PhysicalApplicationPath, "temp"); repository.WebApplicationPath = Path.Combine(Request.PhysicalApplicationPath, "bin"); if (!Directory.Exists(repository.WebPublishFolder)) { Directory.CreateDirectory(repository.WebPublishFolder); } FileHelper.PurgeTempDirectory(repository.WebPublishFolder); reportToExecute.InitForExecution(); execution.RenderHTMLDisplayForViewer(); return(Redirect(reportToExecute.WebTempUrl + Path.GetFileName(execution.Report.HTMLDisplayFilePath))); } } catch (Exception ex) { return(HandleException(ex)); } return(Content(string.Format("Error: Report file not found.\r\n{0}", path))); }
public ActionResult Detail(string folder) { ActionResult result; try { CheckAuthentication(); if (string.IsNullOrEmpty(folder)) { folder = Session[SessionLastFolder] == null ? Repository.ReportsFolder : Session[SessionLastFolder] as string; } SecurityFolder securityFolder = WebUser.FindSecurityFolder(folder); if (securityFolder != null && !string.IsNullOrEmpty(securityFolder.DescriptionFile)) { string descFile = Path.Combine(folder, securityFolder.DescriptionFile); string descFileCSHTML = Path.Combine(folder, Path.GetFileNameWithoutExtension(securityFolder.DescriptionFile) + ".cshtml"); Session[SessionLastFolder] = folder; if (System.IO.File.Exists(descFileCSHTML)) { //Assume that it is a view...try to copy it in the Views\Home folder string destFile = Path.Combine(Path.Combine(Request.PhysicalApplicationPath, "Views\\Home"), Path.GetFileName(descFileCSHTML)); try { if (!System.IO.File.Exists(destFile)) { System.IO.File.Copy(descFileCSHTML, destFile, false); } } catch { } return(View(Path.GetFileNameWithoutExtension(destFile), (object)folder)); } else if (System.IO.File.Exists(descFile)) { return(new FilePathResult(descFile, "text/html")); } } FolderDetailModel model = new FolderDetailModel() { FolderPath = folder, Repository = Repository, User = WebUser }; if (folder == "*") { model.IsRecursive = true; model.FolderPath = Repository.ReportsFolder; } else { Session[SessionLastFolder] = folder; } result = View(model); } catch (Exception ex) { return(HandleException(ex)); } return(result); }