using Microsoft.Extensions.DependencyInjection;
using SlnMesnac.Repository;
using SlnMesnac.Repository.service;
using System;
using System.Collections.Generic;
using System.Linq;
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.Navigation;
using System.Windows.Shapes;
namespace SlnMesnac.WPF.Page.ControlPage
{
///
/// UserTaskControl.xaml 的交互逻辑
///
public partial class UserTaskControl : UserControl
{
private IAirportTaskService _taskservice;
public Action StopTaskAction;
public UserTaskControl()
{
InitializeComponent();
_taskservice = App.ServiceProvider.GetService();
Init();
}
private void Init()
{
Dictionary dicItem = new Dictionary();
dicItem.Add(1, "1号站台");
dicItem.Add(2, "2号站台");
dicItem.Add(3, "3号站台");
dicItem.Add(4, "4号站台");
dicItem.Add(5, "5号站台");
dicItem.Add(6, "6号站台");
AreaNo.ItemsSource = dicItem;
AreaNo.SelectedIndex = 0;
}
///
/// 测试1
///
///
///
private void Button_Click_1(object sender, RoutedEventArgs e)
{
MessageBox.Show("开始定位抓取");
}
private void Button_Click_2(object sender, RoutedEventArgs e)
{
MessageBox.Show("结束定位抓取");
}
private void Button_Click_3(object sender, RoutedEventArgs e)
{
MessageBox.Show("调用小车");
}
private void Button_Click_4(object sender, RoutedEventArgs e)
{
MessageBox.Show("入库小车");
}
private void Button_Click_5(object sender, RoutedEventArgs e)
{
MessageBox.Show("手动停止任务");
}
private void Button_Click_6(object sender, RoutedEventArgs e)
{
MessageBox.Show("手动清除报警");
}
private void Button_Click_7(object sender, RoutedEventArgs e)
{
MessageBox.Show("流程开始");
}
///
/// 新建任务
///
///
///
private void NewAirportTask_Click(object sender, RoutedEventArgs e)
{
//判空
if (string.IsNullOrEmpty(BoxNo.Text.Trim()) || string.IsNullOrEmpty(AreaNo.Text.Trim()))
{
MessageBox.Show("请输入完整任务信息!");
return;
}
//判断站台任务是否结束
AirportTask airportTask = new AirportTask()
{
taskno = string.IsNullOrEmpty(taskNo.Text.Trim()) ? Guid.NewGuid().ToString("N") : taskNo.Text.Trim(),
conveyorno = AreaNo.SelectedValue.ToString(),
flightno = AirNo.Text,
totalcount = Convert.ToInt32(BoxNo.Text),
loadcount = 0,
taskstate = "等待",
starttime = DateTime.Now
};
if (_taskservice.AddTaskAsync(airportTask).Result)
{
MessageBox.Show($"{AirNo.Text} 航班任务添加成功");
}
else
{
MessageBox.Show($"{AirNo.Text} 航班任务添加失败");
}
}
private void AreaNo_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
}
private void StopAll_Click(object sender, RoutedEventArgs e)
{
if(MessageBox.Show("是否确认停止所有任务并归为所有小车?", "确认", MessageBoxButton.OKCancel) == MessageBoxResult.OK)
{
this.StopTaskAction.Invoke();
}
}
}
}