This commit is contained in:
2020-09-17 18:16:42 +00:00
parent 352208e555
commit fd96300c9d
3 changed files with 21 additions and 26 deletions

View File

@@ -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<dynamic>($"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<string>(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