|
@@ -1,8 +1,14 @@
|
|
|
using CallCenter.Caches;
|
|
|
+using CallCenter.Devices;
|
|
|
using CallCenter.Notifications;
|
|
|
using CallCenter.Realtimes;
|
|
|
+using CallCenter.Share.Enums;
|
|
|
using CallCenter.Tels;
|
|
|
using MediatR;
|
|
|
+using Microsoft.Extensions.Options;
|
|
|
+using NewRock.Sdk;
|
|
|
+using NewRock.Sdk.Control.Request;
|
|
|
+using NewRock.Sdk.Control.Response;
|
|
|
using XF.Domain.Cache;
|
|
|
|
|
|
namespace CallCenter.Application.Handlers
|
|
@@ -14,13 +20,18 @@ namespace CallCenter.Application.Handlers
|
|
|
private readonly ITypedCache<Tel> _typedCache;
|
|
|
private readonly IUserCacheManager _userCacheManager;
|
|
|
private readonly IRealtimeService _realtimeService;
|
|
|
- public IdleNotificationHandler(ITelRepository telRepository, ITelCacheManager telCacheManager, ITypedCache<Tel> typedCache, IUserCacheManager userCacheManager, IRealtimeService realtimeService)
|
|
|
+ private readonly INewRockClient _newRockClient;
|
|
|
+ private readonly IOptionsSnapshot<DeviceConfigs> _options;
|
|
|
+
|
|
|
+ public IdleNotificationHandler(ITelRepository telRepository, ITelCacheManager telCacheManager, ITypedCache<Tel> typedCache, IUserCacheManager userCacheManager, IRealtimeService realtimeService,INewRockClient newRockClient,IOptionsSnapshot<DeviceConfigs> options)
|
|
|
{
|
|
|
_telRepository = telRepository;
|
|
|
_telCacheManager = telCacheManager;
|
|
|
_typedCache = typedCache;
|
|
|
_userCacheManager = userCacheManager;
|
|
|
_realtimeService = realtimeService;
|
|
|
+ _newRockClient = newRockClient;
|
|
|
+ _options = options;
|
|
|
}
|
|
|
|
|
|
public async Task Handle(IdleNotification notification, CancellationToken cancellationToken)
|
|
@@ -30,6 +41,51 @@ namespace CallCenter.Application.Handlers
|
|
|
//await _telRepository.UpdateAsync(telModel, cancellationToken);
|
|
|
_typedCache.Set(notification.TelNo, telModel);
|
|
|
|
|
|
+
|
|
|
+ foreach (var group in telModel.Groups)
|
|
|
+ {
|
|
|
+ var result = await _newRockClient.QueryExtGroup(new QueryExtGroupRequest()
|
|
|
+ {
|
|
|
+ Attribute = "Query",
|
|
|
+ Group = new QueryExtGroup() { Id = group.No }
|
|
|
+ }, _options.Value.ReceiveKey,
|
|
|
+ _options.Value.Expired,
|
|
|
+ cancellationToken);
|
|
|
+
|
|
|
+ var exts = result.Group.First().Ext.Select(x=>x.Id).ToList();
|
|
|
+ exts.Add(notification.TelNo);
|
|
|
+
|
|
|
+ //更新
|
|
|
+ var groupModel = new Group()
|
|
|
+ {
|
|
|
+ Id = group.No,
|
|
|
+ Voicefile = group.Voice,
|
|
|
+ };
|
|
|
+ switch (group.Distribution)
|
|
|
+ {
|
|
|
+ case EDistribution.Sequential:
|
|
|
+ groupModel.Distribution = "sequential";
|
|
|
+ break;
|
|
|
+ case EDistribution.Group:
|
|
|
+ groupModel.Distribution = "group";
|
|
|
+ break;
|
|
|
+ case EDistribution.Circular:
|
|
|
+ groupModel.Distribution = "circular";
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ break;
|
|
|
+ }
|
|
|
+
|
|
|
+ groupModel.Ext = exts;
|
|
|
+ await _newRockClient.ConfigExtGroup(
|
|
|
+ new AssginConfigGroupRequest() { Attribute = "Assign", Group = groupModel, },
|
|
|
+ _options.Value.ReceiveKey,
|
|
|
+ _options.Value.Expired,
|
|
|
+ cancellationToken
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
var workModel = _userCacheManager.GetWorkByTel(notification.TelNo);
|
|
|
if (workModel != null)
|
|
|
{
|