添加报警窗口
出库流程调试、优化
This commit is contained in:
154
货架标准上位机/Views/Windows/WarningWindow.xaml.cs
Normal file
154
货架标准上位机/Views/Windows/WarningWindow.xaml.cs
Normal file
@ -0,0 +1,154 @@
|
||||
using 货架标准上位机.ViewModel;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Media;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Shapes;
|
||||
using WCS.Model.WebSocketModel;
|
||||
using HandyControl.Controls;
|
||||
using WCS.Model;
|
||||
using 货架标准上位机.Api;
|
||||
using TouchSocket.Core;
|
||||
using Window = HandyControl.Controls.Window;
|
||||
|
||||
namespace 货架标准上位机
|
||||
{
|
||||
/// <summary>
|
||||
/// 提示框
|
||||
/// </summary>
|
||||
public partial class WarningWindow : HandyControl.Controls.Window
|
||||
{
|
||||
public WebSocketMessageModel warning { get; set; }
|
||||
public WarningWindow(WebSocketMessageModel _warning)
|
||||
{
|
||||
InitializeComponent();
|
||||
this.Topmost = true; // 设置窗口始终在最上方
|
||||
this.WindowStyle = WindowStyle.None; // 可选,移除窗口的标准边框
|
||||
warning = _warning;
|
||||
}
|
||||
|
||||
private void closeClick(object sender, RoutedEventArgs e)
|
||||
{
|
||||
//this.Close();
|
||||
WarningManager.RemoveWarning(warning.Guid);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 显示提示框
|
||||
/// </summary>
|
||||
/// <param name="content">内容</param>
|
||||
/// <param name="isVisCloseBut">界面右上角是否显示关闭按钮</param>
|
||||
/// <returns>点击的按钮文本</returns>
|
||||
public static WarningWindow Show(string content, WebSocketMessageModel _warning, bool isVisCloseBut = true, Window owner = null)
|
||||
{
|
||||
return Show(content, string.Empty, _warning, isVisCloseBut);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 显示提示框
|
||||
/// </summary>
|
||||
/// <param name="content">内容</param>
|
||||
/// <param name="title">标题</param>
|
||||
/// <param name="isVisCloseBut">界面右上角是否显示关闭按钮</param>
|
||||
/// <returns>点击的按钮文本</returns>
|
||||
public static WarningWindow Show(string content, string title, WebSocketMessageModel _warning, bool isVisCloseBut = true, Window owner = null)
|
||||
{
|
||||
return Show(content, title, new string[] { "确认", "忽略" }, _warning, isVisCloseBut);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 显示提示框
|
||||
/// </summary>
|
||||
/// <param name="content">内容</param>
|
||||
/// <param name="buttons">按钮内容</param>
|
||||
/// <param name="isVisCloseBut">界面右上角是否显示关闭按钮</param>
|
||||
/// <returns>点击的按钮文本</returns>
|
||||
public static WarningWindow Show(string content, IEnumerable<string> buttons, WebSocketMessageModel _warning, bool isVisCloseBut = true, Window owner = null)
|
||||
{
|
||||
return Show(content, string.Empty, buttons, _warning, isVisCloseBut);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 显示提示框
|
||||
/// </summary>
|
||||
/// <param name="content">内容</param>
|
||||
/// <param name="title">标题</param>
|
||||
/// <param name="buttons">按钮内容</param>
|
||||
/// <param name="isVisCloseBut">界面右上角是否显示关闭按钮</param>
|
||||
/// <returns>点击的按钮文本</returns>
|
||||
public static WarningWindow Show(string content, string title, IEnumerable<string> buttons, WebSocketMessageModel _warning, bool isVisCloseBut = true, Window owner = null)
|
||||
{
|
||||
WarningWindow WaningWindow;
|
||||
string clikename = string.Empty;
|
||||
WaningWindow = new WarningWindow(_warning);
|
||||
Application.Current.Dispatcher.Invoke(new Action(() =>
|
||||
{
|
||||
WaningWindow = new WarningWindow(_warning);
|
||||
WaningWindow.DataContext = new { Title = title, Content = content, IsClose = isVisCloseBut };
|
||||
WaningWindow.spacingPanel.Children.Clear();
|
||||
|
||||
foreach (var item in buttons)
|
||||
{
|
||||
Button button = new Button()
|
||||
{
|
||||
Content = item,
|
||||
};
|
||||
button.Click += (s, e) =>
|
||||
{
|
||||
clikename = ((Button)s).Content.ToString();
|
||||
Logs.Write($"用户{LocalStatic.CurrentUser}在处理异常报警{_warning.Guid}时点击了" + clikename);
|
||||
#region 调用接口处理异常/消除报警
|
||||
try
|
||||
{
|
||||
var body = new SolveWarningRequest()
|
||||
{
|
||||
Guid = _warning.Guid,
|
||||
SolveType = clikename == "确认" ? SolveTypeEnum.处理 : SolveTypeEnum.忽略,
|
||||
};
|
||||
var Result = ApiHelp.GetDataFromHttp<ResponseCommon<object>>(LocalFile.Config.ApiIpHost + "warning/solveWarning", body, "POST");
|
||||
if (Result != null && Result.Code == 200)
|
||||
{
|
||||
//消除异常或已不存在该异常
|
||||
WaningWindow.Close();
|
||||
}
|
||||
else if (Result != null && !string.IsNullOrEmpty(Result.Message))
|
||||
{
|
||||
Growl.Warning(Result.Message);
|
||||
}
|
||||
else if (Result == null)
|
||||
{
|
||||
Growl.Warning("调用后台接口失败!");
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Growl.Warning(ex.Message);
|
||||
}
|
||||
#endregion
|
||||
};
|
||||
|
||||
WaningWindow.spacingPanel.Children.Add(button);
|
||||
}
|
||||
|
||||
WaningWindow.Owner = owner == null ? System.Windows.Application.Current.MainWindow : owner;
|
||||
WaningWindow.Show();
|
||||
}));
|
||||
return WaningWindow;
|
||||
}
|
||||
|
||||
private void previewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
DragMove();
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user