This commit is contained in:
@@ -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
|
//Get data
|
||||||
var ReportData = await GetReportData(new ReportDataParameter() { ObjectType = report.ObjectType, SelectedRowIds = reportParam.SelectedRowIds, DataListKey = reportParam.DataListKey, ListView = reportParam.ListView });
|
var ReportData = await GetReportData(new ReportDataParameter() { ObjectType = report.ObjectType, SelectedRowIds = reportParam.SelectedRowIds, DataListKey = reportParam.DataListKey, ListView = reportParam.ListView });
|
||||||
|
|
||||||
@@ -475,18 +479,13 @@ namespace AyaNova.Biz
|
|||||||
var ReportDataObject = $"{{ ayReportData:{ReportData}, ayReportMetaData:{reportMeta}, ayClientMetaData:{clientMeta}, ayServerMetaData:{serverMeta} }}";
|
var ReportDataObject = $"{{ ayReportData:{ReportData}, ayReportMetaData:{reportMeta}, ayClientMetaData:{clientMeta}, ayServerMetaData:{serverMeta} }}";
|
||||||
log.LogDebug($"Calling ayPreRender...");
|
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
|
//PRE_RENDER WITH TIMEOUT
|
||||||
var w = new WaitForFunctionOptions() { Timeout = 10000 };
|
//Note: defaults to 30 seconds, going to leave that in as the default
|
||||||
//var test = await page.WaitForExpressionAsync($"aytest()==true", w);
|
//in future may need to adjust but would probably do it in the context of a setting of some kind
|
||||||
// var PreParedReportDataObject = await page.WaitForExpressionAsync($"ayPreRender({ReportDataObject})!=null", w);
|
await page.WaitForExpressionAsync($"ayPreRender({ReportDataObject})", WaitTimeout);
|
||||||
|
|
||||||
//new style, nothing to return, keeps data on page
|
|
||||||
await page.WaitForExpressionAsync($"ayPreRenderEx({ReportDataObject})", w);
|
|
||||||
|
|
||||||
//compile the template
|
//compile the template
|
||||||
|
//NOTE: TIMEOUT?
|
||||||
log.LogDebug($"Calling Handlebars.compile...");
|
log.LogDebug($"Calling Handlebars.compile...");
|
||||||
var compileScript = $"Handlebars.compile(`{report.Template}`)(PreParedReportDataObject);";
|
var compileScript = $"Handlebars.compile(`{report.Template}`)(PreParedReportDataObject);";
|
||||||
var compiledHTML = await page.EvaluateExpressionAsync<string>(compileScript);
|
var compiledHTML = await page.EvaluateExpressionAsync<string>(compileScript);
|
||||||
@@ -513,6 +512,10 @@ namespace AyaNova.Biz
|
|||||||
}
|
}
|
||||||
catch (System.Exception ex)
|
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:
|
//This is the error when a helper is used on the template but doesn't exist:
|
||||||
//Evaluation failed: d
|
//Evaluation failed: d
|
||||||
|
|||||||
@@ -1,27 +1,18 @@
|
|||||||
|
let PreParedReportDataObject = null;
|
||||||
|
|
||||||
//////////////////////////////////
|
//////////////////////////////////
|
||||||
// Pre render function
|
// Pre render function
|
||||||
//
|
//
|
||||||
async function ayPreRender(ayAllData) {
|
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") {
|
if (typeof ayPrepareData === "function") {
|
||||||
PreParedReportDataObject = await ayPrepareData(ayAllData);
|
PreParedReportDataObject = await ayPrepareData(ayAllData);
|
||||||
} else {
|
} else {
|
||||||
PreParedReportDataObject = ayAllData;
|
PreParedReportDataObject = ayAllData;
|
||||||
}
|
}
|
||||||
DataReady=true;
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////////////////
|
///////////////////////////////////////
|
||||||
// Set our stock handlebars helpers
|
// Set our stock handlebars helpers
|
||||||
//
|
//
|
||||||
|
|||||||
@@ -11,10 +11,11 @@ namespace AyaNova.Util
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
internal static class ServerBootConfig
|
internal static class ServerBootConfig
|
||||||
{
|
{
|
||||||
//#################################################
|
//############################################################################################################
|
||||||
//STATIC HARD CODED DEFAULTS NOT SET THROUGH CONFIG
|
//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
|
//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)
|
#if (DEBUG)
|
||||||
|
|||||||
Reference in New Issue
Block a user