/// <summary> /// 获取卡号 /// </summary> /// <returns></returns> public override int GetCardNo() { int iCardNo = 0; byte bSection = 3; Dictionary <byte, List <byte> > dicSetcion = EquipmentGeneral.GetCardSectionPieceList(); try { if (!ReadCardsPrepare(bSection)) { return(0); } YuChuanDevice.rf_beep(_iBeepInterval); byte[] arrData = new byte[16]; int iResRead = YuChuanDevice.rf_read(dicSetcion[bSection][1], arrData); string strPiece = YuChuanDevice.ChangeHexToString(arrData); if (strPiece.Length == 32) { string strHexCardNo = strPiece.Substring(2, 1) + strPiece.Substring(3, 1) + strPiece.Substring(0, 1) + strPiece.Substring(1, 1); iCardNo = Convert.ToInt32(strHexCardNo, 16); } } catch (Exception ex) { return(0); } return(iCardNo); }
/// <summary> /// 获得卡片的固有ID号 /// </summary> /// <returns></returns> public override string GetMacID() { string strMacID = string.Empty; string strPwd = this._strSectionPwd; try { this._strSectionPwd = string.Empty.PadLeft(12, 'F'); if (!ReadCardsPrepare(0)) { return(string.Empty); } YuChuanDevice.rf_beep(_iBeepInterval); byte[] arrData = new byte[16]; int iResRead = YuChuanDevice.rf_read(0, arrData); strMacID = YuChuanDevice.ChangeHexToString(arrData).ToUpper(); this._strSectionPwd = strPwd; } catch (Exception ex) { this._strSectionPwd = strPwd; throw ex; } return(strMacID); }
public override decimal GetSubzVal() { decimal dSubzVal = 0.00M; byte bSection = 2; try { if (!ReadCardsPrepare(bSection)) { return(0); } YuChuanDevice.rf_beep(_iBeepInterval); Dictionary <byte, List <byte> > dicSection = EquipmentGeneral.GetCardSectionPieceList(); byte[] arrData = new byte[16]; int iResRead = YuChuanDevice.rf_read(dicSection[bSection][0], arrData); if (iResRead != 0) { //读数失败 return(0); } string strPiece = YuChuanDevice.ChangeHexToString(arrData); if (strPiece.Length != 32) { //读取块数据不完整,不足32位 return(0); } dSubzVal = EquipmentGeneral.HexMoneyToDouble(strPiece.Substring(0, 8)); } catch (Exception ex) { throw ex; } return(dSubzVal); }
public override PaymentCard GetUserBasicInfos() { PaymentCard payCard = new PaymentCard(); byte bSection = 3; try { Dictionary <byte, List <byte> > dicSection = EquipmentGeneral.GetCardSectionPieceList(); string strPwdTemp = this._strSectionPwd; this._strSectionPwd = string.Empty.PadRight(12, 'F'); payCard.MACID = GetMacID(); this._strSectionPwd = strPwdTemp; #region 读第1块 if (!ReadCardsPrepare(bSection)) { return(null); } byte[] arrData = new byte[16]; int iResRead = YuChuanDevice.rf_read(dicSection[bSection][1], arrData); if (iResRead != 0) { //读数失败 return(null); } string strPiece1 = YuChuanDevice.ChangeHexToString(arrData); if (strPiece1.Length != 32) { //读取到的块数据不完整,不足32位 return(null); } #endregion #region 读第2块 if (!ReadCardsPrepare(bSection)) { return(null); } arrData = new byte[16]; iResRead = YuChuanDevice.rf_read(dicSection[bSection][2], arrData); if (iResRead != 0) { //读数失败 return(null); } string strPiece2 = YuChuanDevice.ChangeHexToString(arrData); if (strPiece2.Length != 32) { //读取块数据不完整,不足32位 return(null); } #endregion #region 解释第一块数据 string strPieceData = strPiece1; //出厂ID payCard.MACID = GetMacID(); //卡号 string strHexCardNo = strPieceData.Substring(2, 1) + strPieceData.Substring(3, 1) + strPieceData.Substring(0, 1) + strPieceData.Substring(1, 1); payCard.No = Convert.ToInt32(strHexCardNo, 16); //状态 payCard.Valid = strPieceData.Substring(4, 2) == "80" ? true : false; //注册时间 try { payCard.ExpiryDate = DateTime.ParseExact(strPieceData.Substring(6, 6), "yyMMdd", null); } catch (Exception EX) { payCard.ExpiryDate = null; } //系统功能 payCard.FunctionCode = Convert.ToString(Convert.ToInt32(strPieceData.Substring(12, 4), 16), 2).PadLeft(16, '0'); //卡片所有人姓名 payCard.Name = EquipmentGeneral.HexToStr(strPieceData.Substring(16, 16)); #endregion #region 解释第二块数据 strPieceData = strPiece2; //最低余额 payCard.LimitRemainder = (decimal)(Convert.ToInt32(strPieceData.Substring(0, 8), 16) / 100.00M); //消费密码 payCard.PaymentPassword = strPieceData.Substring(8, 6); //每天最大消费额 payCard.DailyMaxPayment = (decimal)(Convert.ToInt32(strPieceData.Substring(14, 8), 16) / 100.00M); //时段消费次数 payCard.Span1PaymentCount = Convert.ToInt32(strPieceData.Substring(22, 2), 16); payCard.Span2PaymentCount = Convert.ToInt32(strPieceData.Substring(24, 2), 16); payCard.Span3PaymentCount = Convert.ToInt32(strPieceData.Substring(26, 2), 16); payCard.Span4PaymentCount = Convert.ToInt32(strPieceData.Substring(28, 2), 16); //卡类型 payCard.Type = ((char)Convert.ToByte(strPieceData.Substring(30, 2), 16)).ToString(); #endregion } catch (Exception ex) { throw ex; } return(payCard); }
public override List <string> GetPhoneNumList() { List <string> listPhones = new List <string>(); byte bSection = 10; try { YuChuanDevice.rf_beep(_iBeepInterval); Dictionary <byte, List <byte> > dicSection = EquipmentGeneral.GetCardSectionPieceList(); if (!ReadCardsPrepare(bSection)) { return(null); } byte[] arrData = new byte[16]; int iResRead = YuChuanDevice.rf_read(dicSection[bSection][0], arrData); if (iResRead != 0) { //读数失败 return(null); } string strPiece = YuChuanDevice.ChangeHexToString(arrData); if (strPiece.Length != 32) { //读取块数据不完整,不足32位 return(null); } strPiece = strPiece.ToUpper().TrimEnd('F'); strPiece = Convert.ToChar(Convert.ToInt32(strPiece.Substring(0, 2), 16)).ToString() + strPiece.Substring(2, strPiece.Length - 2); listPhones.Add(strPiece); string strEmpty = string.Empty; strEmpty = strEmpty.PadRight(16, '0'); for (int i = 0; i < 2; i++) { if (!ReadCardsPrepare(bSection)) { return(null); } arrData = new byte[16]; iResRead = YuChuanDevice.rf_read(dicSection[bSection][i + 1], arrData); if (iResRead != 0) { //读数失败 return(null); } strPiece = YuChuanDevice.ChangeHexToString(arrData); if (strPiece.Length != 32) { //读取块数据不完整,不足32位 return(null); } string strPhoneOneTmp = strPiece.Substring(0, 16); string strPhoneTwoTmp = strPiece.Substring(16, 16); if (strPhoneOneTmp != strEmpty) { string strPhoneOne = GetPhoneNum(strPhoneOneTmp); if (!string.IsNullOrEmpty(strPhoneOne) && strPhoneOne.Substring(0, 1) != "1" && strPhoneOne.Length != 7 && strPhoneOne.Length != 8) { strPhoneOne = "0" + strPhoneOne; } listPhones.Add(strPhoneOne); } if (strPhoneTwoTmp != strEmpty) { string strPhoneTwo = GetPhoneNum(strPhoneTwoTmp); if (!string.IsNullOrEmpty(strPhoneTwo) && strPhoneTwo.Substring(0, 1) != "1" && strPhoneTwo.Length != 7 && strPhoneTwo.Length != 8) { strPhoneTwo = "0" + strPhoneTwo; } listPhones.Add(strPhoneTwo); } } } catch (Exception ex) { throw ex; } return(listPhones); }
public override bool RechargeSubsidize(decimal p_dMoney) { try { byte bSection = 2; Dictionary <byte, List <byte> > dicSection = EquipmentGeneral.GetCardSectionPieceList(); #region 读第1块 if (!ReadCardsPrepare((bSection))) { return(false); } byte[] arrData = new byte[16]; int iResRead = YuChuanDevice.rf_read(dicSection[bSection][0], arrData); if (iResRead != 0) { //读数失败 return(false); } string strPiece8 = YuChuanDevice.ChangeHexToString(arrData); if (strPiece8.Length != 32) { //读取块数据不完整,不足32位 return(false); } decimal dMoney = EquipmentGeneral.HexMoneyToDouble(strPiece8.Substring(0, 8)); #endregion dMoney = dMoney + p_dMoney; #region 写入第1块数据 if (!ReadCardsPrepare((bSection))) { return(false); } //水控金额 string strCardVal = EquipmentGeneral.IntToHex((int)(dMoney * 100), 8).PadRight(8, '0'); strCardVal = strCardVal.Substring(6, 2) + strCardVal.Substring(4, 2) + strCardVal.Substring(2, 2) + strCardVal.Substring(0, 2); //水控金额反码 string strComplement = EquipmentGeneral.GetComplement(strCardVal); string strPieceData = strCardVal + strComplement + strCardVal + this._strSubValCRC; if (strPieceData.Length != 32) { return(false); } arrData = YuChuanDevice.ChangeStrToHex(strPieceData); int iRes = YuChuanDevice.rf_write(dicSection[bSection][0], arrData); if (iRes == 0) { YuChuanDevice.rf_beep(_iBeepInterval); } else { return(false); } #endregion #region 读第2块 if (!ReadCardsPrepare((bSection))) { return(false); } arrData = new byte[16]; iResRead = YuChuanDevice.rf_read(dicSection[bSection][1], arrData); if (iResRead != 0) { //读数失败 return(false); } string strPiece9 = YuChuanDevice.ChangeHexToString(arrData); if (strPiece9.Length != 32) { //读取块数据不完整,不足32位 return(false); } dMoney = EquipmentGeneral.HexMoneyToDouble(strPiece9.Substring(0, 8)); #endregion dMoney = dMoney + p_dMoney; #region 写入第2块数据 if (!ReadCardsPrepare((bSection))) { return(false); } //水控备份金额 string strCardBakVal = EquipmentGeneral.IntToHex((int)(dMoney * 100), 8).PadRight(8, '0'); strCardBakVal = strCardBakVal.Substring(6, 2) + strCardBakVal.Substring(4, 2) + strCardBakVal.Substring(2, 2) + strCardBakVal.Substring(0, 2); //水控备份金额反码 string strBakComplement = EquipmentGeneral.GetComplement(strCardBakVal); strPieceData = strCardBakVal + strBakComplement + strCardBakVal + this._strSubValBakCRC; if (strPieceData.Length != 32) { return(false); } arrData = YuChuanDevice.ChangeStrToHex(strPieceData); iRes = YuChuanDevice.rf_write(dicSection[bSection][1], arrData); if (iRes == 0) { YuChuanDevice.rf_beep(_iBeepInterval); } else { return(false); } #endregion } catch (Exception ex) { return(false); } return(true); }