You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

137 lines
4.0 KiB
C#

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
{
/// <summary>
/// UserTaskControl.xaml 的交互逻辑
/// </summary>
public partial class UserTaskControl : UserControl
{
private IAirportTaskService _taskservice;
public Action StopTaskAction;
public UserTaskControl()
{
InitializeComponent();
_taskservice = App.ServiceProvider.GetService<IAirportTaskService>();
Init();
}
private void Init()
{
Dictionary<int, string> dicItem = new Dictionary<int, string>();
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;
}
/// <summary>
/// 测试1
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
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("流程开始");
}
/// <summary>
/// 新建任务
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
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)
{
this.StopTaskAction.Invoke();
}
}
}