MdpApiPullScheduleJob.cs 1.0 KB

1234567891011121314151617181920
  1. using Admin.NET.Plugin.AiDOP.DataPlatform.UnifiedIngress;
  2. using Furion.Schedule;
  3. using Microsoft.Extensions.Configuration;
  4. using Microsoft.Extensions.DependencyInjection;
  5. using Microsoft.Extensions.Logging;
  6. namespace Admin.NET.Plugin.AiDOP.Job;
  7. [JobDetail("job_mdp_api_pull", Description = "数据中台 API 拉取", GroupName = "default", Concurrent = false)]
  8. [PeriodSeconds(15, TriggerId = "trigger_mdp_api_pull", Description = "续接已启用的 API 拉取任务", RunOnStart = false)]
  9. public sealed class MdpApiPullScheduleJob(IServiceScopeFactory scopes, IConfiguration config, ILogger<MdpApiPullScheduleJob> logger) : IJob
  10. {
  11. public async Task ExecuteAsync(JobExecutingContext context, CancellationToken stoppingToken)
  12. {
  13. if (!AidopJobGate.ShouldRun(nameof(MdpApiPullScheduleJob), logger)
  14. || !config.GetValue<bool>("MdpApiPull:ScheduleEnabled")) return;
  15. using var scope = scopes.CreateScope();
  16. await scope.ServiceProvider.GetRequiredService<MdpApiPullService>().RunScheduledAsync(stoppingToken);
  17. }
  18. }