using FastEndpoints; using FrameworkBLL.SchedulerTaskGenerator; using FrameworkDAL.CustomCode.SchedulerTaskGenerator; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using static GB5Shared.GB5Constant.Constant; namespace FrameworkSL.Endpoints.JobDefine { /// /// Resumes a paused job: sets MJOBDEFINE.STATUS=Active and (re)registers its /// native Quartz trigger from the current MJOBDEFINE/TSCHEDULER configuration. /// public sealed class ResumeJobDefine : BaseEndpoint> { private readonly IJobDefineOperationsBLL _ops; private readonly ILoginContextProvider _loginProvider; public ResumeJobDefine(IJobDefineOperationsBLL ops, ILoginContextProvider loginProvider) { _ops = ops; _loginProvider = loginProvider; } public override void Configure() { Post("/JobDefine/Resume"); AllowAnonymous(); // Internal scheduler admin call — matches Scheduler/* endpoint convention } public sealed record ResumeJobDefineParameters( int JobId, [property: FromHeader] string Login ); protected override async Task> ExecuteAsync( ResumeJobDefineParameters req, LoginDTO loginDTO, CancellationToken ct) { try { if (string.IsNullOrWhiteSpace(loginDTO?.DatabaseName)) loginDTO = _loginProvider.GetLogin(); await _ops.ResumeAsync(req.JobId, loginDTO, ct); return await GB5Shared.ResponseStandard.Response.CreateSuccessResponse( $"Job {req.JobId} resumed.", CacheKeyLevel.NOT_REQUIRED, loginDTO); } catch (Exception ex) { return await GB5Shared.ResponseStandard.Response.CreateExceptionError( ex, CacheKeyLevel.NOT_REQUIRED, loginDTO, ex.Message, 500); } } } }