From ffa24f861eb5f28036dadd71904877e8d82c0400 Mon Sep 17 00:00:00 2001 From: "David P.G" Date: Tue, 16 Sep 2025 12:29:09 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=BA=86=E7=9B=AE=E5=BD=95?= =?UTF-8?q?=E6=9E=B6=E6=9E=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../DTOs/Events/DataChangedEventArgs.cs | 1 + .../DTOs/Events/DeviceChangedEventArgs.cs | 1 + .../DTOs/Events/MenuChangedEventArgs.cs | 1 + .../DTOs/Events/MqttServerChangedEventArgs.cs | 1 + .../DTOs/Events/NlogChangedEventArgs.cs | 1 + .../DTOs/Events/VariableChangedEventArgs.cs | 1 + .../Events/VariableTableChangedEventArgs.cs | 1 + .../{Triggers => }/TriggerDefinitionDto.cs | 7 ++++--- .../EventHandlers/AlarmEventHandler.cs | 1 + .../Events/DeviceActiveChangedEventArgs.cs | 7 +------ .../Events/DeviceConnectChangedEventArgs.cs | 14 +------------- .../{ => Database}/IDeviceAppService.cs | 2 +- .../{ => Database}/IEmailAppService.cs | 2 +- .../{ => Database}/IHistoryAppService.cs | 2 +- .../{ => Database}/IMqttAliasAppService.cs | 4 +--- .../{ => Database}/IMqttAppService.cs | 2 +- .../{ => Database}/INlogAppService.cs | 2 +- .../{ => Database}/IVariableAppService.cs | 2 +- .../{ => Database}/IVariableTableAppService.cs | 5 +---- .../Interfaces/IAppDataCenterService.cs | 1 + .../IDeviceManagementService.cs | 3 +-- .../{ => Management}/ILogManagementService.cs | 2 +- .../{ => Management}/IMenuManagementService.cs | 2 +- .../{ => Management}/IMqttManagementService.cs | 2 +- .../Management}/IVariableManagementService.cs | 5 +---- .../IVariableTableManagementService.cs | 3 +-- DMS.Application/Profiles/MappingProfile.cs | 1 - .../Services/AppDataCenterService.cs | 1 + DMS.Application/Services/DataLoaderService.cs | 1 + .../{ => Database}/DeviceAppService.cs | 5 +++-- .../Services/{ => Database}/EmailAppService.cs | 3 ++- .../{ => Database}/HistoryAppService.cs | 4 ++-- .../{ => Database}/MqttAliasAppService.cs | 7 ++----- .../Services/{ => Database}/MqttAppService.cs | 7 ++++--- .../Services/{ => Database}/NlogAppService.cs | 3 ++- .../{ => Database}/VariableAppService.cs | 9 ++++----- .../{ => Database}/VariableTableAppService.cs | 7 +++---- .../DeviceManagementService.cs | 5 ++++- .../{ => Management}/LogManagementService.cs | 6 ++++-- .../{ => Management}/MenuManagementService.cs | 10 ++-------- .../{ => Management}/MqttManagementService.cs | 11 +++-------- .../VariableManagementService.cs | 6 ++++-- .../VariableTableManagementService.cs | 12 ++++-------- .../Triggers/ITriggerManagementService.cs | 2 +- .../Triggers/Impl/TriggerActionExecutor.cs | 1 - .../Triggers/Impl/TriggerEvaluationService.cs | 2 +- .../Triggers/Impl/TriggerManagementService.cs | 2 +- .../Services/Triggers/TriggerContext.cs | 1 - .../Enums}/DataChangeType.cs | 2 +- .../Services/BaseServiceTest.cs | 2 ++ .../Services/DeviceAppServiceTest.cs | 2 ++ .../Services/VariableAppServiceTest.cs | 2 ++ .../Services/VariableTableAppServiceTest.cs | 2 ++ .../Services/OpcUaServiceManager.cs | 18 ++++++++---------- .../Services/S7ServiceManager.cs | 9 ++++----- .../ViewModelTest/BaseServiceTest.cs | 2 ++ DMS.WPF/App.xaml.cs | 4 ++++ DMS.WPF/Services/EmailDataService.cs | 1 + .../Services/EmailFunctionalityTestService.cs | 1 + DMS.WPF/Services/LogDataService.cs | 1 + DMS.WPF/Services/MqttDataService.cs | 1 + DMS.WPF/ViewModels/DevicesViewModel.cs | 1 + .../Dialogs/EmailAccountDialogViewModel.cs | 1 + .../Dialogs/EmailTemplateDialogViewModel.cs | 1 + .../Dialogs/MqttSelectionDialogViewModel.cs | 1 + .../Dialogs/TriggerDialogViewModel.cs | 2 +- .../Dialogs/VariableDialogViewModel.cs | 1 + DMS.WPF/ViewModels/EmailManagementViewModel.cs | 1 + .../ViewModels/Items/DeviceItemViewModel.cs | 2 +- DMS.WPF/ViewModels/LogHistoryViewModel.cs | 2 ++ DMS.WPF/ViewModels/MqttsViewModel.cs | 1 + DMS.WPF/ViewModels/TriggersViewModel.cs | 2 +- DMS.WPF/ViewModels/VariableHistoryViewModel.cs | 1 + DMS.WPF/ViewModels/VariableTableViewModel.cs | 1 + 74 files changed, 122 insertions(+), 123 deletions(-) rename DMS.Application/DTOs/{Triggers => }/TriggerDefinitionDto.cs (95%) rename DMS.Application/Interfaces/{ => Database}/IDeviceAppService.cs (96%) rename DMS.Application/Interfaces/{ => Database}/IEmailAppService.cs (97%) rename DMS.Application/Interfaces/{ => Database}/IHistoryAppService.cs (97%) rename DMS.Application/Interfaces/{ => Database}/IMqttAliasAppService.cs (91%) rename DMS.Application/Interfaces/{ => Database}/IMqttAppService.cs (94%) rename DMS.Application/Interfaces/{ => Database}/INlogAppService.cs (95%) rename DMS.Application/Interfaces/{ => Database}/IVariableAppService.cs (97%) rename DMS.Application/Interfaces/{ => Database}/IVariableTableAppService.cs (82%) rename DMS.Application/Interfaces/{ => Management}/IDeviceManagementService.cs (95%) rename DMS.Application/Interfaces/{ => Management}/ILogManagementService.cs (95%) rename DMS.Application/Interfaces/{ => Management}/IMenuManagementService.cs (96%) rename DMS.Application/Interfaces/{ => Management}/IMqttManagementService.cs (96%) rename DMS.Application/{Services => Interfaces/Management}/IVariableManagementService.cs (93%) rename DMS.Application/Interfaces/{ => Management}/IVariableTableManagementService.cs (95%) rename DMS.Application/Services/{ => Database}/DeviceAppService.cs (99%) rename DMS.Application/Services/{ => Database}/EmailAppService.cs (98%) rename DMS.Application/Services/{ => Database}/HistoryAppService.cs (97%) rename DMS.Application/Services/{ => Database}/MqttAliasAppService.cs (96%) rename DMS.Application/Services/{ => Database}/MqttAppService.cs (98%) rename DMS.Application/Services/{ => Database}/NlogAppService.cs (97%) rename DMS.Application/Services/{ => Database}/VariableAppService.cs (99%) rename DMS.Application/Services/{ => Database}/VariableTableAppService.cs (98%) rename DMS.Application/Services/{ => Management}/DeviceManagementService.cs (95%) rename DMS.Application/Services/{ => Management}/LogManagementService.cs (94%) rename DMS.Application/Services/{ => Management}/MenuManagementService.cs (95%) rename DMS.Application/Services/{ => Management}/MqttManagementService.cs (93%) rename DMS.Application/Services/{ => Management}/VariableManagementService.cs (96%) rename DMS.Application/Services/{ => Management}/VariableTableManagementService.cs (96%) rename {DMS.Application/DTOs/Events => DMS.Core/Enums}/DataChangeType.cs (93%) diff --git a/DMS.Application/DTOs/Events/DataChangedEventArgs.cs b/DMS.Application/DTOs/Events/DataChangedEventArgs.cs index c2304bd..8f503b0 100644 --- a/DMS.Application/DTOs/Events/DataChangedEventArgs.cs +++ b/DMS.Application/DTOs/Events/DataChangedEventArgs.cs @@ -1,4 +1,5 @@ using System; +using DMS.Core.Enums; namespace DMS.Application.DTOs.Events { diff --git a/DMS.Application/DTOs/Events/DeviceChangedEventArgs.cs b/DMS.Application/DTOs/Events/DeviceChangedEventArgs.cs index f216214..2be3d8c 100644 --- a/DMS.Application/DTOs/Events/DeviceChangedEventArgs.cs +++ b/DMS.Application/DTOs/Events/DeviceChangedEventArgs.cs @@ -1,4 +1,5 @@ using System; +using DMS.Core.Enums; namespace DMS.Application.DTOs.Events { diff --git a/DMS.Application/DTOs/Events/MenuChangedEventArgs.cs b/DMS.Application/DTOs/Events/MenuChangedEventArgs.cs index 17aa32c..d716cb2 100644 --- a/DMS.Application/DTOs/Events/MenuChangedEventArgs.cs +++ b/DMS.Application/DTOs/Events/MenuChangedEventArgs.cs @@ -1,4 +1,5 @@ using System; +using DMS.Core.Enums; namespace DMS.Application.DTOs.Events { diff --git a/DMS.Application/DTOs/Events/MqttServerChangedEventArgs.cs b/DMS.Application/DTOs/Events/MqttServerChangedEventArgs.cs index c5566a4..484a623 100644 --- a/DMS.Application/DTOs/Events/MqttServerChangedEventArgs.cs +++ b/DMS.Application/DTOs/Events/MqttServerChangedEventArgs.cs @@ -1,4 +1,5 @@ using System; +using DMS.Core.Enums; namespace DMS.Application.DTOs.Events { diff --git a/DMS.Application/DTOs/Events/NlogChangedEventArgs.cs b/DMS.Application/DTOs/Events/NlogChangedEventArgs.cs index 2f03f2c..f4798c8 100644 --- a/DMS.Application/DTOs/Events/NlogChangedEventArgs.cs +++ b/DMS.Application/DTOs/Events/NlogChangedEventArgs.cs @@ -1,4 +1,5 @@ using System; +using DMS.Core.Enums; namespace DMS.Application.DTOs.Events { diff --git a/DMS.Application/DTOs/Events/VariableChangedEventArgs.cs b/DMS.Application/DTOs/Events/VariableChangedEventArgs.cs index 5e33f26..9ed030a 100644 --- a/DMS.Application/DTOs/Events/VariableChangedEventArgs.cs +++ b/DMS.Application/DTOs/Events/VariableChangedEventArgs.cs @@ -1,4 +1,5 @@ using System; +using DMS.Core.Enums; namespace DMS.Application.DTOs.Events { diff --git a/DMS.Application/DTOs/Events/VariableTableChangedEventArgs.cs b/DMS.Application/DTOs/Events/VariableTableChangedEventArgs.cs index 31bd448..053468d 100644 --- a/DMS.Application/DTOs/Events/VariableTableChangedEventArgs.cs +++ b/DMS.Application/DTOs/Events/VariableTableChangedEventArgs.cs @@ -1,4 +1,5 @@ using System; +using DMS.Core.Enums; namespace DMS.Application.DTOs.Events { diff --git a/DMS.Application/DTOs/Triggers/TriggerDefinitionDto.cs b/DMS.Application/DTOs/TriggerDefinitionDto.cs similarity index 95% rename from DMS.Application/DTOs/Triggers/TriggerDefinitionDto.cs rename to DMS.Application/DTOs/TriggerDefinitionDto.cs index 7d7f348..dbf1d5b 100644 --- a/DMS.Application/DTOs/Triggers/TriggerDefinitionDto.cs +++ b/DMS.Application/DTOs/TriggerDefinitionDto.cs @@ -1,7 +1,8 @@ -using System; -using DMS.Core.Models.Triggers; // 引入枚举 +using DMS.Core.Models.Triggers; -namespace DMS.Application.DTOs.Triggers +// 引入枚举 + +namespace DMS.Application.DTOs { /// /// 触发器定义 DTO (用于应用层与表示层之间的数据传输) diff --git a/DMS.Application/EventHandlers/AlarmEventHandler.cs b/DMS.Application/EventHandlers/AlarmEventHandler.cs index 7fbf15c..5a50140 100644 --- a/DMS.Application/EventHandlers/AlarmEventHandler.cs +++ b/DMS.Application/EventHandlers/AlarmEventHandler.cs @@ -1,5 +1,6 @@ using DMS.Application.DTOs; using DMS.Application.Interfaces; +using DMS.Application.Interfaces.Database; using DMS.Core.Events; using DMS.Core.Interfaces.Repositories; using DMS.Core.Models; diff --git a/DMS.Application/Events/DeviceActiveChangedEventArgs.cs b/DMS.Application/Events/DeviceActiveChangedEventArgs.cs index 3b22cd1..7898904 100644 --- a/DMS.Application/Events/DeviceActiveChangedEventArgs.cs +++ b/DMS.Application/Events/DeviceActiveChangedEventArgs.cs @@ -17,10 +17,6 @@ public class DeviceActiveChangedEventArgs : EventArgs /// public string DeviceName { get; } - /// - /// 旧状态 - /// - public bool OldStatus { get; } /// /// 新状态 @@ -39,11 +35,10 @@ public class DeviceActiveChangedEventArgs : EventArgs /// 设备名称 /// 旧状态 /// 新状态 - public DeviceActiveChangedEventArgs(int deviceId, string deviceName, bool oldStatus, bool newStatus) + public DeviceActiveChangedEventArgs(int deviceId, string deviceName, bool newStatus) { DeviceId = deviceId; DeviceName = deviceName; - OldStatus = oldStatus; NewStatus = newStatus; ChangeTime = DateTime.Now; } diff --git a/DMS.Application/Events/DeviceConnectChangedEventArgs.cs b/DMS.Application/Events/DeviceConnectChangedEventArgs.cs index 8b2e33f..028231a 100644 --- a/DMS.Application/Events/DeviceConnectChangedEventArgs.cs +++ b/DMS.Application/Events/DeviceConnectChangedEventArgs.cs @@ -12,21 +12,11 @@ public class DeviceConnectChangedEventArgs /// public string DeviceName { get; } - /// - /// 旧状态 - /// - public bool OldStatus { get; } - /// /// 新状态 /// public bool NewStatus { get; } - /// - /// 状态改变时间 - /// - public DateTime ChangeTime { get; } - /// /// 初始化DeviceStatusChangedEventArgs类的新实例 /// @@ -34,12 +24,10 @@ public class DeviceConnectChangedEventArgs /// 设备名称 /// 旧状态 /// 新状态 - public DeviceConnectChangedEventArgs(int deviceId, string deviceName, bool oldStatus, bool newStatus) + public DeviceConnectChangedEventArgs(int deviceId, string deviceName, bool newStatus) { DeviceId = deviceId; DeviceName = deviceName; - OldStatus = oldStatus; NewStatus = newStatus; - ChangeTime = DateTime.Now; } } \ No newline at end of file diff --git a/DMS.Application/Interfaces/IDeviceAppService.cs b/DMS.Application/Interfaces/Database/IDeviceAppService.cs similarity index 96% rename from DMS.Application/Interfaces/IDeviceAppService.cs rename to DMS.Application/Interfaces/Database/IDeviceAppService.cs index 4b54f6c..cee2baa 100644 --- a/DMS.Application/Interfaces/IDeviceAppService.cs +++ b/DMS.Application/Interfaces/Database/IDeviceAppService.cs @@ -2,7 +2,7 @@ using DMS.Application.DTOs; using DMS.Core.Enums; using DMS.Core.Models; -namespace DMS.Application.Interfaces; +namespace DMS.Application.Interfaces.Database; /// /// 定义设备管理相关的应用服务操作。 diff --git a/DMS.Application/Interfaces/IEmailAppService.cs b/DMS.Application/Interfaces/Database/IEmailAppService.cs similarity index 97% rename from DMS.Application/Interfaces/IEmailAppService.cs rename to DMS.Application/Interfaces/Database/IEmailAppService.cs index d8144d2..67453b3 100644 --- a/DMS.Application/Interfaces/IEmailAppService.cs +++ b/DMS.Application/Interfaces/Database/IEmailAppService.cs @@ -1,6 +1,6 @@ using DMS.Application.DTOs; -namespace DMS.Application.Interfaces +namespace DMS.Application.Interfaces.Database { /// /// 邮件应用服务接口 diff --git a/DMS.Application/Interfaces/IHistoryAppService.cs b/DMS.Application/Interfaces/Database/IHistoryAppService.cs similarity index 97% rename from DMS.Application/Interfaces/IHistoryAppService.cs rename to DMS.Application/Interfaces/Database/IHistoryAppService.cs index 5441baf..5eb46b6 100644 --- a/DMS.Application/Interfaces/IHistoryAppService.cs +++ b/DMS.Application/Interfaces/Database/IHistoryAppService.cs @@ -1,6 +1,6 @@ using DMS.Application.DTOs; -namespace DMS.Application.Interfaces; +namespace DMS.Application.Interfaces.Database; /// /// 定义历史记录管理相关的应用服务操作。 diff --git a/DMS.Application/Interfaces/IMqttAliasAppService.cs b/DMS.Application/Interfaces/Database/IMqttAliasAppService.cs similarity index 91% rename from DMS.Application/Interfaces/IMqttAliasAppService.cs rename to DMS.Application/Interfaces/Database/IMqttAliasAppService.cs index 2ca8272..fbe8802 100644 --- a/DMS.Application/Interfaces/IMqttAliasAppService.cs +++ b/DMS.Application/Interfaces/Database/IMqttAliasAppService.cs @@ -1,8 +1,6 @@ using DMS.Application.DTOs; -using System.Collections.Generic; -using System.Threading.Tasks; -namespace DMS.Application.Interfaces; +namespace DMS.Application.Interfaces.Database; /// /// 定义了MQTT别名管理相关的应用服务操作。 diff --git a/DMS.Application/Interfaces/IMqttAppService.cs b/DMS.Application/Interfaces/Database/IMqttAppService.cs similarity index 94% rename from DMS.Application/Interfaces/IMqttAppService.cs rename to DMS.Application/Interfaces/Database/IMqttAppService.cs index ebe6559..5e8b2b6 100644 --- a/DMS.Application/Interfaces/IMqttAppService.cs +++ b/DMS.Application/Interfaces/Database/IMqttAppService.cs @@ -1,6 +1,6 @@ using DMS.Application.DTOs; -namespace DMS.Application.Interfaces; +namespace DMS.Application.Interfaces.Database; /// /// 定义MQTT服务器管理相关的应用服务操作。 diff --git a/DMS.Application/Interfaces/INlogAppService.cs b/DMS.Application/Interfaces/Database/INlogAppService.cs similarity index 95% rename from DMS.Application/Interfaces/INlogAppService.cs rename to DMS.Application/Interfaces/Database/INlogAppService.cs index b8ee522..1aabb68 100644 --- a/DMS.Application/Interfaces/INlogAppService.cs +++ b/DMS.Application/Interfaces/Database/INlogAppService.cs @@ -1,6 +1,6 @@ using DMS.Application.DTOs; -namespace DMS.Application.Interfaces; +namespace DMS.Application.Interfaces.Database; /// /// 定义Nlog日志管理相关的应用服务操作。 diff --git a/DMS.Application/Interfaces/IVariableAppService.cs b/DMS.Application/Interfaces/Database/IVariableAppService.cs similarity index 97% rename from DMS.Application/Interfaces/IVariableAppService.cs rename to DMS.Application/Interfaces/Database/IVariableAppService.cs index 47786c8..6a35c0f 100644 --- a/DMS.Application/Interfaces/IVariableAppService.cs +++ b/DMS.Application/Interfaces/Database/IVariableAppService.cs @@ -1,6 +1,6 @@ using DMS.Application.DTOs; -namespace DMS.Application.Interfaces; +namespace DMS.Application.Interfaces.Database; /// /// 定义变量管理相关的应用服务操作。 diff --git a/DMS.Application/Interfaces/IVariableTableAppService.cs b/DMS.Application/Interfaces/Database/IVariableTableAppService.cs similarity index 82% rename from DMS.Application/Interfaces/IVariableTableAppService.cs rename to DMS.Application/Interfaces/Database/IVariableTableAppService.cs index e3e0cb8..2087c0a 100644 --- a/DMS.Application/Interfaces/IVariableTableAppService.cs +++ b/DMS.Application/Interfaces/Database/IVariableTableAppService.cs @@ -1,9 +1,6 @@ - using DMS.Application.DTOs; -using System.Collections.Generic; -using System.Threading.Tasks; -namespace DMS.Application.Interfaces +namespace DMS.Application.Interfaces.Database { public interface IVariableTableAppService { diff --git a/DMS.Application/Interfaces/IAppDataCenterService.cs b/DMS.Application/Interfaces/IAppDataCenterService.cs index 737504b..40b8560 100644 --- a/DMS.Application/Interfaces/IAppDataCenterService.cs +++ b/DMS.Application/Interfaces/IAppDataCenterService.cs @@ -1,6 +1,7 @@ using System.Collections.Concurrent; using DMS.Application.DTOs; using DMS.Application.DTOs.Events; +using DMS.Application.Interfaces.Management; using DMS.Application.Services; using DMS.Core.Models; diff --git a/DMS.Application/Interfaces/IDeviceManagementService.cs b/DMS.Application/Interfaces/Management/IDeviceManagementService.cs similarity index 95% rename from DMS.Application/Interfaces/IDeviceManagementService.cs rename to DMS.Application/Interfaces/Management/IDeviceManagementService.cs index 6dbbd50..f97debc 100644 --- a/DMS.Application/Interfaces/IDeviceManagementService.cs +++ b/DMS.Application/Interfaces/Management/IDeviceManagementService.cs @@ -1,8 +1,7 @@ -using System.Collections.Concurrent; using DMS.Application.DTOs; using DMS.Application.DTOs.Events; -namespace DMS.Application.Services; +namespace DMS.Application.Interfaces.Management; public interface IDeviceManagementService { diff --git a/DMS.Application/Interfaces/ILogManagementService.cs b/DMS.Application/Interfaces/Management/ILogManagementService.cs similarity index 95% rename from DMS.Application/Interfaces/ILogManagementService.cs rename to DMS.Application/Interfaces/Management/ILogManagementService.cs index 8737a1e..f66dc37 100644 --- a/DMS.Application/Interfaces/ILogManagementService.cs +++ b/DMS.Application/Interfaces/Management/ILogManagementService.cs @@ -1,7 +1,7 @@ using DMS.Application.DTOs; using DMS.Application.DTOs.Events; -namespace DMS.Application.Interfaces; +namespace DMS.Application.Interfaces.Management; public interface ILogManagementService { diff --git a/DMS.Application/Interfaces/IMenuManagementService.cs b/DMS.Application/Interfaces/Management/IMenuManagementService.cs similarity index 96% rename from DMS.Application/Interfaces/IMenuManagementService.cs rename to DMS.Application/Interfaces/Management/IMenuManagementService.cs index b9586c0..ae1a5e2 100644 --- a/DMS.Application/Interfaces/IMenuManagementService.cs +++ b/DMS.Application/Interfaces/Management/IMenuManagementService.cs @@ -1,6 +1,6 @@ using DMS.Application.DTOs; -namespace DMS.Application.Interfaces; +namespace DMS.Application.Interfaces.Management; public interface IMenuManagementService { diff --git a/DMS.Application/Interfaces/IMqttManagementService.cs b/DMS.Application/Interfaces/Management/IMqttManagementService.cs similarity index 96% rename from DMS.Application/Interfaces/IMqttManagementService.cs rename to DMS.Application/Interfaces/Management/IMqttManagementService.cs index c7f2238..c13ef7d 100644 --- a/DMS.Application/Interfaces/IMqttManagementService.cs +++ b/DMS.Application/Interfaces/Management/IMqttManagementService.cs @@ -1,6 +1,6 @@ using DMS.Application.DTOs; -namespace DMS.Application.Interfaces; +namespace DMS.Application.Interfaces.Management; public interface IMqttManagementService { diff --git a/DMS.Application/Services/IVariableManagementService.cs b/DMS.Application/Interfaces/Management/IVariableManagementService.cs similarity index 93% rename from DMS.Application/Services/IVariableManagementService.cs rename to DMS.Application/Interfaces/Management/IVariableManagementService.cs index 517ef62..fb9aacf 100644 --- a/DMS.Application/Services/IVariableManagementService.cs +++ b/DMS.Application/Interfaces/Management/IVariableManagementService.cs @@ -1,10 +1,7 @@ using System.Collections.Concurrent; using DMS.Application.DTOs; -using DMS.Application.DTOs.Events; -using DMS.Core.Events; -using DMS.Core.Models; -namespace DMS.Application.Services; +namespace DMS.Application.Interfaces.Management; public interface IVariableManagementService { diff --git a/DMS.Application/Interfaces/IVariableTableManagementService.cs b/DMS.Application/Interfaces/Management/IVariableTableManagementService.cs similarity index 95% rename from DMS.Application/Interfaces/IVariableTableManagementService.cs rename to DMS.Application/Interfaces/Management/IVariableTableManagementService.cs index 025bd85..a16ca7b 100644 --- a/DMS.Application/Interfaces/IVariableTableManagementService.cs +++ b/DMS.Application/Interfaces/Management/IVariableTableManagementService.cs @@ -1,8 +1,7 @@ -using System.Collections.Concurrent; using DMS.Application.DTOs; using DMS.Application.DTOs.Events; -namespace DMS.Application.Services; +namespace DMS.Application.Interfaces.Management; public interface IVariableTableManagementService { diff --git a/DMS.Application/Profiles/MappingProfile.cs b/DMS.Application/Profiles/MappingProfile.cs index c863d5d..5e54cde 100644 --- a/DMS.Application/Profiles/MappingProfile.cs +++ b/DMS.Application/Profiles/MappingProfile.cs @@ -1,7 +1,6 @@ using AutoMapper; using DMS.Core.Models; using DMS.Application.DTOs; -using DMS.Application.DTOs.Triggers; using DMS.Core.Models.Triggers; namespace DMS.Application.Profiles; diff --git a/DMS.Application/Services/AppDataCenterService.cs b/DMS.Application/Services/AppDataCenterService.cs index f3b4e47..2ae495e 100644 --- a/DMS.Application/Services/AppDataCenterService.cs +++ b/DMS.Application/Services/AppDataCenterService.cs @@ -11,6 +11,7 @@ using System.Collections.Generic; using System.Threading.Tasks; using System; using System.Linq; +using DMS.Application.Interfaces.Management; using DMS.Core.Events; namespace DMS.Application.Services; diff --git a/DMS.Application/Services/DataLoaderService.cs b/DMS.Application/Services/DataLoaderService.cs index 890f61c..57c46de 100644 --- a/DMS.Application/Services/DataLoaderService.cs +++ b/DMS.Application/Services/DataLoaderService.cs @@ -4,6 +4,7 @@ using DMS.Application.Interfaces; using DMS.Core.Interfaces; using System.Collections.Concurrent; using DMS.Application.DTOs.Events; +using DMS.Application.Interfaces.Database; using DMS.Core.Models; namespace DMS.Application.Services; diff --git a/DMS.Application/Services/DeviceAppService.cs b/DMS.Application/Services/Database/DeviceAppService.cs similarity index 99% rename from DMS.Application/Services/DeviceAppService.cs rename to DMS.Application/Services/Database/DeviceAppService.cs index c62bd87..11caecf 100644 --- a/DMS.Application/Services/DeviceAppService.cs +++ b/DMS.Application/Services/Database/DeviceAppService.cs @@ -1,11 +1,12 @@ using AutoMapper; -using DMS.Core.Models; using DMS.Application.DTOs; using DMS.Application.Interfaces; +using DMS.Application.Interfaces.Database; using DMS.Core.Enums; using DMS.Core.Interfaces; +using DMS.Core.Models; -namespace DMS.Application.Services; +namespace DMS.Application.Services.Database; /// /// 设备应用服务,负责处理设备相关的业务逻辑。 diff --git a/DMS.Application/Services/EmailAppService.cs b/DMS.Application/Services/Database/EmailAppService.cs similarity index 98% rename from DMS.Application/Services/EmailAppService.cs rename to DMS.Application/Services/Database/EmailAppService.cs index 2d7d34d..226ffb2 100644 --- a/DMS.Application/Services/EmailAppService.cs +++ b/DMS.Application/Services/Database/EmailAppService.cs @@ -1,11 +1,12 @@ using AutoMapper; using DMS.Application.DTOs; using DMS.Application.Interfaces; +using DMS.Application.Interfaces.Database; using DMS.Core.Interfaces.Repositories; using DMS.Core.Interfaces.Services; using DMS.Core.Models; -namespace DMS.Application.Services +namespace DMS.Application.Services.Database { /// /// 邮件应用服务实现 diff --git a/DMS.Application/Services/HistoryAppService.cs b/DMS.Application/Services/Database/HistoryAppService.cs similarity index 97% rename from DMS.Application/Services/HistoryAppService.cs rename to DMS.Application/Services/Database/HistoryAppService.cs index 7a97165..4945229 100644 --- a/DMS.Application/Services/HistoryAppService.cs +++ b/DMS.Application/Services/Database/HistoryAppService.cs @@ -1,9 +1,9 @@ using AutoMapper; using DMS.Application.DTOs; -using DMS.Application.Interfaces; +using DMS.Application.Interfaces.Database; using DMS.Core.Interfaces; -namespace DMS.Application.Services; +namespace DMS.Application.Services.Database; /// /// 历史记录应用服务实现类,负责处理变量历史记录相关的业务逻辑。 diff --git a/DMS.Application/Services/MqttAliasAppService.cs b/DMS.Application/Services/Database/MqttAliasAppService.cs similarity index 96% rename from DMS.Application/Services/MqttAliasAppService.cs rename to DMS.Application/Services/Database/MqttAliasAppService.cs index 78c77a2..eaecd3d 100644 --- a/DMS.Application/Services/MqttAliasAppService.cs +++ b/DMS.Application/Services/Database/MqttAliasAppService.cs @@ -1,13 +1,10 @@ using AutoMapper; using DMS.Application.DTOs; using DMS.Application.Interfaces; +using DMS.Application.Interfaces.Database; using DMS.Core.Interfaces; -using DMS.Core.Models; -using System.Collections.Generic; -using System.Threading.Tasks; -using System; -namespace DMS.Application.Services; +namespace DMS.Application.Services.Database; /// /// IMqttAliasAppService 的实现,负责管理变量与MQTT服务器的别名关联。 diff --git a/DMS.Application/Services/MqttAppService.cs b/DMS.Application/Services/Database/MqttAppService.cs similarity index 98% rename from DMS.Application/Services/MqttAppService.cs rename to DMS.Application/Services/Database/MqttAppService.cs index 634027f..f6b2572 100644 --- a/DMS.Application/Services/MqttAppService.cs +++ b/DMS.Application/Services/Database/MqttAppService.cs @@ -1,10 +1,11 @@ using AutoMapper; -using DMS.Core.Interfaces; -using DMS.Core.Models; using DMS.Application.DTOs; using DMS.Application.Interfaces; +using DMS.Application.Interfaces.Database; +using DMS.Core.Interfaces; +using DMS.Core.Models; -namespace DMS.Application.Services; +namespace DMS.Application.Services.Database; /// /// MQTT应用服务,负责处理MQTT服务器相关的业务逻辑。 diff --git a/DMS.Application/Services/NlogAppService.cs b/DMS.Application/Services/Database/NlogAppService.cs similarity index 97% rename from DMS.Application/Services/NlogAppService.cs rename to DMS.Application/Services/Database/NlogAppService.cs index 2b5244b..da95f35 100644 --- a/DMS.Application/Services/NlogAppService.cs +++ b/DMS.Application/Services/Database/NlogAppService.cs @@ -1,9 +1,10 @@ using AutoMapper; using DMS.Application.DTOs; using DMS.Application.Interfaces; +using DMS.Application.Interfaces.Database; using DMS.Core.Interfaces; -namespace DMS.Application.Services; +namespace DMS.Application.Services.Database; /// /// Nlog日志应用服务,负责处理Nlog日志相关的业务逻辑。 diff --git a/DMS.Application/Services/VariableAppService.cs b/DMS.Application/Services/Database/VariableAppService.cs similarity index 99% rename from DMS.Application/Services/VariableAppService.cs rename to DMS.Application/Services/Database/VariableAppService.cs index 61148f0..c17ea5f 100644 --- a/DMS.Application/Services/VariableAppService.cs +++ b/DMS.Application/Services/Database/VariableAppService.cs @@ -1,12 +1,11 @@ using AutoMapper; -using DMS.Core.Interfaces; -using DMS.Core.Models; using DMS.Application.DTOs; using DMS.Application.Interfaces; -using System.Collections.Generic; -using System.Linq; +using DMS.Application.Interfaces.Database; +using DMS.Core.Interfaces; +using DMS.Core.Models; -namespace DMS.Application.Services; +namespace DMS.Application.Services.Database; /// /// 变量应用服务,负责处理变量相关的业务逻辑。 diff --git a/DMS.Application/Services/VariableTableAppService.cs b/DMS.Application/Services/Database/VariableTableAppService.cs similarity index 98% rename from DMS.Application/Services/VariableTableAppService.cs rename to DMS.Application/Services/Database/VariableTableAppService.cs index 3c431fb..cb53fba 100644 --- a/DMS.Application/Services/VariableTableAppService.cs +++ b/DMS.Application/Services/Database/VariableTableAppService.cs @@ -1,13 +1,12 @@ using AutoMapper; using DMS.Application.DTOs; using DMS.Application.Interfaces; +using DMS.Application.Interfaces.Database; +using DMS.Core.Enums; using DMS.Core.Interfaces; using DMS.Core.Models; -using System.Collections.Generic; -using System.Threading.Tasks; -using DMS.Core.Enums; -namespace DMS.Application.Services +namespace DMS.Application.Services.Database { /// /// 变量表应用服务,负责处理变量表相关的业务逻辑。 diff --git a/DMS.Application/Services/DeviceManagementService.cs b/DMS.Application/Services/Management/DeviceManagementService.cs similarity index 95% rename from DMS.Application/Services/DeviceManagementService.cs rename to DMS.Application/Services/Management/DeviceManagementService.cs index 39686b5..e9204e0 100644 --- a/DMS.Application/Services/DeviceManagementService.cs +++ b/DMS.Application/Services/Management/DeviceManagementService.cs @@ -1,8 +1,11 @@ using DMS.Application.DTOs; using DMS.Application.DTOs.Events; using DMS.Application.Interfaces; +using DMS.Application.Interfaces.Database; +using DMS.Application.Interfaces.Management; +using DMS.Core.Enums; -namespace DMS.Application.Services; +namespace DMS.Application.Services.Management; /// /// 设备管理服务,负责设备相关的业务逻辑。 diff --git a/DMS.Application/Services/LogManagementService.cs b/DMS.Application/Services/Management/LogManagementService.cs similarity index 94% rename from DMS.Application/Services/LogManagementService.cs rename to DMS.Application/Services/Management/LogManagementService.cs index 4360f55..2c13dd0 100644 --- a/DMS.Application/Services/LogManagementService.cs +++ b/DMS.Application/Services/Management/LogManagementService.cs @@ -1,9 +1,11 @@ -using System.Collections.Concurrent; using DMS.Application.DTOs; using DMS.Application.DTOs.Events; using DMS.Application.Interfaces; +using DMS.Application.Interfaces.Database; +using DMS.Application.Interfaces.Management; +using DMS.Core.Enums; -namespace DMS.Application.Services; +namespace DMS.Application.Services.Management; /// /// 日志管理服务,负责日志相关的业务逻辑。 diff --git a/DMS.Application/Services/MenuManagementService.cs b/DMS.Application/Services/Management/MenuManagementService.cs similarity index 95% rename from DMS.Application/Services/MenuManagementService.cs rename to DMS.Application/Services/Management/MenuManagementService.cs index 355fbb6..7ef02a8 100644 --- a/DMS.Application/Services/MenuManagementService.cs +++ b/DMS.Application/Services/Management/MenuManagementService.cs @@ -1,16 +1,10 @@ -using AutoMapper; using DMS.Application.DTOs; using DMS.Application.DTOs.Events; -using DMS.Core.Models; using DMS.Application.Interfaces; -using DMS.Core.Interfaces; +using DMS.Application.Interfaces.Management; using DMS.Core.Enums; -using System.Collections.Concurrent; -using System.Collections.Generic; -using System.Threading.Tasks; -using System; -namespace DMS.Application.Services; +namespace DMS.Application.Services.Management; /// /// 菜单管理服务,负责菜单相关的业务逻辑。 diff --git a/DMS.Application/Services/MqttManagementService.cs b/DMS.Application/Services/Management/MqttManagementService.cs similarity index 93% rename from DMS.Application/Services/MqttManagementService.cs rename to DMS.Application/Services/Management/MqttManagementService.cs index 003aa73..27d6bbb 100644 --- a/DMS.Application/Services/MqttManagementService.cs +++ b/DMS.Application/Services/Management/MqttManagementService.cs @@ -1,16 +1,11 @@ -using AutoMapper; using DMS.Application.DTOs; using DMS.Application.DTOs.Events; -using DMS.Core.Models; using DMS.Application.Interfaces; -using DMS.Core.Interfaces; +using DMS.Application.Interfaces.Database; +using DMS.Application.Interfaces.Management; using DMS.Core.Enums; -using System.Collections.Concurrent; -using System.Collections.Generic; -using System.Threading.Tasks; -using System; -namespace DMS.Application.Services; +namespace DMS.Application.Services.Management; /// /// MQTT管理服务,负责MQTT相关的业务逻辑。 diff --git a/DMS.Application/Services/VariableManagementService.cs b/DMS.Application/Services/Management/VariableManagementService.cs similarity index 96% rename from DMS.Application/Services/VariableManagementService.cs rename to DMS.Application/Services/Management/VariableManagementService.cs index 493f36c..d87a5fd 100644 --- a/DMS.Application/Services/VariableManagementService.cs +++ b/DMS.Application/Services/Management/VariableManagementService.cs @@ -2,9 +2,11 @@ using System.Collections.Concurrent; using DMS.Application.DTOs; using DMS.Application.DTOs.Events; using DMS.Application.Interfaces; -using DMS.Core.Events; +using DMS.Application.Interfaces.Database; +using DMS.Application.Interfaces.Management; +using DMS.Core.Enums; -namespace DMS.Application.Services; +namespace DMS.Application.Services.Management; /// /// 变量管理服务,负责变量相关的业务逻辑。 diff --git a/DMS.Application/Services/VariableTableManagementService.cs b/DMS.Application/Services/Management/VariableTableManagementService.cs similarity index 96% rename from DMS.Application/Services/VariableTableManagementService.cs rename to DMS.Application/Services/Management/VariableTableManagementService.cs index 3a18f87..0aee0d1 100644 --- a/DMS.Application/Services/VariableTableManagementService.cs +++ b/DMS.Application/Services/Management/VariableTableManagementService.cs @@ -1,16 +1,12 @@ -using AutoMapper; +using System.Collections.Concurrent; using DMS.Application.DTOs; using DMS.Application.DTOs.Events; -using DMS.Core.Models; using DMS.Application.Interfaces; -using DMS.Core.Interfaces; +using DMS.Application.Interfaces.Database; +using DMS.Application.Interfaces.Management; using DMS.Core.Enums; -using System.Collections.Concurrent; -using System.Collections.Generic; -using System.Threading.Tasks; -using System; -namespace DMS.Application.Services; +namespace DMS.Application.Services.Management; /// /// 变量表管理服务,负责变量表相关的业务逻辑。 diff --git a/DMS.Application/Services/Triggers/ITriggerManagementService.cs b/DMS.Application/Services/Triggers/ITriggerManagementService.cs index 4d956cf..00f9ce5 100644 --- a/DMS.Application/Services/Triggers/ITriggerManagementService.cs +++ b/DMS.Application/Services/Triggers/ITriggerManagementService.cs @@ -1,7 +1,7 @@ using System; using System.Collections.Generic; using System.Threading.Tasks; -using DMS.Application.DTOs.Triggers; +using DMS.Application.DTOs; namespace DMS.Application.Services.Triggers { diff --git a/DMS.Application/Services/Triggers/Impl/TriggerActionExecutor.cs b/DMS.Application/Services/Triggers/Impl/TriggerActionExecutor.cs index a5d4593..29e84d5 100644 --- a/DMS.Application/Services/Triggers/Impl/TriggerActionExecutor.cs +++ b/DMS.Application/Services/Triggers/Impl/TriggerActionExecutor.cs @@ -2,7 +2,6 @@ using System; using System.Collections.Generic; using System.Text.Json; using System.Threading.Tasks; -using DMS.Application.DTOs.Triggers; using DMS.Application.Services.Triggers; using DMS.Core.Interfaces.Services; using DMS.Core.Models.Triggers; diff --git a/DMS.Application/Services/Triggers/Impl/TriggerEvaluationService.cs b/DMS.Application/Services/Triggers/Impl/TriggerEvaluationService.cs index b59ff81..5622700 100644 --- a/DMS.Application/Services/Triggers/Impl/TriggerEvaluationService.cs +++ b/DMS.Application/Services/Triggers/Impl/TriggerEvaluationService.cs @@ -3,10 +3,10 @@ using System.Collections.Concurrent; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; +using DMS.Application.DTOs; // 明确指定 Timer 类型,避免歧义 using ThreadingTimer = System.Threading.Timer; using TimersTimer = System.Timers.Timer; -using DMS.Application.DTOs.Triggers; using DMS.Application.Services.Triggers; using DMS.Core.Models.Triggers; using Microsoft.Extensions.Logging; // 使用 Microsoft.Extensions.Logging.ILogger diff --git a/DMS.Application/Services/Triggers/Impl/TriggerManagementService.cs b/DMS.Application/Services/Triggers/Impl/TriggerManagementService.cs index c68a70a..ff8bfbb 100644 --- a/DMS.Application/Services/Triggers/Impl/TriggerManagementService.cs +++ b/DMS.Application/Services/Triggers/Impl/TriggerManagementService.cs @@ -2,7 +2,7 @@ using System; using System.Collections.Generic; using System.Threading.Tasks; using AutoMapper; -using DMS.Application.DTOs.Triggers; +using DMS.Application.DTOs; using DMS.Application.Services.Triggers; using DMS.Core.Interfaces; using DMS.Core.Models.Triggers; diff --git a/DMS.Application/Services/Triggers/TriggerContext.cs b/DMS.Application/Services/Triggers/TriggerContext.cs index 667d1f8..03fc7c0 100644 --- a/DMS.Application/Services/Triggers/TriggerContext.cs +++ b/DMS.Application/Services/Triggers/TriggerContext.cs @@ -1,6 +1,5 @@ using System; using DMS.Application.DTOs; -using DMS.Application.DTOs.Triggers; namespace DMS.Application.Services.Triggers { diff --git a/DMS.Application/DTOs/Events/DataChangeType.cs b/DMS.Core/Enums/DataChangeType.cs similarity index 93% rename from DMS.Application/DTOs/Events/DataChangeType.cs rename to DMS.Core/Enums/DataChangeType.cs index 8bc84fc..5ccfaec 100644 --- a/DMS.Application/DTOs/Events/DataChangeType.cs +++ b/DMS.Core/Enums/DataChangeType.cs @@ -1,4 +1,4 @@ -namespace DMS.Application.DTOs.Events +namespace DMS.Core.Enums { /// /// 数据变更类型枚举 diff --git a/DMS.Infrastructure.UnitTests/Services/BaseServiceTest.cs b/DMS.Infrastructure.UnitTests/Services/BaseServiceTest.cs index a67b5a8..41c1048 100644 --- a/DMS.Infrastructure.UnitTests/Services/BaseServiceTest.cs +++ b/DMS.Infrastructure.UnitTests/Services/BaseServiceTest.cs @@ -3,7 +3,9 @@ using AutoMapper; using AutoMapper.Internal; using DMS.Application.Interfaces; +using DMS.Application.Interfaces.Database; using DMS.Application.Services; +using DMS.Application.Services.Database; using DMS.Core.Interfaces; using DMS.Core.Interfaces.Repositories; using DMS.Infrastructure.Data; diff --git a/DMS.Infrastructure.UnitTests/Services/DeviceAppServiceTest.cs b/DMS.Infrastructure.UnitTests/Services/DeviceAppServiceTest.cs index 42d37aa..25a5ca0 100644 --- a/DMS.Infrastructure.UnitTests/Services/DeviceAppServiceTest.cs +++ b/DMS.Infrastructure.UnitTests/Services/DeviceAppServiceTest.cs @@ -1,6 +1,8 @@ using DMS.Application.DTOs; using DMS.Application.Interfaces; +using DMS.Application.Interfaces.Database; using DMS.Application.Services; +using DMS.Application.Services.Database; using JetBrains.Annotations; using Microsoft.Extensions.DependencyInjection; diff --git a/DMS.Infrastructure.UnitTests/Services/VariableAppServiceTest.cs b/DMS.Infrastructure.UnitTests/Services/VariableAppServiceTest.cs index 8617994..a74cd02 100644 --- a/DMS.Infrastructure.UnitTests/Services/VariableAppServiceTest.cs +++ b/DMS.Infrastructure.UnitTests/Services/VariableAppServiceTest.cs @@ -1,6 +1,8 @@ using DMS.Application.DTOs; using DMS.Application.Interfaces; +using DMS.Application.Interfaces.Database; using DMS.Application.Services; +using DMS.Application.Services.Database; using JetBrains.Annotations; using Microsoft.Extensions.DependencyInjection; diff --git a/DMS.Infrastructure.UnitTests/Services/VariableTableAppServiceTest.cs b/DMS.Infrastructure.UnitTests/Services/VariableTableAppServiceTest.cs index 7e31d9f..9c51353 100644 --- a/DMS.Infrastructure.UnitTests/Services/VariableTableAppServiceTest.cs +++ b/DMS.Infrastructure.UnitTests/Services/VariableTableAppServiceTest.cs @@ -1,6 +1,8 @@ using DMS.Application.DTOs; using DMS.Application.Interfaces; +using DMS.Application.Interfaces.Database; using DMS.Application.Services; +using DMS.Application.Services.Database; using JetBrains.Annotations; using Microsoft.Extensions.DependencyInjection; diff --git a/DMS.Infrastructure/Services/OpcUaServiceManager.cs b/DMS.Infrastructure/Services/OpcUaServiceManager.cs index 4ed44de..ad21c9b 100644 --- a/DMS.Infrastructure/Services/OpcUaServiceManager.cs +++ b/DMS.Infrastructure/Services/OpcUaServiceManager.cs @@ -189,17 +189,18 @@ namespace DMS.Infrastructure.Services { context.IsConnected = true; context.Device.IsRunning = true; - _eventService.RaiseDeviceConnectChanged( - this, new DeviceConnectChangedEventArgs(context.Device.Id, context.Device.Name, false, true)); await SetupSubscriptionsAsync(context, cancellationToken); _logger.LogInformation("设备 {DeviceName} 连接成功", context.Device.Name); } else { - _eventService.RaiseDeviceConnectChanged( - this, new DeviceConnectChangedEventArgs(context.Device.Id, context.Device.Name, false, false)); + context.IsConnected = false; + context.Device.IsRunning = false; _logger.LogWarning("设备 {DeviceName} 连接失败", context.Device.Name); } + + _eventService.RaiseDeviceConnectChanged( + this, new DeviceConnectChangedEventArgs(context.Device.Id, context.Device.Name, context.IsConnected)); } catch (Exception ex) { @@ -208,7 +209,7 @@ namespace DMS.Infrastructure.Services context.IsConnected = false; context.Device.IsRunning = false; _eventService.RaiseDeviceConnectChanged( - this, new DeviceConnectChangedEventArgs(context.Device.Id, context.Device.Name, false, false)); + this, new DeviceConnectChangedEventArgs(context.Device.Id, context.Device.Name, false)); } finally { @@ -231,7 +232,7 @@ namespace DMS.Infrastructure.Services context.IsConnected = false; context.Device.IsRunning = false; _eventService.RaiseDeviceConnectChanged( - this, new DeviceConnectChangedEventArgs(context.Device.Id, context.Device.Name, false, false)); + this, new DeviceConnectChangedEventArgs(context.Device.Id, context.Device.Name, false)); _logger.LogInformation("设备 {DeviceName} 连接已断开", context.Device.Name); } catch (Exception ex) @@ -269,16 +270,13 @@ namespace DMS.Infrastructure.Services "为设备 {DeviceName} 设置PollingInterval {PollingInterval} 的订阅,变量数: {VariableCount}", context.Device.Name, pollingInterval, variables.Count); - // 根据PollingInterval计算发布间隔和采样间隔(毫秒) - var publishingInterval = GetPublishingIntervalFromPollLevel(pollingInterval); - // var samplingInterval = GetSamplingIntervalFromPollLevel(pollLevel); var opcUaNodes = variables .Select(v => new OpcUaNode { NodeId = v.OpcUaNodeId }) .ToList(); context.OpcUaService.SubscribeToNode(opcUaNodes, HandleDataChanged, - publishingInterval, publishingInterval); + pollingInterval, pollingInterval); } _logger.LogInformation("设备 {DeviceName} 订阅设置完成", context.Device.Name); diff --git a/DMS.Infrastructure/Services/S7ServiceManager.cs b/DMS.Infrastructure/Services/S7ServiceManager.cs index fb76c94..4cf15d3 100644 --- a/DMS.Infrastructure/Services/S7ServiceManager.cs +++ b/DMS.Infrastructure/Services/S7ServiceManager.cs @@ -186,8 +186,6 @@ namespace DMS.Infrastructure.Services { _logger.LogWarning("设备 {DeviceName} 连接失败", context.Device.Name); } - _eventService.RaiseDeviceConnectChanged( - this, new DeviceConnectChangedEventArgs(context.Device.Id, context.Device.Name, false, context.IsConnected)); } catch (Exception ex) { @@ -195,11 +193,12 @@ namespace DMS.Infrastructure.Services context.Device.Name, ex.Message); context.IsConnected = false; - _eventService.RaiseDeviceConnectChanged( - this, new DeviceConnectChangedEventArgs(context.Device.Id, context.Device.Name, false, context.IsConnected)); + } finally { + _eventService.RaiseDeviceConnectChanged( + this, new DeviceConnectChangedEventArgs(context.Device.Id, context.Device.Name, context.IsConnected)); _semaphore.Release(); } } @@ -219,7 +218,7 @@ namespace DMS.Infrastructure.Services context.IsConnected = false; _eventService.RaiseDeviceConnectChanged( - this, new DeviceConnectChangedEventArgs(context.Device.Id, context.Device.Name, false, context.IsConnected)); + this, new DeviceConnectChangedEventArgs(context.Device.Id, context.Device.Name, context.IsConnected)); _logger.LogInformation("设备 {DeviceName} 连接已断开", context.Device.Name); } catch (Exception ex) diff --git a/DMS.WPF.UnitTests/ViewModelTest/BaseServiceTest.cs b/DMS.WPF.UnitTests/ViewModelTest/BaseServiceTest.cs index 19c828f..de225e4 100644 --- a/DMS.WPF.UnitTests/ViewModelTest/BaseServiceTest.cs +++ b/DMS.WPF.UnitTests/ViewModelTest/BaseServiceTest.cs @@ -3,7 +3,9 @@ using AutoMapper; using AutoMapper.Internal; using DMS.Application.Interfaces; +using DMS.Application.Interfaces.Database; using DMS.Application.Services; +using DMS.Application.Services.Database; using DMS.Core.Interfaces; using DMS.Core.Interfaces.Repositories; using DMS.Infrastructure.Configurations; diff --git a/DMS.WPF/App.xaml.cs b/DMS.WPF/App.xaml.cs index 57328f5..4c7ad62 100644 --- a/DMS.WPF/App.xaml.cs +++ b/DMS.WPF/App.xaml.cs @@ -2,7 +2,11 @@ using AutoMapper; using AutoMapper.Internal; using DMS.Application.Interfaces; +using DMS.Application.Interfaces.Database; +using DMS.Application.Interfaces.Management; using DMS.Application.Services; +using DMS.Application.Services.Database; +using DMS.Application.Services.Management; using DMS.Application.Services.Processors; using DMS.Application.Services.Triggers; using DMS.Application.Services.Triggers.Impl; diff --git a/DMS.WPF/Services/EmailDataService.cs b/DMS.WPF/Services/EmailDataService.cs index d9febd2..e25a04b 100644 --- a/DMS.WPF/Services/EmailDataService.cs +++ b/DMS.WPF/Services/EmailDataService.cs @@ -4,6 +4,7 @@ using AutoMapper; using CommunityToolkit.Mvvm.ComponentModel; using DMS.Application.DTOs; using DMS.Application.Interfaces; +using DMS.Application.Interfaces.Database; using DMS.WPF.Interfaces; namespace DMS.WPF.Services; diff --git a/DMS.WPF/Services/EmailFunctionalityTestService.cs b/DMS.WPF/Services/EmailFunctionalityTestService.cs index c66c8b3..973c70a 100644 --- a/DMS.WPF/Services/EmailFunctionalityTestService.cs +++ b/DMS.WPF/Services/EmailFunctionalityTestService.cs @@ -1,5 +1,6 @@ using DMS.Application.DTOs; using DMS.Application.Interfaces; +using DMS.Application.Interfaces.Database; using DMS.Core.Interfaces.Repositories; using DMS.Core.Interfaces.Services; using DMS.Core.Models; diff --git a/DMS.WPF/Services/LogDataService.cs b/DMS.WPF/Services/LogDataService.cs index e3ea201..16153cd 100644 --- a/DMS.WPF/Services/LogDataService.cs +++ b/DMS.WPF/Services/LogDataService.cs @@ -4,6 +4,7 @@ using CommunityToolkit.Mvvm.ComponentModel; using DMS.Application.DTOs; using DMS.Application.DTOs.Events; using DMS.Application.Interfaces; +using DMS.Core.Enums; using DMS.WPF.Interfaces; using DMS.WPF.ViewModels.Items; diff --git a/DMS.WPF/Services/MqttDataService.cs b/DMS.WPF/Services/MqttDataService.cs index fcf6b5f..621bc85 100644 --- a/DMS.WPF/Services/MqttDataService.cs +++ b/DMS.WPF/Services/MqttDataService.cs @@ -3,6 +3,7 @@ using AutoMapper; using CommunityToolkit.Mvvm.ComponentModel; using DMS.Application.DTOs; using DMS.Application.Interfaces; +using DMS.Application.Interfaces.Database; using DMS.WPF.Interfaces; using DMS.WPF.ViewModels.Items; diff --git a/DMS.WPF/ViewModels/DevicesViewModel.cs b/DMS.WPF/ViewModels/DevicesViewModel.cs index 22a3899..66374a7 100644 --- a/DMS.WPF/ViewModels/DevicesViewModel.cs +++ b/DMS.WPF/ViewModels/DevicesViewModel.cs @@ -4,6 +4,7 @@ using CommunityToolkit.Mvvm.ComponentModel; using CommunityToolkit.Mvvm.Input; using DMS.Application.DTOs; using DMS.Application.Interfaces; +using DMS.Application.Interfaces.Database; using DMS.Core.Enums; using DMS.WPF.Interfaces; using DMS.WPF.Services; diff --git a/DMS.WPF/ViewModels/Dialogs/EmailAccountDialogViewModel.cs b/DMS.WPF/ViewModels/Dialogs/EmailAccountDialogViewModel.cs index 5c3888e..0e7e5ee 100644 --- a/DMS.WPF/ViewModels/Dialogs/EmailAccountDialogViewModel.cs +++ b/DMS.WPF/ViewModels/Dialogs/EmailAccountDialogViewModel.cs @@ -2,6 +2,7 @@ using CommunityToolkit.Mvvm.ComponentModel; using CommunityToolkit.Mvvm.Input; using DMS.Application.DTOs; using DMS.Application.Interfaces; +using DMS.Application.Interfaces.Database; using DMS.WPF.Interfaces; namespace DMS.WPF.ViewModels.Dialogs diff --git a/DMS.WPF/ViewModels/Dialogs/EmailTemplateDialogViewModel.cs b/DMS.WPF/ViewModels/Dialogs/EmailTemplateDialogViewModel.cs index 3f61fd6..01e849e 100644 --- a/DMS.WPF/ViewModels/Dialogs/EmailTemplateDialogViewModel.cs +++ b/DMS.WPF/ViewModels/Dialogs/EmailTemplateDialogViewModel.cs @@ -2,6 +2,7 @@ using CommunityToolkit.Mvvm.ComponentModel; using CommunityToolkit.Mvvm.Input; using DMS.Application.DTOs; using DMS.Application.Interfaces; +using DMS.Application.Interfaces.Database; using DMS.WPF.Interfaces; namespace DMS.WPF.ViewModels.Dialogs diff --git a/DMS.WPF/ViewModels/Dialogs/MqttSelectionDialogViewModel.cs b/DMS.WPF/ViewModels/Dialogs/MqttSelectionDialogViewModel.cs index 02fcd2e..394e7ca 100644 --- a/DMS.WPF/ViewModels/Dialogs/MqttSelectionDialogViewModel.cs +++ b/DMS.WPF/ViewModels/Dialogs/MqttSelectionDialogViewModel.cs @@ -6,6 +6,7 @@ using DMS.WPF.ViewModels.Items; using System; using System.Collections.ObjectModel; using System.Threading.Tasks; +using DMS.Application.Interfaces.Database; namespace DMS.WPF.ViewModels.Dialogs { diff --git a/DMS.WPF/ViewModels/Dialogs/TriggerDialogViewModel.cs b/DMS.WPF/ViewModels/Dialogs/TriggerDialogViewModel.cs index 10ed01d..1f1e897 100644 --- a/DMS.WPF/ViewModels/Dialogs/TriggerDialogViewModel.cs +++ b/DMS.WPF/ViewModels/Dialogs/TriggerDialogViewModel.cs @@ -3,8 +3,8 @@ using System.Windows; using CommunityToolkit.Mvvm.ComponentModel; using CommunityToolkit.Mvvm.Input; using DMS.Application.DTOs; -using DMS.Application.DTOs.Triggers; using DMS.Application.Interfaces; +using DMS.Application.Interfaces.Database; using DMS.Core.Models.Triggers; using DMS.WPF.Interfaces; diff --git a/DMS.WPF/ViewModels/Dialogs/VariableDialogViewModel.cs b/DMS.WPF/ViewModels/Dialogs/VariableDialogViewModel.cs index 81a4419..b4655c6 100644 --- a/DMS.WPF/ViewModels/Dialogs/VariableDialogViewModel.cs +++ b/DMS.WPF/ViewModels/Dialogs/VariableDialogViewModel.cs @@ -3,6 +3,7 @@ using CommunityToolkit.Mvvm.ComponentModel; using CommunityToolkit.Mvvm.Input; using DMS.Application.DTOs; using DMS.Application.Interfaces; +using DMS.Application.Interfaces.Database; using DMS.Core.Enums; using DMS.WPF.Interfaces; using DMS.WPF.Services; diff --git a/DMS.WPF/ViewModels/EmailManagementViewModel.cs b/DMS.WPF/ViewModels/EmailManagementViewModel.cs index 11fe60b..ef95de5 100644 --- a/DMS.WPF/ViewModels/EmailManagementViewModel.cs +++ b/DMS.WPF/ViewModels/EmailManagementViewModel.cs @@ -5,6 +5,7 @@ using DMS.Application.Interfaces; using DMS.WPF.Interfaces; using DMS.WPF.ViewModels.Dialogs; using System.Collections.ObjectModel; +using DMS.Application.Interfaces.Database; using Microsoft.Extensions.DependencyInjection; namespace DMS.WPF.ViewModels diff --git a/DMS.WPF/ViewModels/Items/DeviceItemViewModel.cs b/DMS.WPF/ViewModels/Items/DeviceItemViewModel.cs index 9651ff9..a081d06 100644 --- a/DMS.WPF/ViewModels/Items/DeviceItemViewModel.cs +++ b/DMS.WPF/ViewModels/Items/DeviceItemViewModel.cs @@ -92,7 +92,7 @@ public partial class DeviceItemViewModel : ObservableObject if (Id > 0 && EventService != null ) { // 发布设备状态改变事件 - EventService.RaiseDeviceActiveChanged(this, new DeviceActiveChangedEventArgs(Id, Name, oldValue, newValue)); + EventService.RaiseDeviceActiveChanged(this, new DeviceActiveChangedEventArgs(Id, Name, newValue)); } } diff --git a/DMS.WPF/ViewModels/LogHistoryViewModel.cs b/DMS.WPF/ViewModels/LogHistoryViewModel.cs index d1487e1..2360b18 100644 --- a/DMS.WPF/ViewModels/LogHistoryViewModel.cs +++ b/DMS.WPF/ViewModels/LogHistoryViewModel.cs @@ -17,6 +17,8 @@ using System.Collections.ObjectModel; using System; using DMS.WPF.Services; using DMS.Application.DTOs.Events; +using DMS.Application.Interfaces.Database; +using DMS.Core.Enums; namespace DMS.WPF.ViewModels; diff --git a/DMS.WPF/ViewModels/MqttsViewModel.cs b/DMS.WPF/ViewModels/MqttsViewModel.cs index 90515ee..5dba6e0 100644 --- a/DMS.WPF/ViewModels/MqttsViewModel.cs +++ b/DMS.WPF/ViewModels/MqttsViewModel.cs @@ -4,6 +4,7 @@ using CommunityToolkit.Mvvm.ComponentModel; using CommunityToolkit.Mvvm.Input; using DMS.Application.DTOs; using DMS.Application.Interfaces; +using DMS.Application.Interfaces.Database; using DMS.Core.Enums; using DMS.WPF.Interfaces; using DMS.WPF.Services; diff --git a/DMS.WPF/ViewModels/TriggersViewModel.cs b/DMS.WPF/ViewModels/TriggersViewModel.cs index d087eec..6c14180 100644 --- a/DMS.WPF/ViewModels/TriggersViewModel.cs +++ b/DMS.WPF/ViewModels/TriggersViewModel.cs @@ -4,7 +4,7 @@ using System.Linq; using System.Threading.Tasks; using CommunityToolkit.Mvvm.ComponentModel; using CommunityToolkit.Mvvm.Input; -using DMS.Application.DTOs.Triggers; +using DMS.Application.DTOs; using DMS.Application.Services.Triggers; using DMS.WPF.Interfaces; using DMS.WPF.Services; diff --git a/DMS.WPF/ViewModels/VariableHistoryViewModel.cs b/DMS.WPF/ViewModels/VariableHistoryViewModel.cs index a116ef2..3ed88d3 100644 --- a/DMS.WPF/ViewModels/VariableHistoryViewModel.cs +++ b/DMS.WPF/ViewModels/VariableHistoryViewModel.cs @@ -11,6 +11,7 @@ using DMS.WPF.ViewModels.Items; using Microsoft.Extensions.DependencyInjection; using ObservableCollections; using System.Linq; +using DMS.Application.Interfaces.Database; namespace DMS.WPF.ViewModels; diff --git a/DMS.WPF/ViewModels/VariableTableViewModel.cs b/DMS.WPF/ViewModels/VariableTableViewModel.cs index 12bc2d0..58cc923 100644 --- a/DMS.WPF/ViewModels/VariableTableViewModel.cs +++ b/DMS.WPF/ViewModels/VariableTableViewModel.cs @@ -4,6 +4,7 @@ using CommunityToolkit.Mvvm.ComponentModel; using CommunityToolkit.Mvvm.Input; using DMS.Application.DTOs; using DMS.Application.Interfaces; +using DMS.Application.Interfaces.Database; using DMS.Core.Enums; using DMS.Core.Models; using DMS.WPF.Interfaces;