Add operation kind
This commit is contained in:
@ -1,6 +1,34 @@
|
||||
namespace Hcs.WebApp.BackgroundServices
|
||||
using Hcs.WebApp.BackgroundServices.DataParsers;
|
||||
using Hcs.WebApp.Services;
|
||||
|
||||
namespace Hcs.WebApp.BackgroundServices
|
||||
{
|
||||
public class DataParsingService
|
||||
public class DataParsingService(
|
||||
DataParsingState state,
|
||||
DataParserFactory dataParserFactory,
|
||||
IServiceScopeFactory scopeFactory) : BackgroundService
|
||||
{
|
||||
private readonly DataParsingState state = state;
|
||||
private readonly DataParserFactory dataParserFactory = dataParserFactory;
|
||||
private readonly IServiceScopeFactory scopeFactory = scopeFactory;
|
||||
|
||||
protected override async Task ExecuteAsync(CancellationToken stoppingToken)
|
||||
{
|
||||
await InitializeStateAsync();
|
||||
}
|
||||
|
||||
private async Task InitializeStateAsync()
|
||||
{
|
||||
using var scope = scopeFactory.CreateScope();
|
||||
var headquartersService = scope.ServiceProvider.GetRequiredService<HeadquartersService>();
|
||||
|
||||
var operations = await headquartersService.GetResultWaitingOperationsAsync();
|
||||
foreach (var operation in operations)
|
||||
{
|
||||
state.EnqueueOperation(operation);
|
||||
}
|
||||
|
||||
state.Ready = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user