将 NotificationHelper.ShowMessage改为具体的ShowError得方法

This commit is contained in:
2025-07-06 15:36:53 +08:00
parent b0874a4f02
commit 0980f84d09
13 changed files with 45 additions and 55 deletions

View File

@@ -127,8 +127,7 @@ public partial class DataServices : ObservableRecipient, IRecipient<LoadMessage>
catch (Exception e)
{
// 捕获加载数据时发生的异常,并通过通知和日志记录错误信息。
NotificationHelper.ShowMessage($"加载数据出现了错误:{e.Message}");
_logger.LogError($"加载数据出现了错误:{e}");
NotificationHelper.ShowError($"加载数据出现了错误:{e.Message}", e);
}
}

View File

@@ -203,14 +203,14 @@ namespace PMSWPF.Services
client.UseConnectedHandler(e =>
{
Logger.Info($"Connected to MQTT broker: {mqtt.Name}");
NotificationHelper.ShowMessage($"已连接到MQTT服务器: {mqtt.Name}", NotificationType.Success);
NotificationHelper.ShowSuccess($"已连接到MQTT服务器: {mqtt.Name}");
});
// 设置断开连接事件处理程序。
client.UseDisconnectedHandler(async e =>
{
Logger.Warn($"Disconnected from MQTT broker: {mqtt.Name}. Reason: {e.Reason}");
NotificationHelper.ShowMessage($"与MQTT服务器断开连接: {mqtt.Name}", NotificationType.Warning);
NotificationHelper.ShowInfo($"与MQTT服务器断开连接: {mqtt.Name}");
// 尝试重新连接。
await Task.Delay(TimeSpan.FromSeconds(5)); // 等待5秒后重连
try
@@ -231,7 +231,7 @@ namespace PMSWPF.Services
catch (Exception ex)
{
Logger.Error(ex, $"Failed to connect to MQTT broker: {mqtt.Name}");
NotificationHelper.ShowMessage($"连接MQTT服务器失败: {mqtt.Name} - {ex.Message}", NotificationType.Error);
NotificationHelper.ShowError($"连接MQTT服务器失败: {mqtt.Name} - {ex.Message}", ex);
}
}

View File

@@ -63,8 +63,7 @@ public partial class NavgatorServices : ObservableRecipient, IRecipient<Navgator
}
catch (Exception e)
{
NotificationHelper.ShowMessage($"切换视图时发生了错误:{e.Message}", NotificationType.Error);
_logger.LogError($"切换视图时发生了错误:{e}");
NotificationHelper.ShowError($"切换视图时发生了错误:{e.Message}", e);
}
}