2023-08-25 15:32:06 +10:00
|
|
|
using PARR.EsppTemplateSync;
|
|
|
|
|
|
|
|
|
|
namespace PARR.EsppTemplateSyncWorker
|
|
|
|
|
{
|
|
|
|
|
public class Worker : BackgroundService
|
|
|
|
|
{
|
|
|
|
|
private readonly ILogger<Worker> _logger;
|
|
|
|
|
private readonly ITemplateSyncer templateSyncer;
|
|
|
|
|
|
|
|
|
|
public Worker(ILogger<Worker> logger, ITemplateSyncer templateSyncer)
|
|
|
|
|
{
|
|
|
|
|
_logger = logger;
|
|
|
|
|
this.templateSyncer = templateSyncer;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override async Task ExecuteAsync(CancellationToken stoppingToken)
|
|
|
|
|
{
|
2023-09-01 11:47:39 +10:00
|
|
|
|
2023-08-31 12:04:05 +10:00
|
|
|
await templateSyncer.StartAsync();
|
2023-08-25 15:32:06 +10:00
|
|
|
|
2023-09-01 11:47:39 +10:00
|
|
|
|
2023-08-25 15:32:06 +10:00
|
|
|
//while (!stoppingToken.IsCancellationRequested)
|
|
|
|
|
//{
|
|
|
|
|
// _logger.LogInformation("Worker running at: {time}", DateTimeOffset.Now);
|
|
|
|
|
// await Task.Delay(1 * 1000, stoppingToken);
|
|
|
|
|
//}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override Task StopAsync(CancellationToken cancellationToken)
|
|
|
|
|
{
|
2023-08-31 12:04:05 +10:00
|
|
|
templateSyncer.Stop();
|
2023-08-25 15:32:06 +10:00
|
|
|
|
|
|
|
|
return base.StopAsync(cancellationToken);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|