|
@@ -1,8 +1,10 @@
|
|
|
using CallCenter.Calls;
|
|
|
+using CallCenter.NewRock.Handlers;
|
|
|
using CallCenter.Notifications;
|
|
|
using CallCenter.Share.Dtos;
|
|
|
using CallCenter.Share.Enums;
|
|
|
using MediatR;
|
|
|
+using Microsoft.Extensions.Logging;
|
|
|
using Microsoft.Extensions.Options;
|
|
|
using NewRock.Sdk.Extensions;
|
|
|
using System.Text;
|
|
@@ -18,14 +20,16 @@ namespace CallCenter.Application.Handlers
|
|
|
private readonly ICallRepository _callRepository;
|
|
|
private readonly IOptionsSnapshot<SendCallRecord> _sendCallRecordOptions;
|
|
|
private readonly IHttpClientFactory _httpClientFactory;
|
|
|
+ private readonly ILogger<CdrNotificationHandler> _logger;
|
|
|
|
|
|
- public CdrNotificationHandler(ICallRecordRepository callRecordRepository, ICallDetailRepository callDetailRepository, ICallRepository callRepository, IOptionsSnapshot<SendCallRecord> sendCallRecordOptions, IHttpClientFactory httpClientFactory)
|
|
|
+ public CdrNotificationHandler(ICallRecordRepository callRecordRepository, ICallDetailRepository callDetailRepository, ICallRepository callRepository, IOptionsSnapshot<SendCallRecord> sendCallRecordOptions, IHttpClientFactory httpClientFactory,ILogger<CdrNotificationHandler> logger)
|
|
|
{
|
|
|
_callRecordRepository = callRecordRepository;
|
|
|
_callDetailRepository = callDetailRepository;
|
|
|
_callRepository = callRepository;
|
|
|
_sendCallRecordOptions = sendCallRecordOptions;
|
|
|
_httpClientFactory = httpClientFactory;
|
|
|
+ _logger = logger;
|
|
|
}
|
|
|
|
|
|
|
|
@@ -106,12 +110,13 @@ namespace CallCenter.Application.Handlers
|
|
|
|
|
|
var list = new List<OutCallDto>();
|
|
|
list.Add(callDto);
|
|
|
+
|
|
|
try
|
|
|
{
|
|
|
var client = _httpClientFactory.CreateClient();
|
|
|
client.DefaultRequestHeaders.ConnectionClose = true;
|
|
|
var requestContent = JsonSerializer.Serialize(list);
|
|
|
-
|
|
|
+ _logger.LogInformation(requestContent);
|
|
|
var content = new StringContent(requestContent,Encoding.UTF8, "application/json");
|
|
|
|
|
|
var responseMessage = await client.PostAsync(_sendCallRecordOptions.Value.FwUrl, content, cancellationToken);
|