Phase0_Day2_volpro_side

This commit is contained in:
2026-05-16 23:24:41 +08:00
parent 1b2792f2ed
commit 0f0d0c6a9b
21 changed files with 963 additions and 0 deletions

View File

@@ -0,0 +1,27 @@
using Quartz;
using Microsoft.Extensions.DependencyInjection;
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<Igateway_nodesService>();
var httpFactory = sp.GetService<IHttpClientFactory>();
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 { }
}
}
}