Exemple #1
0
        /// <summary>
        /// 手动添加
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnAddToDatabase_Click(object sender, EventArgs e)
        {
            Model.VisaInfo_Tmp model = new VisaInfo_Tmp();
            if (!CtrlsToModel(model))
            {
                return;
            }

            //读取成功了
            if (!_bllVisaInfoTmp.Add(model))
            {
                MessageBoxEx.Show(Resources.FailedAddToDatabase);
                return;
            }
            LoadDataToList();
            _curIdx = 0;
            UpdateState();
        }
Exemple #2
0
        private void btnReadData_Click(object sender, EventArgs e)
        {
            VisaInfo_Tmp model = _idCard.RecogoInfo(txtPicPath.Text, checkRegSucShowDlg.Checked);

            if (model == null)
            {
                return;
            }
            //读取成功了
            if (!_bllVisaInfoTmp.Add(model))
            {
                MessageBoxEx.Show(Resources.FailedAddToDatabase);
                return;
            }
            LoadDataToList();
            _curIdx = 0;
            UpdateState();
        }
Exemple #3
0
        public TravelAgency.Model.VisaInfo_Tmp RecogoInfo(string picPath, bool showDlgWhenSuccess = true)
        {
            //直接返回
            if (!_kernelLoaded)
            {
                MessageBoxEx.Show("Please successful loading recognition engine");
                return(null);
            }
            int nRet      = 0;
            int nCardType = 13;

            if (nCardType <= 0)
            {
                MessageBoxEx.Show("Invalid CardSizeType,please re-enter a valid.");
                return(null);
            }

            int[] nSubID = new int[1];
            nSubID[0] = 0;
            nRet      = IDCardDll.SetIDCardID(nCardType, nSubID, 1);

            int ncardType = 0;

            nRet = IDCardDll.ClassifyIDCard(ref ncardType);
            //get param
            //int nDG = 2 + 4 + 8 + 16; //DG1234
            //int nSaveImage = 1 + 2 + 4 + 8 + 16;
            //bool bVIZ = true;

            //ncardType = 1;
            if (ncardType == 1)
            {
                nRet = IDCardDll.RecogChipCard(nDG, bVIZ, nSaveImage);
            }

            if (ncardType == 2)
            {
                nRet = IDCardDll.RecogGeneralMRZCard(bVIZ, nSaveImage);
            }

            if (ncardType == 3)
            {
                nRet = IDCardDll.RecogCommonCard(nSaveImage);
            }
            StringBuilder sb = new StringBuilder();

            if (nRet < 0)
            {
                sb.Append("Return value:");
                sb.Append(nRet.ToString());
                sb.Append("\r\n");
                sb.Append("recognition failure");
                MessageBoxEx.Show(sb.ToString());
                return(null);
            }

            int MAX_CH_NUM = 128;

            char[] cArrFieldValue = new char[MAX_CH_NUM];
            char[] cArrFieldName  = new char[MAX_CH_NUM];
            if (showDlgWhenSuccess)
            {
                MessageBoxEx.Show("recognition successful\r\n");
            }

            //返回的model
            TravelAgency.Model.VisaInfo_Tmp visaInfo = new VisaInfo_Tmp();
            sb.Clear();
            //string info = "";
            for (int i = 1; ; i++)
            {
                nRet = IDCardDll.GetRecogResult(i, cArrFieldValue, ref MAX_CH_NUM);
                if (nRet == 3)
                {
                    break;
                }
                IDCardDll.GetFieldName(i, cArrFieldName, ref MAX_CH_NUM);

                //对返回的model进行修改

                string strFiledValue = new string(cArrFieldValue);
                strFiledValue = strFiledValue.Substring(0, strFiledValue.IndexOf('\0'));
                string strFiledName = new string(cArrFieldName);
                strFiledName = strFiledName.Substring(0, strFiledName.IndexOf('\0'));

                sb.Append(strFiledName);
                sb.Append(":");
                sb.Append(strFiledValue);
                sb.Append("\n");
            }
            string[] infos = sb.ToString().Split('\n');

            try
            {
                visaInfo.Name        = infos[1].Split(':')[1];
                visaInfo.EnglishName = infos[2].Split(':')[1];
                visaInfo.Sex         = infos[3].Split(':')[1];
                visaInfo.Birthday    = DateTime.Parse(infos[4].Split(':')[1]);
                visaInfo.PassportNo  = infos[0].Split(':')[1];
                visaInfo.LicenceTime = DateTime.Parse(infos[15].Split(':')[1]);
                visaInfo.Birthplace  = infos[13].Split(':')[1];
                visaInfo.IssuePlace  = infos[14].Split(':')[1];
                visaInfo.ExpiryDate  = DateTime.Parse(infos[5].Split(':')[1]);
            }
            catch (Exception)
            {
                MessageBoxEx.Show("解析信息出现错误,请放好签证后重新进行识别!");
                return(null);
            }
            //save Image
            String strImgPath = picPath + "\\" + visaInfo.PassportNo + ".jpg";

            char[] carrImgPath = strImgPath.ToCharArray();
            nRet = IDCardDll.SaveImageEx(carrImgPath, nSaveImage);
            if (nRet != 0)
            {
                MessageBoxEx.Show("SaveImage Failed!");
                return(null);
            }
            return(visaInfo);
        }