/// <summary> /// 取得消费资料 /// </summary> /// <param name="p_intDeviceNo"></param> /// <returns></returns> public override List <PaymentInfo> GetPaymentInfo(int p_intDeviceNo) { try { //取得消费记录数 int l_intRecordNum = GetPaymentNum(p_intDeviceNo); //Thread.Sleep(3000); //如果未能连接到机械 if (l_intRecordNum == 0) { string data = JocatDevice.GetPaymentInfo(ComPort, BaudRate, p_intDeviceNo, 0); return(new List <PaymentInfo>()); } if (l_intRecordNum == -1) { return(null); } List <PaymentInfo> l_lisReturn = new List <PaymentInfo>(); string l_strData = ""; for (int i = 0; i < l_intRecordNum; i = i + m_intPaymentDataNum) { //l_strData = JocatDevice.GetPaymentInfo(ComPort, BaudRate, p_intDeviceNo, i); l_strData = JocatDevice.GetPaymentInfo(int.Parse(ComPort.ToString()), int.Parse(BaudRate.ToString()), int.Parse(p_intDeviceNo.ToString()), i); if (l_strData == "85" || l_strData == "86") { i = i - m_intPaymentDataNum; continue; } if (l_strData.Length % 52 != 0) { i = i - m_intPaymentDataNum; continue; } int l_intSeed = 0; string l_strPaymentInfo = ""; //此处有可能遇到l_strData的值为85的情况 bool signSuccess = true; List <PaymentInfo> l_tmpPaymentInfos = new List <PaymentInfo>(); while (l_intSeed < l_strData.Length) { l_strPaymentInfo = l_strData.Substring(l_intSeed, 52); try { l_tmpPaymentInfos.Add(EncodePaymentInfo(l_strPaymentInfo)); } catch (Exception Ex) { signSuccess = false; break; } l_intSeed = l_intSeed + 52; } if (signSuccess) { l_lisReturn.AddRange(l_tmpPaymentInfos); } else { //捕抓机台返回的错误数据,使循环返回对上一次序列重新取数。 i = i - m_intPaymentDataNum; } if ((i + m_intPaymentDataNum) > l_intRecordNum) { Thread.Sleep(3000); break; } Thread.Sleep(3000); } return(l_lisReturn); } catch (Exception) { throw; } }