using FastEndpoints; using FrameworkBLL.ReportOrchestration; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; namespace FrameworkSL.Endpoints.CommonReport { /// /// Called by the SysJob worker to execute a previously queued async report. /// The worker reconstructs the LoginDTO from the TSYSJOB row and calls this /// endpoint. The orchestrator deserialises the context, executes the report, /// writes the output file, and returns the file path stored in RESULTLOCATION. /// public class ExecuteAsyncJob : BaseEndpoint> { private readonly IQueryOrchestrator _orchestrator; public ExecuteAsyncJob(IQueryOrchestrator orchestrator) => _orchestrator = orchestrator; public override void Configure() { Post("/CommonReport/ExecuteAsyncJob"); AllowAnonymous(); } public record ExecuteAsyncJobParameters( [property: FromHeader] string Login, [property: QueryParam] int SysJobId ); protected override string? GetCacheKey(ExecuteAsyncJobParameters req, LoginDTO login) => null; protected override async Task> ExecuteAsync( ExecuteAsyncJobParameters req, LoginDTO loginDTO, CancellationToken ct) { string resultLocation = await _orchestrator .ExecuteAsyncJobAsync(req.SysJobId, loginDTO, ct) .ConfigureAwait(false); return await GB5Shared.ResponseStandard.Response .CreateSuccessResponse( (object)new { ResultLocation = resultLocation, SysJobId = req.SysJobId }, GB5Shared.GB5Constant.Constant.CacheKeyLevel.NOT_REQUIRED, loginDTO) .ConfigureAwait(false); } } }