Phase0_Day2_volpro_side
This commit is contained in:
27
api_sqlsugar/Warehouse/Services/SyncDevicesJob.cs
Normal file
27
api_sqlsugar/Warehouse/Services/SyncDevicesJob.cs
Normal 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 { }
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user