|
@@ -7,6 +7,7 @@ using Push.Share.Dtos.FWMessage;
|
|
|
using Push.Share.Enums;
|
|
|
using System.Net;
|
|
|
using System.Xml;
|
|
|
+using Microsoft.Extensions.Logging;
|
|
|
using XF.Domain.Cache;
|
|
|
using XF.Domain.Dependency;
|
|
|
using XF.Domain.Exceptions;
|
|
@@ -28,6 +29,7 @@ public class PushDomainService : IPushDomainService, IScopeDependency
|
|
|
private readonly IMediator _mediator;
|
|
|
private readonly ITypedCache<CacheWaitSendId> _cacheWaitSendId;
|
|
|
private readonly ICapPublisher _capPublisher;
|
|
|
+ private readonly ILogger<PushDomainService> _logger;
|
|
|
|
|
|
/// <summary>
|
|
|
///
|
|
@@ -42,8 +44,8 @@ public class PushDomainService : IPushDomainService, IScopeDependency
|
|
|
public PushDomainService(IRepository<Message> messageRepository, IHttpClientFactory httpClientFactory
|
|
|
, IMapper mapper, IConfiguration config, IMediator mediator,
|
|
|
ITypedCache<CacheWaitSendId> cacheWaitSendId,
|
|
|
- ICapPublisher capPublisher
|
|
|
- )
|
|
|
+ ICapPublisher capPublisher,
|
|
|
+ ILogger<PushDomainService> logger)
|
|
|
{
|
|
|
_messageRepository = messageRepository;
|
|
|
_httpClientFactory = httpClientFactory;
|
|
@@ -53,6 +55,7 @@ public class PushDomainService : IPushDomainService, IScopeDependency
|
|
|
_mediator = mediator;
|
|
|
_cacheWaitSendId = cacheWaitSendId;
|
|
|
_capPublisher = capPublisher;
|
|
|
+ _logger = logger;
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
@@ -108,7 +111,7 @@ public class PushDomainService : IPushDomainService, IScopeDependency
|
|
|
message.Status = EPushStatus.Failed;
|
|
|
}
|
|
|
|
|
|
- await _messageRepository.AddAsync(message); //写入本地数据库
|
|
|
+ await _messageRepository.AddAsync(message, cancellation); //写入本地数据库
|
|
|
|
|
|
if (message.ClientId == "Hotline")
|
|
|
{
|
|
@@ -314,6 +317,7 @@ public class PushDomainService : IPushDomainService, IScopeDependency
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|
|
|
+ _logger.LogError(ex.InnerException?.Message);
|
|
|
strResult = ex.Message;
|
|
|
}
|
|
|
|
|
@@ -367,7 +371,7 @@ public class PushDomainService : IPushDomainService, IScopeDependency
|
|
|
var result = string.Empty;
|
|
|
try
|
|
|
{
|
|
|
- using (var client = _httpClientFactory.CreateClient())
|
|
|
+ using var client = _httpClientFactory.CreateClient();
|
|
|
using (var response = await client.PostAsync(url, content))
|
|
|
{
|
|
|
if (response.StatusCode == HttpStatusCode.OK)
|
|
@@ -381,6 +385,7 @@ public class PushDomainService : IPushDomainService, IScopeDependency
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|
|
|
+ _logger.LogError(ex.InnerException?.Message);
|
|
|
result = ex.Message;
|
|
|
}
|
|
|
|