This commit is contained in:
2021-12-29 19:35:41 +00:00
parent 8684d20bac
commit 04062df1e1
7 changed files with 45 additions and 22 deletions

4
.vscode/launch.json vendored
View File

@@ -48,8 +48,8 @@
"AYANOVA_DATA_PATH": "c:\\temp\\ravendata",
"AYANOVA_USE_URLS": "http://*:7575;",
"AYANOVA_SERVER_TEST_MODE": "false",
//"AYANOVA_REPORT_RENDERING_TIMEOUT":"19",
"AYANOVA_SERVER_TEST_MODE_SEEDLEVEL": "small",
"AYANOVA_REPORT_RENDERING_TIMEOUT":"60",
"AYANOVA_SERVER_TEST_MODE_SEEDLEVEL": "large",
"AYANOVA_BACKUP_PG_DUMP_PATH": "C:\\data\\code\\postgres_14\\bin\\"
},
"sourceFileMap": {

View File

@@ -856,6 +856,8 @@ namespace AyaNova.Biz
ReportData.Add(jo);
}
}
vc.Clear();
oc.Clear();
return ReportData;
}

View File

@@ -832,6 +832,8 @@ namespace AyaNova.Biz
ReportData.Add(jo);
}
}
vc.Clear();
oc.Clear();
return ReportData;
}

View File

@@ -381,7 +381,7 @@ namespace AyaNova.Biz
AuthorizationRoles effectiveRoles = CurrentUserRoles;
if (!RequestIsCustomerWorkOrderReport && !AyaNova.Api.ControllerHelpers.Authorized.HasReadFullRole(effectiveRoles, report.AType))
{
log.LogDebug($"bail: user unauthorized");
@@ -490,7 +490,12 @@ namespace AyaNova.Biz
var ReportJSFolderPath = Path.Combine(ServerBootConfig.AYANOVA_CONTENT_ROOT_PATH, "resource", "rpt");
//Keep for debugging headfully
//var lo = new LaunchOptions { Headless = false };
var lo = new LaunchOptions { Headless = true };
if (!AutoDownloadChromium)
{
lo.ExecutablePath = ServerBootConfig.AYANOVA_REPORT_RENDER_BROWSER_PATH;
@@ -511,10 +516,7 @@ namespace AyaNova.Biz
*/
}
else
{
// #if (DEBUG)
// log.LogInformation($"DBG: ReportBiz::calling browserfetcher");
// #endif
{
log.LogDebug($"Windows: Calling browserFetcher download async now:");
await new BrowserFetcher().DownloadAsync(BrowserFetcher.DefaultChromiumRevision);
}
@@ -524,7 +526,13 @@ namespace AyaNova.Biz
//*** DANGER: --disable-dev-shm-usage will crash linux ayanova when it runs out of memory ****
//that was only suitable for dockerized scenario as it had an alt swap system
//var OriginalDefaultArgs = "--disable-dev-shm-usage --single-process --no-sandbox --disable-gpu --no-zygote ";
//Keep for debugging headfully
// var DefaultArgs = "--no-sandbox";
var DefaultArgs = "--headless --no-sandbox";
if (!string.IsNullOrWhiteSpace(ServerBootConfig.AYANOVA_REPORT_RENDER_BROWSER_PARAMS))
{
log.LogDebug($"AYANOVA_REPORT_RENDER_BROWSER_PARAMS will be used: {ServerBootConfig.AYANOVA_REPORT_RENDER_BROWSER_PARAMS}");
@@ -615,8 +623,8 @@ namespace AyaNova.Biz
if (!string.IsNullOrWhiteSpace(report.JsHelpers))
await page.AddScriptTagAsync(new AddTagOptions() { Content = report.JsHelpers });
if (!string.IsNullOrWhiteSpace(report.Style))
await page.AddStyleTagAsync(new AddTagOptions() { Content = report.Style });
// if (!string.IsNullOrWhiteSpace(report.Style))
// await page.AddStyleTagAsync(new AddTagOptions() { Content = report.Style });
log.LogDebug($"Preparing page: adding Client meta data");
@@ -682,17 +690,20 @@ namespace AyaNova.Biz
var compiledHTML = await page.EvaluateExpressionAsync<string>(compileScript);
if (!ReportRenderManager.KeepGoing(job.GId))
return;
//render report as HTML
log.LogDebug($"Setting page content to compiled HTML");
await page.SetContentAsync(compiledHTML);
//add style
// if (!string.IsNullOrWhiteSpace(report.Style))
// {
// log.LogDebug($"Adding report template Style CSS");
// await page.AddStyleTagAsync(new AddTagOptions { Content = report.Style });
// }
// log.LogInformation(report.Style);
// log.LogInformation(compiledHTML);
log.LogDebug($"Setting page content to style and compiled HTML");
await page.SetContentAsync($"<style>{report.Style}</style>{compiledHTML}");
//add style (after page or it won't work)
if (!string.IsNullOrWhiteSpace(report.Style))
{
log.LogDebug($"Adding report template Style CSS");
await page.AddStyleTagAsync(new AddTagOptions { Content = report.Style });
}
string outputFileName = StringUtil.ReplaceLastOccurrence(FileUtil.NewRandomFileName, ".", "") + ".pdf";
string outputFullPath = System.IO.Path.Combine(FileUtil.TemporaryFilesFolder, outputFileName);
@@ -779,7 +790,7 @@ namespace AyaNova.Biz
return;
//render to pdf and return
log.LogDebug($"Calling render page contents to PDF");
await page.PdfAsync(outputFullPath, PdfOptions);//###### TODO: SLOW NEEDS TIMEOUT HERE ONCE SUPPORTED, open bug: https://github.com/hardkoded/puppeteer-sharp/issues/1710
await page.PdfAsync(outputFullPath, PdfOptions);
log.LogDebug($"Closing Page");
await page.CloseAsync();

View File

@@ -986,11 +986,11 @@ namespace AyaNova.Biz
}
ReportData.Add(jo);
}
batchResults.Clear();
}
// #if (DEBUG)
// watch.Stop();
// System.Diagnostics.Debug.WriteLine($"Workorderbiz::GetReportData took ms: {watch.ElapsedMilliseconds}");
// #endif
vc.Clear();
oc.Clear();
return ReportData;
}

View File

@@ -12,6 +12,10 @@ namespace AyaNova.Util
// {
// System.Diagnostics.Debug.WriteLine("constructing objectcache");
// }
internal void Clear()
{
_cache.Clear();
}
internal void Add(object value, string key, long? id = 0)
{

View File

@@ -12,6 +12,10 @@ namespace AyaNova.Util
// {
// System.Diagnostics.Debug.WriteLine("constructing vizcache");
// }
internal void Clear()
{
_vizCache.Clear();
}
internal void Add(string value, string key, long? id = 0)
{
if (value == null) value = string.Empty;