This commit is contained in:
@@ -209,8 +209,8 @@ namespace AyaNova.Api.Controllers
|
||||
var API_URL = $"http://127.0.0.1:{httpConnectionFeature.LocalPort}/api/v8/";
|
||||
try
|
||||
{
|
||||
var Expires = DateTime.UtcNow.AddMinutes(ServerBootConfig.AYANOVA_REPORT_RENDERING_TIMEOUT);
|
||||
var result = await biz.RenderReport(reportRequest, API_URL);
|
||||
|
||||
var result = await biz.RenderReport(reportRequest,DateTime.UtcNow.AddMinutes(ServerBootConfig.AYANOVA_REPORT_RENDERING_TIMEOUT), API_URL);
|
||||
|
||||
if (string.IsNullOrWhiteSpace(result))
|
||||
return BadRequest(new ApiErrorResponse(biz.Errors));
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using AyaNova.Models;
|
||||
using Newtonsoft.Json.Linq;
|
||||
@@ -11,7 +12,7 @@ namespace AyaNova.Biz
|
||||
|
||||
//Get items indicated in id list in report format
|
||||
//called by ReportBiz rendering code
|
||||
Task<JArray> GetReportData(DataListSelectedRequest dataListSelectedRequest);
|
||||
Task<JArray> GetReportData(DataListSelectedRequest dataListSelectedRequest, DateTime renderTimeOutExpiry);
|
||||
const int REPORT_DATA_BATCH_SIZE = 100;
|
||||
|
||||
|
||||
|
||||
@@ -346,7 +346,7 @@ namespace AyaNova.Biz
|
||||
//REPORT DATA
|
||||
//Data fetched to return to report designer for Client report design usage
|
||||
|
||||
public async Task<Newtonsoft.Json.Linq.JArray> GetReportData(DataListSelectedRequest selectedRequest, bool requestIsCustomerWorkOrderReport = false)
|
||||
public async Task<Newtonsoft.Json.Linq.JArray> GetReportData(DataListSelectedRequest selectedRequest, DateTime renderTimeOutExpiry, bool requestIsCustomerWorkOrderReport = false)
|
||||
{
|
||||
var log = AyaNova.Util.ApplicationLogging.CreateLogger("ReportBiz::GetReportData");
|
||||
AuthorizationRoles effectiveRoles = CurrentUserRoles;
|
||||
@@ -371,7 +371,7 @@ namespace AyaNova.Biz
|
||||
log.LogDebug($"Instantiating biz object handler for {selectedRequest.AType}");
|
||||
var biz = BizObjectFactory.GetBizObject(selectedRequest.AType, ct, UserId, CurrentUserRoles, UserTranslationId);
|
||||
log.LogDebug($"Fetching data for {selectedRequest.SelectedRowIds.Length} {selectedRequest.AType} items");
|
||||
return await ((IReportAbleObject)biz).GetReportData(selectedRequest);
|
||||
return await ((IReportAbleObject)biz).GetReportData(selectedRequest, renderTimeOutExpiry);
|
||||
}
|
||||
|
||||
|
||||
@@ -380,9 +380,9 @@ namespace AyaNova.Biz
|
||||
//RENDER
|
||||
//
|
||||
|
||||
public async Task<string> RenderReport(DataListReportRequest reportRequest, string apiUrl)
|
||||
public async Task<string> RenderReport(DataListReportRequest reportRequest, DateTime renderTimeOutExpiry, string apiUrl)
|
||||
{
|
||||
var log = AyaNova.Util.ApplicationLogging.CreateLogger("ReportBiz::RenderReport");
|
||||
var log = AyaNova.Util.ApplicationLogging.CreateLogger($"ReportBiz::RenderReport id {reportRequest.ReportId}, timeout @ {renderTimeOutExpiry.ToString()}");
|
||||
// #if (DEBUG)
|
||||
// log.LogInformation($"DBG: ReportBiz::RenderReport called");
|
||||
// #endif
|
||||
@@ -399,6 +399,9 @@ namespace AyaNova.Biz
|
||||
RequestIsCustomerWorkOrderReport = true;
|
||||
}
|
||||
|
||||
if (DateTime.UtcNow > renderTimeOutExpiry)
|
||||
throw new ReportRenderTimeOutException();
|
||||
|
||||
//get report, vet security, see what we need before init in case of issue
|
||||
// #if (DEBUG)
|
||||
// log.LogInformation($"DBG: ReportBiz::RenderReport get report from db");
|
||||
@@ -434,7 +437,7 @@ namespace AyaNova.Biz
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//includeWoItemDescendants?
|
||||
reportRequest.IncludeWoItemDescendants = report.IncludeWoItemDescendants;
|
||||
|
||||
@@ -442,7 +445,7 @@ namespace AyaNova.Biz
|
||||
// #if (DEBUG)
|
||||
// log.LogInformation($"DBG: ReportBiz::RenderReport GetReportData");
|
||||
// #endif
|
||||
var ReportData = await GetReportData(reportRequest, RequestIsCustomerWorkOrderReport);//###### TODO: SLOW NEEDS TIMEOUT HERE ONCE IT WORKS IS SUPPORTED
|
||||
var ReportData = await GetReportData(reportRequest, renderTimeOutExpiry, RequestIsCustomerWorkOrderReport);//###### 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)
|
||||
{
|
||||
@@ -451,7 +454,8 @@ namespace AyaNova.Biz
|
||||
// #if (DEBUG)
|
||||
// log.LogInformation($"DBG: ReportBiz::RenderReport got report data");
|
||||
// #endif
|
||||
|
||||
if (DateTime.UtcNow > renderTimeOutExpiry)
|
||||
throw new ReportRenderTimeOutException();
|
||||
//initialization
|
||||
log.LogDebug("Initializing report rendering system");
|
||||
bool AutoDownloadChromium = true;
|
||||
|
||||
22
server/AyaNova/util/ReportRenderTimeOutException.cs
Normal file
22
server/AyaNova/util/ReportRenderTimeOutException.cs
Normal file
@@ -0,0 +1,22 @@
|
||||
using System;
|
||||
|
||||
namespace AyaNova.Util
|
||||
{
|
||||
public class ReportRenderTimeOutException : Exception
|
||||
{
|
||||
public ReportRenderTimeOutException()
|
||||
{
|
||||
}
|
||||
|
||||
public ReportRenderTimeOutException(string message)
|
||||
: base(message)
|
||||
{
|
||||
}
|
||||
|
||||
public ReportRenderTimeOutException(string message, Exception inner)
|
||||
: base(message, inner)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
}//eons
|
||||
Reference in New Issue
Block a user