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:
@@ -98,24 +98,23 @@ public class MqttAppService : IMqttAppService
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 异步删除一个MQTT服务器(事务性操作)。
|
||||
/// 异步根据ID删除一个MQTT服务器(事务性操作)。
|
||||
/// </summary>
|
||||
/// <param name="id">要删除MQTT服务器的ID。</param>
|
||||
/// <returns>表示异步操作的任务。</returns>
|
||||
/// <returns>如果删除成功则为 true,否则为 false。</returns>
|
||||
/// <exception cref="ApplicationException">如果删除MQTT服务器时发生错误。</exception>
|
||||
public async Task DeleteMqttServerAsync(int id)
|
||||
public async Task<int> DeleteMqttServerAsync(int id)
|
||||
{
|
||||
try
|
||||
{
|
||||
await _repoManager.BeginTranAsync();
|
||||
await _repoManager.MqttServers.DeleteByIdAsync(id);
|
||||
await _repoManager.CommitAsync();
|
||||
return await _repoManager.MqttServers.DeleteByIdAsync(id);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
await _repoManager.RollbackAsync();
|
||||
throw new ApplicationException("删除MQTT服务器时发生错误,操作已回滚。", ex);
|
||||
throw new ApplicationException($"删除MQTT服务器时发生错误,操作已回滚,错误信息:{ex.Message}", ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user