1 feat(mqtt): 实现MQTT服务器状态管理与事件系统
2
3 1. 在MqttServer和MqttServerDto模型中添加IsConnect属性,用于跟踪连接状态
4 2. 重构MqttManagementService服务,使用事件驱动方式管理服务器状态变化
5 3. 实现MqttServerChangedEventArgs事件参数类,支持区分不同变更类型
6 4. 在IEventService中添加OnMqttServerChanged事件,实现事件通知机制
7 5. 优化数据存储结构,将MqttServers从ObservableCollection改为ObservableDictionary
8 6. 更新MqttServiceManager以正确处理连接状态和事件触发
9 7. 在WPF层更新UI以响应服务器状态变化
10 8. 删除不再需要的Helper类(DataServicesHelper, MessageHelper, SiemensHelper)
11 9. 在NLog配置中添加调试器输出目标以便调试
12 10. 完善VariableHistoryViewModel防止空引用异常
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
using System.Collections.ObjectModel;
|
||||
using AutoMapper;
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using CommunityToolkit.Mvvm.Input;
|
||||
@@ -12,6 +11,8 @@ using DMS.WPF.Services;
|
||||
using DMS.WPF.ViewModels.Dialogs;
|
||||
using DMS.WPF.ViewModels.Items;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using ObservableCollections;
|
||||
using System.Collections.ObjectModel;
|
||||
|
||||
namespace DMS.WPF.ViewModels;
|
||||
|
||||
@@ -29,10 +30,11 @@ public partial class MqttsViewModel : ViewModelBase
|
||||
private readonly INotificationService _notificationService;
|
||||
|
||||
/// <summary>
|
||||
/// MQTT服务器列表。
|
||||
/// 设备列表。
|
||||
/// </summary>
|
||||
[ObservableProperty]
|
||||
private ObservableCollection<MqttServerItemViewModel> _mqtts;
|
||||
private INotifyCollectionChangedSynchronizedViewList<MqttServerItemViewModel> _mqttServeise;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 当前选中的MQTT服务器。
|
||||
@@ -61,8 +63,8 @@ public partial class MqttsViewModel : ViewModelBase
|
||||
_mapper = mapper;
|
||||
_navigationService = navigationService;
|
||||
_notificationService = notificationService;
|
||||
|
||||
Mqtts = _dataStorageService.MqttServers;
|
||||
|
||||
_mqttServeise = _dataStorageService.MqttServers.ToNotifyCollectionChanged(x=>x.Value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
Reference in New Issue
Block a user