|
@@ -28,9 +28,10 @@ namespace CallCenter.Application.Handlers
|
|
|
private readonly IRealtimeService _realtimeService;
|
|
|
private readonly IUserCacheManager _userCacheManager;
|
|
|
private readonly IWorkRepository _workRepository;
|
|
|
+ private readonly ICallRecordFailRepository _callRecordFailRepository;
|
|
|
|
|
|
|
|
|
- public CdrNotificationHandler(ICallRecordRepository callRecordRepository, ICallDetailRepository callDetailRepository, ICallRepository callRepository, IOptionsSnapshot<SendCallRecord> sendCallRecordOptions, IHttpClientFactory httpClientFactory,ILogger<CdrNotificationHandler> logger,IRealtimeService realtimeService,IUserCacheManager userCacheManager,IWorkRepository workRepository)
|
|
|
+ public CdrNotificationHandler(ICallRecordRepository callRecordRepository, ICallDetailRepository callDetailRepository, ICallRepository callRepository, IOptionsSnapshot<SendCallRecord> sendCallRecordOptions, IHttpClientFactory httpClientFactory,ILogger<CdrNotificationHandler> logger,IRealtimeService realtimeService,IUserCacheManager userCacheManager,IWorkRepository workRepository,ICallRecordFailRepository callRecordFailRepository)
|
|
|
{
|
|
|
_callRecordRepository = callRecordRepository;
|
|
|
_callDetailRepository = callDetailRepository;
|
|
@@ -41,6 +42,7 @@ namespace CallCenter.Application.Handlers
|
|
|
_realtimeService = realtimeService;
|
|
|
_userCacheManager = userCacheManager;
|
|
|
_workRepository = workRepository;
|
|
|
+ _callRecordFailRepository = callRecordFailRepository;
|
|
|
}
|
|
|
|
|
|
|
|
@@ -163,6 +165,7 @@ namespace CallCenter.Application.Handlers
|
|
|
var list = new List<OutCallDto>();
|
|
|
list.Add(callDto);
|
|
|
|
|
|
+ string respContentString = "";
|
|
|
try
|
|
|
{
|
|
|
using var client = _httpClientFactory.CreateClient();
|
|
@@ -172,12 +175,19 @@ namespace CallCenter.Application.Handlers
|
|
|
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);
|
|
|
+ respContentString = await respContent.ReadAsStringAsync(cancellationToken);
|
|
|
var result = JsonSerializer.Deserialize<FwResult>(respContentString);
|
|
|
_logger.LogInformation("推送通话报告结果:" + respContentString);
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|
|
|
+ //新增未推送成功记录
|
|
|
+ var callRecordFail = new CallRecordFail();
|
|
|
+ callRecordFail.FailType = EFailType.CallRecord;
|
|
|
+ callRecordFail.FailString = respContentString;
|
|
|
+ callRecordFail.FailReason = ex.Message;
|
|
|
+ await _callRecordFailRepository.AddAsync(callRecordFail, cancellationToken);
|
|
|
+
|
|
|
_logger.LogInformation("推送通话报告失败:" + ex.Message);
|
|
|
//throw new UserFriendlyException(ex.Message);
|
|
|
}
|
|
@@ -231,12 +241,18 @@ namespace CallCenter.Application.Handlers
|
|
|
var content = new StringContent(requestContent, Encoding.UTF8, "application/json");
|
|
|
var responseMessage = await client.PostAsync(_sendCallRecordOptions.Value.NotReceivedUrl, content, cancellationToken);
|
|
|
var respContent = responseMessage.Content;
|
|
|
- var respContentString = await respContent.ReadAsStringAsync(cancellationToken);
|
|
|
+ respContentString = await respContent.ReadAsStringAsync(cancellationToken);
|
|
|
var result = JsonSerializer.Deserialize<FwResult>(respContentString);
|
|
|
_logger.LogInformation("推送未接听报告结果:" + respContentString);
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|
|
|
+ //新增未推送成功记录
|
|
|
+ var callRecordFail = new CallRecordFail();
|
|
|
+ callRecordFail.FailType = EFailType.NotReceived;
|
|
|
+ callRecordFail.FailString = respContentString;
|
|
|
+ callRecordFail.FailReason = ex.Message;
|
|
|
+ await _callRecordFailRepository.AddAsync(callRecordFail, cancellationToken);
|
|
|
_logger.LogInformation("推送未接听报告失败:" + ex.Message);
|
|
|
//throw new UserFriendlyException(ex.Message);
|
|
|
}
|