hwh
2025-02-10 b16c4927b99063f463f83f855c53fb0af8440072
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
using Furion.Schedule;
using Microsoft.AspNetCore.SignalR;
using Microsoft.Extensions.Logging;
 
namespace WCS.Application;
/// <summary>
/// PLC作业任务
/// </summary>
[JobDetail("job_plc", Description = "PLC作业任务", GroupName = "default", Concurrent = false)]
[Daily(TriggerId = "trigger_plc", Description = "PLC作业任务")]
public class PLCJob : IJob
{
    private readonly IServiceScopeFactory _scopeFactory;
    private readonly ILogger _logger;
 
    public PLCJob(IServiceScopeFactory scopeFactory, ILoggerFactory loggerFactory)
    {
        _scopeFactory = scopeFactory;
        _logger = loggerFactory.CreateLogger(CommonConst.SysLogCategoryName);
    }
 
    public async Task ExecuteAsync(JobExecutingContext context, CancellationToken stoppingToken)
    {
        //using var serviceScope = _scopeFactory.CreateScope();
 
        //var rep = serviceScope.ServiceProvider.GetRequiredService<SqlSugarRepository<SysOnlineUser>>();
        //await rep.CopyNew().AsDeleteable().ExecuteCommandAsync(stoppingToken);
 
        PLCTaskAction.Init();
 
 
        //string msg = $"【{DateTime.Now}】PLC服务启动...";
        //var originColor = Console.ForegroundColor;
        //Console.ForegroundColor = ConsoleColor.Red;
        //Console.WriteLine(msg);
        //Console.ForegroundColor = originColor;
 
        //// 自定义日志
        //_logger.LogInformation(msg);
    }
}