This commit is contained in:
2021-10-26 13:59:05 +00:00
parent 2e9b584626
commit 980788d332
3 changed files with 12 additions and 15 deletions

View File

@@ -207,6 +207,7 @@ namespace AyaNova.Api.Controllers
{
var result = await biz.RenderReport(reportRequest, API_URL);
if (string.IsNullOrWhiteSpace(result))
return BadRequest(new ApiErrorResponse(biz.Errors));
else

View File

@@ -417,12 +417,12 @@ namespace AyaNova.Biz
//Default timeout for each operation of report generation
var WaitTimeout = new WaitForFunctionOptions() { Timeout = ServerBootConfig.REPORT_RENDERING_OPERATION_TIMEOUT };
//includeWoItemDescendants?
reportRequest.IncludeWoItemDescendants = report.IncludeWoItemDescendants;
//Get data
var ReportData = await GetReportData(reportRequest);//SLOW
var ReportData = await GetReportData(reportRequest);//###### TODO: SLOW NEEDS TIMEOUT HERE ONCE IT WORKS IS SUPPORTED
//if GetReportData errored then will return null so need to return that as well here
if (ReportData == null)
{
@@ -478,6 +478,9 @@ namespace AyaNova.Biz
using (var browser = await Puppeteer.LaunchAsync(lo))
using (var page = await browser.NewPageAsync())
{
//see catch block
// var ChromiumProcessID = browser.Process.Id;
@@ -589,18 +592,16 @@ namespace AyaNova.Biz
#if (DEBUG)
//view page contents
var pagecontent = await page.GetContentAsync();
// #if (DEBUG)
// //view page contents
// var pagecontent = await page.GetContentAsync();
#endif
// #endif
//prePareData / preRender
var ReportDataObject = $"{{ ayReportData:{ReportData}, ayReportMetaData:{reportMeta}, ayClientMetaData:{clientMeta}, ayServerMetaData:{serverMeta} }}";
log.LogDebug($"Calling ayPreRender...");
//PRE_RENDER WITH TIMEOUT
//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
@@ -628,6 +629,7 @@ namespace AyaNova.Biz
//https://pptr.dev/#?product=Puppeteer&version=v5.3.0&show=api-pagepdfoptions
log.LogDebug($"Resolving PDF Options from report settings");
var PdfOptions = new PdfOptions() { };
PdfOptions.DisplayHeaderFooter = report.DisplayHeaderFooter;
if (report.DisplayHeaderFooter)
{
@@ -699,7 +701,7 @@ namespace AyaNova.Biz
//render to pdf and return
log.LogDebug($"Calling render page contents to PDF");
await page.PdfAsync(outputFullPath, PdfOptions);//SLOW
await page.PdfAsync(outputFullPath, PdfOptions);//###### TODO: SLOW NEEDS TIMEOUT HERE ONCE SUPPORTED, open bug: https://github.com/hardkoded/puppeteer-sharp/issues/1710
log.LogDebug($"Completed, returning results");
return outputFileName;

View File

@@ -9,12 +9,6 @@ namespace AyaNova.Generator
{
//This is a temporary class until .net 2.1 is released
//https://docs.microsoft.com/en-us/dotnet/standard/microservices-architecture/multi-container-microservice-net-applications/background-tasks-with-ihostedservice
//Here is how it's supposed to be done with .net 3.x:
//https://docs.microsoft.com/en-us/aspnet/core/fundamentals/host/hosted-services?view=aspnetcore-3.0&tabs=netcore-cli
//right now it's working so fuck it basically
// Copyright (c) .NET Foundation. Licensed under the Apache License, Version 2.0.
/// <summary>