You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
328 lines
18 KiB
C#
328 lines
18 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading;
|
|
using demo.ExternalDevices;
|
|
using demo.Recode;
|
|
using demo.ClassHelper.RandomOperate;
|
|
using demo.ClassHelper.MsgBox;
|
|
using System.Windows.Forms;
|
|
|
|
namespace demo
|
|
{
|
|
class ReadCard
|
|
{
|
|
#region 单件类访问接口
|
|
private static ReadCard m_instance = new ReadCard();
|
|
/// <summary>
|
|
/// 单件类访问接口
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public static ReadCard Instance
|
|
{
|
|
get { return m_instance; }
|
|
private set { m_instance = value; }
|
|
}
|
|
#endregion
|
|
|
|
public delUpdatePost UpdatePost = null;
|
|
|
|
public void SelectFailed(string msg)
|
|
{
|
|
TriColorLight.ShowRed();
|
|
ops.pause_proc_by_name("推身份证", 1);
|
|
DialogResult result = MsgBoxHelper.ShowYesNoAndTips(msg);
|
|
switch (result)
|
|
{
|
|
case DialogResult.No:
|
|
ops.pause_proc_by_name("推身份证", 0);//PlatformConnection.WorkResetPause();
|
|
PlatformConnection.Instance.StopWork();
|
|
break;
|
|
case DialogResult.Yes:
|
|
ops.pause_proc_by_name("推身份证", 0);
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
comm_net.set_int_var("isFirstRead_ok", 0);
|
|
}
|
|
#region 第一次读卡
|
|
public bool ReadFirst()
|
|
{
|
|
PostInfo postInfo = new PostInfo();
|
|
ReadFirstInfo firstInfo = new ReadFirstInfo();
|
|
#region 空泡
|
|
if (false == GlobalVariable.bReadCard)
|
|
{
|
|
//lock (GlobalVariable.lockList)
|
|
//{
|
|
// Thread.Sleep(960);
|
|
// comm_net.set_int_var("isFirstRead_ok", 1);
|
|
// postInfo.idNoOne = GlobalVariable.IDNo_One = firstInfo.no = RandomHelper.GetRandomCode(GlobalVariable.randomTelNo, 18);
|
|
// postInfo.recvName = firstInfo.name = GlobalVariable.IDName_One = RandomHelper.GetRandomCode(GlobalVariable.randomName, 3);
|
|
// postInfo.recvNo = RandomHelper.GetRandomCode(GlobalVariable.randomTelNo, 11);
|
|
// int addressIndex = RandomHelper.GetRandom(0, GlobalVariable.address.Length);
|
|
// postInfo.recvAddress = GlobalVariable.address[addressIndex];
|
|
// postInfo.postNo = RandomHelper.GetRandomCode(GlobalVariable.randomTraceNo, GlobalVariable.scanGunParam.barcodeLen);
|
|
|
|
// postInfo.sendName = GlobalVariable.send_Name;
|
|
// postInfo.sendNo = GlobalVariable.send_NO;
|
|
// postInfo.sendAddress = GlobalVariable.send_Address;
|
|
// postInfo.id = RandomHelper.GetRandomCode(GlobalVariable.randomTelNo, 32);
|
|
// //postInfo.emsDepartment = "揽投部";
|
|
|
|
// //sys.sys_EnterCriticalSection(Varialble.hsection);
|
|
// GlobalVariable.list_PostInfo.Add(postInfo);
|
|
// lock (GlobalVariable.lockFirstInfo)
|
|
// {
|
|
// GlobalVariable.list_FirstInfo.Add(firstInfo);
|
|
// }
|
|
// lock (GlobalVariable.lockBarcodeInfo)
|
|
// {
|
|
// GlobalVariable.list_BarcodeInfo.Add(postInfo.postNo);
|
|
// }
|
|
|
|
// OleDbAccess.InsertDataToLetterAccess(GlobalVariable.accessLetterPath, GlobalVariable.tableName_Letter,postInfo.id, GlobalVariable.GetCurrentTime(), postInfo.recvName,
|
|
// GlobalVariable.IDNo_One, postInfo.recvNo, postInfo.recvAddress, postInfo.postNo, postInfo.sendName, postInfo.sendNo, postInfo.sendAddress);
|
|
// PlatformConnection.WriteToDgv_PostInfo(true, GlobalVariable.IDName_One, GlobalVariable.IDNo_One, postInfo.recvNo, postInfo.postNo);
|
|
//}
|
|
//UpdatePost(postInfo.postNo, postInfo.recvName, postInfo.recvNo, postInfo.recvAddress);
|
|
Thread.Sleep(960);
|
|
comm_net.set_int_var("isFirstRead_ok", 1);
|
|
return true;
|
|
}
|
|
#endregion
|
|
lock (GlobalVariable.lockList)
|
|
{
|
|
if (IDCard.ReadMsg(GlobalVariable.Card1Port, ref GlobalVariable.IDName_One, ref GlobalVariable.IDNo_One))
|
|
{
|
|
if (!ClassFirstCount.InsertInfo(GlobalVariable.IDName_One, GlobalVariable.IDNo_One, null, EM_Read_State.成功))
|
|
{
|
|
TriColorLight.ShowRed();
|
|
PlatformConnection.Instance.StopWork();
|
|
MsgBoxHelper.ShowWarning("前段读卡成功后数量统计失败,关软件重启");
|
|
return false;
|
|
}
|
|
bool ret;
|
|
if (true == GlobalVariable.bGetRemoteInfoOnTime)
|
|
{
|
|
ret = OperMySql.SelectPostInfoBySfzID(GlobalVariable.IDNo_One, ref postInfo.id, ref postInfo.recvAddress, ref postInfo.postNo, ref postInfo.recvName, ref postInfo.recvNo, ref postInfo.applicantName);
|
|
}
|
|
else
|
|
{
|
|
ret = MySqlite.SelectPostInfoBySfzID(GlobalVariable.IDNo_One, ref postInfo.id, ref postInfo.recvAddress, ref postInfo.postNo, ref postInfo.recvName, ref postInfo.recvNo, ref postInfo.applicantName);
|
|
}
|
|
//0313bool ret = OperLocalAccess.SelectInfoFromSFZ(GlobalVariable.IDNo_One, ref postInfo);
|
|
|
|
//bool ret = OperMySql.SelectSingleInfo(3, GlobalVariable.IDNo_One, ref postInfo.recvAddress);//postInfo.recvAddress = postRecv[1];//GlobalVariable.address[addressIndex];
|
|
if (!ret)
|
|
{
|
|
//SelectFailed("未查询到收件地址,请检查网络连接状况");
|
|
comm_net.set_int_var("isFirstRead_ok", 0);
|
|
if (!ClassFirstCount.InsertInfo(GlobalVariable.IDName_One, GlobalVariable.IDNo_One, null, EM_Read_State.省外))
|
|
{
|
|
TriColorLight.ShowRed();
|
|
PlatformConnection.Instance.StopWork();
|
|
MsgBoxHelper.ShowWarning("前段读卡省外数量统计失败,关软件重启");
|
|
return false;
|
|
}
|
|
PlatformConnection.WriteToDgv_PostInfo(false, GlobalVariable.IDName_One, GlobalVariable.IDNo_One, postInfo.recvNo, postInfo.postNo);
|
|
return false;
|
|
}
|
|
if (postInfo.recvAddress == null)
|
|
{
|
|
//SelectFailed("未查询到收件地址,请确认数据库能否查询到");
|
|
comm_net.set_int_var("isFirstRead_ok", 0);
|
|
if (!ClassFirstCount.InsertInfo(GlobalVariable.IDName_One, GlobalVariable.IDNo_One, null, EM_Read_State.省外))
|
|
{
|
|
TriColorLight.ShowRed();
|
|
PlatformConnection.Instance.StopWork();
|
|
MsgBoxHelper.ShowWarning("前段读卡省外数量统计失败,关软件重启");
|
|
return false;
|
|
}
|
|
PlatformConnection.WriteToDgv_PostInfo(false, GlobalVariable.IDName_One, GlobalVariable.IDNo_One, postInfo.recvNo, postInfo.postNo);
|
|
return false;
|
|
}
|
|
if ((false == postInfo.recvAddress.Contains("湖北省")) &&
|
|
(false == postInfo.recvAddress.Contains("武汉")) &&
|
|
(false == postInfo.recvAddress.Contains("黄石")) &&
|
|
(false == postInfo.recvAddress.Contains("襄樊")) &&
|
|
(false == postInfo.recvAddress.Contains("襄阳")) &&
|
|
(false == postInfo.recvAddress.Contains("十堰")) &&
|
|
(false == postInfo.recvAddress.Contains("荆州")) &&
|
|
(false == postInfo.recvAddress.Contains("宜昌")) &&
|
|
(false == postInfo.recvAddress.Contains("荆门")) &&
|
|
(false == postInfo.recvAddress.Contains("鄂州")) &&
|
|
(false == postInfo.recvAddress.Contains("孝感")) &&
|
|
(false == postInfo.recvAddress.Contains("黄冈")) &&
|
|
(false == postInfo.recvAddress.Contains("咸宁")) &&
|
|
(false == postInfo.recvAddress.Contains("随州")) &&
|
|
(false == postInfo.recvAddress.Contains("恩施")) &&
|
|
(false == postInfo.recvAddress.Contains("仙桃")) &&
|
|
(false == postInfo.recvAddress.Contains("潜江")) &&
|
|
(false == postInfo.recvAddress.Contains("天门")) &&
|
|
(false == postInfo.recvAddress.Contains("神农架")))
|
|
{
|
|
comm_net.set_int_var("isFirstRead_ok", 0);
|
|
if (!ClassFirstCount.InsertInfo(GlobalVariable.IDName_One, GlobalVariable.IDNo_One, null, EM_Read_State.省外))
|
|
{
|
|
TriColorLight.ShowRed();
|
|
PlatformConnection.Instance.StopWork();
|
|
MsgBoxHelper.ShowWarning("前段读卡省外数量统计失败,关软件重启");
|
|
return false;
|
|
}
|
|
PlatformConnection.WriteToDgv_PostInfo(false, GlobalVariable.IDName_One, GlobalVariable.IDNo_One, postInfo.recvNo, postInfo.postNo);
|
|
return false;
|
|
}
|
|
|
|
//First.Instance.WriteMsg(string.Format("{0} {1}", postInfo.recvName, postInfo.recvNo));
|
|
//postInfo.recvName = firstInfo.name = GlobalVariable.IDName_One;
|
|
postInfo.idNoOne = firstInfo.no = GlobalVariable.IDNo_One;
|
|
|
|
//ret = OperMySql.SelectSingleInfo(2, GlobalVariable.IDNo_One, ref postInfo.recvName);//postInfo.recvNo = postRecv[0];//RandomHelper.GetRandomCode(GlobalVariable.randomTelNo, 11);
|
|
if ((!ret) || (postInfo.recvName == null))
|
|
{
|
|
SelectFailed("未查询到收件人姓名,请检查网络连接状况");
|
|
PlatformConnection.WriteToDgv_PostInfo(false, GlobalVariable.IDName_One, GlobalVariable.IDNo_One, postInfo.recvNo, postInfo.postNo);
|
|
return false;
|
|
}
|
|
|
|
//ret = OperMySql.SelectSingleInfo(4, GlobalVariable.IDNo_One, ref postInfo.recvNo);//postInfo.recvNo = postRecv[0];//RandomHelper.GetRandomCode(GlobalVariable.randomTelNo, 11);
|
|
if ((!ret) || (postInfo.recvNo == null))
|
|
{
|
|
SelectFailed("未查询到收件人联系电话,请检查网络连接状况");
|
|
PlatformConnection.WriteToDgv_PostInfo(false, GlobalVariable.IDName_One, GlobalVariable.IDNo_One, postInfo.recvNo, postInfo.postNo);
|
|
return false;
|
|
}
|
|
|
|
//ret = OperMySql.SelectSingleInfo(1, GlobalVariable.IDNo_One, ref postInfo.postNo);//postInfo.postNo = postRecv[2];//RandomHelper.GetRandomCode(GlobalVariable.randomTraceNo, GlobalVariable.scanGunParam.barcodeLen);
|
|
if ((!ret) || (postInfo.postNo == null))
|
|
{
|
|
SelectFailed("未查询到快递单号,请检查网络连接状况");
|
|
PlatformConnection.WriteToDgv_PostInfo(false, GlobalVariable.IDName_One, GlobalVariable.IDNo_One, postInfo.recvNo, postInfo.postNo);
|
|
return false;
|
|
}
|
|
|
|
//ret = OperMySql.SelectSingleInfo(6, GlobalVariable.IDNo_One, ref postInfo.emsDepartment);//postInfo.postNo = postRecv[2];//RandomHelper.GetRandomCode(GlobalVariable.randomTraceNo, GlobalVariable.scanGunParam.barcodeLen);
|
|
//if ((!ret) || (postInfo.postNo == null))
|
|
//{
|
|
// SelectFailed("未查询到揽投部,请检查网络连接状况");
|
|
// PlatformConnection.WriteToDgv_PostInfo(false, GlobalVariable.IDName_One, GlobalVariable.IDNo_One, postInfo.recvNo, postInfo.postNo);
|
|
// return false;
|
|
//}
|
|
|
|
//if (postInfo.applicantName!=postInfo.recvName)
|
|
//{
|
|
// postInfo.recvName = postInfo.recvName + "转" + postInfo.applicantName;
|
|
//}
|
|
postInfo.applicantName = GlobalVariable.IDName_One;
|
|
|
|
postInfo.sendName = GlobalVariable.send_Name;
|
|
postInfo.sendNo = GlobalVariable.send_NO;
|
|
postInfo.sendAddress = GlobalVariable.send_Address;
|
|
|
|
if (!ClassFirstCount.InsertInfo(GlobalVariable.IDName_One, GlobalVariable.IDNo_One, null, EM_Read_State.省内))
|
|
{
|
|
TriColorLight.ShowRed();
|
|
PlatformConnection.Instance.StopWork();
|
|
MsgBoxHelper.ShowWarning("前段读卡省内数量统计失败,关软件重启");
|
|
return false;
|
|
}
|
|
try
|
|
{
|
|
First.Instance.WriteMsg(GlobalVariable.IDName_One + " " + GlobalVariable.IDNo_One, postInfo.id + " " + postInfo.recvAddress + " " + postInfo.postNo + " " + postInfo.recvName + " " + postInfo.recvNo + " " + postInfo.applicantName);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
|
|
}
|
|
|
|
|
|
if (!OleDbAccess.InsertDataToLetterAccess(GlobalVariable.accessLetterPath, GlobalVariable.tableName_Letter, postInfo.id,GlobalVariable.GetCurrentTime(), postInfo.recvName,
|
|
GlobalVariable.IDNo_One, postInfo.recvNo, postInfo.recvAddress, postInfo.postNo, postInfo.sendName, postInfo.sendNo, postInfo.sendAddress))
|
|
{
|
|
comm_net.set_int_var("isFirstRead_ok", 0);
|
|
PlatformConnection.WriteToDgv_PostInfo(false, GlobalVariable.IDName_One, GlobalVariable.IDNo_One, postInfo.recvNo, postInfo.postNo);
|
|
TriColorLight.ShowRed();
|
|
PlatformConnection.Instance.StopWork();
|
|
lock (GlobalVariable.lockShowMsgBox)
|
|
{
|
|
MsgBoxHelper.ShowWarning("第一次读卡后获取的邮寄信息插入到Access失败,请重启软件");
|
|
}
|
|
return false;
|
|
}
|
|
|
|
//sys.sys_EnterCriticalSection(Varialble.hsection);
|
|
GlobalVariable.list_PostInfo.Add(postInfo);
|
|
//sys.sys_LeaveCriticalSection(Varialble.hsection);
|
|
lock (GlobalVariable.lockFirstInfo)
|
|
{
|
|
GlobalVariable.list_FirstInfo.Add(firstInfo);
|
|
}
|
|
lock (GlobalVariable.lockBarcodeInfo)
|
|
{
|
|
GlobalVariable.list_BarcodeInfo.Add(postInfo.postNo);
|
|
}
|
|
|
|
comm_net.set_int_var("isFirstRead_ok", 1);
|
|
PlatformConnection.WriteToDgv_PostInfo(true, GlobalVariable.IDName_One, GlobalVariable.IDNo_One, postInfo.recvNo, postInfo.postNo);
|
|
UpdatePost(postInfo.postNo, postInfo.recvName, postInfo.recvNo, postInfo.recvAddress);
|
|
return true;
|
|
}
|
|
else
|
|
{
|
|
comm_net.set_var("isFirstRead_ok", "0");
|
|
PlatformConnection.WriteToDgv_PostInfo(false, GlobalVariable.IDName_One, GlobalVariable.IDNo_One, postInfo.recvNo, postInfo.postNo);
|
|
if (!ClassFirstCount.InsertInfo(GlobalVariable.IDName_One, GlobalVariable.IDNo_One, null, EM_Read_State.失败))
|
|
{
|
|
TriColorLight.ShowRed();
|
|
PlatformConnection.Instance.StopWork();
|
|
MsgBoxHelper.ShowWarning("前段读卡失败数量统计失败,关软件重启");
|
|
return false;
|
|
}
|
|
return false;
|
|
}
|
|
}
|
|
}
|
|
#endregion 第一次读卡
|
|
|
|
#region 第二次读身份证
|
|
public bool ReadSecondIDC()
|
|
{
|
|
GlobalVariable.IDName_Two = null;
|
|
GlobalVariable.IDNo_Two = null;
|
|
if (false == GlobalVariable.bReadCard2)
|
|
{
|
|
//lock (GlobalVariable.lockFirstInfo)
|
|
//{
|
|
// GlobalVariable.IDName_Two = GlobalVariable.list_FirstInfo[0].name;
|
|
// GlobalVariable.IDNo_Two = GlobalVariable.list_FirstInfo[0].no;
|
|
// GlobalVariable.list_FirstInfo.RemoveAt(0);
|
|
//}
|
|
comm_net.set_int_var("isSecondRead_ok", 1);
|
|
Thread.Sleep(950);
|
|
return true;
|
|
}
|
|
bool ret = false;
|
|
if (IDCard.ReadMsg(GlobalVariable.Card2Port, ref GlobalVariable.IDName_Two, ref GlobalVariable.IDNo_Two))
|
|
{
|
|
comm_net.set_int_var("isSecondRead_ok", 1);
|
|
//Second.Instance.WriteMsg(string.Format("{0} {1}", GlobalVariable.IDName_Two, GlobalVariable.IDNo_Two));
|
|
ret = true;
|
|
}
|
|
else
|
|
{
|
|
//Thread.Sleep(950);
|
|
lock (GlobalVariable.lockPrintTimeout)
|
|
{
|
|
GlobalVariable.printTimeout = 0;
|
|
}
|
|
comm_net.set_int_var("isSecondRead_ok", 0);
|
|
}
|
|
return ret;
|
|
}
|
|
#endregion 第二次读身份证
|
|
}
|
|
}
|