コード例 #1
0
        public override bool Select(out string msg)
        {
            bool res = true;
            int  st  = 0;

            byte[] cardUid = new byte[10];
            if (!string.IsNullOrEmpty(CardId))
            {
                msg = "CardID is empty";
                return(false);
            }
            ReaderDllMethod.HexToBin(CardId, cardUid, CardId.Length);
            byte [] cardsak = new byte[1];
            st = ReaderDllMethod.mwSelect(handle, cardUid, CardId.Length, out cardsak[0]); //请求卡TYPE A 类型卡片
            if (st < 0)
            {
                msg = st.ToString() + "*" + ReaderDllMethod.getErrMsg(st);
                res = false;
            }
            else
            {
                msg = st.ToString() + "*" + ReaderDllMethod.getErrMsg(st);
                StringBuilder cardStr = new StringBuilder();
                ReaderDllMethod.BinToHex(cardsak, cardStr, st);
                CardSak = cardStr.ToString();
                DevBeep(1, 1, 2);
            }
            return(res);
        }
コード例 #2
0
        public override bool Anticoll(out string msg)
        {
            bool res = true;
            int  st  = 0;

            byte[] cardUid = new byte[10];
            if (!string.IsNullOrEmpty(CardId))
            {
                msg = "CardID is empty";
                return(false);
            }
            ReaderDllMethod.HexToBin(CardId, cardUid, CardId.Length);
            st = ReaderDllMethod.mwAnticoll(handle, cardUid); //请求卡TYPE A 类型卡片
            if (st < 0)
            {
                msg = st.ToString() + "*" + ReaderDllMethod.getErrMsg(st);
                res = false;
            }
            else
            {
                msg = st.ToString() + "*" + ReaderDllMethod.getErrMsg(st);
                DevBeep(1, 1, 2);
            }
            return(res);
        }
コード例 #3
0
        public override bool Halt(out string msg)
        {
            bool res = true;
            int  st  = 0;

            st = ReaderDllMethod.mwHalt(handle); //将选定的卡片置于HALT模式,需要Request All将其唤醒
            if (st < 0)
            {
                msg = st.ToString() + "*" + ReaderDllMethod.getErrMsg(st);
                res = false;
            }
            else
            {
                msg = st.ToString() + "*" + ReaderDllMethod.getErrMsg(st);
            }
            return(res);
        }
コード例 #4
0
        /// <summary>
        /// 连接读卡器
        /// </summary>
        /// <param name="msg">输出信息</param>
        /// <returns>是否成功</returns>
        public override bool DevOpen(out string msg)
        {
            msg = "读卡器连接成功!";
            bool res = true;
            int  st  = 0;

            st = ReaderDllMethod.mwDevOpen("USB", "", out handle); //打开读写器
            if (st < 0)
            {
                msg = ReaderDllMethod.getErrMsg(st);
                res = false;
            }
            else
            {
                DevBeep(1, 1, 3);
            }
            return(res);
        }
コード例 #5
0
        public override bool MifareWrite(Int32 blockNo, byte[] blockData, out string msg)
        {
            bool res = true;
            int  st  = 0;

            st = ReaderDllMethod.mwMifareWrite(handle, blockNo, blockData); //读数据
            if (st < 0)
            {
                msg = st.ToString() + "*" + ReaderDllMethod.getErrMsg(st);
                res = false;
            }
            else
            {
                msg = st.ToString() + "*" + ReaderDllMethod.getErrMsg(st);
                DevBeep(1, 1, 2);
            }
            return(res);
        }
コード例 #6
0
        public override bool MifareAuthHex(Int32 sectorNo, string strKey, out string msg)
        {
            bool res = true;
            int  st  = 0;

            st = ReaderDllMethod.mwMifareAuthHex(handle, 0, sectorNo, strKey); //验证密码
            if (st < 0)
            {
                msg = st.ToString() + "*" + ReaderDllMethod.getErrMsg(st);
                res = false;
            }
            else
            {
                msg = st.ToString() + "*" + ReaderDllMethod.getErrMsg(st);
                DevBeep(1, 1, 2);
            }
            return(res);
        }
コード例 #7
0
        /// <summary>
        /// 获取硬件版本号
        /// <param name="msg">输出信息</param>
        /// <returns></returns>
        public override bool GetDevVer(out string msg)
        {
            bool res = true;
            int  st  = 0;

            byte[] hardwareVer = new byte[24];
            st = ReaderDllMethod.mwDevGetHardwareVer(handle, hardwareVer);
            if (st < 0)
            {
                msg = st.ToString() + "*" + ReaderDllMethod.getErrMsg(st);
                res = false;
            }
            else
            {
                msg = "1*" + Encoding.Default.GetString(hardwareVer, 0, st);
            }
            return(res);
        }
コード例 #8
0
        public override bool Request(out string msg)
        {
            bool   res = true;
            int    st  = 0;
            ushort cardtype;

            st = ReaderDllMethod.mwRequest(handle, Mode, out cardtype); //请求卡TYPE A 类型卡片
            if (st < 0)
            {
                msg = st.ToString() + "*" + ReaderDllMethod.getErrMsg(st);
                res = false;
            }
            else
            {
                msg      = st.ToString() + "*" + ReaderDllMethod.getErrMsg(st);
                CardType = cardtype;
                DevBeep(1, 1, 2);
            }
            return(res);
        }
コード例 #9
0
        public override bool Rats(out string msg)
        {
            bool res = true;
            int  st  = 0;

            byte[] cardUid = new byte[50];

            st = ReaderDllMethod.mwRats(handle, cardUid); //获取TYPE-A类型的智能卡复位信息
            if (st < 0)
            {
                msg = st.ToString() + "*" + ReaderDllMethod.getErrMsg(st);
                res = false;
            }
            else
            {
                msg = st.ToString() + "*" + ReaderDllMethod.getErrMsg(st);
                StringBuilder cardStr = new StringBuilder();
                ReaderDllMethod.BinToHex(cardUid, cardStr, st);
                AtrInfo = cardStr.ToString();
                DevBeep(1, 1, 2);
            }
            return(res);
        }
コード例 #10
0
        public override bool OpenCard(out string msg)
        {
            bool res = true;
            int  st  = 0;

            byte[] cardUid = new byte[10];
            st = ReaderDllMethod.mwOpenCard(handle, Mode, cardUid); //打开卡片
            if (st < 0)
            {
                msg = st.ToString() + "*" + ReaderDllMethod.getErrMsg(st);
                res = false;
            }
            else
            {
                StringBuilder cardUidStr = new StringBuilder();
                ReaderDllMethod.BinToHex(cardUid, cardUidStr, st);//将卡号转换为16进制字符串
                msg    = st.ToString() + "*" + ReaderDllMethod.getErrMsg(st);
                CardId = cardUidStr.ToString();
                DevBeep(1, 1, 2);
            }

            return(res);
        }