HandSrmTaskRevert.xaml.cs 3.39 KB
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Windows;
using System.Windows.Controls;

namespace HH_WCS_Standard
{
    /// <summary>
    /// HandSrmTaskRevert.xaml 的交互逻辑
    /// </summary>
    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<BindComboxType<string>> bindComboxTypes = new List<BindComboxType<string>>();
            foreach (var device in deviceList)
            {
                bindComboxTypes.Add(new BindComboxType<string> { Name = device.Name, Type = device.Code });
            }
            //Comm_Device.ItemsSource = bindComboxTypes;
            //Comm_Device.DisplayMemberPath = "Name";
            //Comm_Device.SelectedValuePath = "Type";
        }

        /// <summary>
        /// 按钮点击事件入口
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btn_Click(object sender, RoutedEventArgs e)
        {
            //if (Comm_Device.SelectedValue == null)
            //{
            //    MessageBox.Show($"请选择设备");
            //    return;
            //}
            var deviceCode = "Srm01";
            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() == "FullIn")
            {
                bllResult = excute.FullInExcute();
            }
            else if (button.CommandParameter.ToString() == "Del")
            {
                bllResult = excute.DeleteTask();
            }
            //else if (button.CommandParameter.ToString() == "TakeErr")
            //{
            //    bllResult = excute.TakeErrorExcute();
            //}
            else
            {
                bllResult = BllResult.Error($"恢复设备{deviceCode}任务失败,未找到对应的操作类型");
            }
            if (bllResult.Success)
            {
                MessageBox.Show("设备任务恢复成功");
            }
            else
            {
                MessageBox.Show($"设备任务恢复失败,错误原因是:{bllResult.Msg}");
            }
        }
    }
}