using _0_Framework.Application.FaceEmbedding;
using Microsoft.AspNetCore.SignalR;
using ServiceHost.Hubs;
using System.Threading.Tasks;
namespace ServiceHost
{
///
/// پیادهسازی سرویس اطلاعرسانی Face Embedding با استفاده از SignalR
///
public class FaceEmbeddingNotificationService : IFaceEmbeddingNotificationService
{
private readonly IHubContext _hubContext;
public FaceEmbeddingNotificationService(IHubContext hubContext)
{
_hubContext = hubContext;
}
public async Task NotifyEmbeddingCreatedAsync(long workshopId, long employeeId, string employeeFullName)
{
var groupName = FaceEmbeddingHub.GetGroupName(workshopId);
await _hubContext.Clients.Group(groupName).SendAsync("EmbeddingCreated", new
{
workshopId,
employeeId,
employeeFullName,
timestamp = System.DateTime.UtcNow
});
}
public async Task NotifyEmbeddingDeletedAsync(long workshopId, long employeeId)
{
var groupName = FaceEmbeddingHub.GetGroupName(workshopId);
await _hubContext.Clients.Group(groupName).SendAsync("EmbeddingDeleted", new
{
workshopId,
employeeId,
timestamp = System.DateTime.UtcNow
});
}
public async Task NotifyEmbeddingRefinedAsync(long workshopId, long employeeId)
{
var groupName = FaceEmbeddingHub.GetGroupName(workshopId);
await _hubContext.Clients.Group(groupName).SendAsync("EmbeddingRefined", new
{
workshopId,
employeeId,
timestamp = System.DateTime.UtcNow
});
}
}
}