fix 心跳间隔任务调整
This commit is contained in:
@@ -22,17 +22,17 @@ public class HeartbeatJob : BaseJob
|
||||
{
|
||||
var devices = await DbContext.Queryable<DeviceEntity>().Where(x => x.Enable).Where(x => x.HeartbeatInterval > 0).ToListAsync();
|
||||
|
||||
devices.AsParallel().ForAll(device =>
|
||||
await Parallel.ForEachAsync(devices, async (device, cancellationToken) =>
|
||||
{
|
||||
try
|
||||
{
|
||||
var ipInfo = JsonConvert.DeserializeObject<IPPortDto>(device.ConnectionInfo);
|
||||
new TcpClient().Connect(IPAddress.Parse(ipInfo.IP), ipInfo.Port);
|
||||
await new TcpClient().ConnectAsync(IPAddress.Parse(ipInfo.IP), ipInfo.Port, cancellationToken);
|
||||
|
||||
DbContext.Updateable<DeviceRegistryEntity>()
|
||||
await DbContext.Updateable<DeviceRegistryEntity>()
|
||||
.SetColumns(x => x.LastHeartbeatTime == DateTime.Now)
|
||||
.Where(x => x.DeviceUniqueNo == device.UniqueNo)
|
||||
.ExecuteCommand();
|
||||
.ExecuteCommandAsync(cancellationToken);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user