|
@@ -12,11 +12,16 @@ public class CallCenterHub : Hub
|
|
{
|
|
{
|
|
private readonly ISessionContext _sessionContext;
|
|
private readonly ISessionContext _sessionContext;
|
|
private readonly IWorkRepository _workRepository;
|
|
private readonly IWorkRepository _workRepository;
|
|
|
|
+ private readonly IUserCacheManager _userCacheManager;
|
|
|
|
|
|
- public CallCenterHub(ISessionContext sessionContext, IWorkRepository workRepository)
|
|
|
|
|
|
+ public CallCenterHub(
|
|
|
|
+ ISessionContext sessionContext,
|
|
|
|
+ IWorkRepository workRepository,
|
|
|
|
+ IUserCacheManager userCacheManager)
|
|
{
|
|
{
|
|
_sessionContext = sessionContext;
|
|
_sessionContext = sessionContext;
|
|
_workRepository = workRepository;
|
|
_workRepository = workRepository;
|
|
|
|
+ _userCacheManager = userCacheManager;
|
|
}
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// <summary>
|
|
@@ -26,7 +31,7 @@ public class CallCenterHub : Hub
|
|
public override async Task OnConnectedAsync()
|
|
public override async Task OnConnectedAsync()
|
|
{
|
|
{
|
|
var userId = _sessionContext.RequiredUserId;
|
|
var userId = _sessionContext.RequiredUserId;
|
|
- var work = await _workRepository.GetCurrentWorkByUserAsync(userId, Context.ConnectionAborted);
|
|
|
|
|
|
+ var work = _userCacheManager.GetWorkByUser(userId);
|
|
if (work == null)
|
|
if (work == null)
|
|
throw new UserFriendlyException($"未查询到上班记录, userId: {userId}");
|
|
throw new UserFriendlyException($"未查询到上班记录, userId: {userId}");
|
|
work.SignalRId = Context.ConnectionId;
|
|
work.SignalRId = Context.ConnectionId;
|