This commit is contained in:
2021-12-27 20:11:58 +00:00
parent 76f42101c7
commit 5252a989b2
3 changed files with 18 additions and 34 deletions

View File

@@ -185,12 +185,12 @@ namespace AyaNova.Api.Controllers
return Ok(ApiOkResponse.Response(reportData));
}
catch (ReportRenderTimeOutException)
{
{
log.LogInformation($"GetReportData timeout data list key: {selectedRequest.DataListKey}, record count:{selectedRequest.SelectedRowIds.LongLength}, user:{UserNameFromContext.Name(HttpContext.Items)} ");
//note: this route is called by the report designer to get a limited subset of records so we should never see this error but including it for completeness
//report designer should show this as a general error
//note: this route is called by the report designer to get a limited subset of records so we should never see this error but including it for completeness
//report designer should show this as a general error
return BadRequest(new ApiErrorResponse(ApiErrorCode.INVALID_OPERATION, null, "timeout - select fewer records"));
}
}
@@ -242,7 +242,7 @@ namespace AyaNova.Api.Controllers
/// <summary>
/// <summary>
/// Start Render Report job
/// </summary>
/// <param name="reportRequest">report id and object id values for object type specified in report template</param>
@@ -253,35 +253,18 @@ namespace AyaNova.Api.Controllers
{
if (!serverState.IsOpen)
return StatusCode(503, new ApiErrorResponse(serverState.ApiErrorCode, null, serverState.Reason));
ReportBiz biz = ReportBiz.GetBiz(ct, HttpContext);
if (!Authorized.HasReadFullRole(HttpContext.Items, biz.BizType))
return StatusCode(403, new ApiNotAuthorizedResponse());
if (!ModelState.IsValid)
return BadRequest(new ApiErrorResponse(ModelState));
var httpConnectionFeature = HttpContext.Features.Get<IHttpConnectionFeature>();
var API_URL = $"http://127.0.0.1:{httpConnectionFeature.LocalPort}/api/v8/";
try
{
var result = await biz.RequestRenderReport(reportRequest, DateTime.UtcNow.AddMinutes(ServerBootConfig.AYANOVA_REPORT_RENDERING_TIMEOUT), API_URL,UserNameFromContext.Name(HttpContext.Items));
if (string.IsNullOrWhiteSpace(result))
return BadRequest(new ApiErrorResponse(biz.Errors));
else
return Ok(ApiOkResponse.Response(result));
}
catch (ReportRenderTimeOutException)
{
log.LogInformation($"Report render timeout, exceeded timeout setting of {ServerBootConfig.AYANOVA_REPORT_RENDERING_TIMEOUT} minutes, report id: {reportRequest.ReportId}, record count:{reportRequest.SelectedRowIds.LongLength}, user:{UserNameFromContext.Name(HttpContext.Items)} ");
return Ok(ApiOkResponse.Response(new { timeout = true, timeoutconfigminutes = ServerBootConfig.AYANOVA_REPORT_RENDERING_TIMEOUT }));
}
catch (System.Exception ex)
{
//The Javascript evaluation stack trace can be in the message making it long and internalized,
//however the info is useful as it can indicate exactly which function failed etc so sending it all back is best
return BadRequest(new ApiErrorResponse(ApiErrorCode.INVALID_OPERATION, null, ex.Message));
}
var API_URL = $"http://127.0.0.1:{httpConnectionFeature.LocalPort}/api/{AyaNovaVersion.CurrentApiVersion}/";
var result = await biz.RequestRenderReport(reportRequest, DateTime.UtcNow.AddMinutes(ServerBootConfig.AYANOVA_REPORT_RENDERING_TIMEOUT), API_URL, UserNameFromContext.Name(HttpContext.Items));
if (result == null)
return BadRequest(new ApiErrorResponse(biz.Errors));
else
return Accepted(new { JobId = result });
}

View File

