|
|
@ -5,21 +5,21 @@ |
|
|
|
using Microsoft.Extensions.Options; |
|
|
|
using Microsoft.Extensions.Logging; |
|
|
|
using Dapper; |
|
|
|
using IntegrationEvents; |
|
|
|
using IntegrationEvents.Events; |
|
|
|
using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Abstractions; |
|
|
|
|
|
|
|
public class SagaManagerService : ISagaManagerService |
|
|
|
{ |
|
|
|
private readonly SagaManagerSettings _settings; |
|
|
|
private readonly ISagaManagerIntegrationEventService _sagaManagerIntegrationEventService; |
|
|
|
private readonly IEventBus _eventBus; |
|
|
|
private readonly ILogger<SagaManagerService> _logger; |
|
|
|
|
|
|
|
public SagaManagerService(IOptions<SagaManagerSettings> settings, |
|
|
|
ISagaManagerIntegrationEventService sagaManagerIntegrationEventService, |
|
|
|
IEventBus eventBus, |
|
|
|
ILogger<SagaManagerService> logger) |
|
|
|
{ |
|
|
|
_settings = settings.Value; |
|
|
|
_sagaManagerIntegrationEventService = sagaManagerIntegrationEventService; |
|
|
|
_eventBus = eventBus; |
|
|
|
_logger = logger; |
|
|
|
} |
|
|
|
|
|
|
@ -29,8 +29,8 @@ |
|
|
|
|
|
|
|
foreach (var orderId in orderIds) |
|
|
|
{ |
|
|
|
var confirmGracePeriodEvent = new ConfirmGracePeriodCommand(orderId); |
|
|
|
_sagaManagerIntegrationEventService.PublishThroughEventBus(confirmGracePeriodEvent); |
|
|
|
var confirmGracePeriodEvent = new GracePeriodConfirmedIntegrationEvent(orderId); |
|
|
|
_eventBus.Publish(confirmGracePeriodEvent); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
@ -45,9 +45,9 @@ |
|
|
|
conn.Open(); |
|
|
|
orderIds = conn.Query<int>( |
|
|
|
@"SELECT Id FROM [Microsoft.eShopOnContainers.Services.OrderingDb].[ordering].[orders]
|
|
|
|
WHERE DATEDIFF(hour, [OrderDate], GETDATE()) >= @GracePeriod |
|
|
|
WHERE DATEDIFF(hour, [OrderDate], GETDATE()) >= @GracePeriodTime |
|
|
|
AND [OrderStatusId] = 1",
|
|
|
|
new { GracePeriod = _settings.GracePeriod }); |
|
|
|
new { GracePeriodTime = _settings.GracePeriodTime }); |
|
|
|
} |
|
|
|
catch (SqlException exception) |
|
|
|
{ |
|
|
|