Esempio n. 1
0
        /// <summary>
        /// 公交签到
        /// </summary>
        /// <returns></returns>
        public static BusRegisterInfo BusRegister()
        {
            SysBLL.Authcode = BusLogin();
            string reqsn = SysBLL.getSerialNum();
            //公交卡签到
            BusInterface     access = new BusInterface();
            BusRegisterParam param  = new BusRegisterParam();

            param.authcode     = SysBLL.Authcode;                // 认证码 not nullA
            param.servicename  = "DL002";                        //交易类型编号 not nullA
            param.trandateTime = SysBLL.getYYYYMMDDHHMMSSTime(); //交易日期 YYYYMMDDHHMMSS not nullA
            param.resqn        = reqsn;                          //请求流水号  not nullA
            param.btype        = "0010";                         //业务类型 not nullA
            param.terno        = SysBLL.getMac();                //终端编号  not nullA
            param.tradeno      = SysBLL.getHHMMSSITime10();      //交易流水号 not nullA
            param.loginId      = SysBLL.getCpuNo();              //设备ID
            BusRegisterInfo busRegisterInfo1 = access.BusRegister(param);

            param.btype    = "0011";                              //业务类型 not nullA
            param.authcode = busRegisterInfo1.msgrsp.authcode;    // 认证码 not nullA
            param.opno     = busRegisterInfo1.cpumsg.OUTPUT.OPNO; //操作员卡号 null
            param.random   = busRegisterInfo1.cpumsg.OUTPUT.RANDOM;
            BusRegisterInfo busRegisterInfo2 = access.BusRegister(param);

            busRegisterInfo2.msgrsp             = new BusRegisterMsgrsp();
            busRegisterInfo2.msgrsp.authcode    = busRegisterInfo1.msgrsp.authcode;
            busRegisterInfo2.cpumsg.OUTPUT.OPNO = busRegisterInfo1.cpumsg.OUTPUT.OPNO;
            return(busRegisterInfo2);
        }
Esempio n. 2
0
        public static BusCpuCardInfo GetOrder(BusReChangeParam busReChangeParam, BusCpuCardParam param, string paycode)
        {
            Boolean isSuccess = false;
            //签到
            BusRegisterInfo busRegisterInfo = BusAccess.BusRegister();

            if (busRegisterInfo.cpumsg.OUTPUT != null)
            {
                isSuccess = true;
            }
            if (isSuccess == false)
            {
                throw new WtException(WtExceptionCode.Bus.BUS_PAY);
            }
            isSuccess = false;
            //公交卡充值


            param.authcode     = SysBLL.Authcode;;                       // 认证码   not null
            param.servicename  = "DD006";                                //交易类型编号  not null
            param.trandateTime = SysBLL.getYYYYMMDDHHMMSSTime();         //交易日期:YYYYMMDDHHMMSS not null
            param.resqn        = SysBLL.getSerialNum();                  //请求流水号  not null
            param.paymentno    = busReChangeParam.paymentno;             //用户名 用户编号 not null
            param.paymentAmout = busReChangeParam.paymentAmout + "00";   //账单金额   not null
            param.billDate     = DateTime.Now.Year.ToString();           //账单日期 not null
            param.merchantNo   = "S000000200";                           //缴费单位编号 not null
            param.step         = "0";                                    //执行第几步 Not null
            param.money        = busReChangeParam.paymentAmout + "00";   //充值金额 Not null
            param.serno        = SysBLL.getSerialNum().Substring(0, 12); //业务流水号  not null
            param.appsid       = busReChangeParam.appsid;                //应用序列号
            param.btype        = "1931";                                 //业务类型  not null
            param.opno         = busRegisterInfo.cpumsg.OUTPUT.OPNO;     //操作员卡号 not null
            param.scode        = busRegisterInfo.cpumsg.OUTPUT.SCODE;    //签到码 not null
            param.terno        = SysBLL.getMac();                        //终端编号 Not null
            param.loginId      = SysBLL.getCpuNo();                      //设备ID
            param.CMTYPE       = "0";
            param.WMONEY       = busReChangeParam.wmoney;
            param.inapdu       = "no";
            param.tradeno      = busReChangeParam.trandeNo;
            //param.payCode = paycode;
            //param.orderno = busReChangeParam.orderno;
            BusInterface   access          = new BusInterface();
            BusCpuCardInfo busCpuCardInfo1 = access.BusCpuCard(param);

            //  orderno = busCpuCardInfo1.msgrsp.orderno;
            return(busCpuCardInfo1);
        }
