将 NotificationHelper.ShowMessage改为具体的ShowError得方法
This commit is contained in:
@@ -92,7 +92,7 @@ public partial class DevicesViewModel : ViewModelBase
|
||||
{
|
||||
if (SelectedDevice == null)
|
||||
{
|
||||
NotificationHelper.ShowMessage("你没有选择任何设备,请选择设备后再点击删除设备", NotificationType.Error);
|
||||
NotificationHelper.ShowError("你没有选择任何设备,请选择设备后再点击删除设备");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -106,7 +106,7 @@ public partial class DevicesViewModel : ViewModelBase
|
||||
|
||||
MessageHelper.SendLoadMessage(LoadTypes.Menu);
|
||||
MessageHelper.SendLoadMessage(LoadTypes.Devices);
|
||||
NotificationHelper.ShowMessage($"删除设备成功,设备名:{SelectedDevice.Name}", NotificationType.Success);
|
||||
NotificationHelper.ShowSuccess($"删除设备成功,设备名:{SelectedDevice.Name}");
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
@@ -125,7 +125,7 @@ public partial class DevicesViewModel : ViewModelBase
|
||||
{
|
||||
if (SelectedDevice == null)
|
||||
{
|
||||
NotificationHelper.ShowMessage("你没有选择任何设备,请选择设备后再点击编辑设备", NotificationType.Error);
|
||||
NotificationHelper.ShowError("你没有选择任何设备,请选择设备后再点击编辑设备");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -77,7 +77,7 @@ public partial class MainViewModel : ViewModelBase
|
||||
if (menu.Parent?.Data is not Device device)
|
||||
{
|
||||
_logger.LogWarning("尝试添加变量表时,Parent 或 Parent.Data 为空,或 Parent.Data 不是 Device 类型。");
|
||||
NotificationHelper.ShowMessage("操作失败:无法获取有效的设备信息。", NotificationType.Error);
|
||||
NotificationHelper.ShowError("操作失败:无法获取有效的设备信息。");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -118,14 +118,14 @@ public partial class MainViewModel : ViewModelBase
|
||||
// 变量表和菜单都添加成功
|
||||
MessageHelper.SendLoadMessage(LoadTypes.Menu);
|
||||
MessageHelper.SendLoadMessage(LoadTypes.Devices);
|
||||
NotificationHelper.ShowMessage($"变量表:{varTable.Name},添加成功", NotificationType.Success);
|
||||
NotificationHelper.ShowSuccess($"变量表:{varTable.Name},添加成功");
|
||||
_logger.LogInformation($"变量表:{varTable.Name},添加成功");
|
||||
}
|
||||
else
|
||||
{
|
||||
await db.RollbackTranAsync();
|
||||
// 变量表菜单添加失败 (此时变量表可能已添加成功,需要根据业务决定是否回滚)
|
||||
NotificationHelper.ShowMessage($"变量表:{varTable.Name},添加菜单失败", NotificationType.Error);
|
||||
NotificationHelper.ShowError($"变量表:{varTable.Name},添加菜单失败");
|
||||
_logger.LogError($"变量表:{varTable.Name},添加菜单失败");
|
||||
// 考虑:如果菜单添加失败,是否需要删除之前添加的变量表?
|
||||
// 例如:await _varTableRepository.Delete(addVarTableId);
|
||||
@@ -190,7 +190,7 @@ public partial class MainViewModel : ViewModelBase
|
||||
}
|
||||
else
|
||||
{
|
||||
NotificationHelper.ShowMessage($"菜单:{menu.Name},没有对应的ViewModel.");
|
||||
NotificationHelper.ShowInfo($"菜单:{menu.Name},没有对应的ViewModel.");
|
||||
_logger.LogInformation($"菜单:{menu.Name},没有对应的ViewModel.");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -81,7 +81,7 @@ namespace PMSWPF.ViewModels
|
||||
// await _dataServices.UpdateVariableDataAsync(variable);
|
||||
// }
|
||||
|
||||
NotificationHelper.ShowMessage("MQTT服务器详情保存功能待实现。", NotificationType.Info);
|
||||
NotificationHelper.ShowInfo("MQTT服务器详情保存功能待实现。");
|
||||
_logger.LogInformation("Save changes for MQTT server detail initiated.");
|
||||
}
|
||||
|
||||
@@ -94,7 +94,7 @@ namespace PMSWPF.ViewModels
|
||||
{
|
||||
if (CurrentMqtt == null || variablesToRemove == null || variablesToRemove.Count == 0)
|
||||
{
|
||||
NotificationHelper.ShowMessage("请选择要移除的变量。", NotificationType.Warning);
|
||||
NotificationHelper.ShowInfo("请选择要移除的变量。");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -117,7 +117,7 @@ namespace PMSWPF.ViewModels
|
||||
|
||||
// TODO: 这里需要调用DataServices来更新数据库中VariableData的Mqtt关联
|
||||
// 例如:await _dataServices.UpdateVariableDataAssociationsAsync(variablesToRemove);
|
||||
NotificationHelper.ShowMessage("变量移除成功,请记得保存更改。", NotificationType.Success);
|
||||
NotificationHelper.ShowSuccess("变量移除成功,请记得保存更改。");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -131,7 +131,7 @@ namespace PMSWPF.ViewModels
|
||||
// TODO: 实现选择变量的对话框,让用户选择要添加的变量
|
||||
// 例如:var selectedVariables = await _dialogService.ShowVariableSelectionDialogAsync();
|
||||
// 这里只是一个占位符,实际需要一个UI来选择变量
|
||||
NotificationHelper.ShowMessage("添加变量功能待实现,需要一个变量选择对话框。", NotificationType.Info);
|
||||
NotificationHelper.ShowInfo("添加变量功能待实现,需要一个变量选择对话框。");
|
||||
_logger.LogInformation("Add variables to MQTT server initiated.");
|
||||
|
||||
// 假设我们已经通过对话框获取到了一些要添加的变量
|
||||
|
||||
@@ -81,7 +81,7 @@ public partial class MqttsViewModel : ViewModelBase
|
||||
{
|
||||
if (SelectedMqtt == null)
|
||||
{
|
||||
NotificationHelper.ShowMessage("你没有选择任何MQTT,请选择MQTT后再点击删除", NotificationType.Error);
|
||||
NotificationHelper.ShowError("你没有选择任何MQTT,请选择MQTT后再点击删除");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -92,7 +92,7 @@ public partial class MqttsViewModel : ViewModelBase
|
||||
await _mqttRepository.Delete(SelectedMqtt);
|
||||
MessageHelper.SendLoadMessage(LoadTypes.Mqtts);
|
||||
MessageHelper.SendLoadMessage(LoadTypes.Menu);
|
||||
NotificationHelper.ShowMessage($"删除MQTT成功,MQTT名:{SelectedMqtt.Name}", NotificationType.Success);
|
||||
NotificationHelper.ShowSuccess($"删除MQTT成功,MQTT名:{SelectedMqtt.Name}");
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
@@ -108,7 +108,7 @@ public partial class MqttsViewModel : ViewModelBase
|
||||
{
|
||||
if (SelectedMqtt == null)
|
||||
{
|
||||
NotificationHelper.ShowMessage("你没有选择任何MQTT,请选择MQTT后再点击编辑", NotificationType.Error);
|
||||
NotificationHelper.ShowError("你没有选择任何MQTT,请选择MQTT后再点击编辑");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -114,12 +114,12 @@ public partial class SettingViewModel : ViewModelBase
|
||||
using (var db = DbContext.GetInstance())
|
||||
{
|
||||
await db.Ado.OpenAsync();
|
||||
NotificationHelper.ShowMessage("连接成功!");
|
||||
NotificationHelper.ShowSuccess("连接成功!");
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
NotificationHelper.ShowMessage($"连接失败:{ex.Message}");
|
||||
NotificationHelper.ShowError($"连接失败:{ex.Message}", ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -115,7 +115,7 @@ partial class VariableTableViewModel : ViewModelBase
|
||||
modifiedData.IsModified = false;
|
||||
}
|
||||
|
||||
NotificationHelper.ShowMessage($"修改的{modifiedDatas.Count}变量保存成功.", NotificationType.Success);
|
||||
NotificationHelper.ShowSuccess($"修改的{modifiedDatas.Count}变量保存成功.");
|
||||
}
|
||||
|
||||
[RelayCommand]
|
||||
@@ -136,7 +136,7 @@ partial class VariableTableViewModel : ViewModelBase
|
||||
// 更新变量表中的
|
||||
if (index >= 0 && index < variableTable.DataVariables.Count)
|
||||
variableTable.DataVariables[index] = varData;
|
||||
NotificationHelper.ShowMessage($"编辑变量成功:{varData?.Name}", NotificationType.Success);
|
||||
NotificationHelper.ShowSuccess($"编辑变量成功:{varData?.Name}");
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
@@ -175,7 +175,7 @@ partial class VariableTableViewModel : ViewModelBase
|
||||
|
||||
string msgSuccess = $"成功导入变量:{resVarDataCount}个。";
|
||||
Logger.Info(msgSuccess);
|
||||
NotificationHelper.ShowMessage(msgSuccess, NotificationType.Success);
|
||||
NotificationHelper.ShowSuccess(msgSuccess);
|
||||
|
||||
}
|
||||
catch (Exception e)
|
||||
@@ -203,7 +203,7 @@ partial class VariableTableViewModel : ViewModelBase
|
||||
await _varDataRepository.AddAsync(varData);
|
||||
// 更新当前页面的
|
||||
DataVariables.Add(varData);
|
||||
NotificationHelper.ShowMessage($"添加变量成功:{varData?.Name}", NotificationType.Success);
|
||||
NotificationHelper.ShowSuccess($"添加变量成功:{varData?.Name}");
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
@@ -216,7 +216,7 @@ partial class VariableTableViewModel : ViewModelBase
|
||||
{
|
||||
if (variablesToDelete == null || !variablesToDelete.Any())
|
||||
{
|
||||
NotificationHelper.ShowMessage("请选择要删除的变量", NotificationType.Warning);
|
||||
NotificationHelper.ShowInfo("请选择要删除的变量");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -238,11 +238,11 @@ partial class VariableTableViewModel : ViewModelBase
|
||||
{
|
||||
DataVariables.Remove(variable);
|
||||
}
|
||||
NotificationHelper.ShowMessage($"成功删除 {result} 个变量", NotificationType.Success);
|
||||
NotificationHelper.ShowSuccess($"成功删除 {result} 个变量");
|
||||
}
|
||||
else
|
||||
{
|
||||
NotificationHelper.ShowMessage("删除变量失败", NotificationType.Error);
|
||||
NotificationHelper.ShowError("删除变量失败");
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
@@ -256,7 +256,7 @@ partial class VariableTableViewModel : ViewModelBase
|
||||
{
|
||||
if (variablesToChange == null || !variablesToChange.Any())
|
||||
{
|
||||
NotificationHelper.ShowMessage("请选择要修改轮询频率的变量", NotificationType.Warning);
|
||||
NotificationHelper.ShowInfo("请选择要修改轮询频率的变量");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -270,7 +270,7 @@ partial class VariableTableViewModel : ViewModelBase
|
||||
}
|
||||
|
||||
await _varDataRepository.UpdateAsync(variablesToChange);
|
||||
NotificationHelper.ShowMessage($"已成功更新 {variablesToChange.Count} 个变量的轮询频率", NotificationType.Success);
|
||||
NotificationHelper.ShowSuccess($"已成功更新 {variablesToChange.Count} 个变量的轮询频率");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -279,7 +279,7 @@ partial class VariableTableViewModel : ViewModelBase
|
||||
{
|
||||
if (variablesToAddMqtt == null || !variablesToAddMqtt.Any())
|
||||
{
|
||||
NotificationHelper.ShowMessage("请选择要添加MQTT服务器的变量", NotificationType.Warning);
|
||||
NotificationHelper.ShowInfo("请选择要添加MQTT服务器的变量");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -307,7 +307,7 @@ partial class VariableTableViewModel : ViewModelBase
|
||||
|
||||
// 批量更新数据库
|
||||
await _varDataRepository.UpdateAsync(variablesToAddMqtt.ToList());
|
||||
NotificationHelper.ShowMessage($"已成功为 {variablesToAddMqtt.Count} 个变量添加MQTT服务器: {selectedMqtt.Name}", NotificationType.Success);
|
||||
NotificationHelper.ShowSuccess($"已成功为 {variablesToAddMqtt.Count} 个变量添加MQTT服务器: {selectedMqtt.Name}");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -333,11 +333,11 @@ partial class VariableTableViewModel : ViewModelBase
|
||||
if (res > 0)
|
||||
{
|
||||
var statusMessage = active ? "已启用" : "已停用";
|
||||
NotificationHelper.ShowMessage($"变量表:{VariableTable.Name},{statusMessage}", NotificationType.Success);
|
||||
NotificationHelper.ShowSuccess($"变量表:{VariableTable.Name},{statusMessage}");
|
||||
}
|
||||
else
|
||||
{
|
||||
NotificationHelper.ShowMessage($"变量表:{VariableTable.Name},状态修改失败,状态:{active}", NotificationType.Error);
|
||||
NotificationHelper.ShowError($"变量表:{VariableTable.Name},状态修改失败,状态:{active}");
|
||||
// _logger.LogInformation($"变量表:{VariableTable.Name},状态修改失败,状态:{active}");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user