switching to JOB for report rendering
This commit is contained in:
@@ -241,6 +241,50 @@ namespace AyaNova.Api.Controllers
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Start Render Report job
|
||||
/// </summary>
|
||||
/// <param name="reportRequest">report id and object id values for object type specified in report template</param>
|
||||
/// <param name="apiVersion">From route path</param>
|
||||
/// <returns>Job Id</returns>
|
||||
[HttpPost("render-job")]
|
||||
public async Task<IActionResult> RequestRenderReport([FromBody] DataListReportRequest reportRequest, ApiVersion apiVersion)
|
||||
{
|
||||
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));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Download a rendered report
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user