|
|
@ -13,9 +13,9 @@ using System.Threading.Tasks; |
|
|
using System.Windows.Forms; |
|
|
using System.Windows.Forms; |
|
|
using ButcherFactory.Utils; |
|
|
using ButcherFactory.Utils; |
|
|
using ButcherFactory.BO.LocalBL; |
|
|
using ButcherFactory.BO.LocalBL; |
|
|
using ButcherFactory.Controls; |
|
|
|
|
|
using HidLibrary.Honeywell1902Series; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
using ButcherFactory.Controls; |
|
|
|
|
|
using WebSocketSharp; |
|
|
|
|
|
|
|
|
namespace ButcherFactory.SegmentInStore_ |
|
|
namespace ButcherFactory.SegmentInStore_ |
|
|
{ |
|
|
{ |
|
|
public partial class SegmentInStoreForm : Form, IWithRoleForm |
|
|
public partial class SegmentInStoreForm : Form, IWithRoleForm |
|
|
@ -38,10 +38,9 @@ namespace ButcherFactory.SegmentInStore_ |
|
|
BindingList<SegmentInStore> unInstoreList; |
|
|
BindingList<SegmentInStore> unInstoreList; |
|
|
BindingList<SegmentCodeError> exceptionList; |
|
|
BindingList<SegmentCodeError> exceptionList; |
|
|
BindingList<SegmentInStore> backStoreList; |
|
|
BindingList<SegmentInStore> backStoreList; |
|
|
private static Scanner1902 _scanner; |
|
|
|
|
|
long? storeID; |
|
|
long? storeID; |
|
|
bool isBack = false; |
|
|
bool isBack = false; |
|
|
|
|
|
|
|
|
|
|
|
WebSocket ws; |
|
|
|
|
|
|
|
|
public SegmentInStoreForm() |
|
|
public SegmentInStoreForm() |
|
|
{ |
|
|
{ |
|
|
@ -53,11 +52,8 @@ namespace ButcherFactory.SegmentInStore_ |
|
|
uploadData.Abort(); |
|
|
uploadData.Abort(); |
|
|
if (checkHasData != null && checkHasData.IsAlive) |
|
|
if (checkHasData != null && checkHasData.IsAlive) |
|
|
checkHasData.Abort(); |
|
|
checkHasData.Abort(); |
|
|
if (_scanner != null) |
|
|
|
|
|
{ |
|
|
|
|
|
_scanner.StopListen(); |
|
|
|
|
|
_scanner.Dispose(); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
if (ws != null) |
|
|
|
|
|
ws.Close(); |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
storeSelect.SelectedIndexChanged += delegate |
|
|
storeSelect.SelectedIndexChanged += delegate |
|
|
@ -68,8 +64,21 @@ namespace ButcherFactory.SegmentInStore_ |
|
|
storeID = (long)storeSelect.SelectedValue; |
|
|
storeID = (long)storeSelect.SelectedValue; |
|
|
XmlUtil.SerializerObjToFile(new SegmentInStoreFormConfig { StoreID = storeID }); |
|
|
XmlUtil.SerializerObjToFile(new SegmentInStoreFormConfig { StoreID = storeID }); |
|
|
}; |
|
|
}; |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.Load += SegmentInStoreForm_Load; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void SegmentInStoreForm_Load(object sender, EventArgs e) |
|
|
|
|
|
{ |
|
|
|
|
|
ws = new WebSocket("ws://127.0.0.1:12346"); |
|
|
|
|
|
ws.OnMessage += (s, l) => |
|
|
|
|
|
{ |
|
|
|
|
|
ScannerDataRecieved(l.Data); |
|
|
|
|
|
}; |
|
|
|
|
|
ws.Connect(); |
|
|
|
|
|
if (ws.ReadyState != WebSocketState.Open) |
|
|
|
|
|
throw new Exception("扫码服务异常,请检查"); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
protected override void OnLoad(EventArgs e) |
|
|
protected override void OnLoad(EventArgs e) |
|
|
{ |
|
|
{ |
|
|
base.OnLoad(e); |
|
|
base.OnLoad(e); |
|
|
@ -77,21 +86,20 @@ namespace ButcherFactory.SegmentInStore_ |
|
|
var initTask = new Thread(LoadBind); |
|
|
var initTask = new Thread(LoadBind); |
|
|
initTask.Start(); |
|
|
initTask.Start(); |
|
|
uploadData = new Thread(UpLoadLocalData); |
|
|
uploadData = new Thread(UpLoadLocalData); |
|
|
uploadData.Start(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var vid = Int32.Parse("0C2E", System.Globalization.NumberStyles.HexNumber); |
|
|
|
|
|
var pid = Int32.Parse("0927", System.Globalization.NumberStyles.HexNumber); |
|
|
|
|
|
_scanner = Scanner1902.Enumerate(vid, pid).FirstOrDefault(); |
|
|
|
|
|
if (_scanner != null) |
|
|
|
|
|
{ |
|
|
|
|
|
_scanner.DataRecieved += ScannerDataRecieved; |
|
|
|
|
|
_scanner.StartListen(); |
|
|
|
|
|
} |
|
|
|
|
|
else |
|
|
|
|
|
{ |
|
|
|
|
|
MessageBox.Show("请连接扫码枪后重新启动程序!"); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
uploadData.Start(); |
|
|
|
|
|
|
|
|
|
|
|
//var vid = Int32.Parse("0C2E", System.Globalization.NumberStyles.HexNumber);
|
|
|
|
|
|
//var pid = Int32.Parse("0927", System.Globalization.NumberStyles.HexNumber);
|
|
|
|
|
|
//_scanner = Scanner1902.Enumerate(vid, pid).FirstOrDefault();
|
|
|
|
|
|
//if (_scanner != null)
|
|
|
|
|
|
//{
|
|
|
|
|
|
// _scanner.DataRecieved += ScannerDataRecieved;
|
|
|
|
|
|
// _scanner.StartListen();
|
|
|
|
|
|
//}
|
|
|
|
|
|
//else
|
|
|
|
|
|
//{
|
|
|
|
|
|
// MessageBox.Show("请连接扫码枪后重新启动程序!");
|
|
|
|
|
|
//}
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
private void LoadBind() |
|
|
private void LoadBind() |
|
|
@ -164,9 +172,9 @@ namespace ButcherFactory.SegmentInStore_ |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
private void ScannerDataRecieved(byte[] data) |
|
|
|
|
|
|
|
|
private void ScannerDataRecieved(string data) |
|
|
{ |
|
|
{ |
|
|
var code = ControlsUtil.ParseCode(Encoding.ASCII.GetString(data)); |
|
|
|
|
|
|
|
|
var code = ControlsUtil.ParseCode(data); |
|
|
if (string.IsNullOrEmpty(code)) |
|
|
if (string.IsNullOrEmpty(code)) |
|
|
return; |
|
|
return; |
|
|
this.Invoke(new Action(() => |
|
|
this.Invoke(new Action(() => |
|
|
|