using Quartz; using Microsoft.Extensions.DependencyInjection; using Warehouse.IServices; namespace VolPro.Warehouse.Services; public class SyncDevicesJob : IJob { public async Task Execute(IJobExecutionContext context) { var sp = (IServiceProvider)context.JobDetail.JobDataMap["ServiceProvider"]; var gwSvc = sp.GetService(); var httpFactory = sp.GetService(); var onlineNodes = await gwSvc.FindAsIQueryable(x => x.IsOnline == "在线" && x.Enable == "启用" && x.BaseUrl != null) .ToListAsync(); foreach (var node in onlineNodes) { try { var http = httpFactory.CreateClient(); await http.PostAsync($"{node.BaseUrl}/api/gateway/devices/sync?adapter={node.AdapterTypes}", null); } catch { } } } }