mirror of
https://github.com/ThingsGateway/ThingsGateway.git
synced 2026-10-23 08:48:59 +08:00
冗余设备删除后会导致后台出错
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user