private ActionResult Execute(string key, string opt, string ext, bool download, bool printing) { if (key.IsEmptyOrNull()) { throw new ArgumentNullException("reportKey"); } var reportInfo = ReportRegistry.GetReport(key); if (reportInfo == null) { throw new ArgumentOutOfRangeException("reportKey"); } if (reportInfo.Permission != null) { Authorization.ValidatePermission(reportInfo.Permission); } var report = (IReport)JsonConvert.DeserializeObject(opt.TrimToNull() ?? "{}", reportInfo.Type, JsonSettings.Tolerant); byte[] renderedBytes = null; if (report is IDataOnlyReport) { ext = "xlsx"; renderedBytes = new ReportRepository().Render((IDataOnlyReport)report); } else { ext = (ext ?? "html").ToLowerInvariant(); if (ext == "htm" || ext == "html") { var result = RenderAsHtml(report, download, printing, ref renderedBytes); if (!download) { return(result); } } else if (ext == "pdf") { renderedBytes = RenderAsPdf(report, key, opt); } else { throw new ArgumentOutOfRangeException("ext"); } } return(PrepareFileResult(report, ext, download, renderedBytes, reportInfo)); }
private ActionResult Execute(string key, string opt, string ext, bool download, bool printing) { if (key.IsEmptyOrNull()) throw new ArgumentNullException("reportKey"); var reportInfo = ReportRegistry.GetReport(key); if (reportInfo == null) throw new ArgumentOutOfRangeException("reportKey"); if (reportInfo.Permission != null) { if (reportInfo.Permission == "") Authorization.ValidateLoggedIn(); else Authorization.ValidatePermission(reportInfo.Permission); } var report = (IReport)JsonConvert.DeserializeObject(opt.TrimToNull() ?? "{}", reportInfo.Type, JsonSettings.Tolerant); byte[] renderedBytes = null; if (report is IDataOnlyReport) { ext = "xlsx"; renderedBytes = new ReportRepository().Render((IDataOnlyReport)report); } else { ext = (ext ?? "html").ToLowerInvariant(); if (ext == "htm" || ext == "html") { var result = RenderAsHtml(report, download, printing, ref renderedBytes); if (!download) return result; } else if (ext == "pdf") { renderedBytes = RenderAsPdf(report, key, opt); } else throw new ArgumentOutOfRangeException("ext"); } return PrepareFileResult(report, ext, download, renderedBytes, reportInfo); }