using CommonFunc; using System; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Data; using System.Linq; using System.Reflection; using System.Text; 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.Shapes; using System.Windows.Threading; using XGL.Data; using XGL.Models; using XGL.UControl; using Thrift.Protocol; using Thrift.Server; using Thrift.Transport; using CentralControl.BaseData; using CentralControl.DBDAO; using XGL.Thrift; using System.Threading; using System.Configuration; namespace XGL.FormItem { /// /// FormHandUp.xaml 的交互逻辑 /// public partial class FormDownLineBoard : Window { PlcHelper plchelper = null; string ipaddress = ""; List listCatchAreas = new List(); List listCarreals = new List(); /// /// 前面跳过的数量, 因为两个站台之间的数量有差异 /// int ShowPageNumber = 5; /// /// 时间刷新 /// private DispatcherTimer dispatcherTimer; /// /// UI数据刷新 /// private DispatcherTimer RefreshUITimer; /// /// 上件区小车列表 /// ObservableCollection Cars = new ObservableCollection(); public FormDownLineBoard() { InitializeComponent(); } private void Window_Loaded(object sender, RoutedEventArgs e) { try { dispatcherTimer = new DispatcherTimer(); dispatcherTimer.Interval = TimeSpan.FromMilliseconds(1000); dispatcherTimer.Tick += DispatcherTimer_Tick; dispatcherTimer.IsEnabled = true; dispatcherTimer.Start(); RefreshUITimer = new DispatcherTimer(); RefreshUITimer.Interval = TimeSpan.FromSeconds(6); RefreshUITimer.Tick += RefreshUITimer_Tick; RefreshUITimer.IsEnabled = true; RefreshUITimer.Start(); txtTime.Content = DateTime.Now.ToLongDateString() + " " + DateTime.Now.ToLongTimeString(); BindLocatorViewList(); } catch (Exception ex) { MethodInfo method = (MethodInfo)MethodBase.GetCurrentMethod(); Common.Log.Error(method.DeclaringType.FullName + "-" + method.Name + "\r\n" + ex.Message + "\r\n" + ex.StackTrace); } } /// /// 绑定左侧库位图形列表 /// private void BindLocatorViewList() { Application.Current.Dispatcher.Invoke(new Action( delegate { DataTable dt = DBService.GetOffLocatorMaterialView(""); List list = new List(); foreach (DataRow dr in dt.Rows) { CarInfo car = new CarInfo(); car.MaterialNo = dr["TrayCode"].ToString(); car.MaterialBarNo = dr["ProductBarNo"].ToString(); car.CarNo = dr["carcode"].ToString(); if (dr["HadNumber"] == DBNull.Value) { car.LineAreaId = 0; } else { car.LineAreaId = Convert.ToInt32(dr["HadNumber"]); } //car.OptDt = Convert.ToDateTime(dr["createtime"]).ToString("yyyy-MM-dd HH:mm:ss"); list.Add(car); } gridMaterial.ItemsSource = list; gridMaterial.Items.Refresh(); })); } private void RefreshUITimer_Tick(object sender, EventArgs e) { try { BindLocatorViewList(); } catch (Exception ex) { CommonFunc.Logger logger = new CommonFunc.Logger(); logger.Error("系统刷新数据上件点异常:" + ex.Message + ex.StackTrace); } } private void DispatcherTimer_Tick(object sender, EventArgs e) { txtTime.Content = DateTime.Now.ToLongDateString() + " " + DateTime.Now.ToLongTimeString(); } private void btnExit_Click(object sender, RoutedEventArgs e) { try { if (MessageBox.Show("是否确认关闭当前窗口", "提示信息", MessageBoxButton.YesNo, MessageBoxImage.Information) == MessageBoxResult.No) { return; } else { Environment.Exit(System.Environment.ExitCode); } } catch (Exception ex) { MethodInfo method = (MethodInfo)MethodBase.GetCurrentMethod(); Common.Log.Error(method.DeclaringType.FullName + "-" + method.Name + "\r\n" + ex.Message + "\r\n" + ex.StackTrace); } } private void GridMaterial_LoadingRow(object sender, DataGridRowEventArgs e) { e.Row.Header = e.Row.GetIndex() + 1; var carinfo = e.Row.Item as CarInfo; if (carinfo.LineAreaId > 0) { e.Row.Background = new SolidColorBrush(Colors.IndianRed); } } } }