예제 #1
0
        /// <summary>
        /// 磁条卡优先,兼容IC卡
        /// </summary>
        /// <returns></returns>
        protected Result DefaultRead3()
        {
            Result ret = DefaultRead();

            if ((ret == Result.Fail) && GlobalAppData.GetInstance().UseICCard)
            {
                //读卡失败,如果有启动IC,则进入IC卡读卡模式
                ReportSync("none");
                CardReader.CardType(0, 0);
                EMVTransProcess emv   = new EMVTransProcess();
                int             state = emv.EMVTransInit(0, EMVTransProcess.PbocTransType.PURCHASE);
                CardReader.CardPowerDown();
                if (state == 0)
                {
                    SaveBoolean("UseICCard", true);//交易变量
                    BankCardNum = emv.EMVInfo.CardNum;
                    Track2      = emv.EMVInfo.Track2;
                    Log.Debug("IC Card In");
                    return(Result.Success);
                }
            }

            return(ret);
        }
예제 #2
0
        /// <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)
            {
                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);
                    nCardType   = 1;
                }

                if (isIcCard && GlobalAppData.GetInstance().UseICCard)
                {
                    Log.Info("IC Card Deal");
                    CardReader.CardType(0, 0);//防止读卡器问题类型问题
                    EMVTransProcess emv   = new EMVTransProcess();
                    int             state = emv.EMVTransInit(0, EMVTransProcess.PbocTransType.PURCHASE);
                    CardReader.CardPowerDown();
                    if (state == 0)
                    {
                        BankCardNum = emv.EMVInfo.CardNum;
                        Track2      = emv.EMVInfo.Track2;
                        ExpDate     = emv.EMVInfo.CardExpDate;
                        CardSeqNum  = emv.EMVInfo.CardSeqNum;
                        nCardType  += 2;
                    }
                }

                BankCardType = (UserBankCardType)nCardType;

                if (isIcCard && nCardType < 2)//不降级处理
                {
                    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);
        }