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

View File

@@ -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
//

View File

@@ -11,10 +11,11 @@ namespace AyaNova.Util
/// </summary>
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)