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 System.Timers;
using XGL.Data;
using XGL.Thrift;
using System.Threading.Tasks;
using Thrift.Transport;
using Thrift.Protocol;
using Helper;
namespace XGL.FormItem
{
///
/// FormBoard.xaml 的交互逻辑
///
public partial class FormOutBoxBoard : Window
{
///
/// 时间刷新计时器
///
private DispatcherTimer dispatcherTimer;
private DispatcherTimer TimerReal;
private int LoopIndex = 1;
private int IsHouseMenuVisible = 0;
private DispatcherTimer ShowTimer;
private DispatcherTimer BarCodeListThriftTimer;//ping thrift ip地址
string ScanStr { get; set; }
DispatcherTimer tm = new DispatcherTimer();
string content = string.Empty;
int loop = 0;//从右向左逐渐进入的循环次数
int loop2 = 0;//左侧到头后,左侧字符逐渐消失的循环次数
bool isOver = false;//所有字符是否均已划过,若都划过,则从头开始
public FormOutBoxBoard()
{
InitializeComponent();
}
private void FormBoard_Loaded(object sender, RoutedEventArgs e)
{
ShowTimer = new System.Windows.Threading.DispatcherTimer();
ShowTimer.Tick += new EventHandler(ShowCurTimer);//起个Timer一直获取当前时间
ShowTimer.Interval = new TimeSpan(0, 0, 0, 1, 0);
ShowTimer.Start();
BarCodeListThriftTimer = new System.Windows.Threading.DispatcherTimer();
BarCodeListThriftTimer.Tick += new EventHandler(ShowBarCodeList);//起个Timer一直获取当前Grid
BarCodeListThriftTimer.Interval = new TimeSpan(0, 0, 0, 10, 0);
BarCodeListThriftTimer.Start();
//创建一个名为"Table_New"的空表
//DataTable dt = new DataTable("Table_New");
////1.创建空列
//DataColumn dc = new DataColumn();
////2.创建带列名和类型名的列(两种方式任选其一)
//dt.Columns.Add("jhdh", typeof(String));
//dt.Columns.Add("wlbm", typeof(String));
//dt.Columns.Add("wlmc", typeof(String));
//dt.Columns.Add("jhrq", typeof(String));
//dt.Columns.Add("jhsl", typeof(String));
//dt.Columns.Add("yslsl", typeof(String));
////1.创建空行
//DataRow dr = dt.NewRow();
//dr["jhdh"] = "10000000001";
//dr["wlbm"] = "CE0A0000B001";
//dr["wlmc"] = "冰箱";
//dr["jhrq"] = "2019-04-15";
//dr["jhsl"] = "200";
//dr["yslsl"] = "3888";
//dt.Rows.Add(dr);
//dr = dt.NewRow();
//dr["jhdh"] = "10000000002";
//dr["wlbm"] = "CE0A0000B002";
//dr["wlmc"] = "洗衣机";
//dr["jhrq"] = "2019-04-14";
//dr["jhsl"] = "2000";
//dr["yslsl"] = "38088";
//dt.Rows.Add(dr);
//DgLoadBox.ItemsSource = dt.DefaultView;
////创建一个名为"Table_New"的空表
//DataTable dt1 = new DataTable("Table_New1");
////1.创建空列
//DataColumn dc1 = new DataColumn();
////2.创建带列名和类型名的列(两种方式任选其一)
//dt1.Columns.Add("kq", typeof(String));
//dt1.Columns.Add("wlbm", typeof(String));
//dt1.Columns.Add("wlmc", typeof(String));
//dt1.Columns.Add("kcsl", typeof(String));
////1.创建空行
//DataRow dr1 = dt1.NewRow();
//dr1["kq"] = "1号库区";
//dr1["wlbm"] = "CE0A0000B001";
//dr1["wlmc"] = "冰箱";
//dr1["kcsl"] = "3888";
//dt1.Rows.Add(dr1);
//dr1 = dt1.NewRow();
//dr1["kq"] = "2号库区";
//dr1["wlbm"] = "CE0A0000B002";
//dr1["wlmc"] = "洗衣机";
//dr1["kcsl"] = "38888";
//dt1.Rows.Add(dr1);
//DgLoadDoor.ItemsSource = dt1.DefaultView;
this.tBoxBarCode.Focus();
}
void BarCode_KeyDown(object sender, KeyEventArgs e)
{
try
{
if (e.Key == Key.Enter)
{
if (this.tBoxBarCode.Text.Length >= 9)
{
try
{
TTransport transport = new TSocket(Common.ThriftConfigIp, Convert.ToInt32(Common.thriftBoxPort));
TProtocol protocol = new TBinaryProtocol(transport);
ThriftService.Client client = new ThriftService.Client(protocol);
transport.Open();
string ret = client.SendOutLocatorBarcode(this.tBoxBarCode.Text);
if (ret == "")
{
Application.Current.Dispatcher.Invoke(new Action(
delegate
{
laberrorlog.Content = ret;
}));
}
else
{
Application.Current.Dispatcher.Invoke(new Action(
delegate
{
laberrorlog.Content = ret;
}));
}
transport.Close();
transport.Dispose();
transport = null;
}
catch (Exception ex)
{
}
this.laberrorlog.Content = "";
}
else
{
this.laberrorlog.Content = "箱体条码输入错误!";
}
}
//else if (e.KeyStates == Keyboard.GetKeyStates(Key.D3) && Keyboard.Modifiers == ModifierKeys.Shift)
//{
// ScanStr += "#";
// this.tBoxBarCode.Text = ScanStr;
//}
//else if (e.Key.ToString().Length == 2)
//{
// ScanStr += e.Key.ToString().Trim('D');
// this.tBoxBarCode.Text = ScanStr;
//}
//else if (e.Key.ToString().Length == 1)
//{
// ScanStr += e.Key.ToString();
// this.tBoxBarCode.Text = ScanStr;
//}
}
catch (Exception ex)
{
this.Focus();
}
}
private void dgData_LoadingRow(object sender, DataGridRowEventArgs e)
{ e.Row.Header = e.Row.GetIndex() + 1; }
public void ShowCurTimer(object sender, EventArgs e)
{
LabDate.Content = DateTime.Now.ToString("yyyy年MM月dd日");
LabTime.Content = DateTime.Now.ToString("HH:mm:ss");
}
///
/// 接收箱体条码集合
///
///
///
public void ShowBarCodeList(object sender, EventArgs e)
{
try
{
TTransport transport = new TSocket(Common.ThriftConfigIp, Convert.ToInt32(Common.thriftBoxPort));
TProtocol protocol = new TBinaryProtocol(transport);
ThriftService.Client client = new ThriftService.Client(protocol);
transport.Open();
string ret = client.GetOutLocatorList();
Application.Current.Dispatcher.Invoke(new Action(
delegate
{
this.DgLoadBox.ItemsSource = JsonHelper.ToDataTable(ret).DefaultView;//将json字符串转换为datatable赋值到gridview
}));
transport.Close();
transport.Dispose();
transport = null;
}
catch (Exception ex)
{
Application.Current.Dispatcher.Invoke(new Action(
delegate
{
this.laberrorlog.Content = ex.Message;
}));
}
}
private void btnExit_Click(object sender, RoutedEventArgs e)
{
if (MessageBox.Show("是否确认关闭程序", "提示信息", MessageBoxButton.YesNo, MessageBoxImage.Information) == MessageBoxResult.No)
{
}
else
{
System.Environment.Exit(System.Environment.ExitCode);
}
}
private void btnHouseMenuVisible_Click(object sender, RoutedEventArgs e)
{
}
}
}