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