Exemplo n.º 1
0
 protected override void OnEnter()
 {
     Track1               = "";
     Track2               = "";
     Track3               = "";
     BankCardNum          = "";
     ExpDate              = "";
     CardSeqNum           = "";
     BankCardType         = UserBankCardType.None;
     CommonData.BIsCardIn = false;
     //设置AID和CA文件前缀
     EMVTransProcess.EMVSetAidAndCAFileName(GetBusinessEntity().SectionName);
     GetElementById(mBackId).Click += new System.Windows.Forms.HtmlElementEventHandler(Back_Click);
     SendMessage(READ_CARD);
 }
Exemplo n.º 2
0
        /// <summary>
        /// 磁条卡优先,兼容IC卡
        /// </summary>
        /// <returns></returns>
        protected Result DefaultRead3()
        {
            Result ret = DefaultRead();

            if ((ret == Result.Fail) && mIsUseICCard)
            {
                //读卡失败,如果有启动IC,则进入IC卡读卡模式
                ReportSync("none");
                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;
                    Log.Debug("IC Card In");
                    return(Result.Success);
                }
            }

            return(ret);
        }
Exemplo n.º 3
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);
        }
Exemplo n.º 4
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)
            {
                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);
        }