using FastEndpoints; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using SwBLL.ChangeRequest; using static GB5Shared.GB5Constant.Constant; using GB5Shared.Authorization; namespace SwSL.EndPoints.ChangeRequest; // Internal system job, dispatched by GB5Framework's Track A scheduler (tracker §45) — replaces // the standalone in-memory Quartz job of the same name (1-minute interval) that used to run // inside SwSL's own process. Runs every Queued Change Request (§37/§43) through // ChangeRequestBLL.ProcessQueuedExecutionsAsync — the same background-execution mechanism // QueueChangeRequestExecution.cs feeds into. Same hardcoded Unisoft TenantId=1 system login // ChangeRequestExecutionWorkerJob itself used (§38). //[MenuRights("SWCHREQ", RightOperation.Update)] public class RunChangeRequestExecutionWorker : BaseEndpoint> { private readonly IChangeRequestBLL _bll; public RunChangeRequestExecutionWorker(IChangeRequestBLL bll) => _bll = bll; public override void Configure() { Get("/ChangeRequest/RunChangeRequestExecutionWorker"); AllowAnonymous(); } public record Parameters([property: FromHeader] string Login); protected override string? GetCacheKey(Parameters req, LoginDTO loginDTO) => null; protected override async Task> ExecuteAsync( Parameters req, LoginDTO loginDTO, CancellationToken ct) { var systemLogin = new LoginDTO { DatabaseName = "Gb5System", ClientId = 1, UserId = -1, DatabaseType = 0, RoleId = -1, UserName = "system", LanguageId = "1" }; var processed = await _bll.ProcessQueuedExecutionsAsync(systemLogin, ct); return await GB5Shared.ResponseStandard.Response.CreateSuccessResponse( $"ChangeRequestExecutionWorker run completed. Processed={processed}.", CacheKeyLevel.NOT_REQUIRED, loginDTO); } }