示例#1
0
 public static CardReaderManager GetInstance(WegenType readerType)
 {
     if (_man == null)
     {
         _man = new CardReaderManager();
         _man.InitReaders();
     }
     foreach (ICardReader reader in _man._Readers)
     {
         reader.WegenType = readerType;
     }
     return(_man);
 }
示例#2
0
        /// <summary>
        /// 询卡
        /// </summary>
        /// <returns></returns>
        public YCTWallet ReadCard(WegenType wg = WegenType.Wengen34)
        {
            var response = Request(YCTCommandType.Poll, null);

            if (response != null && response.IsCommandExcuteOk && response.Data != null && response.Data.Length == 52)
            {
                byte[]    data = response.Data;
                YCTWallet w    = new YCTWallet();
                w.WalletType = data[0];
                if (w.WalletType == 1)
                {
                    w.PhysicalCardID = HexStringConverter.HexToString(Slice(data, 1, 4), string.Empty); //M1钱包物理卡只取前四字节
                }
                else
                {
                    w.PhysicalCardID = HexStringConverter.HexToString(Slice(data, 1, 8), string.Empty);
                }
                w.LogicCardID = HexStringConverter.HexToString(Slice(data, 9, 8), string.Empty);
                w.Balance     = BEBinaryConverter.BytesToInt(Slice(data, 17, 4));
                w.Count       = BEBinaryConverter.BytesToInt(Slice(data, 21, 2));
                w.CardType    = HexStringConverter.HexToString(Slice(data, 23, 2), string.Empty);
                w.MinBalance  = data[25] * 100;
                w.MaxBalance  = BEBinaryConverter.BytesToInt(Slice(data, 26, 3));
                w.Deposit     = BEBinaryConverter.BytesToInt(Slice(data, 29, 4));
                _LastWallet   = w;
                return(w);
            }
            else if (LastError == 0x83) //验证出错,说明卡片是其它IC卡,继续读其序列号
            {
                string sn = ReadSN(wg == WegenType.Wengen26 ? 1 : 0);
                if (sn != null)
                {
                    _LastWallet = new YCTWallet()
                    {
                        LogicCardID = sn, PhysicalCardID = sn, CardType = string.Empty
                    };
                    return(_LastWallet);
                }
            }
            return(null);
        }