This commit is contained in:
@@ -207,6 +207,7 @@ namespace AyaNova.Api.Controllers
|
|||||||
{
|
{
|
||||||
var result = await biz.RenderReport(reportRequest, API_URL);
|
var result = await biz.RenderReport(reportRequest, API_URL);
|
||||||
|
|
||||||
|
|
||||||
if (string.IsNullOrWhiteSpace(result))
|
if (string.IsNullOrWhiteSpace(result))
|
||||||
return BadRequest(new ApiErrorResponse(biz.Errors));
|
return BadRequest(new ApiErrorResponse(biz.Errors));
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -422,7 +422,7 @@ namespace AyaNova.Biz
|
|||||||
reportRequest.IncludeWoItemDescendants = report.IncludeWoItemDescendants;
|
reportRequest.IncludeWoItemDescendants = report.IncludeWoItemDescendants;
|
||||||
|
|
||||||
//Get data
|
//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 GetReportData errored then will return null so need to return that as well here
|
||||||
if (ReportData == null)
|
if (ReportData == null)
|
||||||
{
|
{
|
||||||
@@ -478,6 +478,9 @@ namespace AyaNova.Biz
|
|||||||
using (var browser = await Puppeteer.LaunchAsync(lo))
|
using (var browser = await Puppeteer.LaunchAsync(lo))
|
||||||
using (var page = await browser.NewPageAsync())
|
using (var page = await browser.NewPageAsync())
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//see catch block
|
//see catch block
|
||||||
// var ChromiumProcessID = browser.Process.Id;
|
// var ChromiumProcessID = browser.Process.Id;
|
||||||
|
|
||||||
@@ -589,18 +592,16 @@ namespace AyaNova.Biz
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
#if (DEBUG)
|
// #if (DEBUG)
|
||||||
//view page contents
|
// //view page contents
|
||||||
var pagecontent = await page.GetContentAsync();
|
// var pagecontent = await page.GetContentAsync();
|
||||||
|
|
||||||
#endif
|
// #endif
|
||||||
//prePareData / preRender
|
//prePareData / preRender
|
||||||
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 WITH TIMEOUT
|
//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);
|
await page.WaitForExpressionAsync($"ayPreRender({ReportDataObject})", WaitTimeout);
|
||||||
|
|
||||||
//compile the template
|
//compile the template
|
||||||
@@ -628,6 +629,7 @@ namespace AyaNova.Biz
|
|||||||
//https://pptr.dev/#?product=Puppeteer&version=v5.3.0&show=api-pagepdfoptions
|
//https://pptr.dev/#?product=Puppeteer&version=v5.3.0&show=api-pagepdfoptions
|
||||||
log.LogDebug($"Resolving PDF Options from report settings");
|
log.LogDebug($"Resolving PDF Options from report settings");
|
||||||
var PdfOptions = new PdfOptions() { };
|
var PdfOptions = new PdfOptions() { };
|
||||||
|
|
||||||
PdfOptions.DisplayHeaderFooter = report.DisplayHeaderFooter;
|
PdfOptions.DisplayHeaderFooter = report.DisplayHeaderFooter;
|
||||||
if (report.DisplayHeaderFooter)
|
if (report.DisplayHeaderFooter)
|
||||||
{
|
{
|
||||||
@@ -699,7 +701,7 @@ namespace AyaNova.Biz
|
|||||||
|
|
||||||
//render to pdf and return
|
//render to pdf and return
|
||||||
log.LogDebug($"Calling render page contents to PDF");
|
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");
|
log.LogDebug($"Completed, returning results");
|
||||||
return outputFileName;
|
return outputFileName;
|
||||||
|
|||||||
@@ -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.
|
// Copyright (c) .NET Foundation. Licensed under the Apache License, Version 2.0.
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
Reference in New Issue
Block a user