using FastEndpoints; using FrameworkBLL.Dashboard; using FrameworkDAL.DTO.Dashboard; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using static GB5Shared.GB5Constant.Constant; namespace FrameworkSL.Endpoints.Dashboard { // The cross-host entry point into DashboardHub (Phase 0d) — a BLL running on a DIFFERENT host // (Accounts/Analytics/Compliance, each its own process, no shared DI container with // FrameworkSL) calls this over plain HTTP instead of injecting IDashboardHubNotifier directly, // the same reasoning documented on IDashboardHubNotifier.cs itself. Not yet called by any real // trigger (WarehouseFactPostingBLL/KPIEvaluationBLL/UpdateBRS/Compliance's // AlertCheckSubscriber) — flagged as the concrete next step once one of those is wired. public class NotifyDataChanged : BaseEndpoint> { private readonly IDashboardHubNotifier _notifier; public NotifyDataChanged(IDashboardHubNotifier notifier) { _notifier = notifier; } public override void Configure() { Post("/Dashboard/NotifyDataChanged"); AllowAnonymous(); } public record NotifyDataChangedParameters( [property: FromHeader] string Login, [property: FromBody] NotifyDataChangedDTO Payload ); protected override string? GetCacheKey(NotifyDataChangedParameters req, LoginDTO login) => null; protected override async Task> ExecuteAsync( NotifyDataChangedParameters req, LoginDTO login, CancellationToken ct) { try { await _notifier.NotifyDataChangedAsync(login.ClientId, req.Payload.DatasetKey, req.Payload.OuId); return await GB5Shared.ResponseStandard.Response.CreateSuccessResponse( "Notification sent.", CacheKeyLevel.NOT_REQUIRED, login); } catch (Exception ex) { return await GB5Shared.ResponseStandard.Response.CreateExceptionError( ex, CacheKeyLevel.NOT_REQUIRED, login, ex.Message, 500); } } } }