Example #1
0
        public static bool ICDownAID(List <byte[]> aidItemList)
        {
            bool result = false;

            byte[]      bAllAID = new byte[1024 * 4];
            int         nAllAID = 0;
            TransResult eRet    = TransResult.E_SUCC;

            foreach (byte[] item in aidItemList)
            {
                CDownAID dAID = new CDownAID();
                dAID.BField62 = new byte[item.Length];
                Array.Copy(item, dAID.BField62, item.Length);
                eRet = dAID.Communicate();
                if (eRet != TransResult.E_SUCC)
                {
                    break;
                }

                Array.Copy(dAID.BAID, 0, bAllAID, nAllAID, dAID.BAID.Length);
                nAllAID += dAID.BAID.Length;
            }

            Log.Warn("IC卡下载IC卡参数CDownAID:Ret=" + eRet.ToString());
            if (eRet == TransResult.E_SUCC)
            {
                Log.Info("IC卡AID下载参数成功");
                string caPath = Path.Combine(StartupPath, "pbocaid.txt");
                result = CreateFile(caPath, bAllAID, nAllAID);
            }

            return(result);
        }
Example #2
0
        /// <summary>
        /// 同步下载IC卡AID入口
        /// </summary>
        /// <returns></returns>
        public static bool ICAIDEntry()
        {
            //Log.Info("========开始下载IC卡参数========");
            TransResult   eRet        = TransResult.E_SUCC;
            bool          bResult     = false;
            byte          bContinue   = 0x30;
            List <byte[]> aidItemList = new List <byte[]>();
            CQueryAID     qaid        = new CQueryAID();

            eRet = qaid.Communicate();
            if (eRet == TransResult.E_SUCC)
            {
                bResult = true;
                aidItemList.AddRange(qaid.AIDItemList);
                bContinue = qaid.BField62;
                if (bContinue == 0x32)
                {
                    while (eRet == TransResult.E_SUCC && bContinue == 0x32)
                    {
                        System.Threading.Thread.Sleep(2000);//四川版需要停顿
                        CQueryAID qaid2 = new CQueryAID();
                        qaid2.StrField62 = "1" + aidItemList.Count.ToString().PadLeft(2, '0');
                        eRet             = qaid2.Communicate();
                        if (eRet == TransResult.E_SUCC)
                        {
                            aidItemList.AddRange(qaid2.AIDItemList);
                            bContinue = qaid2.BField62;
                        }
                        else
                        {
                            bResult = false;
                        }
                    }
                }
                if (bResult && aidItemList.Count > 0)
                {
                    System.Threading.Thread.Sleep(2000);//四川版需要停顿
                    bResult = CDownAID.ICDownAID(aidItemList);
                    if (bResult)
                    {
                        CEndAID eaid = new CEndAID();
                        eaid.Communicate();
                    }

                    //string caPath = Path.Combine(StartupPath, "pbocaid.txt");
                    //byte[] bAllAID = new byte[1024 * 4];
                    //int nAllAID = 0;
                    //foreach (byte[] item in aidItemList)
                    //{
                    //    Array.Copy(item, 0, bAllAID, nAllAID, item.Length);
                    //    nAllAID += item.Length;
                    //}
                    //bResult = CreateFile(caPath, bAllAID, nAllAID);
                }
            }
            Log.Warn("IC卡下载IC卡参数CQueryAID:Ret=" + eRet.ToString());
            //Log.Info("========结束下载IC卡参数========");
            return(bResult);
        }