diff --git a/DMS.Application/DTOs/Events/DataLoadCompletedEventArgs.cs b/DMS.Application/DTOs/Events/DataLoadCompletedEventArgs.cs
index e98328d..b81a3cd 100644
--- a/DMS.Application/DTOs/Events/DataLoadCompletedEventArgs.cs
+++ b/DMS.Application/DTOs/Events/DataLoadCompletedEventArgs.cs
@@ -8,20 +8,6 @@ namespace DMS.Application.DTOs.Events
///
public class DataLoadCompletedEventArgs : System.EventArgs
{
- ///
- /// 加载的设备列表
- ///
- public List Devices { get; }
-
- ///
- /// 加载的变量表列表
- ///
- public List VariableTables { get; }
-
- ///
- /// 加载的变量列表
- ///
- public List Variables { get; }
///
/// 加载是否成功
@@ -41,16 +27,10 @@ namespace DMS.Application.DTOs.Events
///
/// 构造函数
///
- /// 设备列表
- /// 变量表列表
- /// 变量列表
/// 是否成功
/// 错误信息
- public DataLoadCompletedEventArgs(List devices, List variableTables, List variables, bool isSuccess, string errorMessage = null)
+ public DataLoadCompletedEventArgs(bool isSuccess, string errorMessage = null)
{
- Devices = devices ?? new List();
- VariableTables = variableTables ?? new List();
- Variables = variables ?? new List();
IsSuccess = isSuccess;
ErrorMessage = errorMessage;
LoadTime = DateTime.Now;
diff --git a/DMS.Application/DTOs/Events/MqttServerChangedEventArgs.cs b/DMS.Application/DTOs/Events/MqttServerChangedEventArgs.cs
new file mode 100644
index 0000000..c5566a4
--- /dev/null
+++ b/DMS.Application/DTOs/Events/MqttServerChangedEventArgs.cs
@@ -0,0 +1,37 @@
+using System;
+
+namespace DMS.Application.DTOs.Events
+{
+ ///
+ /// MQTT服务器变更事件参数
+ ///
+ public class MqttServerChangedEventArgs : System.EventArgs
+ {
+ ///
+ /// 变更类型
+ ///
+ public DataChangeType ChangeType { get; }
+
+ ///
+ /// MQTT服务器DTO
+ ///
+ public MqttServerDto MqttServer { get; }
+
+ ///
+ /// 变更时间
+ ///
+ public DateTime ChangeTime { get; }
+
+ ///
+ /// 构造函数
+ ///
+ /// 变更类型
+ /// MQTT服务器DTO
+ public MqttServerChangedEventArgs(DataChangeType changeType, MqttServerDto mqttServer)
+ {
+ ChangeType = changeType;
+ MqttServer = mqttServer;
+ ChangeTime = DateTime.Now;
+ }
+ }
+}
\ No newline at end of file
diff --git a/DMS.Application/Interfaces/IDataCenterService.cs b/DMS.Application/Interfaces/IDataCenterService.cs
index cd0a8e8..47fb891 100644
--- a/DMS.Application/Interfaces/IDataCenterService.cs
+++ b/DMS.Application/Interfaces/IDataCenterService.cs
@@ -217,6 +217,50 @@ public interface IDataCenterService
#endregion
+ #region MQTT服务器管理
+
+ ///
+ /// 异步根据ID获取MQTT服务器DTO。
+ ///
+ Task GetMqttServerByIdAsync(int id);
+
+ ///
+ /// 异步获取所有MQTT服务器DTO列表。
+ ///
+ Task> GetAllMqttServersAsync();
+
+ ///
+ /// 异步创建一个新的MQTT服务器。
+ ///
+ Task CreateMqttServerAsync(MqttServerDto mqttServerDto);
+
+ ///
+ /// 异步更新一个已存在的MQTT服务器。
+ ///
+ Task UpdateMqttServerAsync(MqttServerDto mqttServerDto);
+
+ ///
+ /// 异步删除一个MQTT服务器。
+ ///
+ Task DeleteMqttServerAsync(int id);
+
+ ///
+ /// 在内存中添加MQTT服务器
+ ///
+ void AddMqttServerToMemory(MqttServerDto mqttServerDto);
+
+ ///
+ /// 在内存中更新MQTT服务器
+ ///
+ void UpdateMqttServerInMemory(MqttServerDto mqttServerDto);
+
+ ///
+ /// 在内存中删除MQTT服务器
+ ///
+ void RemoveMqttServerFromMemory(int mqttServerId);
+
+ #endregion
+
#region 数据存储访问
///
@@ -243,6 +287,11 @@ public interface IDataCenterService
///
ConcurrentDictionary MenuTrees { get; }
+ ///
+ /// 获取所有MQTT服务器的安全字典。
+ ///
+ ConcurrentDictionary MqttServers { get; }
+
#endregion
#region 数据加载和初始化
@@ -272,6 +321,11 @@ public interface IDataCenterService
///
Task> LoadAllMenusAsync();
+ ///
+ /// 异步加载所有MQTT服务器数据。
+ ///
+ Task> LoadAllMqttServersAsync();
+
#endregion
#region 事件定义
@@ -302,9 +356,10 @@ public interface IDataCenterService
event EventHandler MenuChanged;
///
- /// 当数据发生任何变化时触发
+ /// 当MQTT服务器数据发生变化时触发
///
- event EventHandler DataChanged;
+ event EventHandler MqttServerChanged;
+
///
/// 当变量值发生变化时触发
diff --git a/DMS.Application/Services/DataCenterService.cs b/DMS.Application/Services/DataCenterService.cs
index f57f4df..f41d5c9 100644
--- a/DMS.Application/Services/DataCenterService.cs
+++ b/DMS.Application/Services/DataCenterService.cs
@@ -26,6 +26,7 @@ public class DataCenterService : IDataCenterService
private readonly IVariableTableAppService _variableTableAppService;
private readonly IVariableAppService _variableAppService;
private readonly IMenuService _menuService;
+ private readonly IMqttAppService _mqttAppService;
///
/// 安全字典,用于存储所有设备数据
@@ -52,6 +53,11 @@ public class DataCenterService : IDataCenterService
///
public ConcurrentDictionary MenuTrees { get; } = new();
+ ///
+ /// 安全字典,用于存储所有MQTT服务器数据
+ ///
+ public ConcurrentDictionary MqttServers { get; } = new();
+
#region 事件定义
///
@@ -80,9 +86,11 @@ public class DataCenterService : IDataCenterService
public event EventHandler MenuChanged;
///
- /// 当数据发生任何变化时触发
+ /// 当MQTT服务器数据发生变化时触发
///
- public event EventHandler DataChanged;
+ public event EventHandler MqttServerChanged;
+
+
///
/// 当变量值发生变化时触发
@@ -100,13 +108,15 @@ public class DataCenterService : IDataCenterService
/// 变量表应用服务实例。
/// 变量应用服务实例。
/// 菜单服务实例。
+ /// MQTT应用服务实例。
public DataCenterService(
IRepositoryManager repositoryManager,
IMapper mapper,
IDeviceAppService deviceAppService,
IVariableTableAppService variableTableAppService,
IVariableAppService variableAppService,
- IMenuService menuService)
+ IMenuService menuService,
+ IMqttAppService mqttAppService)
{
_repositoryManager = repositoryManager;
_mapper = mapper;
@@ -114,6 +124,7 @@ public class DataCenterService : IDataCenterService
_variableTableAppService = variableTableAppService;
_variableAppService = variableAppService;
_menuService = menuService;
+ _mqttAppService = mqttAppService;
}
#region 设备管理
@@ -545,65 +556,77 @@ public class DataCenterService : IDataCenterService
#endregion
- #region 事件触发方法
+ #region MQTT服务器管理
///
- /// 触发数据加载完成事件
+ /// 异步根据ID获取MQTT服务器DTO。
///
- /// 事件参数
- protected virtual void OnDataLoadCompleted(DataLoadCompletedEventArgs e)
+ public async Task GetMqttServerByIdAsync(int id)
{
- DataLoadCompleted?.Invoke(this, e);
- OnDataChanged(new DataChangedEventArgs(DataChangeType.Loaded));
+ return await _mqttAppService.GetMqttServerByIdAsync(id);
}
///
- /// 触发设备变更事件
+ /// 异步获取所有MQTT服务器DTO列表。
///
- /// 事件参数
- protected virtual void OnDeviceChanged(DeviceChangedEventArgs e)
+ public async Task> GetAllMqttServersAsync()
{
- DeviceChanged?.Invoke(this, e);
- OnDataChanged(new DataChangedEventArgs(e.ChangeType));
+ return await _mqttAppService.GetAllMqttServersAsync();
}
///
- /// 触发变量表变更事件
+ /// 异步创建一个新的MQTT服务器。
///
- /// 事件参数
- protected virtual void OnVariableTableChanged(VariableTableChangedEventArgs e)
+ public async Task CreateMqttServerAsync(MqttServerDto mqttServerDto)
{
- VariableTableChanged?.Invoke(this, e);
- OnDataChanged(new DataChangedEventArgs(e.ChangeType));
+ return await _mqttAppService.CreateMqttServerAsync(mqttServerDto);
}
///
- /// 触发变量变更事件
+ /// 异步更新一个已存在的MQTT服务器。
///
- /// 事件参数
- protected virtual void OnVariableChanged(VariableChangedEventArgs e)
+ public async Task UpdateMqttServerAsync(MqttServerDto mqttServerDto)
{
- VariableChanged?.Invoke(this, e);
- OnDataChanged(new DataChangedEventArgs(e.ChangeType));
+ await _mqttAppService.UpdateMqttServerAsync(mqttServerDto);
}
///
- /// 触发菜单变更事件
+ /// 异步删除一个MQTT服务器。
///
- /// 事件参数
- protected virtual void OnMenuChanged(MenuChangedEventArgs e)
+ public async Task DeleteMqttServerAsync(int id)
{
- MenuChanged?.Invoke(this, e);
- OnDataChanged(new DataChangedEventArgs(e.ChangeType));
+ await _mqttAppService.DeleteMqttServerAsync(id);
}
///
- /// 触发数据变更事件
+ /// 在内存中添加MQTT服务器
///
- /// 事件参数
- protected virtual void OnDataChanged(DataChangedEventArgs e)
+ public void AddMqttServerToMemory(MqttServerDto mqttServerDto)
{
- DataChanged?.Invoke(this, e);
+ if (MqttServers.TryAdd(mqttServerDto.Id, mqttServerDto))
+ {
+ OnMqttServerChanged(new MqttServerChangedEventArgs(DataChangeType.Added, mqttServerDto));
+ }
+ }
+
+ ///
+ /// 在内存中更新MQTT服务器
+ ///
+ public void UpdateMqttServerInMemory(MqttServerDto mqttServerDto)
+ {
+ MqttServers.AddOrUpdate(mqttServerDto.Id, mqttServerDto, (key, oldValue) => mqttServerDto);
+ OnMqttServerChanged(new MqttServerChangedEventArgs(DataChangeType.Updated, mqttServerDto));
+ }
+
+ ///
+ /// 在内存中删除MQTT服务器
+ ///
+ public void RemoveMqttServerFromMemory(int mqttServerId)
+ {
+ if (MqttServers.TryRemove(mqttServerId, out var mqttServerDto))
+ {
+ OnMqttServerChanged(new MqttServerChangedEventArgs(DataChangeType.Deleted, mqttServerDto));
+ }
}
#endregion
@@ -623,125 +646,55 @@ public class DataCenterService : IDataCenterService
Variables.Clear();
Menus.Clear();
MenuTrees.Clear();
+ MqttServers.Clear();
- // 加载所有设备
- var devices = await _repositoryManager.Devices.GetAllAsync();
- var deviceDtos = _mapper.Map>(devices);
+ // 顺序加载所有数据,避免数据库连接并发问题
+ var devices = await LoadAllDevicesAsync();
+ var variableTables = await LoadAllVariableTablesAsync();
+ var variables = await LoadAllVariablesAsync();
+ var menus = await LoadAllMenusAsync();
+ var mqttServers = await LoadAllMqttServersAsync();
- // 加载所有变量表
- var variableTables = await _repositoryManager.VariableTables.GetAllAsync();
- var variableTableDtos = _mapper.Map>(variableTables);
-
- // 加载所有变量
- var variables = await _repositoryManager.Variables.GetAllAsync();
- var variableDtos = _mapper.Map>(variables);
-
- // 加载所有菜单
- var menus = await _repositoryManager.Menus.GetAllAsync();
- var menuDtos = _mapper.Map>(menus);
-
- // 建立设备与变量表的关联
- foreach (var deviceDto in deviceDtos)
+ // 加载设备数据到内存
+ foreach (var device in devices)
{
- deviceDto.VariableTables = variableTableDtos
- .Where(vt => vt.DeviceId == deviceDto.Id)
- .ToList();
-
- // 将设备添加到安全字典
- Devices.TryAdd(deviceDto.Id, deviceDto);
+ Devices.TryAdd(device.Id, device);
}
- // 建立变量表与变量的关联
- foreach (var variableTableDto in variableTableDtos)
+ // 加载变量表数据到内存
+ foreach (var variableTable in variableTables)
{
- variableTableDto.Variables = variableDtos
- .Where(v => v.VariableTableId == variableTableDto.Id)
- .ToList();
- if (Devices.TryGetValue(variableTableDto.DeviceId, out var deviceDto))
- {
- variableTableDto.Device = deviceDto;
- }
-
- // 将变量表添加到安全字典
- VariableTables.TryAdd(variableTableDto.Id, variableTableDto);
+ VariableTables.TryAdd(variableTable.Id, variableTable);
}
- // 将变量添加到安全字典
- foreach (var variableDto in variableDtos)
+ // 加载变量数据到内存
+ foreach (var variable in variables)
{
- if (VariableTables.TryGetValue(variableDto.VariableTableId, out var variableTable))
- {
- variableDto.VariableTable = variableTable;
- }
- Variables.TryAdd(variableDto.Id, variableDto);
+ Variables.TryAdd(variable.Id, variable);
}
- // 将菜单添加到安全字典
- foreach (var menuDto in menuDtos)
+ // 加载菜单数据到内存
+ foreach (var menu in menus)
{
- Menus.TryAdd(menuDto.Id, menuDto);
+ Menus.TryAdd(menu.Id, menu);
}
- BuildMenuTrees();
+ // 加载MQTT服务器数据到内存
+ foreach (var mqttServer in mqttServers)
+ {
+ MqttServers.TryAdd(mqttServer.Id, mqttServer);
+ }
+
+ // 构建菜单树
+ BuildMenuTree();
// 触发数据加载完成事件
- OnDataLoadCompleted(new DataLoadCompletedEventArgs(
- deviceDtos,
- variableTableDtos,
- variableDtos,
- true));
+ OnDataLoadCompleted(new DataLoadCompletedEventArgs(true, "数据加载完成"));
}
catch (Exception ex)
{
- // 触发数据加载失败事件
- OnDataLoadCompleted(new DataLoadCompletedEventArgs(
- new List(),
- new List(),
- new List(),
- false,
- ex.Message));
- throw new ApplicationException($"加载所有数据到内存时发生错误,错误信息:{ex.Message}", ex);
- }
- }
-
- private void BuildMenuTrees()
- {
- // 遍历所有菜单项,构建树形结构
- foreach (var menu in Menus.Values)
- {
- // 检查是否有父ID,并且父ID不为0(通常0或null表示根节点)
- if (Menus.ContainsKey(menu.ParentId) && menu.ParentId != 0)
- {
- // 尝试从查找表中找到父菜单
- if (Menus.TryGetValue(menu.ParentId, out var parentMenu))
- {
- // 将当前菜单添加到父菜单的Children列表中
- parentMenu.Children.Add(menu);
- }
- // else: 如果找不到父菜单,这可能是一个数据完整性问题,可以根据需要处理
- }
- else
- {
- // 如果没有父ID,则这是一个根菜单
- MenuTrees.TryAdd(menu.Id, menu);
- }
- }
- }
-
- ///
- /// 异步加载所有菜单数据。
- ///
- public async Task> LoadAllMenusAsync()
- {
- try
- {
- // 获取所有菜单
- var menus = await _repositoryManager.Menus.GetAllAsync();
- return _mapper.Map>(menus);
- }
- catch (Exception ex)
- {
- throw new ApplicationException($"加载所有菜单数据时发生错误,错误信息:{ex.Message}", ex);
+ OnDataLoadCompleted(new DataLoadCompletedEventArgs(false, $"数据加载失败: {ex.Message}"));
+ throw;
}
}
@@ -750,37 +703,7 @@ public class DataCenterService : IDataCenterService
///
public async Task> LoadAllDevicesAsync()
{
- try
- {
- // 获取所有设备
- var devices = await _repositoryManager.Devices.GetAllAsync();
- var deviceDtos = _mapper.Map>(devices);
-
- // 为每个设备加载关联的变量表和变量
- foreach (var deviceDto in deviceDtos)
- {
- // 获取设备的所有变量表
- var variableTables = await _repositoryManager.VariableTables.GetAllAsync();
- var deviceVariableTables = variableTables.Where(vt => vt.DeviceId == deviceDto.Id)
- .ToList();
- deviceDto.VariableTables = _mapper.Map>(deviceVariableTables);
-
- // 为每个变量表加载关联的变量
- foreach (var variableTableDto in deviceDto.VariableTables)
- {
- var variables = await _repositoryManager.Variables.GetAllAsync();
- var tableVariables = variables.Where(v => v.VariableTableId == variableTableDto.Id)
- .ToList();
- variableTableDto.Variables = _mapper.Map>(tableVariables);
- }
- }
-
- return deviceDtos;
- }
- catch (Exception ex)
- {
- throw new ApplicationException($"加载所有设备数据时发生错误,错误信息:{ex.Message}", ex);
- }
+ return await _deviceAppService.GetAllDevicesAsync();
}
///
@@ -788,27 +711,7 @@ public class DataCenterService : IDataCenterService
///
public async Task> LoadAllVariableTablesAsync()
{
- try
- {
- // 获取所有变量表
- var variableTables = await _repositoryManager.VariableTables.GetAllAsync();
- var variableTableDtos = _mapper.Map>(variableTables);
-
- // 为每个变量表加载关联的变量
- foreach (var variableTableDto in variableTableDtos)
- {
- var variables = await _repositoryManager.Variables.GetAllAsync();
- var tableVariables = variables.Where(v => v.VariableTableId == variableTableDto.Id)
- .ToList();
- variableTableDto.Variables = _mapper.Map>(tableVariables);
- }
-
- return variableTableDtos;
- }
- catch (Exception ex)
- {
- throw new ApplicationException($"加载所有变量表数据时发生错误,错误信息:{ex.Message}", ex);
- }
+ return await _variableTableAppService.GetAllVariableTablesAsync();
}
///
@@ -816,29 +719,107 @@ public class DataCenterService : IDataCenterService
///
public async Task> LoadAllVariablesAsync()
{
- try
- {
- // 获取所有变量
- var variables = await _repositoryManager.Variables.GetAllAsync();
- return _mapper.Map>(variables);
- }
- catch (Exception ex)
- {
- throw new ApplicationException($"加载所有变量数据时发生错误,错误信息:{ex.Message}", ex);
- }
+ return await _variableAppService.GetAllVariablesAsync();
+ }
+
+ ///
+ /// 异步加载所有菜单数据。
+ ///
+ public async Task> LoadAllMenusAsync()
+ {
+ return await _menuService.GetAllMenusAsync();
+ }
+
+ ///
+ /// 异步加载所有MQTT服务器数据。
+ ///
+ public async Task> LoadAllMqttServersAsync()
+ {
+ return await _mqttAppService.GetAllMqttServersAsync();
}
#endregion
#region 事件触发方法
+ ///
+ /// 触发数据加载完成事件
+ ///
+ protected virtual void OnDataLoadCompleted(DataLoadCompletedEventArgs e)
+ {
+ DataLoadCompleted?.Invoke(this, e);
+ }
+
+ ///
+ /// 触发设备变更事件
+ ///
+ protected virtual void OnDeviceChanged(DeviceChangedEventArgs e)
+ {
+ DeviceChanged?.Invoke(this, e);
+ }
+
+ ///
+ /// 触发变量表变更事件
+ ///
+ protected virtual void OnVariableTableChanged(VariableTableChangedEventArgs e)
+ {
+ VariableTableChanged?.Invoke(this, e);
+ }
+
+ ///
+ /// 触发变量变更事件
+ ///
+ protected virtual void OnVariableChanged(VariableChangedEventArgs e)
+ {
+ VariableChanged?.Invoke(this, e);
+ }
+
+ ///
+ /// 触发菜单变更事件
+ ///
+ protected virtual void OnMenuChanged(MenuChangedEventArgs e)
+ {
+ MenuChanged?.Invoke(this, e);
+ }
+
+ ///
+ /// 触发MQTT服务器变更事件
+ ///
+ protected virtual void OnMqttServerChanged(MqttServerChangedEventArgs e)
+ {
+ MqttServerChanged?.Invoke(this, e);
+ }
+
+
///
/// 触发变量值变更事件
///
- public virtual void OnVariableValueChanged(VariableValueChangedEventArgs e)
+ public void OnVariableValueChanged(VariableValueChangedEventArgs e)
{
VariableValueChanged?.Invoke(this, e);
}
#endregion
+
+ #region 私有辅助方法
+
+ ///
+ /// 构建菜单树结构
+ ///
+ private void BuildMenuTree()
+ {
+ // 清空现有菜单树
+ MenuTrees.Clear();
+
+ // 获取所有根菜单
+ var rootMenus = GetRootMenus();
+
+ // 将根菜单添加到菜单树中
+ foreach (var rootMenu in rootMenus)
+ {
+ MenuTrees.TryAdd(rootMenu.Id, rootMenu);
+ }
+ }
+
+ #endregion
}
\ No newline at end of file
diff --git a/DMS.WPF/Services/DataServices.cs b/DMS.WPF/Services/DataServices.cs
index 5a62df1..b3ba276 100644
--- a/DMS.WPF/Services/DataServices.cs
+++ b/DMS.WPF/Services/DataServices.cs
@@ -4,12 +4,14 @@ using AutoMapper;
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Messaging;
using DMS.Application.DTOs;
+using DMS.Application.DTOs.Events;
using DMS.Core.Models;
using DMS.Application.Interfaces;
using DMS.Core.Enums;
using DMS.Core.Models;
using DMS.Message;
using DMS.WPF.ViewModels.Items;
+using Microsoft.IdentityModel.Protocols.OpenIdConnect;
namespace DMS.WPF.Services;
@@ -99,17 +101,27 @@ public partial class DataServices : ObservableObject, IRecipient, I
// 监听变量值变更事件
_dataCenterService.VariableValueChanged += OnVariableValueChanged;
-
+ _dataCenterService.DataLoadCompleted += OnDataLoadCompleted;
+
// 注册消息接收
// WeakReferenceMessenger.Register(this, (r, m) => r.Receive(m));
}
+ private void OnDataLoadCompleted(object? sender, DataLoadCompletedEventArgs e)
+ {
+ if (e.IsSuccess)
+ {
+ LoadAllDatas();
+ }
+
+ }
+
///
/// 异步加载设备数据,并以高效的方式更新UI集合。
/// 此方法会比较新旧数据,只对有变化的设备进行更新、添加或删除,避免不必要的UI刷新。
///
- public async Task LoadAllDatas()
+ private void LoadAllDatas()
{
Devices = _mapper.Map>(_dataCenterService.Devices.Values);
foreach (var device in Devices)
@@ -125,6 +137,9 @@ public partial class DataServices : ObservableObject, IRecipient, I
}
Menus = _mapper.Map>(_dataCenterService.Menus.Values);
+
+ // 加载MQTT服务器数据
+ MqttServers = _mapper.Map>(_dataCenterService.MqttServers.Values);
BuildMenuTrees();
}
diff --git a/DMS.WPF/ViewModels/Items/MqttServerItemViewModel.cs b/DMS.WPF/ViewModels/Items/MqttServerItemViewModel.cs
index acbad3f..d7166d2 100644
--- a/DMS.WPF/ViewModels/Items/MqttServerItemViewModel.cs
+++ b/DMS.WPF/ViewModels/Items/MqttServerItemViewModel.cs
@@ -27,6 +27,9 @@ public partial class MqttServerItemViewModel : ObservableObject
[ObservableProperty]
private bool _isActive;
+
+ [ObservableProperty]
+ private bool _isConnect;
[ObservableProperty]
private string _subscribeTopic;
diff --git a/DMS.WPF/ViewModels/SplashViewModel.cs b/DMS.WPF/ViewModels/SplashViewModel.cs
index eda4e8c..e6072bc 100644
--- a/DMS.WPF/ViewModels/SplashViewModel.cs
+++ b/DMS.WPF/ViewModels/SplashViewModel.cs
@@ -50,17 +50,8 @@ public partial class SplashViewModel : ObservableObject
LoadingMessage = "正在初始化数据库...";
_initializeService.InitializeTables();
_initializeService.InitializeMenus();
- await _dataCenterService.LoadAllDataToMemoryAsync();
-
LoadingMessage = "正在加载系统配置...";
- await _dataServices.LoadAllDatas();
- // await _dataServices.LoadVariableTables();
- // await _dataServices.LoadVariables();
- // await _dataServices.LoadMenus();
-
-
- // _dataServices.AssociateVariableTablesToDevices();
- // _dataServices.AssociateVariablesToVariableTables();
+ await _dataCenterService.LoadAllDataToMemoryAsync();
// 可以在这里添加加载配置的逻辑
await Task.Delay(500); // 模拟耗时
@@ -83,7 +74,7 @@ public partial class SplashViewModel : ObservableObject
{
// 处理初始化过程中的异常
LoadingMessage = $"初始化失败: {ex.Message}";
- Console.WriteLine($"初始化失败: {ex}");
+ _logger.LogError(ex,$"初始化失败: {ex}");
// 在此可以记录日志或显示错误对话框
return false;
}
diff --git a/DMS.WPF/Views/Dialogs/MqttDialog.xaml b/DMS.WPF/Views/Dialogs/MqttDialog.xaml
index 8c188e5..c77c230 100644
--- a/DMS.WPF/Views/Dialogs/MqttDialog.xaml
+++ b/DMS.WPF/Views/Dialogs/MqttDialog.xaml
@@ -63,6 +63,7 @@
Grid.Row="1"
Grid.Column="0"
Margin="0,15,0,0"
+ hc:InfoElement.Title="服务器地址:"
Text="{Binding MqttServer.ServerUrl, UpdateSourceTrigger=PropertyChanged}" />
-
+
@@ -47,7 +47,7 @@
IsOn="{Binding IsActive}"
OffContent="停止"
OnContent="启动" />
-
@@ -62,7 +62,7 @@
VerticalAlignment="Center"
Margin="0,0,8,0"
FontSize="14" />
-
@@ -73,7 +73,7 @@
Margin="0,0,8,0"
FontSize="14" />
-
+
@@ -85,7 +85,7 @@
Margin="0,0,8,0"
FontSize="14" />
-
+
-
+
@@ -102,7 +102,7 @@
VerticalAlignment="Center"
Margin="0,0,8,0"
FontSize="14" />
-
+
@@ -110,7 +110,7 @@
VerticalAlignment="Center"
Margin="0,0,8,0"
FontSize="14" />
-
+
@@ -126,7 +126,7 @@
VerticalAlignment="Center"
Margin="0,0,8,0"
FontSize="14" />
-
+
@@ -134,7 +134,7 @@
VerticalAlignment="Center"
Margin="0,0,8,0"
FontSize="14" />
-
+
@@ -142,7 +142,7 @@
VerticalAlignment="Center"
Margin="0,0,8,0"
FontSize="14" />
-
+
@@ -150,7 +150,8 @@
VerticalAlignment="Center"
Margin="0,0,8,0"
FontSize="14" />
-
+
+