protected override Result ReadOnce() { R80.ActivateResult ret = R80.ICActive(0, ref mCardNo); if (ret == R80.ActivateResult.ET_SETSUCCESS) { return(Result.Success); } return(Result.Again); }
public void OnTimeTick(int count) { lock (this) { try { string mCardNo = ""; R80.ActivateResult ret = R80.ICActive(0, ref mCardNo); if (ret == R80.ActivateResult.ET_SETSUCCESS && mCardNo.Length > 0) { GetElementById("UserName").SetAttribute("value", "0000" + mCardNo); GetElementById("OldPassword").Focus(); GetElementById("OldPassword").Focus(); } } catch (System.Exception ex) { Log.Error("[PetroModifyPassMainDeal][OnTimeTick]Error", ex); } } }
public void OnTimeTick(int count) { lock (this) { try { if (mUserPutCard) { return; } string mCardNo = ""; R80.ActivateResult ret = R80.ICActive(0, ref mCardNo); if (ret == R80.ActivateResult.ET_SETSUCCESS) { mUserPutCard = true; } } catch (System.Exception ex) { Log.Error("[MainPageDeal][OnTimeTick]Error", ex); } } }
/// <summary> /// EMV初始化 /// </summary> /// <param name="dInAmount"></param> /// <param name="pbocType"></param> /// <returns></returns> public int EMVTransInit(double dInAmount, PbocTransType pbocType) { int state = 0; byte[] answer = new byte[128]; int pnLen = 0; int pnChipProtocol = 0; EMVInfo = new EMVData(); long hand = 0; try { #region 卡片上电初始化 if (PayType == 1) { hand = R80.GetHandle(); R80.Status cRet = R80.PowerUp(10, ""); if (cRet != R80.Status.EM_MIFARE_SUCC) { Log.Warn("上电失败"); return(-1); } } else { hand = CardReader.GetHandle(); CardReader.Status cRet = CardReader.CardPowerUp(answer, ref pnLen, ref pnChipProtocol); if (cRet != CardReader.Status.CARD_SUCC) { CardReader.CardPowerDown(); Log.Warn("上电失败"); return(-1); } } state = pboc.App_EMVLInit(PayType, hand); if (state != 0) { Log.Warn("卡片初始化失败"); return(-1); } #endregion #region 获取卡片应用 byte[] appList = new byte[256]; int nListNum = 0; pboc.App_EMVL2SelectApp(pnChipProtocol, appList, ref nListNum); string[] strEmvList = System.Text.Encoding.Default.GetString(appList).Trim().Replace("\0", "").Split('|'); if (nListNum < 1) { CardReader.CardPowerDown(); Log.Warn("卡片无可用的应用"); return(-1); } byte[] inTrace = Encoding.Default.GetBytes("000000"); byte[] inDay = Encoding.Default.GetBytes(DateTime.Now.ToString("yyMMdd")); byte[] inTime = Encoding.Default.GetBytes(DateTime.Now.ToString("HHmmss")); byte[] inAmount = Encoding.Default.GetBytes(Utility.AmountToString(dInAmount.ToString()));; byte[] inOtherAmount = Encoding.Default.GetBytes("000000000000"); int iAppId = 0; bool bEmvOk = false; foreach (string tempEmv in strEmvList) { //A000000333010101|银联 //if (!String.IsNullOrEmpty(tempEmv) && tempEmv.StartsWith("A000000333")) //{ // state = pboc.App_EMVStartEmvApp(iAppId, pnChipProtocol, (int)PbocTransType.PURCHASE, inTrace, inDay, inTime, inAmount, inOtherAmount); // if (state == 0) // { // bEmvOk = true; // break; // } //} state = pboc.App_EMVStartEmvApp(iAppId, pnChipProtocol, (int)pbocType, inTrace, inDay, inTime, inAmount, inOtherAmount); if (state == 0) { bEmvOk = true; break; } iAppId++; } if (!bEmvOk) { CardReader.CardPowerDown(); Log.Warn("没有支持的应用"); return(-1); } #endregion #region 获取卡片卡号信息 byte[] cardNo = new byte[21]; int cardNoLen = 0; byte[] track2 = new byte[38]; int track2Len = 0; byte[] expData = new byte[5]; int expLen = 0; byte[] cardSeqNum = new byte[2]; pboc.App_EMVGetCardNo(cardNo, ref cardNoLen, track2, ref track2Len, expData, ref expLen, cardSeqNum); EMVInfo.CardNum = Encoding.Default.GetString(cardNo).Trim('\0'); EMVInfo.Track2 = Encoding.Default.GetString(track2).Trim('\0'); EMVInfo.CardSeqNum = Convert.ToString(cardSeqNum[0]).Trim('\0'); EMVInfo.CardExpDate = Encoding.Default.GetString(expData).Trim('\0'); if (String.IsNullOrEmpty(EMVInfo.CardNum)) { CardReader.CardPowerDown(); Log.Warn("IC:读卡号失败"); return(-1); } else { EMVInfo.CardNum = EMVInfo.CardNum.Replace('\0', ' ').Trim(); } #endregion } catch (Exception ex) { CardReader.CardPowerDown(); Log.Error("IC:初始化异常", ex); return(-1); } return(0); }
public int QPBOCReadRFCard(double dInAmount, Landi.FrameWorks.EMVTransProcess.PbocTransType pbocType) { int state = 0; byte[] answer = new byte[128]; int pnLen = 0; int pnChipProtocol = 0; EMVInfo = new EMVData(); long hand = 0; try { //pboc.App_EMVSetAidAndCAFileName("yl"); hand = R80.GetHandle(); pboc.App_EMV_ucSetAPDUInterface("CardReader.dll", "Card_ChipIO", "R80.dll", "EA_mifare_sICAppCMDTransfer"); //pboc.App_EMVSetParam(, BankCardConfig.gBatchNo, "", BankCardConfig.gTerminalNo, BankCardConfig.gBranchNo); //pboc.App_EMV_ucSetAPDUInterface("CardReader.dll", "Card_ChipIO", "R80.dll", "Card_ChipIO"); state = pboc.App_EMVLInit(PayType, hand); if (state != 0) { Log.Warn("卡片初始化失败"); return(-1); } #region 获取卡片应用 byte[] appList = new byte[256]; int nListNum = 0; pboc.App_EMVL2SelectApp(pnChipProtocol, appList, ref nListNum); string[] strEmvList = System.Text.Encoding.Default.GetString(appList).Trim().Replace("\0", "").Split('|'); if (nListNum < 1) { Log.Warn("卡片无可用的应用"); return(-1); } byte[] inTrace = Encoding.Default.GetBytes("000000"); byte[] inDay = Encoding.Default.GetBytes(DateTime.Now.ToString("yyMMdd")); byte[] inTime = Encoding.Default.GetBytes(DateTime.Now.ToString("HHmmss")); byte[] inAmount = Encoding.Default.GetBytes(Utility.AmountToString(dInAmount.ToString()));; byte[] inOtherAmount = Encoding.Default.GetBytes("000000000000"); int iAppId = 1; bool bEmvOk = false; foreach (string tempEmv in strEmvList) { //A000000333010101|银联 //if (!String.IsNullOrEmpty(tempEmv) && tempEmv.StartsWith("A000000333")) //{ // state = pboc.App_EMVStartEmvApp(iAppId, pnChipProtocol, (int)PbocTransType.PURCHASE, inTrace, inDay, inTime, inAmount, inOtherAmount); // if (state == 0) // { // bEmvOk = true; // break; // } //} state = pboc.App_EMVStartEmvApp(iAppId, pnChipProtocol, (int)pbocType, inTrace, inDay, inTime, inAmount, inOtherAmount); if (state == 0 || state == 8) { bEmvOk = true; gICAid = tempEmv; break; } iAppId++; } if (!bEmvOk) { Log.Warn("没有支持的应用"); return(-1); } #endregion #region 获取卡片卡号信息 byte[] cardNo = new byte[21]; int cardNoLen = 0; byte[] track2 = new byte[38]; int track2Len = 0; byte[] expData = new byte[5]; int expLen = 0; byte[] cardSeqNum = new byte[2]; pboc.App_EMVGetCardNo(cardNo, ref cardNoLen, track2, ref track2Len, expData, ref expLen, cardSeqNum); EMVInfo.CardNum = Encoding.Default.GetString(cardNo).Trim('\0'); EMVInfo.Track2 = Encoding.Default.GetString(track2).Trim('\0'); EMVInfo.CardSeqNum = Convert.ToString(cardSeqNum[0]).Trim('\0'); EMVInfo.CardExpDate = Encoding.Default.GetString(expData).Trim('\0'); if (String.IsNullOrEmpty(EMVInfo.CardNum)) { Log.Warn("IC:读卡号失败"); return(-1); } else { EMVInfo.CardNum = EMVInfo.CardNum.Replace('\0', ' ').Trim(); } #endregion #region 获取55域 //byte[] field55 = new byte[512]; //int field55Len = 0; ////6 App_EMVGetField55 //pboc.App_EMVGetField55(field55, ref field55Len); //EMVInfo.SendField55 = new byte[field55Len]; //Array.Copy(field55, EMVInfo.SendField55, field55Len); EMVInfo.SendField55 = GetField55(pboc, 0); #endregion } catch (Exception ex) { Log.Error("IC:初始化异常", ex); return(-1); } return(0); }