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.

172 lines
5.5 KiB
C#

2 years ago
using CommonFunc;
using CommonFunc.Tools;
using COSMO.IM.LanJu.Index;
2 years ago
using System;
using System.Collections.Generic;
2 years ago
using System.Data;
2 years ago
using System.Linq;
using System.Reflection;
2 years ago
using System.Text;
2 years ago
using System.Threading.Tasks;
2 years ago
using System.Timers;
2 years ago
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;
2 years ago
using XGL.Data.DBService;
using XGL.Models.Model.FoamingMac;
2 years ago
namespace XGL.Views
{
/// <summary>
/// LanJu_Operator.xaml 的交互逻辑
/// </summary>
public partial class LanJu_Operator : UserControl
{
2 years ago
FormingMachineService formingMachineService = new FormingMachineService();
2 years ago
public static LanJu_Operator lanJu_Operator;
Frame frame = new Frame() { Content = new Views.LanJu_InOut()};
2 years ago
string deviceCode = Utils.GetAppSetting("DeviceCode");
List<FoamingMacModel> orderList = new List<FoamingMacModel>();
FoamingMacModel order = new FoamingMacModel();
Timer timerDeciveState = new Timer();
2 years ago
public enum WindowID
{
frame
}
public LanJu_Operator()
{
InitializeComponent();
WindowChange(WindowID.frame);
2 years ago
timerDeciveState.Interval = Utils.GetAppSetting("GetDeviceStateInterval") == "" ? 15000 : Convert.ToInt32(Utils.GetAppSetting("GetDeviceStateInterval"));
timerDeciveState.Elapsed += TimerDeciveState_Elapsed;
timerDeciveState.Start();
}
private void TimerDeciveState_Elapsed(object sender, ElapsedEventArgs e)
2 years ago
{
2 years ago
DataTable dt = formingMachineService.GetFormingMachineState(deviceCode);
2 years ago
if (dt == null) return;
// 使用Dispatcher来在UI线程上更新UI
this.Dispatcher.Invoke(
new Action(() => { LbDeviceState.Content = dt.Rows[0][0].ToString() == "1" ? "正常" : "异常"; }
),
System.Windows.Threading.DispatcherPriority.Render);
2 years ago
}
public void WindowChange(WindowID windowID)
{
Window1.Content = frame;
}
private void InOut_Click(object sender, RoutedEventArgs e)
{
LanJu_InOut lanJu_InOut = new LanJu_InOut();
Window1.Content = new Frame
{
Content = lanJu_InOut
};
}
private void Complete_Click(object sender, RoutedEventArgs e)
{
LanJu_Complete lanJu_Complete = new LanJu_Complete();
Window1.Content = new Frame
{
Content = lanJu_Complete
};
}
private void DeviceItems_Click(object sender, RoutedEventArgs e)
{
LanJu_DeviceItems lanJu_DeviceItems = new LanJu_DeviceItems();
Window1.Content = new Frame
{
Content = lanJu_DeviceItems
};
}
private void Paused_Click(object sender, RoutedEventArgs e)
{
LanJu_Paused lanJu_Paused = new LanJu_Paused();
Window1.Content= new Frame
{
Content = lanJu_Paused
};
}
/// <summary>
/// 上部按钮
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void Flow_Click(object sender, RoutedEventArgs e)
{
LanJu_Flow lanJu_Flow = new LanJu_Flow();
LanJu_Flow.jump = 1;
Window2.Content = new Frame
{
Content= lanJu_Flow
};
}
private void Material_Click(object sender, RoutedEventArgs e)
{
LanJu_Material lanJu_Material = new LanJu_Material();
Window2.Content = new Frame
{
Content = lanJu_Material
};
}
2 years ago
private void UCOperator_Loaded(object sender, RoutedEventArgs e)
{
GetWorkOrderInfo();
}
2 years ago
2 years ago
private void GetWorkOrderInfo()
{
try
{
//modelWareHouse = new List<WorkOrder>();
//userDbWareHouse = new DBService();
DataTable dt = formingMachineService.GetFormingMachineInfo(deviceCode);
if (dt == null) return;
foreach (DataRow i in dt.Rows)
{
order.workorder_code = i["workorder_code"].ToString();
order.product_name = i["product_name"].ToString();
2 years ago
2 years ago
order.product_code = i["product_code"].ToString();
order.car_num = Convert.ToInt32(i["car_num"].ToString());
order.begin = Convert.ToDateTime(i["begin"].ToString());
order.status = i["status"].ToString();
orderList.Add(order);
}
this.dgWorkOrderInfo.ItemsSource = orderList;
}
catch (Exception ex)
{
LogHelper.instance.log.Error("获取工单准备信息时发生异常:" + ex.Message);
}
}
private void btnPause_Click(object sender, RoutedEventArgs e)
{
var selectedRow = dgWorkOrderInfo.SelectedItem as FoamingMacModel;
var workordercode = selectedRow.workorder_code;
formingMachineService.PauseWorkOrder(workordercode);
GetWorkOrderInfo();
}
2 years ago
}
}