using System.Collections.Generic;
using System.Linq;
using System.Windows;
using System.Windows.Controls;
namespace WCS_YongFeng
{
///
/// HandSrmTaskRevert.xaml 的交互逻辑
///
public partial class HandSrmTaskRevert
{
public HandSrmTaskRevert()
{
InitializeComponent();
}
private void DMSkinWindow_Loaded(object sender, RoutedEventArgs e)
{
var deviceList = App.f_ServiceModels.Select(a => a.device).ToList().FindAll(a => a.Type == "Srm" || a.Type == "Rgv");
List> bindComboxTypes = new List>();
foreach (var device in deviceList)
{
bindComboxTypes.Add(new BindComboxType { Name = device.Name, Type = device.Code });
}
Comm_Device.ItemsSource = bindComboxTypes;
Comm_Device.DisplayMemberPath = "Name";
Comm_Device.SelectedValuePath = "Type";
}
///
/// 按钮点击事件入口
///
///
///
private void btn_Click(object sender, RoutedEventArgs e)
{
//var deviceCode = "Srm01";
if (Comm_Device.SelectedValue == null)
{
MessageBox.Show("请选择必选项", "提示");
return;
}
var deviceCode = Comm_Device.SelectedValue.ToString();
var excute_device = App.i_Excutes.FirstOrDefault(a => a.f_service.device.Code == deviceCode);
if (excute_device == null)
{
MessageBox.Show($"设备{deviceCode}任务恢复失败:找不到对应设备的处理类");
return;
}
var excute = excute_device as I_Excute_S;
if (excute == null)
{
MessageBox.Show($"设备{deviceCode}恢复失败,找不到对应的设备类型");
return;
}
Button button = sender as Button;
BllResult bllResult;
if (button.CommandParameter.ToString() == "Req")
{
bllResult = excute.HandReqExcute();
}
else if (button.CommandParameter.ToString() == "Finish")
{
bllResult = excute.HandFinishExcute();
}
else if (button.CommandParameter.ToString() == "EmptyOut")
{
bllResult = excute.EmptyOutExcute();
}
else if (button.CommandParameter.ToString() == "PickError")
{
bllResult = excute.PickErrorExcute();
}
else if (button.CommandParameter.ToString() == "FullIn")
{
bllResult = excute.FullInExcute();
}
else if (button.CommandParameter.ToString() == "Del")
{
bllResult = excute.DeleteTask();
}
else
{
bllResult = BllResult.Error($"恢复设备{deviceCode}任务失败,未找到对应的操作类型");
}
if (bllResult.Success)
{
MessageBox.Show("设备任务恢复成功");
}
else
{
MessageBox.Show($"设备任务恢复失败,错误原因是:{bllResult.Msg}");
}
}
}
}