@@ -880,7 +880,7 @@ namespace AyaNova.Biz
var report = await ct.Report.FirstOrDefaultAsync(z => z.Id == reportRequest.ReportId);
if (report == null)
{
await JobsBiz.LogJobAsync(job.GId, $"LT:ErrorAPI2010 LT:Report({reportRequest.ReportId})");
await JobsBiz.LogJobAsync(job.GId, $"rendererror:error,\"LT:ErrorAPI2010 LT:Report({reportRequest.ReportId})\"");
await JobsBiz.UpdateJobStatusAsync(job.GId, JobStatus.Failed);
return;
}
@@ -892,7 +892,7 @@ namespace AyaNova.Biz
if (ReportData == null)
{
log.LogDebug($"bail: ReportData == null");
await JobsBiz.LogJobAsync(job.GId, $"{this.GetErrorsAsString()}");//?? circle back on this one
await JobsBiz.LogJobAsync(job.GId, $"rendererror:error,\"{this.GetErrorsAsString()}\"");//?? circle back on this one
await JobsBiz.UpdateJobStatusAsync(job.GId, JobStatus.Failed);
}
// #if (DEBUG)
@@ -1215,7 +1215,7 @@ namespace AyaNova.Biz
await browser.CloseAsync();
log.LogDebug($"Render completed successfully, output filename is: {outputFileName}, logging to job for client");
await JobsBiz.LogJobAsync(job.GId, $"ok:{outputFileName}");
await JobsBiz.LogJobAsync(job.GId, $"reportfilename:\"{outputFileName}\"");
await JobsBiz.UpdateJobStatusAsync(job.GId, JobStatus.Completed);
return;
}
@@ -1242,10 +1242,10 @@ namespace AyaNova.Biz
{
log.LogInformation($"Exception caught while rendering report \"{report.Name}\", report Page console log:");
log.LogInformation(PageLog.ToString());
await JobsBiz.LogJobAsync(job.GId, $"rendererror:\"{PageLog.ToString()}\"");//parseable for print client
await JobsBiz.LogJobAsync(job.GId, $"rendererror:exception,\"{PageLog.ToString()}\"");//parseable for print client
}
await JobsBiz.LogJobAsync(job.GId, $"exception:\"{ExceptionUtil.ExtractAllExceptionMessages(ex)}\"");//parseable for print client
await JobsBiz.LogJobAsync(job.GId, $"rendererror:exception,\"{ExceptionUtil.ExtractAllExceptionMessages(ex)}\"");//parseable for print client
await JobsBiz.UpdateJobStatusAsync(job.GId, JobStatus.Failed);
// var v=await page.GetContentAsync();//for debugging purposes
@@ -1272,7 +1272,7 @@ namespace AyaNova.Biz
static async Task HandleTimeOut(OpsJob job, ILogger log, DataListReportRequest reportRequest, string userName)
{
log.LogInformation($"Report render timeout, exceeded timeout setting of {ServerBootConfig.AYANOVA_REPORT_RENDERING_TIMEOUT} minutes, report id: {reportRequest.ReportId}, record count:{reportRequest.SelectedRowIds.LongLength}, user:{userName}");
await JobsBiz.LogJobAsync(job.GId, $"timeout,{ServerBootConfig.AYANOVA_REPORT_RENDERING_TIMEOUT}");//parseable for print client
await JobsBiz.LogJobAsync(job.GId, $"rendererror:timeout,{ServerBootConfig.AYANOVA_REPORT_RENDERING_TIMEOUT}");//parseable for print client
await JobsBiz.UpdateJobStatusAsync(job.GId, JobStatus.Failed);
}
}

View File

@@ -7,5 +7,6 @@ namespace AyaNova.Util
{
public const string VersionString = "8.0.0-beta.0.6";
public const string FullNameAndVersion = "AyaNova server " + VersionString;
public const string CurrentApiVersion="v8";
}//eoc
}//eons