Files
parr_api/PARR.Worker/PARR.Worker/Worker.cs
Mikhail Kuznetsov 118cd280df Syncer АИХ ИТ
2023-06-01 12:30:38 +10:00

31 lines
1.1 KiB
C#

using Microsoft.EntityFrameworkCore;
using PARR.DAL.Services.Interfaces;
namespace PARR.Worker
{
public class Worker : BackgroundService
{
private readonly ILogger<Worker> logger;
private readonly IHostService hostService;
public Worker(ILogger<Worker> logger, IHostService hostService)
{
this.logger = logger;
this.hostService = hostService;
}
protected override async Task ExecuteAsync(CancellationToken stoppingToken)
{
logger.LogInformation("--- Сервис запущен! ---");
while (!stoppingToken.IsCancellationRequested)
{
var hosts = await hostService.Get().ToListAsync();
foreach ( var host in hosts ) { logger.LogInformation($"{host.HostName}"); }
// syncher.InvokeAsync();
//await attachmentUploader.UploadAsync();
//logger.LogInformation("Worker running at: {time}", DateTimeOffset.Now);
await Task.Delay(60000, stoppingToken);
}
}
}
}