diff --git a/server/AyaNova/biz/ReportBiz.cs b/server/AyaNova/biz/ReportBiz.cs index b9b43b7c..ab9f2a32 100644 --- a/server/AyaNova/biz/ReportBiz.cs +++ b/server/AyaNova/biz/ReportBiz.cs @@ -355,6 +355,10 @@ namespace AyaNova.Biz } + //Default timeout for each operation of report generation + var WaitTimeout = new WaitForFunctionOptions() { Timeout = ServerBootConfig.REPORT_RENDERING_OPERATION_TIMEOUT }; + + //Get data var ReportData = await GetReportData(new ReportDataParameter() { ObjectType = report.ObjectType, SelectedRowIds = reportParam.SelectedRowIds, DataListKey = reportParam.DataListKey, ListView = reportParam.ListView }); @@ -383,7 +387,7 @@ namespace AyaNova.Biz { try { - + log.LogDebug($"Preparing page: adding base reporting scripts to page"); @@ -475,18 +479,13 @@ namespace AyaNova.Biz var ReportDataObject = $"{{ ayReportData:{ReportData}, ayReportMetaData:{reportMeta}, ayClientMetaData:{clientMeta}, ayServerMetaData:{serverMeta} }}"; log.LogDebug($"Calling ayPreRender..."); - //PRE-RENDER ORIGINAL WAY - // var PreParedReportDataObject = await page.EvaluateExpressionAsync($"ayPreRender({ReportDataObject});");//note ayPreRender is async but dont' use await to call it as the EvaluateExpressionAsync function knows how to handle that already - //PRE_RENDER WITH TIMEOUT - var w = new WaitForFunctionOptions() { Timeout = 10000 }; - //var test = await page.WaitForExpressionAsync($"aytest()==true", w); - // var PreParedReportDataObject = await page.WaitForExpressionAsync($"ayPreRender({ReportDataObject})!=null", w); - - //new style, nothing to return, keeps data on page - await page.WaitForExpressionAsync($"ayPreRenderEx({ReportDataObject})", w); + //Note: defaults to 30 seconds, going to leave that in as the default + //in future may need to adjust but would probably do it in the context of a setting of some kind + await page.WaitForExpressionAsync($"ayPreRender({ReportDataObject})", WaitTimeout); //compile the template + //NOTE: TIMEOUT? log.LogDebug($"Calling Handlebars.compile..."); var compileScript = $"Handlebars.compile(`{report.Template}`)(PreParedReportDataObject);"; var compiledHTML = await page.EvaluateExpressionAsync(compileScript); @@ -513,6 +512,10 @@ namespace AyaNova.Biz } catch (System.Exception ex) { + //NOTE: in future may need to kill the chromium process if it's found to be hanging around + //my preliminary thinking is to keep track of the browser.process.processid above and check if still present and zap if so + //maybe *from* the controller (return pid as a return property from here? Kill it if still hanging around) + //https://stackoverflow.com/questions/1642231/how-to-kill-a-c-sharp-process //This is the error when a helper is used on the template but doesn't exist: //Evaluation failed: d diff --git a/server/AyaNova/resource/rpt/ay-report.js b/server/AyaNova/resource/rpt/ay-report.js index 8a5d710c..dee04339 100644 --- a/server/AyaNova/resource/rpt/ay-report.js +++ b/server/AyaNova/resource/rpt/ay-report.js @@ -1,27 +1,18 @@ +let PreParedReportDataObject = null; + ////////////////////////////////// // Pre render function // async function ayPreRender(ayAllData) { - if (typeof ayPrepareData === "function") { - return await ayPrepareData(ayAllData); - } else { - return ayAllData; - } -} - -let PreParedReportDataObject = null; -let DataReady=false; - -async function ayPreRenderEx(ayAllData) { if (typeof ayPrepareData === "function") { PreParedReportDataObject = await ayPrepareData(ayAllData); } else { PreParedReportDataObject = ayAllData; - } - DataReady=true; + } return true; } + /////////////////////////////////////// // Set our stock handlebars helpers // diff --git a/server/AyaNova/util/ServerBootConfig.cs b/server/AyaNova/util/ServerBootConfig.cs index 7508f6a1..b3b8e4fd 100644 --- a/server/AyaNova/util/ServerBootConfig.cs +++ b/server/AyaNova/util/ServerBootConfig.cs @@ -11,10 +11,11 @@ namespace AyaNova.Util /// internal static class ServerBootConfig { - //################################################# + //############################################################################################################ //STATIC HARD CODED DEFAULTS NOT SET THROUGH CONFIG - internal const int FAILED_AUTH_DELAY = 3000; - //################################################## + internal const int FAILED_AUTH_DELAY = 3000;//ms + internal const int REPORT_RENDERING_OPERATION_TIMEOUT = 20000;//ms + //############################################################################################################ //Diagnostic static values used during development, may not be related to config at all, this is just a convenient class to put them in #if (DEBUG)