SCLS/SSWCS_JXDL(2019)/Symbol3204/CGetSerialData.cs
2025-05-19 09:45:29 +08:00

54 lines
1.6 KiB
C#
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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 = "Symbol3204GetSerialData---" + ex.Message;
return null;
}
}
}
}