using EntitlementBLL.Demo; using FastEndpoints; using GB5Shared.Authorization; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using static GB5Shared.GB5Constant.Constant; namespace EntitlementSL.Endpoints.Demo; // Internal system job, dispatched by GB5Framework's Track A scheduler (MJOBDEFINE/TSCHEDULER, // tracker §45/§46) — issues warnings, expires sessions, and resets pooled instances. Gated the // same way every other Track-A-dispatched internal action in this module is // ([MenuRights]/AllowAnonymous, RunKillSwitchMonitor.cs's own precedent) — Track A calls this // over plain HTTP with a Login header, never a JWT. [MenuRights("entdemo", RightOperation.Update)] public class RunDemoSessionWorker : BaseEndpoint> { private readonly IDemoSessionBLL _DemoSessionBLL; public RunDemoSessionWorker(IDemoSessionBLL demoSessionBLL) => _DemoSessionBLL = demoSessionBLL; public override void Configure() { Get("/Demo/RunDemoSessionWorker"); AllowAnonymous(); } public record Params([property: FromHeader] string Login); protected override string? GetCacheKey(Params req, LoginDTO loginDTO) => null; protected override async Task> ExecuteAsync(Params req, LoginDTO loginDTO, CancellationToken ct) { var processed = await _DemoSessionBLL.ProcessExpiringAndExpiredSessionsAsync(ct); return await GB5Shared.ResponseStandard.Response.CreateSuccessResponse( $"DemoSessionWorker run completed — {processed} session(s) touched.", CacheKeyLevel.NOT_REQUIRED, loginDTO); } }