diff --git a/ButcherFactory.Form/ButcherFactory.Form.csproj b/ButcherFactory.Form/ButcherFactory.Form.csproj
index 7293c7b..2297bcd 100644
--- a/ButcherFactory.Form/ButcherFactory.Form.csproj
+++ b/ButcherFactory.Form/ButcherFactory.Form.csproj
@@ -52,6 +52,10 @@
+
+ False
+ ..\..\..\tsref\Debug\websocket-sharp.dll
+
@@ -211,6 +215,12 @@
InStoreSummaryView.cs
+
+ Form
+
+
+ SegmentInStoreForm.cs
+
@@ -402,6 +412,9 @@
InStoreSummaryView.cs
+
+ SegmentInStoreForm.cs
+
SegmentPickUpForm.cs
diff --git a/ButcherFactory.Form/SegmentInStore_/SegmentInStoreForm.cs b/ButcherFactory.Form/SegmentInStore_/SegmentInStoreForm.cs
index a495bf6..a273285 100644
--- a/ButcherFactory.Form/SegmentInStore_/SegmentInStoreForm.cs
+++ b/ButcherFactory.Form/SegmentInStore_/SegmentInStoreForm.cs
@@ -13,9 +13,9 @@ using System.Threading.Tasks;
using System.Windows.Forms;
using ButcherFactory.Utils;
using ButcherFactory.BO.LocalBL;
-using ButcherFactory.Controls;
-using HidLibrary.Honeywell1902Series;
-
+using ButcherFactory.Controls;
+using WebSocketSharp;
+
namespace ButcherFactory.SegmentInStore_
{
public partial class SegmentInStoreForm : Form, IWithRoleForm
@@ -38,10 +38,9 @@ namespace ButcherFactory.SegmentInStore_
BindingList unInstoreList;
BindingList exceptionList;
BindingList backStoreList;
- private static Scanner1902 _scanner;
long? storeID;
bool isBack = false;
-
+ WebSocket ws;
public SegmentInStoreForm()
{
@@ -53,11 +52,8 @@ namespace ButcherFactory.SegmentInStore_
uploadData.Abort();
if (checkHasData != null && checkHasData.IsAlive)
checkHasData.Abort();
- if (_scanner != null)
- {
- _scanner.StopListen();
- _scanner.Dispose();
- }
+ if (ws != null)
+ ws.Close();
};
storeSelect.SelectedIndexChanged += delegate
@@ -68,8 +64,21 @@ namespace ButcherFactory.SegmentInStore_
storeID = (long)storeSelect.SelectedValue;
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)
{
base.OnLoad(e);
@@ -77,21 +86,20 @@ namespace ButcherFactory.SegmentInStore_
var initTask = new Thread(LoadBind);
initTask.Start();
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()
@@ -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))
return;
this.Invoke(new Action(() =>