Browse Source

需求单No.156433“扫码入库”客户端,增加斑马DS2278 支持

master
yibo 4 years ago
parent
commit
9c22986e4d
2 changed files with 50 additions and 29 deletions
  1. +13
    -0
      ButcherFactory.Form/ButcherFactory.Form.csproj
  2. +37
    -29
      ButcherFactory.Form/SegmentInStore_/SegmentInStoreForm.cs

+ 13
- 0
ButcherFactory.Form/ButcherFactory.Form.csproj View File

@ -52,6 +52,10 @@
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
<Reference Include="websocket-sharp, Version=1.0.2.59611, Culture=neutral, PublicKeyToken=5660b08a1845a91e, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\tsref\Debug\websocket-sharp.dll</HintPath>
</Reference>
<Reference Include="WindowsBase" />
<Reference Include="WinFormControl, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL" />
</ItemGroup>
@ -211,6 +215,12 @@
<Compile Include="SegmentInStore_\InStoreSummaryView.Designer.cs">
<DependentUpon>InStoreSummaryView.cs</DependentUpon>
</Compile>
<Compile Include="SegmentInStore_\SegmentInStoreForm.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="SegmentInStore_\SegmentInStoreForm.Designer.cs">
<DependentUpon>SegmentInStoreForm.cs</DependentUpon>
</Compile>
<Compile Include="SegmentInStore_\SegmentInStoreFormConfig.cs" />
<Compile Include="SegmentPickUp_\SegmentPickUpConfig.cs" />
<Compile Include="SegmentPickUp_\SegmentPickUpForm.cs">
@ -402,6 +412,9 @@
<EmbeddedResource Include="SegmentInStore_\InStoreSummaryView.resx">
<DependentUpon>InStoreSummaryView.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="SegmentInStore_\SegmentInStoreForm.resx">
<DependentUpon>SegmentInStoreForm.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="SegmentPickUp_\SegmentPickUpForm.resx">
<DependentUpon>SegmentPickUpForm.cs</DependentUpon>
</EmbeddedResource>


+ 37
- 29
ButcherFactory.Form/SegmentInStore_/SegmentInStoreForm.cs View File

@ -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<SegmentInStore> unInstoreList;
BindingList<SegmentCodeError> exceptionList;
BindingList<SegmentInStore> 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(() =>


Loading…
Cancel
Save