using FrameworkBLL.Dashboard; using Microsoft.AspNetCore.SignalR; using Microsoft.Extensions.Logging; namespace FrameworkSL.Hubs.Dashboard { // ============================================================ // DashboardHubNotifier — SL implementation of IDashboardHubNotifier. // // Wraps IHubContext so any in-process FrameworkBLL caller can // push a "this dataset changed" notification without referencing ASP.NET types directly — // same pattern as SysJobHubNotifier. // // Registration: // services.AddSingleton(); // ============================================================ public class DashboardHubNotifier : IDashboardHubNotifier { private readonly IHubContext _hub; private readonly ILogger _logger; public DashboardHubNotifier(IHubContext hub, ILogger logger) { _hub = hub; _logger = logger; } public async Task NotifyDataChangedAsync(int clientId, string datasetKey, int? ouId) { try { await _hub.Clients .Group(DashboardHub.TenantGroup(clientId)) .DataChanged(datasetKey, ouId, DateTime.UtcNow); } catch (Exception ex) { _logger.LogWarning(ex, "DashboardHubNotifier: failed to push DataChanged for client {ClientId} dataset {DatasetKey}", clientId, datasetKey); } } } }