using FastEndpoints; using FrameworkBLL.SysJobRun; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using System; using System.Threading; using System.Threading.Tasks; using static FrameworkDAL.Constant.Constant; using static FrameworkSL.Endpoints.SysJobRun.GetSysJobRun; namespace FrameworkSL.Endpoints.SysJobRun { /// /// Paginated run history for a job (or all jobs). /// Pass SysJobId to drill into a specific job's execution history. /// public class GetListSysJobRun : BaseEndpoint> { private readonly ISysJobRunBLL _SysJobRunBLL; public GetListSysJobRun(ISysJobRunBLL SysJobRunBLL) { _SysJobRunBLL = SysJobRunBLL; } public override void Configure() { Post("/SysJobRun/GetListSysJobRun"); AllowAnonymous(); } public record GetListSysJobRunParameters( [property: FromHeader] string Login, [property: QueryParam] int? SysJobId, [property: QueryParam] int? Status, [property: QueryParam] DateTime? DateFrom, [property: QueryParam] DateTime? DateTo, [property: QueryParam] int FirstNumber, [property: QueryParam] int MaxResult ); protected override async Task> ExecuteAsync(GetListSysJobRunParameters req, LoginDTO LoginDTO, CancellationToken ct) { try { var Result = await _SysJobRunBLL.GetListSysJobRun(req.SysJobId, req.Status, req.DateFrom, req.DateTo, req.FirstNumber, req.MaxResult, LoginDTO!); return await GB5Shared.ResponseStandard.Response.CreateSuccessResponse(Result, CacheKeyLevel.UserLevel, LoginDTO); } catch (Exception ex) { return await GB5Shared.ResponseStandard.Response.CreateExceptionError(ex, CacheKeyLevel.UserLevel, LoginDTO, ex.Message, 500); } } } }