25 lines
687 B
C#
25 lines
687 B
C#
// 已迁移到 TaskController.RuleEngine() — 构建时需删除此文件
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace Warehouse.Services;
|
|
|
|
/// <summary>
|
|
/// 规则引擎定时任务。
|
|
/// Cron: 0/10 * * * * ? (每10秒)
|
|
/// 挂载到 Vol.Pro Quartz 调度器。
|
|
/// </summary>
|
|
public class RuleEngineJob : IJob
|
|
{
|
|
public async Task Execute(IJobExecutionContext context)
|
|
{
|
|
var sp = (IServiceProvider)context.JobDetail.JobDataMap["ServiceProvider"];
|
|
if (sp == null) return;
|
|
|
|
var engine = sp.GetService<RuleEngineService>();
|
|
if (engine == null) return;
|
|
|
|
await engine.EvaluateAllAsync();
|
|
}
|
|
}
|