Пример #1
0
        /// <summary>
        /// IC卡读取
        /// </summary>
        /// <param name="icCard"></param>
        private void Read(ICCard icCard)
        {
            ICCardHotReset();
            ICCardReader reader = new ICCardReader(this);

            reader.SelectPaySystem();
            reader.GetAID(icCard);
            reader.GetPDOL(icCard);
            reader.GPO(icCard);          //应用初始化
            reader.GetData(icCard);      //卡片数据读取
            reader.GENERATEARQC(icCard); //生成应用密文
        }
Пример #2
0
 /// <summary>
 /// 异步读卡
 /// </summary>
 /// <returns></returns>
 private Task <ICCard> ReadICCardAsync(string ipaddrs)
 {
     return(Task <ICCard> .Factory.StartNew(() => {
         ICCard iccd = new ICCard {
             PhysicCode = "0", UserCode = ""
         };
         #region
         if (string.IsNullOrEmpty(ipaddrs))
         {
             return iccd;
         }
         Log log = LogFactory.GetLogger("ReadICCardAsync");
         try
         {
             IPAddress ip;
             if (!IPAddress.TryParse(ipaddrs, out ip))
             {
                 return iccd;
             }
             ICCardReader reader = new ICCardReader(ipaddrs);
             bool nback = reader.Connect();
             if (nback)
             {
                 uint physic = 0;
                 int ret = reader.GetPhyscard(ref physic);
                 if (ret == 0)
                 {
                     string physc = physic.ToString();
                     iccd.PhysicCode = physc;
                     ICCard ccd = new CWICCard().Find(ic => ic.PhysicCode == physc);
                     if (ccd != null)
                     {
                         iccd.UserCode = ccd.UserCode;
                     }
                 }
             }
             reader.Disconnect();
         }
         catch (Exception ex)
         {
             log.Error(ex.ToString());
         }
         #endregion
         return iccd;
     }));
 }