protected Result DefaultRead() { string trk1 = "", trk2 = "", trk3 = ""; CardReader.Status ret = CardReader.InsertCard(ref trk1, ref trk2, ref trk3); if (ret == CardReader.Status.CARD_SUCC) { if (CardReader.IsUse) { CommonData.BIsCardIn = true;//有卡进入 } if (trk1.Trim() == "") { Log.Debug("Track1 : NULL"); } else { Log.Debug("Track1 : IN"); } if (trk2.Trim() == "") { Log.Debug("Track2 : NULL"); } else { Log.Debug("Track2 : IN"); } if (trk3.Trim() == "") { Log.Debug("Track3 : NULL"); } else { Log.Debug("Track3 : IN"); } Track1 = trk1; Track2 = trk2; Track3 = trk3; string CardNumber = Utility.GetCardNumber(trk2, trk3); BankCardNum = CardNumber; if (CardNumber.Trim().Length > 0) { return(Result.Success); } else { return(Result.Fail); } } else if (ret == CardReader.Status.CARD_WAIT) { return(Result.Again); } else { Log.Error("ReaderOnce:" + ret.ToString()); return(Result.HardwareError); } }
/// <summary> /// IC卡优先,兼容磁条卡,不降级处理 /// </summary> /// <returns></returns> protected Result DefaultRead4() { bool isIcCard = true; int nCardType = 0; string trk1 = "", trk2 = "", trk3 = ""; CardReader.Status ret = CardReader.InsertCard(ref trk1, ref trk2, ref trk3); if (ret == CardReader.Status.CARD_SUCC) { if (CardReader.IsUse) { CommonData.BIsCardIn = true;//有卡进入 } //读卡模式隐藏按钮 ReportSync("none"); //Log.Debug("Track1:" + trk1); //Log.Debug("Track2 : " + trk2); //Log.Debug("Track3 : " + trk3); string CardNumber = Utility.GetCardNumber(trk2, trk3); if (CardNumber.Trim().Length > 0) { Log.Info("MS Card Deal"); Track1 = trk1; Track2 = trk2; Track3 = trk3; BankCardNum = CardNumber; ExpDate = Utility.GetExpDate(trk2, trk3); isIcCard = Utility.CheckIcCardFlag(trk2); Log.Info("isIcCard=" + isIcCard.ToString()); //isIcCard = true;//可能存在二磁道 ic卡判断错误的情况 所以IC卡都需要验证以防 45错误 nCardType = 1; } if (!CardReader.IsUse) { isIcCard = false; } if (isIcCard && mIsUseICCard) { //CardReader.CardType(0, 0);//防止读卡器问题类型问题 EMVTransProcess emv = new EMVTransProcess(); int state = emv.EMVTransInit(0, EMVTransProcess.PbocTransType.PURCHASE); CardReader.CardPowerDown(); if (state == 0) { Log.Info("IC Card Deal"); BankCardNum = emv.EMVInfo.CardNum; Track2 = emv.EMVInfo.Track2; ExpDate = emv.EMVInfo.CardExpDate; CardSeqNum = emv.EMVInfo.CardSeqNum; nCardType += 2; } //else // isIcCard = false;//防止纯磁条卡无法交易 } BankCardType = (UserBankCardType)nCardType; if (mIsUseICCard && isIcCard && nCardType < 2)//开启IC卡,不降级处理 { return(Result.Fail); } if (BankCardType == UserBankCardType.None) { return(Result.Fail); } } else if (ret == CardReader.Status.CARD_WAIT) { return(Result.Again); } else { Log.Error("ReaderOnce:" + ret.ToString()); return(Result.HardwareError); } return(Result.Success); }