using CommonFunc; using System; using System.Collections.Generic; using System.Data; using System.Linq; using System.Reflection; using System.Text; using System.Threading; 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 Thrift.Protocol; using Thrift.Server; using Thrift.Transport; using CentralControl.BaseData; using CentralControl.DBDAO; namespace XGL.FormItem { /// /// FormHandUp.xaml 的交互逻辑 /// public partial class FormTakeOff : Window { /// /// 时间刷新 /// private DispatcherTimer dispatcherTimer; public FormTakeOff() { InitializeComponent(); } private void Window_Loaded(object sender, RoutedEventArgs e) { try { string thriftport = System.Configuration.ConfigurationManager.AppSettings["localPort"]; Thread offMaterialThriftThread = new Thread(new ParameterizedThreadStart(StartOffThriftLogic)); offMaterialThriftThread.Start(thriftport); dispatcherTimer = new DispatcherTimer(); dispatcherTimer.Interval = TimeSpan.FromMilliseconds(1000); dispatcherTimer.Tick += DispatcherTimer_Tick; dispatcherTimer.IsEnabled = true; dispatcherTimer.Start(); txtTime.Content = DateTime.Now.ToLongDateString() + " " + DateTime.Now.ToLongTimeString(); List tests = new List() { // new test() //{ // ProductCode="e", //}, new test() { ProductCode="d", }, new test() { ProductCode="c", }, new test() { ProductCode="b", }, new test() { ProductCode="a", } }; lvCars.ItemsSource = tests; lvCars.Items.Refresh(); List tests1 = new List() { new test() { ProductCode="f", }, new test() { ProductCode="e", }, new test() { ProductCode="d", }, new test() { ProductCode="c", }, new test() { ProductCode="b", }, new test() { ProductCode="a", } }; List tests2 = new List() { new test() { ProductCode="c", }, new test() { ProductCode="b", }, new test() { ProductCode="a", } }; lvCar.ItemsSource = tests1; lvCar.Items.Refresh(); lvEmptyCars1.ItemsSource = tests2; lvEmptyCars1.Items.Refresh(); lvEmptyCars2.ItemsSource = tests2; lvEmptyCars2.Items.Refresh(); } 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 StartOffThriftLogic(object thriftpoint) { int point = Convert.ToInt32(thriftpoint); XGL.Thrift.ThriftServiceImp business = new XGL.Thrift.ThriftServiceImp(); business.GetUnloadMaterialEvent += GetUnloadMaterial; XGL.Thrift.ThriftCommon thriftCommon = new XGL.Thrift.ThriftCommon(); thriftCommon.Start(business, point); } string GetUnloadMaterial(string carno, string materialno, string materialdesc, string orderno, string str1, string str2, string str3) { Application.Current.Dispatcher.Invoke(new Action( delegate { lblBarcode.Content = str1; lblCarNo.Content = carno; lblMaterialDesc.Content = materialdesc; lblMaterialMode.Content = str2; lblMaterialNo.Content = materialno; lblOrdercode.Content = orderno; })); return ""; } 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 btnTakeOff_Click(object sender, RoutedEventArgs e) { try { TTransport transport = new TSocket(Common.ThriftConfigIp, Convert.ToInt32(Common.ThriftConfigPort)); TProtocol protocol = new TBinaryProtocol(transport); ThriftService.Client client = new ThriftService.Client(protocol); transport.Open(); client.UnloadCarMaterial(lblCarNo.Content.ToString().Trim()); transport.Close(); } 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 btnPullBack_Click(object sender, RoutedEventArgs e) { try { TTransport transport = new TSocket(Common.ThriftConfigIp, Convert.ToInt32(Common.ThriftConfigPort)); TProtocol protocol = new TBinaryProtocol(transport); ThriftService.Client client = new ThriftService.Client(protocol); transport.Open(); List list = new List(); list.Add(lblCarNo.Content.ToString().Trim()); client.HaulbackCarFromPoint(list); transport.Close(); } 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 BindPlan() //{ // try // { // using (basedata_orderplanDb orderplanDb = new basedata_orderplanDb()) // { // List models = orderplanDb.GetVList(""); // gridPlan.ItemsSource = models; // gridPlan.Items.Refresh(); // } // } // 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 BindBill() { try { } 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 BindKC() { try { using (basedata_carrealinfoDb carrealinfoDb = new basedata_carrealinfoDb()) { DataSet ds = carrealinfoDb.GetDataCount(" AreaType>=4"); //gridEmergency.ItemsSource = ds.Tables[0].DefaultView; //gridEmergency.Items.Refresh(); } } catch (Exception ex) { MethodInfo method = (MethodInfo)MethodBase.GetCurrentMethod(); Common.Log.Error(method.DeclaringType.FullName + "-" + method.Name + "\r\n" + ex.Message + "\r\n" + ex.StackTrace); } } } }