using System; using System.Threading.Tasks; using FrameworkBLL.SystemJob; using Microsoft.AspNetCore.SignalR; using Microsoft.Extensions.Logging; namespace FrameworkSL.Hubs.SysJob { // ============================================================ // SysJobHubNotifier — SL implementation of ISysJobHubNotifier. // // Wraps IHubContext so that // FrameworkBLL (SysJobShareBLL) can push real-time notifications // to specific users without referencing ASP.NET types directly. // // Registration: // services.AddSingleton(); // ============================================================ public class SysJobHubNotifier : ISysJobHubNotifier { private readonly IHubContext _hub; private readonly ILogger _logger; public SysJobHubNotifier( IHubContext hub, ILogger logger) { _hub = hub; _logger = logger; } public async Task NotifyJobSharedAsync(int recipientUserId, int sysJobId, string sharedByName) { try { await _hub.Clients .Group(SysJobHub.UserGroup(recipientUserId)) .JobShared(sysJobId, sharedByName); } catch (Exception ex) { _logger.LogWarning(ex, "SysJobHubNotifier: failed to push JobShared to user {UserId} for job {SysJobId}", recipientUserId, sysJobId); } } } }