Add result wait service

This commit is contained in:
2025-10-30 12:25:03 +09:00
parent 3bd7341ecc
commit e31a075f58
10 changed files with 152 additions and 32 deletions

View File

@ -1,10 +1,12 @@
using Hcs.WebApp.Data.Hcs;
using Hcs.WebApp.Services;
namespace Hcs.WebApp.BackgroundServices.CampaignManagers
{
public abstract class ManagerBase(OperationExecutionState operationExecutionState, Campaign campaign) : IManager
public abstract class ManagerBase(OperationExecutionState operationExecutionState, ResultWaitState resultWaitState, Campaign campaign) : IManager
{
protected readonly OperationExecutionState operationExecutionState = operationExecutionState;
protected readonly ResultWaitState resultWaitState = resultWaitState;
protected readonly Campaign campaign = campaign;
public IManager.ManagerState State { get; protected set; } = IManager.ManagerState.Created;
@ -12,5 +14,13 @@ namespace Hcs.WebApp.BackgroundServices.CampaignManagers
public abstract Task StartAsync(IServiceScope scope);
public abstract Task CheckStateAsync(IServiceScope scope);
public async Task EndWithFailAsync(IServiceScope scope, Exception e)
{
State = IManager.ManagerState.Ended;
var headquartersService = scope.ServiceProvider.GetRequiredService<HeadquartersService>();
await headquartersService.SetCampaignEndedWithFailAsync(campaign.Id, e.Message);
}
}
}