Rename wait to get
This commit is contained in:
@ -7,7 +7,7 @@ namespace Hcs.WebApp.BackgroundServices
|
||||
public class CampaignManagementService(
|
||||
CampaignManagementState campaignManagementState,
|
||||
OperationExecutionState operationExecutionState,
|
||||
ResultWaitState resultWaitState,
|
||||
ResultGetState resultGetState,
|
||||
ManagerFactory managerFactory,
|
||||
IServiceScopeFactory scopeFactory) : BackgroundService
|
||||
{
|
||||
@ -17,7 +17,7 @@ namespace Hcs.WebApp.BackgroundServices
|
||||
|
||||
private readonly CampaignManagementState campaignManagementState = campaignManagementState;
|
||||
private readonly OperationExecutionState operationExecutionState = operationExecutionState;
|
||||
private readonly ResultWaitState resultWaitState = resultWaitState;
|
||||
private readonly ResultGetState resultGetState = resultGetState;
|
||||
private readonly ManagerFactory managerFactory = managerFactory;
|
||||
private readonly IServiceScopeFactory scopeFactory = scopeFactory;
|
||||
private readonly List<IManager> managers = [];
|
||||
@ -75,7 +75,7 @@ namespace Hcs.WebApp.BackgroundServices
|
||||
|
||||
private async Task WaitForOtherStates()
|
||||
{
|
||||
while (!operationExecutionState.Ready || !resultWaitState.Ready)
|
||||
while (!operationExecutionState.Ready || !resultGetState.Ready)
|
||||
{
|
||||
await Task.Delay(STATES_WAIT_TIME);
|
||||
}
|
||||
|
||||
@ -7,8 +7,8 @@ namespace Hcs.WebApp.BackgroundServices.CampaignManagers
|
||||
public class ExportCommonRegistryElementsManager_15_7_0_1(
|
||||
IServiceScopeFactory scopeFactory,
|
||||
OperationExecutionState operationExecutionState,
|
||||
ResultWaitState resultWaitState,
|
||||
Campaign campaign) : ManagerBase(scopeFactory, operationExecutionState, resultWaitState, campaign)
|
||||
ResultGetState resultGetState,
|
||||
Campaign campaign) : ManagerBase(scopeFactory, operationExecutionState, resultGetState, campaign)
|
||||
{
|
||||
private enum Step
|
||||
{
|
||||
@ -97,14 +97,14 @@ namespace Hcs.WebApp.BackgroundServices.CampaignManagers
|
||||
{
|
||||
if (!string.IsNullOrEmpty(operation.MessageGuid))
|
||||
{
|
||||
resultWaitState.EnqueueOperation(operation);
|
||||
resultGetState.EnqueueOperation(operation);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private async Task DoResultWaitStepAsync()
|
||||
{
|
||||
if (resultWaitState.HasCampaignOperation(campaign.Id)) return;
|
||||
if (resultGetState.HasCampaignOperation(campaign.Id)) return;
|
||||
|
||||
DateTime endedAt = default;
|
||||
|
||||
|
||||
@ -7,8 +7,8 @@ namespace Hcs.WebApp.BackgroundServices.CampaignManagers
|
||||
public class ExportPrivateRegistryElementsManager_15_7_0_1(
|
||||
IServiceScopeFactory scopeFactory,
|
||||
OperationExecutionState operationExecutionState,
|
||||
ResultWaitState resultWaitState,
|
||||
Campaign campaign) : ManagerBase(scopeFactory, operationExecutionState, resultWaitState, campaign)
|
||||
ResultGetState resultGetState,
|
||||
Campaign campaign) : ManagerBase(scopeFactory, operationExecutionState, resultGetState, campaign)
|
||||
{
|
||||
private enum Step
|
||||
{
|
||||
@ -97,14 +97,14 @@ namespace Hcs.WebApp.BackgroundServices.CampaignManagers
|
||||
{
|
||||
if (!string.IsNullOrEmpty(operation.MessageGuid))
|
||||
{
|
||||
resultWaitState.EnqueueOperation(operation);
|
||||
resultGetState.EnqueueOperation(operation);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private async Task DoResultWaitStepAsync()
|
||||
{
|
||||
if (resultWaitState.HasCampaignOperation(campaign.Id)) return;
|
||||
if (resultGetState.HasCampaignOperation(campaign.Id)) return;
|
||||
|
||||
DateTime endedAt = default;
|
||||
|
||||
|
||||
@ -7,12 +7,12 @@ namespace Hcs.WebApp.BackgroundServices.CampaignManagers
|
||||
public abstract class ManagerBase(
|
||||
IServiceScopeFactory scopeFactory,
|
||||
OperationExecutionState operationExecutionState,
|
||||
ResultWaitState resultWaitState,
|
||||
ResultGetState resultGetState,
|
||||
Campaign campaign) : IManager
|
||||
{
|
||||
protected readonly IServiceScope scope = scopeFactory.CreateScope();
|
||||
protected readonly OperationExecutionState operationExecutionState = operationExecutionState;
|
||||
protected readonly ResultWaitState resultWaitState = resultWaitState;
|
||||
protected readonly ResultGetState resultGetState = resultGetState;
|
||||
protected readonly Campaign campaign = campaign;
|
||||
|
||||
private HeadquartersService? headquartersService;
|
||||
|
||||
@ -2,19 +2,19 @@
|
||||
|
||||
namespace Hcs.WebApp.BackgroundServices.CampaignManagers
|
||||
{
|
||||
public class ManagerFactory(IServiceScopeFactory serviceScopeFactory, OperationExecutionState operationExecutionState, ResultWaitState resultWaitState)
|
||||
public class ManagerFactory(IServiceScopeFactory serviceScopeFactory, OperationExecutionState operationExecutionState, ResultGetState resultGetState)
|
||||
{
|
||||
protected readonly IServiceScopeFactory serviceScopeFactory = serviceScopeFactory;
|
||||
protected readonly OperationExecutionState operationExecutionState = operationExecutionState;
|
||||
protected readonly ResultWaitState resultWaitState = resultWaitState;
|
||||
protected readonly ResultGetState resultGetState = resultGetState;
|
||||
|
||||
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),
|
||||
Campaign.CampaignType.ParseHousesData_15_7_0_1 => new ParseHousesDataManager_15_7_0_1(serviceScopeFactory, operationExecutionState, resultWaitState, campaign)
|
||||
Campaign.CampaignType.ExportPrivateRegistryElements_15_7_0_1 => new ExportPrivateRegistryElementsManager_15_7_0_1(serviceScopeFactory, operationExecutionState, resultGetState, campaign),
|
||||
Campaign.CampaignType.ExportCommonRegistryElements_15_7_0_1 => new ExportCommonRegistryElementsManager_15_7_0_1(serviceScopeFactory, operationExecutionState, resultGetState, campaign),
|
||||
Campaign.CampaignType.ParseHousesData_15_7_0_1 => new ParseHousesDataManager_15_7_0_1(serviceScopeFactory, operationExecutionState, resultGetState, campaign)
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@ -5,8 +5,8 @@ namespace Hcs.WebApp.BackgroundServices.CampaignManagers
|
||||
public class ParseHousesDataManager_15_7_0_1(
|
||||
IServiceScopeFactory scopeFactory,
|
||||
OperationExecutionState operationExecutionState,
|
||||
ResultWaitState resultWaitState,
|
||||
Campaign campaign) : ManagerBase(scopeFactory, operationExecutionState, resultWaitState, campaign)
|
||||
ResultGetState resultGetState,
|
||||
Campaign campaign) : ManagerBase(scopeFactory, operationExecutionState, resultGetState, campaign)
|
||||
{
|
||||
protected override int StepCount => throw new NotImplementedException();
|
||||
|
||||
|
||||
@ -9,12 +9,12 @@ using Hcs.WebApp.Utils;
|
||||
|
||||
namespace Hcs.WebApp.BackgroundServices
|
||||
{
|
||||
public class ResultWaitService(
|
||||
ResultWaitState state,
|
||||
public class ResultGetService(
|
||||
ResultGetState state,
|
||||
ResultGetterFactory resultGetterFactory,
|
||||
IServiceScopeFactory scopeFactory) : BackgroundService
|
||||
{
|
||||
private class WaitState
|
||||
private class GetState
|
||||
{
|
||||
public int attempt;
|
||||
public int timer;
|
||||
@ -24,10 +24,10 @@ namespace Hcs.WebApp.BackgroundServices
|
||||
private const int ITERATION_TIME = 10000;
|
||||
private const int SLEEP_TIME = 30000;
|
||||
|
||||
private readonly ResultWaitState state = state;
|
||||
private readonly ResultGetState state = state;
|
||||
private readonly ResultGetterFactory resultGetterFactory = resultGetterFactory;
|
||||
private readonly IServiceScopeFactory scopeFactory = scopeFactory;
|
||||
private readonly List<(Operation operation, WaitState state)> entries = [];
|
||||
private readonly List<(Operation operation, GetState state)> entries = [];
|
||||
|
||||
private Broker.Logger.ILogger logger;
|
||||
private IMessageCapturer messageCapturer;
|
||||
@ -47,7 +47,7 @@ namespace Hcs.WebApp.BackgroundServices
|
||||
|
||||
if (stoppingToken.IsCancellationRequested) return;
|
||||
|
||||
entries.Add(new (operation, new WaitState()));
|
||||
entries.Add(new (operation, new GetState()));
|
||||
}
|
||||
|
||||
if (entries.Count > 0)
|
||||
@ -3,7 +3,7 @@ using System.Collections.Concurrent;
|
||||
|
||||
namespace Hcs.WebApp.BackgroundServices
|
||||
{
|
||||
public class ResultWaitState
|
||||
public class ResultGetState
|
||||
{
|
||||
public delegate void OperationEnded(int operationId, int campaignId, DateTime endedAt, string failureReason);
|
||||
|
||||
@ -12,7 +12,7 @@
|
||||
@inject HeadquartersService HeadquartersService
|
||||
@inject CampaignManagementState CampaignManagementState
|
||||
@inject OperationExecutionState OperationExecutionState
|
||||
@inject ResultWaitState ResultWaitState
|
||||
@inject ResultGetState ResultGetState
|
||||
|
||||
<PageTitle>Кампании</PageTitle>
|
||||
|
||||
@ -89,7 +89,7 @@
|
||||
OperationExecutionState.OnOperationExecuted += OnOperationExecuted;
|
||||
OperationExecutionState.OnOperationEnded += OnOperationEnded;
|
||||
|
||||
ResultWaitState.OnOperationEnded += OnOperationEnded;
|
||||
ResultGetState.OnOperationEnded += OnOperationEnded;
|
||||
}
|
||||
|
||||
ChangeState(PageState.Idle);
|
||||
@ -267,6 +267,6 @@
|
||||
OperationExecutionState.OnOperationExecuted -= OnOperationExecuted;
|
||||
OperationExecutionState.OnOperationEnded -= OnOperationEnded;
|
||||
|
||||
ResultWaitState.OnOperationEnded -= OnOperationEnded;
|
||||
ResultGetState.OnOperationEnded -= OnOperationEnded;
|
||||
}
|
||||
}
|
||||
|
||||
@ -11,7 +11,7 @@
|
||||
@inject AuthenticationStateProvider AuthenticationStateProvider
|
||||
@inject HeadquartersService HeadquartersService
|
||||
@inject OperationExecutionState OperationExecutionState
|
||||
@inject ResultWaitState ResultWaitState
|
||||
@inject ResultGetState ResultGetState
|
||||
|
||||
<PageTitle>Операции</PageTitle>
|
||||
|
||||
@ -66,7 +66,7 @@
|
||||
OperationExecutionState.OnOperationExecuted += OnOperationExecuted;
|
||||
OperationExecutionState.OnOperationEnded += OnOperationEnded;
|
||||
|
||||
ResultWaitState.OnOperationEnded += OnOperationEnded;
|
||||
ResultGetState.OnOperationEnded += OnOperationEnded;
|
||||
}
|
||||
|
||||
ChangeState(PageState.Idle);
|
||||
@ -142,6 +142,6 @@
|
||||
OperationExecutionState.OnOperationExecuted -= OnOperationExecuted;
|
||||
OperationExecutionState.OnOperationEnded -= OnOperationEnded;
|
||||
|
||||
ResultWaitState.OnOperationEnded -= OnOperationEnded;
|
||||
ResultGetState.OnOperationEnded -= OnOperationEnded;
|
||||
}
|
||||
}
|
||||
|
||||
@ -73,14 +73,14 @@ builder.Services.AddScoped<HouseService>();
|
||||
|
||||
builder.Services.AddSingleton<CampaignManagementState>();
|
||||
builder.Services.AddSingleton<OperationExecutionState>();
|
||||
builder.Services.AddSingleton<ResultWaitState>();
|
||||
builder.Services.AddSingleton<ResultGetState>();
|
||||
builder.Services.AddSingleton<ManagerFactory>();
|
||||
builder.Services.AddSingleton<ExecutorFactory>();
|
||||
builder.Services.AddSingleton<ResultGetterFactory>();
|
||||
|
||||
builder.Services.AddHostedService<CampaignManagementService>();
|
||||
builder.Services.AddHostedService<OperationExecutionService>();
|
||||
builder.Services.AddHostedService<ResultWaitService>();
|
||||
builder.Services.AddHostedService<ResultGetService>();
|
||||
|
||||
var activator = new RadzenComponentActivator();
|
||||
activator.Override(typeof(RadzenDataGrid<>), typeof(LocalizedRadzenDataGrid<>));
|
||||
|
||||
Reference in New Issue
Block a user