| 1234567891011121314151617181920212223242526272829303132333435363738 |
- using Admin.NET.Plugin.AiDOP.Entity.S8;
- namespace Admin.NET.Plugin.AiDOP.Service.S8;
- /// <summary>
- /// 监视规则轮询调度服务(首轮存根)。
- /// 后续接入 Admin.NET 定时任务机制后,由调度器周期调用 <see cref="RunOnceAsync"/>,
- /// 按各规则的 PollIntervalSeconds 逐条评估并生成异常记录。
- /// </summary>
- public class S8WatchSchedulerService : ITransient
- {
- private readonly SqlSugarRepository<AdoS8WatchRule> _ruleRep;
- private readonly SqlSugarRepository<AdoS8Exception> _exceptionRep;
- private readonly S8NotificationService _notificationService;
- public S8WatchSchedulerService(
- SqlSugarRepository<AdoS8WatchRule> ruleRep,
- SqlSugarRepository<AdoS8Exception> exceptionRep,
- S8NotificationService notificationService)
- {
- _ruleRep = ruleRep;
- _exceptionRep = exceptionRep;
- _notificationService = notificationService;
- }
- /// <summary>
- /// 单次轮询入口。当前为存根,返回已启用规则数量,不做实际数据采集。
- /// </summary>
- public async Task<int> RunOnceAsync()
- {
- var enabledRules = await _ruleRep.AsQueryable()
- .Where(x => x.Enabled)
- .CountAsync();
- // TODO: 逐条评估规则、生成异常、触发通知
- return enabledRules;
- }
- }
|