Esempio n. 3
0
        /// <summary>
        /// 公交卡查询
        /// </summary>
        /// <returns></returns>
        public static BusQueryThatInfo QueryBus()
        {
            bool isSuccess = false;
            //签到
            BusRegisterInfo busRegisterInfo = BusAccess.BusRegister();

            if (busRegisterInfo.cpumsg != null)
            {
                isSuccess = true;
            }
            //公交卡签到未成功
            if (isSuccess == false)
            {
                throw new Exception("公交卡签到未成功");
            }
            isSuccess = false;
            BusQueryInfo busQueryInfo = new BusQueryInfo();

            //公交卡查询
            BusInterface  access       = new BusInterface();
            BusQueryParam param        = new BusQueryParam();
            string        inapdu       = "";
            string        trandateTime = SysBLL.getYYYYMMDDHHMMSSTime();
            string        reqsn        = SysBLL.getSerialNum();
            string        APDUDATA     = "";
            string        APDUSW       = "";
            string        RETDATA      = "";
            int           APDUSUM      = 0;
            string        step         = "0";

            param.authcode     = SysBLL.Authcode;
            param.servicename  = "DS001";
            param.trandateTime = trandateTime;
            param.reqsn        = reqsn;
            param.opno         = busRegisterInfo.cpumsg.OUTPUT.OPNO;
            param.scode        = busRegisterInfo.cpumsg.OUTPUT.SCODE;
            param.terno        = SysBLL.getMac();
            param.tradeno      = SysBLL.getHHMMSSITime10();
            param.btype        = "1900";
            param.inapdu       = inapdu;
            param.step         = step;
            param.loginId      = SysBLL.getCpuNo(); //设备ID
            busQueryInfo       = access.BusQuery1(param);


            if (busQueryInfo.cpumsg.OUTPUT.OUTAPDU.APDU != null)
            {
                isSuccess = true;
            }
            //公交查询未成功
            if (isSuccess == false)
            {
                throw new Exception("公交查询未成功");
            }
            isSuccess = false;

            step = busQueryInfo.cpumsg.OUTPUT.STEP;
            string     status = busQueryInfo.cpumsg.OUTPUT.OUTAPDU.LASTAPDU;
            BusCardBLL bus    = new BusCardBLL();

            string port = SysConfigHelper.readerNode("CRT603Port");
            //int openRet = CRT603.CRT603Vx_OpenConnection(Int32.Parse(port), 19200);
            //上电
            int iOutAtrLen = 0;

            byte[] byOutAtrData      = new byte[1024];
            int    chipRet           = CRT603.CRT603Vx_RF_chipPower(ref iOutAtrLen, byOutAtrData);
            string apduData          = "";
            List <BusQueryApdu> apdu = busQueryInfo.cpumsg.OUTPUT.OUTAPDU.APDU;
            string result            = "";
            string last = "";

            for (int i = 0; i < apdu.Count; i++)
            {
                APDUDATA = APDUDATA + apdu[i].APDUDATA + "|";

                result = bus.sendApdu(apdu[i].APDUDATA);

                last   = result.Substring(result.Length - 4);
                APDUSW = APDUSW + last + "|";
                result = result.Remove(result.Length - 4, 4);
                if (apduData != null)
                {
                    RETDATA = RETDATA + result + "|";
                }
                Thread.Sleep(20);
                APDUSUM++;
            }
            //CRT603.CRT603Vx_CloseConnection();
            APDUDATA = APDUDATA.Remove(APDUDATA.Length - 1, 1);
            APDUSW   = APDUSW.Remove(APDUSW.Length - 1, 1);
            RETDATA  = RETDATA.Remove(RETDATA.Length - 1, 1);
            BusQueryThatInfo busQueryInfo2 = null;

            while (true)
            {
                param.inapdu   = "yes";
                param.step     = step;
                param.APDUSUM  = APDUSUM.ToString();
                param.APDUDATA = APDUDATA;
                param.APDUSW   = APDUSW;
                param.RETDATA  = RETDATA;
                //表示最后一条
                if (status.Equals("01"))
                {
                    //结果
                    busQueryInfo2 = access.BusQuery2(param);
                    //处理结果
                    return(busQueryInfo2);
                }
                //继续查询
                busQueryInfo2 = access.BusQuery2(param);
                if (busQueryInfo2.cpumsg.OUTPUT != null)
                {
                    isSuccess = true;
                }
                //公交查询未成功
                if (isSuccess == false)
                {
                    throw new Exception("公交查询未成功");
                }
                isSuccess = false;
                APDUDATA  = "";
                APDUSW    = "";
                RETDATA   = "";
                List <BusQueryApdu> apdu2 = busQueryInfo.cpumsg.OUTPUT.OUTAPDU.APDU;

                for (int i = 0; i < apdu.Count; i++)
                {
                    APDUDATA = APDUDATA + apdu2[i].APDUDATA + "|";
                    result   = bus.sendApdu(apdu2[i].APDUDATA);
                    last     = result.Substring(result.Length - 4);
                    result   = result.Remove(result.Length - 4, 4);
                    APDUSW   = last + APDUSW + "|";
                    //执行apdu
                    RETDATA = RETDATA + result + "|";
                }
                APDUDATA = APDUDATA.Remove(APDUDATA.Length - 1, 1);
                APDUSW   = APDUSW.Remove(APDUSW.Length - 1, 1);
                RETDATA  = RETDATA.Remove(RETDATA.Length - 1, 1);
                step     = busQueryInfo.cpumsg.OUTPUT.STEP;
                status   = busQueryInfo.cpumsg.OUTPUT.OUTAPDU.LASTAPDU;
            }
        }