You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

44 lines
1.2 KiB
C#

10 months ago
using NewLife.Log;
using NewLife.Threading;
using WorkerSynReport.Plc;
namespace WorkerSynReport;
public class PclWorker:BackgroundService
{
private readonly IServiceScopeFactory _scopeFactory;
private readonly ILogger<PclWorker> _logger;
TimerX? _timer;
public PclWorker(ILogger<PclWorker> logger, IServiceScopeFactory scopeFactory)
{
_logger = logger;
this._scopeFactory = scopeFactory;
}
protected override async Task ExecuteAsync(CancellationToken stoppingToken)
{
6 months ago
_timer ??= new TimerX(DoPlc, "", 100, 10000);
10 months ago
_timer.Async = true;
// while (!stoppingToken.IsCancellationRequested)
// {
//
// await Task.Delay(1000, stoppingToken);
// }
}
private void DoPlc(Object state)
{
6 months ago
// _logger.LogInformation("{Data}",DateTime.Now.ToFullString());
10 months ago
//todo 备份数据库
// using var scope = _scopeFactory.CreateScope();
// var services = scope.ServiceProvider;
// ReportReadDb? readDb = services.GetService<ReportReadDb>();
//
// readDb?.ReadReport();
// readDb?.ReadFeededDry();
}
}