Change events args

This commit is contained in:
2025-11-05 18:17:19 +09:00
parent 8fd7d4a571
commit e58221c430
11 changed files with 96 additions and 65 deletions

View File

@ -5,7 +5,6 @@ using Hcs.WebApp.BackgroundServices.OperationExecutors;
using Hcs.WebApp.Config;
using Hcs.WebApp.Services;
using Hcs.WebApp.Utils;
using System.Transactions;
namespace Hcs.WebApp.BackgroundServices
{
@ -40,25 +39,28 @@ namespace Hcs.WebApp.BackgroundServices
var messageGuid = string.Empty;
try
{
var startedAt = DateTime.UtcNow;
await headquartersService.SetOperationStartedAsync(operation.Id, startedAt);
state.InvokeOnOperationStarted(operation.Id, operation.CampaignId, startedAt);
var executor = executorFactory.CreateExecutor(scope, client, operation);
await headquartersService.SetOperationStartedAsync(operation.Id);
state.InvokeOnOperationStarted(operation);
messageGuid = await executor.ExecuteAsync(stoppingToken);
}
catch (Exception e)
{
await headquartersService.SetOperationEndedWithFailAsync(operation.Id, e.CombineMessages());
var endedAt = DateTime.UtcNow;
var failureReason = e.CombineMessages();
await headquartersService.SetOperationEndedWithFailAsync(operation.Id, endedAt, failureReason);
state.InvokeOnOperationEnded(operation);
state.InvokeOnOperationEnded(operation.Id, operation.CampaignId, endedAt, failureReason);
}
if (!string.IsNullOrEmpty(messageGuid))
{
await headquartersService.SetOperationMessageGuidAsync(operation.Id, messageGuid);
state.InvokeOnOperationExecuted(operation);
state.InvokeOnOperationExecuted(operation.Id, operation.CampaignId, messageGuid);
}
state.UnsetProcessingOperation(operation);