From 241d57651920d02c19f6efcd52ca6a032237dd4c Mon Sep 17 00:00:00 2001 From: "2248356998 qq.com" <2248356998@qq.com> Date: Sun, 16 Jul 2023 11:36:45 +0800 Subject: [PATCH] =?UTF-8?q?=E5=86=97=E4=BD=99=E8=AE=BE=E5=A4=87=E5=88=A0?= =?UTF-8?q?=E9=99=A4=E5=90=8E=E4=BC=9A=E5=AF=BC=E8=87=B4=E5=90=8E=E5=8F=B0?= =?UTF-8?q?=E5=87=BA=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Workers/Collect/CollectDeviceWorker.cs | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/ThingsGateway.Web.Foundation/Workers/Collect/CollectDeviceWorker.cs b/src/ThingsGateway.Web.Foundation/Workers/Collect/CollectDeviceWorker.cs index ba229c109..42c9e7a67 100644 --- a/src/ThingsGateway.Web.Foundation/Workers/Collect/CollectDeviceWorker.cs +++ b/src/ThingsGateway.Web.Foundation/Workers/Collect/CollectDeviceWorker.cs @@ -174,10 +174,16 @@ public class CollectDeviceWorker : BackgroundService } else { - var Redundantdev = (await _collectDeviceService.GetCollectDeviceRuntimeAsync(dev.RedundantDeviceId)).FirstOrDefault(); - dev.DevicePropertys = Redundantdev.DevicePropertys; - dev.RedundantEnum = RedundantEnum.Standby; - _logger?.LogInformation(dev.Name + "切换到备用通道"); + try + { + var Redundantdev = (await _collectDeviceService.GetCollectDeviceRuntimeAsync(dev.RedundantDeviceId)).FirstOrDefault(); + dev.DevicePropertys = Redundantdev.DevicePropertys; + dev.RedundantEnum = RedundantEnum.Standby; + _logger?.LogInformation(dev.Name + "切换到备用通道"); + } + catch + { + } } } devCore.Init(dev); @@ -510,7 +516,7 @@ public class CollectDeviceWorker : BackgroundService if (devcore.Device.DeviceStatus == DeviceStatusEnum.OffLine) { - if (devcore.Device.IsRedundant) + if (devcore.Device.IsRedundant && _collectDeviceService.GetCacheList().Any(a => a.Id == devcore.Device.RedundantDeviceId)) { await UpDeviceRedundantThreadAsync(devcore.Device.Id); }