public static void waitBankCard() { StringBuilder info1 = new StringBuilder(260); try { string port = SysConfigHelper.readerNode("CRT310Port"); StringBuilder info = new StringBuilder(260); int handle = CRT310.TT_OpenDevice(new StringBuilder("COM" + port), new StringBuilder("9600"), new StringBuilder()); CRT310.TT_SetCardMode(1, info1); StringBuilder info2 = new StringBuilder(260); CRT310.TT_WaitCard(0, info2).ToString(); //停卡位置 CRT310.CRT310_CardPosition(handle, 0x4); } catch (Exception e) { throw new Exception("系统异常"); } finally { //关闭端口 CRT310.TT_CloseDevice(info1); } }
//public override Card getCardInfo(string cardNo) //{ // //TODO 调用万通卡查询余额的方法,返回卡片信息 // return null; //} //public override bool Recharge(string cardNo, int gasValue) //{ // throw new NotImplementedException(); //} //public override bool Recharge(string cardNo, double moneyCount) //{ // //TODO 调用拉卡拉消费的方法 // //TODO 调用拉卡拉消费的方法,如果失败,提示错误,跳出方法 // //TODO 调用拉卡拉消费的方法,如果成功,调用万通卡的充值方法 // return false; //} /// <summary> /// 调用读卡器,拿到万通卡卡号 /// </summary> /// <returns></returns> public string GetCardNo() { string port = SysConfigHelper.readerNode("CRT310Port"); StringBuilder info = new StringBuilder(260); int handle = CRT310.CommOpen("COM" + port); try { //进卡控制 CRT310.CRT310_CardSetting(handle, 0x3, 0x1); //停卡位置 CRT310.CRT310_CardPosition(handle, 0x4); Byte atPosition = new byte(); Byte frontSetting = new byte(); Byte rearSetting = new byte(); //读取状态 int hasCard = CRT310.CRT310_GetStatus(handle, ref atPosition, ref frontSetting, ref rearSetting);//卡没插好,怎么办 Byte cpuType = new byte(); Byte[] exdata = new byte[1024]; int exdataLen = 0; //CPU卡复位 CRT310.CPU_ColdReset(handle, 0x0, ref cpuType, exdata, ref exdataLen); executeAPDU(handle, "00A40000023F00"); executeAPDU(handle, "00A40000023F20"); string cardNoSource = executeAPDU(handle, "00B0950000"); //进卡控制 CRT310.CRT310_CardSetting(handle, 0x1, 0x1); string result = DecryptCardNo(cardNoSource); return(result); } catch (Exception e) { throw new WtException(WtExceptionCode.Card.WT_READ_CARD, e.Message); } finally { //关闭端口 CRT310.CommClose(handle); } }
/// <summary> /// 等待插卡 /// </summary> public static void waitCard() { int handle = 0; try { string port = SysConfigHelper.readerNode("CRT310Port"); StringBuilder info = new StringBuilder(260); handle = CRT310.CommOpen("COM" + port); //进卡控制 CRT310.CRT310_CardSetting(handle, 0x3, 0x1); //停卡位置 CRT310.CRT310_CardPosition(handle, 0x4); } catch (ThreadAbortException ae) { log.Write("error:等待插卡方法异常:" + ae.Message); } catch (Exception e) { throw new Exception("系统异常"); } finally { CRT310.CommClose(handle); } }