|
@@ -20,6 +20,7 @@ using Group = NewRock.Sdk.Control.Request.Group;
|
|
|
using CallCenter.Share.Enums;
|
|
|
using CallCenter.Caches;
|
|
|
using Microsoft.AspNetCore.Http;
|
|
|
+using CallCenter.Tools;
|
|
|
|
|
|
namespace CallCenter.NewRock
|
|
|
{
|
|
@@ -33,8 +34,9 @@ namespace CallCenter.NewRock
|
|
|
private readonly IUserCacheManager _userCacheManager;
|
|
|
private readonly ITelRestRepository _telRestRepository;
|
|
|
private readonly ITelCacheManager _telCacheManager;
|
|
|
+ private readonly ICallDetailRepository _callDetailRepository;
|
|
|
|
|
|
- public DeviceManager(INewRockClient newRockClient, IOptionsSnapshot<DeviceConfigs> options, IMapper mapper, ICallRepository callRepository, ITelGroupRepository telGroupRepository,IUserCacheManager userCacheManager, ITelRestRepository telRestRepository, ITelCacheManager telCacheManager)
|
|
|
+ public DeviceManager(INewRockClient newRockClient, IOptionsSnapshot<DeviceConfigs> options, IMapper mapper, ICallRepository callRepository, ITelGroupRepository telGroupRepository,IUserCacheManager userCacheManager, ITelRestRepository telRestRepository, ITelCacheManager telCacheManager, ICallDetailRepository callDetailRepository)
|
|
|
{
|
|
|
_newRockClient = newRockClient;
|
|
|
_options = options;
|
|
@@ -44,6 +46,7 @@ namespace CallCenter.NewRock
|
|
|
_userCacheManager = userCacheManager;
|
|
|
_telRestRepository = telRestRepository;
|
|
|
_telCacheManager = telCacheManager;
|
|
|
+ _callDetailRepository = callDetailRepository;
|
|
|
}
|
|
|
|
|
|
#region 查询
|
|
@@ -673,7 +676,7 @@ namespace CallCenter.NewRock
|
|
|
/// <returns></returns>
|
|
|
public async Task ExtToOuterAsync(string from, string to, CancellationToken cancellationToken, string trunkid = "")
|
|
|
{
|
|
|
- await _newRockClient.ExtToOuter(
|
|
|
+ var rsp = await _newRockClient.ExtToOuter(
|
|
|
new ExtToOuterRequest()
|
|
|
{
|
|
|
Attribute = "Connect",
|
|
@@ -684,6 +687,37 @@ namespace CallCenter.NewRock
|
|
|
_options.Value.ReceiveKey,
|
|
|
_options.Value.Expired,
|
|
|
cancellationToken);
|
|
|
+ //写入记录
|
|
|
+ string telNo = (string.IsNullOrEmpty(rsp.Outer.From) || string.IsNullOrWhiteSpace(rsp.Outer.From)) ? rsp.Ext.Id : rsp.Outer.From;
|
|
|
+ var workModel = _userCacheManager.GetWorkByTel(telNo);
|
|
|
+ var isp = PhoneIspTool.GetPhoneIsp(rsp.Outer.To);
|
|
|
+ var callModel = new Call()
|
|
|
+ {
|
|
|
+ CallStatus = ECallStatus.ExtOuterReady,
|
|
|
+ CallDirection = ECallDirection.Out,
|
|
|
+ CallType = ECallType.ExtToOuter,
|
|
|
+ ConversationId = rsp.Outer.Id,
|
|
|
+ FromNo = telNo,
|
|
|
+ ToNo = rsp.Outer.To,
|
|
|
+ Trunk = rsp.Outer.Trunk,
|
|
|
+ UserId = workModel.UserId,
|
|
|
+ UserName = workModel.UserName,
|
|
|
+ PhoneIsp = isp
|
|
|
+ };
|
|
|
+ callModel.Modified();
|
|
|
+ var callId = await _callRepository.AddAsync(callModel,cancellationToken);
|
|
|
+ //写入明细
|
|
|
+ var detail = new CallDetail()
|
|
|
+ {
|
|
|
+ CallId = callId,
|
|
|
+ CallStatus = ECallStatus.ExtOuterReady,
|
|
|
+ ConversationId = rsp.Outer.Id,
|
|
|
+ OMCallId = rsp.Outer.CallId,
|
|
|
+ EventName = "ExtOuterReady",//去电
|
|
|
+ FromNo = telNo,
|
|
|
+ ToNo = rsp.Outer.To,
|
|
|
+ };
|
|
|
+ await _callDetailRepository.AddAsync(detail, cancellationToken);
|
|
|
}
|
|
|
|
|
|
/// <summary>
|