|
@@ -4,6 +4,9 @@ using CallCenter.Share.Dtos;
|
|
|
using CallCenter.Share.Enums;
|
|
|
using MediatR;
|
|
|
using Microsoft.Extensions.Options;
|
|
|
+using NewRock.Sdk.Extensions;
|
|
|
+using Newtonsoft.Json;
|
|
|
+using System.Text;
|
|
|
|
|
|
namespace CallCenter.Application.Handlers
|
|
|
{
|
|
@@ -13,15 +16,18 @@ namespace CallCenter.Application.Handlers
|
|
|
private readonly ICallDetailRepository _callDetailRepository;
|
|
|
private readonly ICallRepository _callRepository;
|
|
|
private readonly IOptionsSnapshot<SendCallRecord> _sendCallRecordOptions;
|
|
|
+ private readonly IHttpClientFactory _httpClientFactory;
|
|
|
|
|
|
- public CdrNotificationHandler(ICallRecordRepository callRecordRepository, ICallDetailRepository callDetailRepository, ICallRepository callRepository, IOptionsSnapshot<SendCallRecord> sendCallRecordOptions)
|
|
|
+ public CdrNotificationHandler(ICallRecordRepository callRecordRepository, ICallDetailRepository callDetailRepository, ICallRepository callRepository, IOptionsSnapshot<SendCallRecord> sendCallRecordOptions, IHttpClientFactory httpClientFactory)
|
|
|
{
|
|
|
_callRecordRepository = callRecordRepository;
|
|
|
_callDetailRepository = callDetailRepository;
|
|
|
_callRepository = callRepository;
|
|
|
- _sendCallRecordOptions= sendCallRecordOptions;
|
|
|
+ _sendCallRecordOptions = sendCallRecordOptions;
|
|
|
+ _httpClientFactory = httpClientFactory;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
public async Task Handle(CdrNotification notification, CancellationToken cancellationToken)
|
|
|
{
|
|
|
var callDetail = await
|
|
@@ -94,7 +100,26 @@ namespace CallCenter.Application.Handlers
|
|
|
callDto.InSeaTime = call.InSeaTime;
|
|
|
callDto.ConnSeaTime = call.ConnSeaTime;
|
|
|
|
|
|
- //_sendCallRecordOptions.Value.FwUrl
|
|
|
+
|
|
|
+ try
|
|
|
+ {
|
|
|
+ var client = _httpClientFactory.CreateClient();
|
|
|
+ client.DefaultRequestHeaders.ConnectionClose = true;
|
|
|
+ var requestContent = JsonConvert.ToString(callDto);
|
|
|
+ var content = new StringContent(requestContent, Encoding.UTF8, "application/json");
|
|
|
+
|
|
|
+ var responseMessage = await client.PostAsync(_sendCallRecordOptions.Value.FwUrl, content, cancellationToken);
|
|
|
+ var respContent = responseMessage.Content;
|
|
|
+ var respContentString = await respContent.ReadAsStringAsync(cancellationToken);
|
|
|
+ var result = respContentString.Deserialize<FwResult>();
|
|
|
+ //成功
|
|
|
+ if (result.code == 1)
|
|
|
+ {
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ catch {}
|
|
|
+ //HttpContent content = new
|
|
|
}
|
|
|
|
|
|
|
|
@@ -102,4 +127,10 @@ namespace CallCenter.Application.Handlers
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ public class FwResult
|
|
|
+ {
|
|
|
+ public int code { get; set; }
|
|
|
+ public string msg { get; set; }
|
|
|
+ }
|
|
|
}
|