Esempio n. 1
0
        /// <summary>
        /// 获取当前读卡器上的IC卡号码,返回8位的卡号或错误信息
        /// 此方法自行处理卡号+加动态码,返回最终卡号,与ReadICCard不同
        /// </summary>
        public static bool GetICCardID(string storePassword, out string icCardId, out string repeatCode, out string errMsg, bool isBeep = true, bool isCreate = false)
        {
            icCardId = string.Empty;
            errMsg   = string.Empty;
            string sICCardID = string.Empty;

            if (!ICCardUtility.ReadICCard(storePassword, out sICCardID, out repeatCode, out errMsg, isBeep, isCreate))
            {
                return(false);
            }

            if (IsValidCardNo(sICCardID))
            {
                try
                {
                    string sRepeatCode = Convert.ToInt32(sICCardID.Substring(8), 16).ToString();
                    sICCardID = sICCardID.Substring(0, 8);
                    int iICCardID = 0;
                    if (ICCardUtility.isNumberic(sICCardID, out iICCardID))
                    {
                        icCardId = iICCardID.ToString();
                    }
                    else
                    {
                        icCardId = sICCardID;
                    }
                    return(true);
                }
                catch
                {
                    errMsg = "读取卡片出错";
                    return(false);
                }
            }
            else
            {
                errMsg = sICCardID;
                return(false);
            }

            return(true);
        }