Files
Backend-Api/ServiceHost/FaceEmbeddingNotificationService.cs

59 lines
1.9 KiB
C#

using _0_Framework.Application.FaceEmbedding;
using Microsoft.AspNetCore.SignalR;
using ServiceHost.Hubs;
using System.Threading.Tasks;
namespace ServiceHost
{
/// <summary>
/// پیاده‌سازی سرویس اطلاع‌رسانی Face Embedding با استفاده از SignalR
/// </summary>
public class FaceEmbeddingNotificationService : IFaceEmbeddingNotificationService
{
private readonly IHubContext<FaceEmbeddingHub> _hubContext;
public FaceEmbeddingNotificationService(IHubContext<FaceEmbeddingHub> 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
});
}
}
}