Add new campaign template
This commit is contained in:
@ -34,24 +34,11 @@ namespace Hcs.WebApp.BackgroundServices
|
||||
if (stoppingToken.IsCancellationRequested) return;
|
||||
|
||||
var manager = managerFactory.CreateManager(campaign);
|
||||
if (manager != null)
|
||||
{
|
||||
managers.Add(manager);
|
||||
|
||||
manager.OnCampaignStarted += OnCampaignStarted;
|
||||
manager.OnCampaignProgressStep += OnCampaignProgressStep;
|
||||
manager.OnCampaignEnded += OnCampaignEnded;
|
||||
}
|
||||
else
|
||||
{
|
||||
using var scope = scopeFactory.CreateScope();
|
||||
var headquartersService = scope.ServiceProvider.GetRequiredService<HeadquartersService>();
|
||||
var endedAt = DateTime.UtcNow;
|
||||
var failureReason = "Не удалось найти подходящий менеджер кампании";
|
||||
await headquartersService.SetCampaignEndedWithFailAsync(campaign.Id, endedAt, failureReason);
|
||||
|
||||
campaignManagementState.InvokeOnCampaignEnded(campaign.Id, campaign.Type, endedAt, failureReason);
|
||||
}
|
||||
managers.Add(manager);
|
||||
}
|
||||
|
||||
foreach (var manager in managers)
|
||||
|
||||
@ -0,0 +1,18 @@
|
||||
using Hcs.WebApp.Data.Hcs;
|
||||
|
||||
namespace Hcs.WebApp.BackgroundServices.CampaignManagers
|
||||
{
|
||||
public class ExportHousesDataManager_15_7_0_1(
|
||||
IServiceScopeFactory scopeFactory,
|
||||
OperationExecutionState operationExecutionState,
|
||||
ResultWaitState resultWaitState,
|
||||
Campaign campaign) : ManagerBase(scopeFactory, operationExecutionState, resultWaitState, campaign)
|
||||
{
|
||||
protected override int StepCount => throw new NotImplementedException();
|
||||
|
||||
public override Task ProcessAsync()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -8,14 +8,13 @@ namespace Hcs.WebApp.BackgroundServices.CampaignManagers
|
||||
protected readonly OperationExecutionState operationExecutionState = operationExecutionState;
|
||||
protected readonly ResultWaitState resultWaitState = resultWaitState;
|
||||
|
||||
public IManager? CreateManager(Campaign campaign)
|
||||
public IManager CreateManager(Campaign campaign)
|
||||
{
|
||||
return campaign.Type switch
|
||||
{
|
||||
Campaign.CampaignType.ExportPrivateRegistryElements_15_7_0_1 => new ExportPrivateRegistryElementsManager_15_7_0_1(serviceScopeFactory, operationExecutionState, resultWaitState, campaign),
|
||||
Campaign.CampaignType.ExportCommonRegistryElements_15_7_0_1 => new ExportCommonRegistryElementsManager_15_7_0_1(serviceScopeFactory, operationExecutionState, resultWaitState, campaign),
|
||||
|
||||
_ => null,
|
||||
Campaign.CampaignType.ExportHousesData_15_7_0_1 => new ExportHousesDataManager_15_7_0_1(serviceScopeFactory, operationExecutionState, resultWaitState, campaign)
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@ -12,9 +12,7 @@ namespace Hcs.WebApp.BackgroundServices.OperationExecutors
|
||||
return operation.Type switch
|
||||
{
|
||||
Operation.OperationType.Nsi_ExportNsiItem_15_7_0_1 => new ExportDataProviderNsiItemExecutor_15_7_0_1(client, scope, operation),
|
||||
Operation.OperationType.NsiCommon_ExportNsiItem_15_7_0_1 => new ExportNsiItemExecutor_15_7_0_1(client, scope, operation),
|
||||
|
||||
_ => throw new NotImplementedException($"Не удалось создать выполнителя операции типа {operation.Type}"),
|
||||
Operation.OperationType.NsiCommon_ExportNsiItem_15_7_0_1 => new ExportNsiItemExecutor_15_7_0_1(client, scope, operation)
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@ -12,9 +12,7 @@ namespace Hcs.WebApp.BackgroundServices.ResultGetters
|
||||
return operation.Type switch
|
||||
{
|
||||
Operation.OperationType.Nsi_ExportNsiItem_15_7_0_1 => new ExportDataProviderNsiItemGetter_15_7_0_1(client, scope, operation),
|
||||
Operation.OperationType.NsiCommon_ExportNsiItem_15_7_0_1 => new ExportNsiItemGetter_15_7_0_1(client, scope, operation),
|
||||
|
||||
_ => throw new NotImplementedException($"Не удалось создать получателя результата операции типа {operation.Type}"),
|
||||
Operation.OperationType.NsiCommon_ExportNsiItem_15_7_0_1 => new ExportNsiItemGetter_15_7_0_1(client, scope, operation)
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user