From 6cff70cd87ac4643ca016037da04393a02cfb52e Mon Sep 17 00:00:00 2001 From: "David P.G" Date: Mon, 6 Oct 2025 17:39:03 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E5=B0=86VariableMqttAlias=E6=94=B9?= =?UTF-8?q?=E4=B8=BAMqttAlias,=E5=B0=86VariableMqttAliasItemViewModel?= =?UTF-8?q?=E6=94=B9=E4=B8=BAMqttAliasItem?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- DMS.Application/DTOs/MqttServerDto.cs | 2 +- DMS.Application/DTOs/VariableDto.cs | 2 +- .../Database/IMqttAliasAppService.cs | 2 +- .../Interfaces/IAppDataStorageService.cs | 2 +- .../Services/AppDataStorageService.cs | 2 +- .../Services/Database/MqttAliasAppService.cs | 4 +-- .../Database/VariableTableAppService.cs | 2 +- .../IVariableMqttAliasRepository.cs | 8 ++--- .../Services/IMqttServiceManager.cs | 4 +-- .../{VariableMqttAlias.cs => MqttAlias.cs} | 2 +- DMS.Core/Models/MqttServer.cs | 2 +- DMS.Core/Models/Variable.cs | 2 +- .../Services/IMqttBackgroundService.cs | 2 +- DMS.Infrastructure/Profiles/MappingProfile.cs | 2 +- .../VariableMqttAliasRepository.cs | 30 +++++++++---------- .../Services/Mqtt/MqttBackgroundService.cs | 2 +- .../Services/Mqtt/MqttDeviceContext.cs | 4 +-- .../Services/Mqtt/MqttServiceManager.cs | 6 ++-- DMS.WPF/DMS.WPF.csproj | 6 ---- DMS.WPF/Profiles/MappingProfile.cs | 2 +- .../MqttAliasBatchEditDialogViewModel.cs | 6 ++-- ...AliasItemViewModel.cs => MqttAliasItem.cs} | 2 +- .../Items/MqttServerItemViewModel.cs | 2 +- .../ViewModels/Items/VariableItemViewModel.cs | 2 +- .../ViewModels/MqttServerDetailViewModel.cs | 4 +-- DMS.WPF/ViewModels/VariableTableViewModel.cs | 2 +- 26 files changed, 50 insertions(+), 56 deletions(-) rename DMS.Core/Models/{VariableMqttAlias.cs => MqttAlias.cs} (97%) rename DMS.WPF/ViewModels/Items/{VariableMqttAliasItemViewModel.cs => MqttAliasItem.cs} (88%) diff --git a/DMS.Application/DTOs/MqttServerDto.cs b/DMS.Application/DTOs/MqttServerDto.cs index 8398d3c..3816159 100644 --- a/DMS.Application/DTOs/MqttServerDto.cs +++ b/DMS.Application/DTOs/MqttServerDto.cs @@ -27,5 +27,5 @@ public class MqttServerDto public string MessageHeader { get; set; } public string MessageContent { get; set; } public string MessageFooter { get; set; } - public List VariableAliases { get; set; } = new(); + public List VariableAliases { get; set; } = new(); } \ No newline at end of file diff --git a/DMS.Application/DTOs/VariableDto.cs b/DMS.Application/DTOs/VariableDto.cs index 06104d6..1b4de20 100644 --- a/DMS.Application/DTOs/VariableDto.cs +++ b/DMS.Application/DTOs/VariableDto.cs @@ -17,7 +17,7 @@ public class VariableDto public double NumericValue { get; set; } public string DisplayValue { get; set; } public VariableTableDto? VariableTable { get; set; } - public List? MqttAliases { get; set; } = new List(); + public List? MqttAliases { get; set; } = new List(); public SignalType SignalType { get; set; } public int PollingInterval { get; set; } public bool IsActive { get; set; } diff --git a/DMS.Application/Interfaces/Database/IMqttAliasAppService.cs b/DMS.Application/Interfaces/Database/IMqttAliasAppService.cs index 22767b6..68bf403 100644 --- a/DMS.Application/Interfaces/Database/IMqttAliasAppService.cs +++ b/DMS.Application/Interfaces/Database/IMqttAliasAppService.cs @@ -12,7 +12,7 @@ public interface IMqttAliasAppService /// /// 异步获取指定变量的所有MQTT别名关联。 /// - Task> GetAliasesForVariableAsync(int variableId); + Task> GetAliasesForVariableAsync(int variableId); /// /// 异步为变量分配或更新一个MQTT别名。 diff --git a/DMS.Application/Interfaces/IAppDataStorageService.cs b/DMS.Application/Interfaces/IAppDataStorageService.cs index 37f45f8..5e9ff18 100644 --- a/DMS.Application/Interfaces/IAppDataStorageService.cs +++ b/DMS.Application/Interfaces/IAppDataStorageService.cs @@ -44,7 +44,7 @@ public interface IAppDataStorageService /// /// 安全字典,用于存储所有MQTT变量别名的数据 /// - ConcurrentDictionary VariableMqttAliases { get; } + ConcurrentDictionary VariableMqttAliases { get; } /// /// 安全字典,用于存储所有触发器定义数据 diff --git a/DMS.Application/Services/AppDataStorageService.cs b/DMS.Application/Services/AppDataStorageService.cs index a703d70..65cc8b8 100644 --- a/DMS.Application/Services/AppDataStorageService.cs +++ b/DMS.Application/Services/AppDataStorageService.cs @@ -41,7 +41,7 @@ public class AppDataStorageService : IAppDataStorageService /// /// 安全字典,用于存储所有MQTT变量别名的数据 /// - public ConcurrentDictionary VariableMqttAliases { get; } = new(); + public ConcurrentDictionary VariableMqttAliases { get; } = new(); diff --git a/DMS.Application/Services/Database/MqttAliasAppService.cs b/DMS.Application/Services/Database/MqttAliasAppService.cs index c0706d6..21b74d8 100644 --- a/DMS.Application/Services/Database/MqttAliasAppService.cs +++ b/DMS.Application/Services/Database/MqttAliasAppService.cs @@ -29,7 +29,7 @@ public class MqttAliasAppService : IMqttAliasAppService /// /// 异步获取指定变量的所有MQTT别名关联。 /// - public async Task> GetAliasesForVariableAsync(int variableId) + public async Task> GetAliasesForVariableAsync(int variableId) { // 从仓储获取别名,并确保加载了关联的MqttServer信息 var aliases = await _repoManager.VariableMqttAliases.GetAliasesForVariableAsync(variableId); @@ -61,7 +61,7 @@ public class MqttAliasAppService : IMqttAliasAppService var variable = await _repoManager.Variables.GetByIdAsync(variableId); var mqttServer = await _repoManager.MqttServers.GetByIdAsync(mqttServerId); - var newAlias = new VariableMqttAlias + var newAlias = new MqttAlias { VariableId = variableId, MqttServerId = mqttServerId, diff --git a/DMS.Application/Services/Database/VariableTableAppService.cs b/DMS.Application/Services/Database/VariableTableAppService.cs index f1d00d4..1ab6821 100644 --- a/DMS.Application/Services/Database/VariableTableAppService.cs +++ b/DMS.Application/Services/Database/VariableTableAppService.cs @@ -156,7 +156,7 @@ namespace DMS.Application.Services.Database await _repositoryManager.Variables.DeleteByVariableTableIdAsync(id); // 删除关联的MQTT别名 - // await _repositoryManager.VariableMqttAlias.DeleteByVariableTableIdAsync(id); + // await _repositoryManager.MqttAlias.DeleteByVariableTableIdAsync(id); // 删除关联的菜单树 await _repositoryManager.Menus.DeleteMenuTreeByTargetIdAsync(MenuType.VariableTableMenu, id); diff --git a/DMS.Core/Interfaces/Repositories/IVariableMqttAliasRepository.cs b/DMS.Core/Interfaces/Repositories/IVariableMqttAliasRepository.cs index f0ae3a7..43fc1cf 100644 --- a/DMS.Core/Interfaces/Repositories/IVariableMqttAliasRepository.cs +++ b/DMS.Core/Interfaces/Repositories/IVariableMqttAliasRepository.cs @@ -4,22 +4,22 @@ using System.Threading.Tasks; namespace DMS.Core.Interfaces.Repositories { - public interface IVariableMqttAliasRepository : IBaseRepository + public interface IVariableMqttAliasRepository : IBaseRepository { /// /// 异步获取指定变量的所有MQTT别名关联。 /// - Task> GetAliasesForVariableAsync(int variableId); + Task> GetAliasesForVariableAsync(int variableId); /// /// 异步根据变量和服务器获取别名关联。 /// - Task GetByVariableAndServerAsync(int variableId, int mqttServerId); + Task GetByVariableAndServerAsync(int variableId, int mqttServerId); /// /// 异步获取所有变量与MQTT别名关联。 /// /// 包含所有变量与MQTT别名关联实体的列表。 - Task> GetAllAsync(); + Task> GetAllAsync(); } } \ No newline at end of file diff --git a/DMS.Core/Interfaces/Services/IMqttServiceManager.cs b/DMS.Core/Interfaces/Services/IMqttServiceManager.cs index 3e6accc..6907a17 100644 --- a/DMS.Core/Interfaces/Services/IMqttServiceManager.cs +++ b/DMS.Core/Interfaces/Services/IMqttServiceManager.cs @@ -25,7 +25,7 @@ namespace DMS.Core.Interfaces.Services /// /// 更新MQTT服务器变量别名 /// - void UpdateVariableMqttAliases(int mqttServerId, List variableMqttAliases); + void UpdateVariableMqttAliases(int mqttServerId, List variableMqttAliases); /// /// 获取MQTT服务器连接状态 @@ -55,7 +55,7 @@ namespace DMS.Core.Interfaces.Services /// /// 发布变量数据到MQTT服务器 /// - Task PublishVariableDataAsync(VariableMqttAlias variableMqtt, CancellationToken cancellationToken = default); + Task PublishVariableDataAsync(MqttAlias variableMqtt, CancellationToken cancellationToken = default); /// /// 发布批量变量数据到MQTT服务器 diff --git a/DMS.Core/Models/VariableMqttAlias.cs b/DMS.Core/Models/MqttAlias.cs similarity index 97% rename from DMS.Core/Models/VariableMqttAlias.cs rename to DMS.Core/Models/MqttAlias.cs index cbce521..3393e3d 100644 --- a/DMS.Core/Models/VariableMqttAlias.cs +++ b/DMS.Core/Models/MqttAlias.cs @@ -4,7 +4,7 @@ using DMS.Core.Models; /// 领域模型:代表一个变量到一个MQTT服务器的特定关联,包含专属别名。 /// 这是一个关联实体,用于解决多对多关系中需要额外属性(别名)的问题。 /// -public class VariableMqttAlias +public class MqttAlias { /// /// 唯一标识符。 diff --git a/DMS.Core/Models/MqttServer.cs b/DMS.Core/Models/MqttServer.cs index f4a31b8..db6bb58 100644 --- a/DMS.Core/Models/MqttServer.cs +++ b/DMS.Core/Models/MqttServer.cs @@ -68,5 +68,5 @@ public class MqttServer /// /// 与此服务器关联的所有变量别名。通过此集合可以反向查找关联的变量。 /// - public List VariableAliases { get; set; } = new(); + public List VariableAliases { get; set; } = new(); } \ No newline at end of file diff --git a/DMS.Core/Models/Variable.cs b/DMS.Core/Models/Variable.cs index a041509..1085677 100644 --- a/DMS.Core/Models/Variable.cs +++ b/DMS.Core/Models/Variable.cs @@ -57,7 +57,7 @@ public class Variable /// /// 此变量的所有MQTT发布别名关联。一个变量可以关联多个MQTT服务器,每个关联可以有独立的别名。 /// - public List MqttAliases { get; set; } = new(); + public List MqttAliases { get; set; } = new(); /// /// OPC UA NodeId (仅当 Protocol 为 OpcUa 时有效)。 diff --git a/DMS.Infrastructure/Interfaces/Services/IMqttBackgroundService.cs b/DMS.Infrastructure/Interfaces/Services/IMqttBackgroundService.cs index f1dc587..05db3f9 100644 --- a/DMS.Infrastructure/Interfaces/Services/IMqttBackgroundService.cs +++ b/DMS.Infrastructure/Interfaces/Services/IMqttBackgroundService.cs @@ -44,7 +44,7 @@ namespace DMS.Infrastructure.Interfaces.Services /// /// 发布变量数据到MQTT服务器 /// - Task PublishVariableDataAsync(VariableMqttAlias variableMqtt, CancellationToken cancellationToken = default); + Task PublishVariableDataAsync(MqttAlias variableMqtt, CancellationToken cancellationToken = default); /// /// 发布批量变量数据到MQTT服务器 diff --git a/DMS.Infrastructure/Profiles/MappingProfile.cs b/DMS.Infrastructure/Profiles/MappingProfile.cs index 4ca067f..665292c 100644 --- a/DMS.Infrastructure/Profiles/MappingProfile.cs +++ b/DMS.Infrastructure/Profiles/MappingProfile.cs @@ -30,7 +30,7 @@ public class MappingProfile : Profile CreateMap() .ForMember(dest => dest.VariableAliases, opt => opt.Ignore()) .ReverseMap(); - CreateMap() + CreateMap() .ReverseMap(); CreateMap().ReverseMap(); diff --git a/DMS.Infrastructure/Repositories/VariableMqttAliasRepository.cs b/DMS.Infrastructure/Repositories/VariableMqttAliasRepository.cs index 71dc76c..1ac75d5 100644 --- a/DMS.Infrastructure/Repositories/VariableMqttAliasRepository.cs +++ b/DMS.Infrastructure/Repositories/VariableMqttAliasRepository.cs @@ -36,20 +36,20 @@ public class VariableMqttAliasRepository : BaseRepository, /// /// 变量与MQTT别名关联的唯一标识符。 /// 对应的变量与MQTT别名关联实体,如果不存在则为null。 - public async Task GetByIdAsync(int id) + public async Task GetByIdAsync(int id) { var dbVariableMqttAlias = await base.GetByIdAsync(id); - return _mapper.Map(dbVariableMqttAlias); + return _mapper.Map(dbVariableMqttAlias); } /// /// 异步获取所有变量与MQTT别名关联。 /// /// 包含所有变量与MQTT别名关联实体的列表。 - public async Task> GetAllAsync() + public async Task> GetAllAsync() { var dbList = await base.GetAllAsync(); - return _mapper.Map>(dbList); + return _mapper.Map>(dbList); } /// @@ -57,7 +57,7 @@ public class VariableMqttAliasRepository : BaseRepository, /// /// 要添加的变量与MQTT别名关联实体。 /// 添加成功后的变量与MQTT别名关联实体(包含数据库生成的ID等信息)。 - public async Task AddAsync(VariableMqttAlias entity) + public async Task AddAsync(MqttAlias entity) { var dbVariableMqttAlias = await base.AddAsync(_mapper.Map(entity)); return _mapper.Map(dbVariableMqttAlias, entity); @@ -68,14 +68,14 @@ public class VariableMqttAliasRepository : BaseRepository, /// /// 要更新的变量与MQTT别名关联实体。 /// 受影响的行数。 - public async Task UpdateAsync(VariableMqttAlias entity) => await base.UpdateAsync(_mapper.Map(entity)); + public async Task UpdateAsync(MqttAlias entity) => await base.UpdateAsync(_mapper.Map(entity)); /// /// 异步删除变量与MQTT别名关联。 /// /// 要删除的变量与MQTT别名关联实体。 /// 受影响的行数。 - public async Task DeleteAsync(VariableMqttAlias entity) => await base.DeleteAsync(_mapper.Map(entity)); + public async Task DeleteAsync(MqttAlias entity) => await base.DeleteAsync(_mapper.Map(entity)); /// /// 异步根据ID删除变量与MQTT别名关联。 @@ -98,24 +98,24 @@ public class VariableMqttAliasRepository : BaseRepository, /// /// 要获取的变量与MQTT别名关联数量。 /// 包含指定数量变量与MQTT别名关联实体的列表。 - public new async Task> TakeAsync(int number) + public new async Task> TakeAsync(int number) { var dbList = await base.TakeAsync(number); - return _mapper.Map>(dbList); + return _mapper.Map>(dbList); } - public async Task> AddBatchAsync(List entities) + public async Task> AddBatchAsync(List entities) { var dbEntities = _mapper.Map>(entities); var addedEntities = await base.AddBatchAsync(dbEntities); - return _mapper.Map>(addedEntities); + return _mapper.Map>(addedEntities); } /// /// 异步获取指定变量的所有MQTT别名关联。 /// - public async Task> GetAliasesForVariableAsync(int variableId) + public async Task> GetAliasesForVariableAsync(int variableId) { // 查询别名关联,并包含关联的Variable和MqttServer信息 var dbList = await _dbContext.GetInstance().Queryable() @@ -139,7 +139,7 @@ public class VariableMqttAliasRepository : BaseRepository, var mqttServerDict = mqttServers.ToDictionary(m => m.Id, m => _mapper.Map(m)); // 映射主实体并设置导航属性 - var result = _mapper.Map>(dbList); + var result = _mapper.Map>(dbList); foreach (var alias in result) { if (variableDict.TryGetValue(alias.VariableId, out var variable)) @@ -159,7 +159,7 @@ public class VariableMqttAliasRepository : BaseRepository, /// /// 异步根据变量和服务器获取别名关联。 /// - public async Task GetByVariableAndServerAsync(int variableId, int mqttServerId) + public async Task GetByVariableAndServerAsync(int variableId, int mqttServerId) { var dbAlias = await _dbContext.GetInstance().Queryable() .Where(x => x.VariableId == variableId && x.MqttServerId == mqttServerId) @@ -178,7 +178,7 @@ public class VariableMqttAliasRepository : BaseRepository, .FirstAsync(); // 映射主实体并设置导航属性 - var result = _mapper.Map(dbAlias); + var result = _mapper.Map(dbAlias); result.Variable = _mapper.Map(variable); result.MqttServer = _mapper.Map(mqttServer); diff --git a/DMS.Infrastructure/Services/Mqtt/MqttBackgroundService.cs b/DMS.Infrastructure/Services/Mqtt/MqttBackgroundService.cs index e04e9cf..2665a78 100644 --- a/DMS.Infrastructure/Services/Mqtt/MqttBackgroundService.cs +++ b/DMS.Infrastructure/Services/Mqtt/MqttBackgroundService.cs @@ -115,7 +115,7 @@ namespace DMS.Infrastructure.Services.Mqtt /// /// 发布变量数据到MQTT服务器 /// - public async Task PublishVariableDataAsync(VariableMqttAlias variableMqtt, CancellationToken cancellationToken = default) + public async Task PublishVariableDataAsync(MqttAlias variableMqtt, CancellationToken cancellationToken = default) { await _mqttServiceManager.PublishVariableDataAsync(variableMqtt, cancellationToken); } diff --git a/DMS.Infrastructure/Services/Mqtt/MqttDeviceContext.cs b/DMS.Infrastructure/Services/Mqtt/MqttDeviceContext.cs index b0c2fb1..30c7506 100644 --- a/DMS.Infrastructure/Services/Mqtt/MqttDeviceContext.cs +++ b/DMS.Infrastructure/Services/Mqtt/MqttDeviceContext.cs @@ -28,14 +28,14 @@ namespace DMS.Infrastructure.Services.Mqtt /// /// 与该MQTT服务器关联的所有变量MQTT别名 /// - public ConcurrentDictionary VariableMqttAliases { get; set; } + public ConcurrentDictionary VariableMqttAliases { get; set; } /// /// 构造函数 /// public MqttDeviceContext() { - VariableMqttAliases = new ConcurrentDictionary(); + VariableMqttAliases = new ConcurrentDictionary(); ReconnectAttempts = 0; } } diff --git a/DMS.Infrastructure/Services/Mqtt/MqttServiceManager.cs b/DMS.Infrastructure/Services/Mqtt/MqttServiceManager.cs index 764e19b..9280f04 100644 --- a/DMS.Infrastructure/Services/Mqtt/MqttServiceManager.cs +++ b/DMS.Infrastructure/Services/Mqtt/MqttServiceManager.cs @@ -94,7 +94,7 @@ namespace DMS.Infrastructure.Services.Mqtt /// /// 更新MQTT服务器变量别名 /// - public void UpdateVariableMqttAliases(int mqttServerId, List variableMqttAliases) + public void UpdateVariableMqttAliases(int mqttServerId, List variableMqttAliases) { if (_mqttContexts.TryGetValue(mqttServerId, out var context)) { @@ -232,7 +232,7 @@ namespace DMS.Infrastructure.Services.Mqtt /// /// 发布变量数据到MQTT服务器 /// - public async Task PublishVariableDataAsync(VariableMqttAlias variableMqtt, CancellationToken cancellationToken = default) + public async Task PublishVariableDataAsync(MqttAlias variableMqtt, CancellationToken cancellationToken = default) { if (variableMqtt?.MqttServer == null || variableMqtt.Variable == null) { @@ -269,7 +269,7 @@ namespace DMS.Infrastructure.Services.Mqtt } } - private string BuildSendMessage(VariableMqttAlias variableMqtt) + private string BuildSendMessage(MqttAlias variableMqtt) { StringBuilder sb = new StringBuilder(); var now = DateTime.Now; diff --git a/DMS.WPF/DMS.WPF.csproj b/DMS.WPF/DMS.WPF.csproj index d66434a..9cabeb9 100644 --- a/DMS.WPF/DMS.WPF.csproj +++ b/DMS.WPF/DMS.WPF.csproj @@ -181,12 +181,6 @@ - - - - - - Always diff --git a/DMS.WPF/Profiles/MappingProfile.cs b/DMS.WPF/Profiles/MappingProfile.cs index 011cc12..de737b8 100644 --- a/DMS.WPF/Profiles/MappingProfile.cs +++ b/DMS.WPF/Profiles/MappingProfile.cs @@ -17,7 +17,7 @@ namespace DMS.WPF.Profiles CreateMap() .ReverseMap(); CreateMap(); - CreateMap().ReverseMap(); + CreateMap().ReverseMap(); CreateMap() diff --git a/DMS.WPF/ViewModels/Dialogs/MqttAliasBatchEditDialogViewModel.cs b/DMS.WPF/ViewModels/Dialogs/MqttAliasBatchEditDialogViewModel.cs index 125209c..d76e15d 100644 --- a/DMS.WPF/ViewModels/Dialogs/MqttAliasBatchEditDialogViewModel.cs +++ b/DMS.WPF/ViewModels/Dialogs/MqttAliasBatchEditDialogViewModel.cs @@ -13,10 +13,10 @@ namespace DMS.WPF.ViewModels.Dialogs /// /// MQTT别名批量编辑对话框的视图模型 /// - public partial class MqttAliasBatchEditDialogViewModel : DialogViewModelBase> + public partial class MqttAliasBatchEditDialogViewModel : DialogViewModelBase> { [ObservableProperty] - private ObservableCollection _variableMqttAliases = new(); + private ObservableCollection _variableMqttAliases = new(); [ObservableProperty] private MqttServerItemViewModel _selectedMqttServer; @@ -41,7 +41,7 @@ namespace DMS.WPF.ViewModels.Dialogs // 检查该变量是否已经有针对此MQTT服务器的别名 var existingAlias = variable.MqttAliases?.FirstOrDefault(ma => ma.MqttServerId == SelectedMqttServer.Id); - var variableMqttAlias = new VariableMqttAliasItemViewModel + var variableMqttAlias = new MqttAliasItem { VariableId = variable.Id, MqttServerId = SelectedMqttServer.Id, diff --git a/DMS.WPF/ViewModels/Items/VariableMqttAliasItemViewModel.cs b/DMS.WPF/ViewModels/Items/MqttAliasItem.cs similarity index 88% rename from DMS.WPF/ViewModels/Items/VariableMqttAliasItemViewModel.cs rename to DMS.WPF/ViewModels/Items/MqttAliasItem.cs index 7216a6e..d8a51ed 100644 --- a/DMS.WPF/ViewModels/Items/VariableMqttAliasItemViewModel.cs +++ b/DMS.WPF/ViewModels/Items/MqttAliasItem.cs @@ -3,7 +3,7 @@ using DMS.Application.DTOs; namespace DMS.WPF.ViewModels.Items; -public partial class VariableMqttAliasItemViewModel : ObservableObject +public partial class MqttAliasItem : ObservableObject { public int Id { get; set; } diff --git a/DMS.WPF/ViewModels/Items/MqttServerItemViewModel.cs b/DMS.WPF/ViewModels/Items/MqttServerItemViewModel.cs index 6a31af6..fe1acb2 100644 --- a/DMS.WPF/ViewModels/Items/MqttServerItemViewModel.cs +++ b/DMS.WPF/ViewModels/Items/MqttServerItemViewModel.cs @@ -62,7 +62,7 @@ public partial class MqttServerItemViewModel : ObservableObject private string _messageFooter; [ObservableProperty] - private ObservableCollection _variableAliases = new(); + private ObservableCollection _variableAliases = new(); } diff --git a/DMS.WPF/ViewModels/Items/VariableItemViewModel.cs b/DMS.WPF/ViewModels/Items/VariableItemViewModel.cs index ca1b7ed..3544464 100644 --- a/DMS.WPF/ViewModels/Items/VariableItemViewModel.cs +++ b/DMS.WPF/ViewModels/Items/VariableItemViewModel.cs @@ -105,7 +105,7 @@ public partial class VariableItemViewModel : ObservableObject /// 一个变量可以有多个MQTT别名。 /// [ObservableProperty] - private List? _mqttAliases=new List(); + private List? _mqttAliases=new List(); /// /// 获取或设置变量的信号类型 (如:AI, DI, AO, DO)。 diff --git a/DMS.WPF/ViewModels/MqttServerDetailViewModel.cs b/DMS.WPF/ViewModels/MqttServerDetailViewModel.cs index e4721d6..c7fde13 100644 --- a/DMS.WPF/ViewModels/MqttServerDetailViewModel.cs +++ b/DMS.WPF/ViewModels/MqttServerDetailViewModel.cs @@ -37,7 +37,7 @@ namespace DMS.WPF.ViewModels /// 与当前MQTT服务器关联的变量数据集合。 /// [ObservableProperty] - private ObservableCollection _associatedVariables; + private ObservableCollection _associatedVariables; /// @@ -198,7 +198,7 @@ namespace DMS.WPF.ViewModels /// 修改变量的MQTT发送名称 /// [RelayCommand] - private async Task ModifyAlias(VariableMqttAlias variableAlias) + private async Task ModifyAlias(MqttAlias variableAlias) { if (variableAlias == null) { diff --git a/DMS.WPF/ViewModels/VariableTableViewModel.cs b/DMS.WPF/ViewModels/VariableTableViewModel.cs index de322c8..80270b9 100644 --- a/DMS.WPF/ViewModels/VariableTableViewModel.cs +++ b/DMS.WPF/ViewModels/VariableTableViewModel.cs @@ -653,7 +653,7 @@ partial class VariableTableViewModel : ViewModelBase, INavigatable if (existingVariableMqtt == null) { // 如果不存在,则添加新的关联 - var variableMqtt = new VariableMqttAliasItemViewModel + var variableMqtt = new MqttAliasItem { VariableId = originalVariable.Id, MqttServerId = selectedMqtt.Id,