76 lines
2.7 KiB
C#
76 lines
2.7 KiB
C#
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Windows;
|
|
|
|
namespace WCS_YongFeng
|
|
{
|
|
/// <summary>
|
|
/// HandDeviceTask.xaml 的交互逻辑
|
|
/// </summary>
|
|
public partial class HandDeviceTask
|
|
{
|
|
public HandDeviceTask()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
|
|
private void DMSkinWindow_Loaded(object sender, RoutedEventArgs e)
|
|
{
|
|
List<BindComboxType<string>> bindComboxTypes = new List<BindComboxType<string>>();
|
|
var deviceList = App.f_ServiceModels.FindAll(a => a.device.Type == "Srm" || a.device.Type == "Rgv");
|
|
foreach (F_ServiceModel device in deviceList)
|
|
{
|
|
bindComboxTypes.Add(new BindComboxType<string> { Name = device.device.Name, Type = device.device.Code });
|
|
}
|
|
Comm_Device.ItemsSource = bindComboxTypes;
|
|
Comm_Device.DisplayMemberPath = "Name";
|
|
Comm_Device.SelectedValuePath = "Type";
|
|
|
|
//任务类型绑定
|
|
Comm.ItemsSource = BindComboxEnumType<E_SrmHandTask>.BindTyps;
|
|
Comm.DisplayMemberPath = "Name";
|
|
Comm.SelectedValuePath = "Type";
|
|
|
|
}
|
|
|
|
private void Button_Click(object sender, RoutedEventArgs e)
|
|
{
|
|
if (Comm.SelectedValue == null) //Comm_Device.SelectedValue == null &&
|
|
{
|
|
MessageBox.Show("请选择必选项", "提示");
|
|
return;
|
|
}
|
|
var deviceCode = Comm_Device.SelectedValue.ToString();
|
|
var taskType = (E_SrmHandTask)Comm.SelectedValue;
|
|
if (string.IsNullOrWhiteSpace(to.Text))
|
|
{
|
|
MessageBox.Show("终点不能为空");
|
|
}
|
|
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)
|
|
{
|
|
var result = excute.HandDeviceTask(taskType.GetIndexInt(), to.Text, to.Text);
|
|
if (!result.Success)
|
|
{
|
|
MessageBox.Show($"手动下发设备{deviceCode}任务失败,错误原因是:【{result.Msg}】");
|
|
return;
|
|
}
|
|
else
|
|
{
|
|
MessageBox.Show($"手动下发设备{deviceCode}任务成功");
|
|
}
|
|
}
|
|
else
|
|
{
|
|
MessageBox.Show($"手动下发设备{deviceCode}任务失败,找不到此设备的类型");
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
} |