fix: 导入配置后报错

This commit is contained in:
iioter 2024-06-10 08:41:54 +08:00
parent f218dfc738
commit 74cb50bf62
2 changed files with 8 additions and 5 deletions

View File

@ -101,11 +101,8 @@ namespace IoTGateway.ViewModel.BasicData
myMqttClient.StartClientAsync().Wait();
//重新启动采集
foreach (var device in devices.Where(x => x.DeviceTypeEnum == DeviceTypeEnum.Device && x.DriverId != null))
{
device.Driver = _drivers.FirstOrDefault(x => x.ID == device.DriverId);
deviceService.CreateDeviceThread(device);
}
deviceService.CreateDeviceThreads();
=
$"成功导入{devices.Count(x => x.DeviceTypeEnum == DeviceTypeEnum.Device)}个设备,{devices.Count(x => x.DeviceTypeEnum == DeviceTypeEnum.Group)}个组";
}

View File

@ -32,6 +32,12 @@ namespace Plugin
_myMqttClient = myMqttClient;
//_uAService = uAService;
_mqttServer = mqttServer ?? throw new ArgumentNullException(nameof(mqttServer));
CreateDeviceThreads();
}
public void CreateDeviceThreads()
{
try
{
using (var dc = new DataContext(_connnectSetting, _dbType))