using FastEndpoints; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using IceImportBLL.IceImportRun; using IceImportSL.Parameters.Run; using static GB5Shared.GB5Constant.Constant; namespace IceImportSL.Endpoints.Run; public class GetImportRunHistory : BaseEndpoint> { private readonly IIceImportRunBLL _runBll; public GetImportRunHistory(IIceImportRunBLL runBll) => _runBll = runBll; public override void Configure() { Get("/IceImport/GetImportRunHistory"); AllowAnonymous(); } // Run status is near-real-time and changes rapidly while a run is in flight — never cache // (matches AutomationSL.EndPoints.Run.GetRunHistory's identical reasoning). protected override string? GetCacheKey(GetImportRunHistoryParameters req, LoginDTO login) => null; protected override async Task> ExecuteAsync( GetImportRunHistoryParameters req, LoginDTO login, CancellationToken ct) { try { var result = await _runBll.GetHistoryAsync(req.IceMapId, req.Page, req.PageSize, login, ct) .ConfigureAwait(false); return await GB5Shared.ResponseStandard.Response.CreateSuccessResponse( result, CacheKeyLevel.NOT_REQUIRED, login); } catch (Exception ex) { return await GB5Shared.ResponseStandard.Response.CreateExceptionError( ex, CacheKeyLevel.NOT_REQUIRED, login, ex.Message, 500); } } }