Add result wait service
This commit is contained in:
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user