From 74cb50bf6298d7afa2372d5b9cdb122c2ce10a11 Mon Sep 17 00:00:00 2001 From: iioter <535915157@qq.com> Date: Mon, 10 Jun 2024 08:41:54 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=AF=BC=E5=85=A5=E9=85=8D=E7=BD=AE?= =?UTF-8?q?=E5=90=8E=E6=8A=A5=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- IoTGateway.ViewModel/BasicData/ImportExcelVM.cs | 7 ++----- Plugins/Plugin/DeviceService.cs | 6 ++++++ 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/IoTGateway.ViewModel/BasicData/ImportExcelVM.cs b/IoTGateway.ViewModel/BasicData/ImportExcelVM.cs index e61a872..2ebaf98 100644 --- a/IoTGateway.ViewModel/BasicData/ImportExcelVM.cs +++ b/IoTGateway.ViewModel/BasicData/ImportExcelVM.cs @@ -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)}个组"; } diff --git a/Plugins/Plugin/DeviceService.cs b/Plugins/Plugin/DeviceService.cs index 7441380..b38a376 100644 --- a/Plugins/Plugin/DeviceService.cs +++ b/Plugins/Plugin/DeviceService.cs @@ -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))