更新项目配置,新增设备同步模块,优化WebSocket和Swagger配置,增强SCADA系统的免登录接口,支持数据字典项和登录日志的免登录查询与记录。调整Java编译设置,确保更好的开发体验。
This commit is contained in:
46
yy-admin-master/YY.Admin/Subscriber/ErrorNotification.cs
Normal file
46
yy-admin-master/YY.Admin/Subscriber/ErrorNotification.cs
Normal file
@@ -0,0 +1,46 @@
|
||||
using HandyControl.Controls;
|
||||
using YY.Admin.Core.BusinessException;
|
||||
|
||||
namespace YY.Admin.EventBus
|
||||
{
|
||||
// 错误事件
|
||||
public class ErrorEvent : PubSubEvent<string>
|
||||
{
|
||||
}
|
||||
|
||||
// 错误处理服务
|
||||
public interface IErrorHandler
|
||||
{
|
||||
void HandleError(Exception ex);
|
||||
}
|
||||
|
||||
public class ErrorHandler : IErrorHandler
|
||||
{
|
||||
private readonly IEventAggregator _eventAggregator;
|
||||
|
||||
public ErrorHandler(
|
||||
IEventAggregator eventAggregator)
|
||||
{
|
||||
_eventAggregator = eventAggregator;
|
||||
}
|
||||
|
||||
public void HandleError(Exception ex)
|
||||
{
|
||||
if (ex is BusinessException bex)
|
||||
{
|
||||
// _logger.LogWarning($"业务错误: {bex.ErrorCode} - {bex.Message}");
|
||||
|
||||
// 在UI线程显示HandyControl提示
|
||||
System.Windows.Application.Current.Dispatcher.Invoke(() =>
|
||||
{
|
||||
Growl.Error(bex.Message);
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
// _logger.LogError(ex, "未处理的异常");
|
||||
_eventAggregator.GetEvent<ErrorEvent>().Publish($"系统错误: {ex.Message}");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user