From 1bc2c29619c6d0e08db081bb4dbf1067b1401ba9 Mon Sep 17 00:00:00 2001 From: John Cardinal Date: Wed, 9 Sep 2020 21:38:43 +0000 Subject: [PATCH] --- .vscode/launch.json | 2 +- .../AyaNova/Controllers/ReportController.cs | 13 +-- server/AyaNova/biz/ReportBiz.cs | 101 ------------------ 3 files changed, 5 insertions(+), 111 deletions(-) diff --git a/.vscode/launch.json b/.vscode/launch.json index 4044e905..ac7626ce 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -52,7 +52,7 @@ "AYANOVA_FOLDER_USER_FILES": "c:\\temp\\RavenTestData\\userfiles", "AYANOVA_FOLDER_BACKUP_FILES": "c:\\temp\\RavenTestData\\backupfiles", "AYANOVA_FOLDER_TEMPORARY_SERVER_FILES": "c:\\temp\\RavenTestData\\tempfiles", - "AYANOVA_SERVER_TEST_MODE": "false", + "AYANOVA_SERVER_TEST_MODE": "true", "AYANOVA_SERVER_TEST_MODE_SEEDLEVEL": "small", "AYANOVA_SERVER_TEST_MODE_TZ_OFFSET": "-7", "AYANOVA_BACKUP_PG_DUMP_PATH": "C:\\data\\code\\PostgreSQLPortable_12.0\\App\\PgSQL\\bin\\" diff --git a/server/AyaNova/Controllers/ReportController.cs b/server/AyaNova/Controllers/ReportController.cs index aa9f99a6..8e7ddf5f 100644 --- a/server/AyaNova/Controllers/ReportController.cs +++ b/server/AyaNova/Controllers/ReportController.cs @@ -233,14 +233,9 @@ namespace AyaNova.Api.Controllers } catch (System.Exception ex) { - //Don't send the full stack trace, just the initial error message from the javascript eval - // "Evaluation failed: ReferenceError: reportdata is not defined\n at ayPrepareData (:5:17)\n at ayPreRender (C:\\data\\code\\raven\\server\\AyaNova\\resource\\rpt\\ay-report.js:13:12)\n at __puppeteer_evaluation_script__:10:25" - var v = ex.Message; - // int positionOfNewLine = v.IndexOf("\n at"); - // if (positionOfNewLine >= 0) - // v = v.Substring(0, positionOfNewLine); - - return BadRequest(new ApiErrorResponse(ApiErrorCode.INVALID_OPERATION, null, v)); + //The Javascript evaluation stack trace can be in the message making it long and internalized, + //however the info is useful as it can indicate exactly which function failed etc so sending it all back is best + return BadRequest(new ApiErrorResponse(ApiErrorCode.INVALID_OPERATION, null, ex.Message)); } } @@ -355,7 +350,7 @@ namespace AyaNova.Api.Controllers //fileData in JSON stringify format FileData = Newtonsoft.Json.JsonConvert.DeserializeObject>(uploadFormData.FormFieldData["FileData"].ToString()); - + //Instantiate the business object handler ReportBiz biz = ReportBiz.GetBiz(ct, HttpContext); diff --git a/server/AyaNova/biz/ReportBiz.cs b/server/AyaNova/biz/ReportBiz.cs index e37ef0de..d7ef5a2e 100644 --- a/server/AyaNova/biz/ReportBiz.cs +++ b/server/AyaNova/biz/ReportBiz.cs @@ -382,13 +382,6 @@ namespace AyaNova.Biz //add Marked for markdown processing await page.AddScriptTagAsync(new AddTagOptions() { Path = Path.Combine(ReportJSFolderPath, "ay-md.js") }); - //Wait, might not need luxon, it appears I only use that for relative date calculations - //Luxon https://moment.github.io/luxon/ - // await page.AddScriptTagAsync(new AddTagOptions() { Path = Path.Combine(ReportJSFolderPath, "ay-lux.js") }); - - - //VueCurrencyInput - base currency handling lib whatever that is - //add stock helpers await page.AddScriptTagAsync(new AddTagOptions() { Path = Path.Combine(ReportJSFolderPath, "ay-report.js") }); @@ -470,104 +463,10 @@ namespace AyaNova.Biz // var v=await page.GetContentAsync(); throw ex; } - } } - // public async Task RenderReport(RenderReportParameter reportParam, string apiUrl, AuthorizationRoles overrideRoles = AuthorizationRoles.NoRole) - // { - // var log = AyaNova.Util.ApplicationLogging.CreateLogger("ReportBiz::RenderReport"); - - // //get report, vet security, see what we need before init in case of issue - // var report = await ct.Report.FirstOrDefaultAsync(z => z.Id == reportParam.ReportId); - // if (report == null) - // { - // AddError(ApiErrorCode.NOT_FOUND, "id"); - // return null; - // } - - // AuthorizationRoles effectiveRoles = CurrentUserRoles; - // if (overrideRoles != AuthorizationRoles.NoRole) - // effectiveRoles = overrideRoles; - - - // if (!AyaNova.Api.ControllerHelpers.Authorized.HasReadFullRole(effectiveRoles, report.ObjectType)) - // { - // AddError(ApiErrorCode.NOT_AUTHORIZED, null, $"User not authorized for {report.ObjectType} type object"); - // return null; - // } - - - // //Get data - // var ReportData = await GetReportData(new ObjectReportDataParameter() { ObjectType = report.ObjectType, SelectedRowIds = reportParam.SelectedRowIds, DataListKey = reportParam.DataListKey, ListView = reportParam.ListView }); - - // //initialization - // log.LogDebug("Initializing report system"); - // var ReportJSFolderPath = Path.Combine(ServerBootConfig.AYANOVA_CONTENT_ROOT_PATH, "resource", "rpt"); - // var lo = new LaunchOptions { Headless = true }; - // bool isWindows = System.Runtime.InteropServices.RuntimeInformation.IsOSPlatform(System.Runtime.InteropServices.OSPlatform.Windows); - // if (!isWindows) - // { - // log.LogDebug($"Not Windows: setting executable path for chrome to expected '/usr/bin/chromium-browser'"); - // lo.ExecutablePath = "/usr/bin/chromium-browser";//this is the default path for docker based alpine dist, but maybe not others, need to make a config setting likely - // lo.Args = new string[] { "--no-sandbox" }; - // } - // else - // { - // log.LogDebug($"Windows: Calling browserFetcher download async now:"); - // await new BrowserFetcher().DownloadAsync(BrowserFetcher.DefaultRevision); - // } - - - // log.LogDebug($"Launching headless Chrome now:"); - // using (var browser = await Puppeteer.LaunchAsync(lo)) - // using (var page = await browser.NewPageAsync()) - // { - // log.LogDebug($"Preparing page: adding base reporting scripts to page"); - - // //Add Handlebars JS for compiling and presenting - // await page.AddScriptTagAsync(new AddTagOptions() { Path = Path.Combine(ReportJSFolderPath, "ay-hb.js") }); - - // //add Marked for markdown processing - // await page.AddScriptTagAsync(new AddTagOptions() { Path = Path.Combine(ReportJSFolderPath, "ay-md.js") }); - - // //add stock helpers - // await page.AddScriptTagAsync(new AddTagOptions() { Path = Path.Combine(ReportJSFolderPath, "ay-report.js") }); - - // //execute to add to handlebars - // await page.EvaluateExpressionAsync("ayRegisterHelpers();"); - - // log.LogDebug($"Preparing page: adding this report's scripts, style and templates to page"); - - // //TODO: CUSTOM HELPERS - - // //compile and run handlebars template - // var compileScript = $"let reportData=ayPreRender({ReportData});Handlebars.compile({report.Template})(reportData);"; - // var resultHTML = await page.EvaluateExpressionAsync(compileScript); - - // //render report as HTML - // await page.SetContentAsync(resultHTML); - - // //add style (after page or it won't work) - // if (!string.IsNullOrWhiteSpace(report.Style)) - // { - // await page.AddStyleTagAsync(new AddTagOptions { Content = report.Style }); - // } - - // //If need the generated page content - // //var pagecontent = await page.GetContentAsync(); - - // //render to pdf and return - // var pdfBuffer = await page.PdfDataAsync(); - // log.LogDebug($"returning results now:"); - // return new RenderedReport() { MimeType = "application/pdf", RenderedOutput = pdfBuffer }; - - // } - // } - - - //////////////////////////////////////////////////////////////////////////////////////////////// //JOB / OPERATIONS //