54 lines
1.6 KiB
C#
54 lines
1.6 KiB
C#
|
using System;
|
|||
|
using System.Collections.Generic;
|
|||
|
using System.Text;
|
|||
|
using System.Data;
|
|||
|
using ICommLayer;
|
|||
|
using DBFactory;
|
|||
|
namespace Symbol3204
|
|||
|
{
|
|||
|
public class CGetSerialData:IGetSerialData
|
|||
|
{
|
|||
|
string _commLayerError;
|
|||
|
|
|||
|
public string CommLayerError
|
|||
|
{
|
|||
|
get { return _commLayerError; }
|
|||
|
set { _commLayerError = value; }
|
|||
|
}
|
|||
|
DBOperator dbo = new DBOperator();
|
|||
|
public CGetSerialData()
|
|||
|
{
|
|||
|
dbo.Open();
|
|||
|
}
|
|||
|
public string GetSerialData(int DeviceIndex)
|
|||
|
{
|
|||
|
try
|
|||
|
{
|
|||
|
CScan cs; ;
|
|||
|
DataSet ds = dbo.ExceSQL("SELECT F_DeviceIndex,F_DeviceKindIndex, F_CommSettings, F_SerialPort FROM T_Base_Device where F_DeviceIndex=" + DeviceIndex);
|
|||
|
DataView dv = ds.Tables[0].DefaultView;
|
|||
|
|
|||
|
if (ds.Tables[0].DefaultView.Count > 0)
|
|||
|
{
|
|||
|
|
|||
|
cs = new CScan(Convert.ToInt16(dv[0]["F_SerialPort"]), Convert.ToString(dv[0]["F_CommSettings"]));
|
|||
|
cs.StartSession();
|
|||
|
string bc = cs.ScanBarCode(8);
|
|||
|
//如果没收到条码,考虑是否需要循环发送10次
|
|||
|
cs.StopScan();
|
|||
|
return bc;
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
return null;
|
|||
|
}
|
|||
|
}
|
|||
|
catch (Exception ex)
|
|||
|
{
|
|||
|
_commLayerError = "Symbol3204:GetSerialData---" + ex.Message;
|
|||
|
return null;
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
}
|