dss 2 years ago
parent
commit
cf88074c06

+ 5 - 1
src/CallCenter.Api/Realtimes/RealtimeService.cs

@@ -78,7 +78,11 @@ namespace CallCenter.Api.Realtimes
             var works = _userCacheManager.GetWorks();
             if (works!=null)
             {
-                await _hubContext.Clients.Clients(works.Where(x=>x.SignalRId!=null && x.SignalRId!="").Select(x => x.SignalRId).ToList()).SendAsync(RealtimeMethods.CallQueue, new { count=1}, cancellationToken);
+                var sendlist = works.Where(x => x.SignalRId != null && x.SignalRId != "").Select(x => x.SignalRId).ToList();
+                foreach (var item in sendlist)
+                {
+                    await _hubContext.Clients.Client(item).SendAsync(RealtimeMethods.CallQueue, new { count = 1 }, cancellationToken);
+                }
             }
         }
     }

+ 4 - 0
src/CallCenter/Caches/IUserCacheManager.cs

@@ -51,5 +51,9 @@ namespace CallCenter.Caches
         /// </summary>
         /// <returns></returns>
         List<Work> GetWorks();
+
+        void AddOrUpdateWorksCache(List<Work> list);
+
+        void RemoveCallCache(string id);
     }
 }

+ 2 - 2
src/CallCenter/Users/UserDomainService.cs

@@ -60,7 +60,7 @@ namespace CallCenter.Users
 
             var work = new Work(userId, user.Name, tel.Id, tel.No);
             await _workRepository.AddAsync(work, cancellationToken);
-
+            _userCacheManager.RemoveCallCache(work.Id);
             if (!string.IsNullOrEmpty(user.StaffNo))
                 await _deviceManager.UpdateStaffNoAsync(tel.No, user.StaffNo, tel.LineId, cancellationToken);
 
@@ -86,7 +86,7 @@ namespace CallCenter.Users
             await _deviceManager.UpdateStaffNoAsync(work.TelNo, string.Empty, tel.LineId, cancellationToken);
             _cacheWork.Remove(work.GetKey(KeyMode.UserId));
             _cacheWork.Remove(work.GetKey(KeyMode.TelNo));
-
+            _userCacheManager.RemoveCallCache(work.Id);
             //foreach (var group in tel.Groups)
             //{
             //    await _deviceManager.ModifyGroupExtAsync(group.No, tel.No, group.Voice, false, cancellationToken);