コード例 #1
0
        public IDCardInfo IDC_ReadIDCPhoto(string directory)
        {
            StringBuilder Name        = new StringBuilder(31);
            StringBuilder Gender      = new StringBuilder(3);
            StringBuilder Folk        = new StringBuilder(10);
            StringBuilder BirthDay    = new StringBuilder(9);
            StringBuilder Code        = new StringBuilder(19);
            StringBuilder Address     = new StringBuilder(71);
            StringBuilder Agency      = new StringBuilder(31);
            StringBuilder ExpireStart = new StringBuilder(9);
            StringBuilder ExpireEnd   = new StringBuilder(9);
            string        _directory  = directory;
            string        _photo      = directory + "\\photo.jpg";
            string        _front      = directory + "\\1.jpg";
            string        _back       = directory + "\\2.jpg";

            FileInfo fileInfo = new FileInfo(_photo);

            if (fileInfo.Exists)
            {
                fileInfo.Delete();
            }
            fileInfo = new FileInfo(_front);
            if (fileInfo.Exists)
            {
                fileInfo.Delete();
            }
            fileInfo = new FileInfo(_back);
            if (fileInfo.Exists)
            {
                fileInfo.Delete();
            }

            int intReadBaseInfosRet = ReadBaseInfosPhoto(Name, Gender, Folk, BirthDay, Code, Address, Agency, ExpireStart, ExpireEnd, _directory);

            if (intReadBaseInfosRet != 1)
            {
                return(null);
            }

            IDCardInfo info = new IDCardInfo
            {
                Name        = Name.ToString().Trim(),
                Gender      = Gender.ToString().Trim(),
                Folk        = Folk.ToString().Trim(),
                BirthDay    = BirthDay.ToString().Trim(),
                Code        = Code.ToString().Trim(),
                Address     = Address.ToString().Trim(),
                Agency      = Agency.ToString().Trim(),
                ExpireStart = ExpireStart.ToString().Trim(),
                ExpireEnd   = ExpireEnd.ToString().Trim(),
                directory   = _directory.ToString().Trim(),
                photo       = _photo,
                front       = _front,
                back        = _back
            };

            return(info);
        }
コード例 #2
0
        public IDCardInfo read()
        {
            reInt = IDC_Authenticate();
            if (reInt != 1)
            {
                if (idcReaderStatesChangedEvent != null)
                {
                    idcReaderStatesChangedEvent("需要重新放卡");
                }
                MessageBox.Show("请重新放置身份证", "提示");
                return(null);
            }
            IDCardInfo info = IDC_ReadIDC();

            if (info != null)
            {
                if (idcReaderReadSuccess != null)
                {
                    idcReaderReadSuccess(info);
                }
            }
            return(info);
            //return IDC_ReadIDCPhoto();
        }
コード例 #3
0
 private void run()
 {
     IsWorking = true;
     try
     {
         while (IsWorking)
         {
             reInt = IDC_Authenticate();
             if (reInt != 1)
             {
                 if (idcReaderStatesChangedEvent != null)
                 {
                     idcReaderStatesChangedEvent("需要重新放卡");
                 }
                 continue;
             }
             IDCardInfo iDCardInfo = read();
             if (iDCardInfo != null)
             {
                 if (idcReaderReadSuccess != null)
                 {
                     idcReaderReadSuccess(iDCardInfo);
                 }
             }
             System.Threading.Thread.Sleep(1111);
             //readEvent.WaitOne();
         }
     }
     finally
     {
         lock (lockIsWorking)
         {
             IsWorking = false;
         }
     }
 }
コード例 #4
0
        public IDCardInfo IDC_ReadIDCLess()
        {
            //StringBuilder Name = new StringBuilder(31);
            //StringBuilder Gender = new StringBuilder(3);
            //StringBuilder Folk = new StringBuilder(10);
            //StringBuilder BirthDay = new StringBuilder(9);
            //StringBuilder Code = new StringBuilder(19);
            //StringBuilder Address = new StringBuilder(71);
            //StringBuilder Agency = new StringBuilder(31);
            //StringBuilder ExpireStart = new StringBuilder(9);
            //StringBuilder ExpireEnd = new StringBuilder(9);
            StringBuilder Name           = new StringBuilder(32);
            StringBuilder Gender         = new StringBuilder(4);
            StringBuilder Folk           = new StringBuilder(16);
            StringBuilder BirthDay       = new StringBuilder(16);
            StringBuilder Code           = new StringBuilder(32);
            StringBuilder Address        = new StringBuilder(128);
            StringBuilder Agency         = new StringBuilder(32);
            StringBuilder ExpireStart    = new StringBuilder(16);
            StringBuilder ExpireEnd      = new StringBuilder(16);
            string        _directory     = System.Environment.CurrentDirectory;
            string        _bmp_photo_old = _directory + "\\photo.bmp";
            string        _photo_old     = _directory + "\\photo.jpg";
            string        _front_old     = _directory + "\\1.jpg";
            string        _back_old      = _directory + "\\2.jpg";

            if (File.Exists(_bmp_photo_old))
            {
                File.Delete(_bmp_photo_old);
            }
            if (File.Exists(_photo_old))
            {
                File.Delete(_photo_old);
            }
            if (File.Exists(_front_old))
            {
                File.Delete(_front_old);
            }
            if (File.Exists(_back_old))
            {
                File.Delete(_back_old);
            }

            int intReadBaseInfosRet = ReadBaseInfos(Name, Gender, Folk, BirthDay, Code, Address, Agency, ExpireStart, ExpireEnd);

            if (intReadBaseInfosRet != 1)
            {
                return(null);
            }
            if (File.Exists(_bmp_photo_old))
            {
                File.Delete(_bmp_photo_old);
            }
            if (File.Exists(_photo_old))
            {
                File.Delete(_photo_old);
            }
            if (File.Exists(_front_old))
            {
                File.Delete(_front_old);
            }
            if (File.Exists(_back_old))
            {
                File.Delete(_back_old);
            }
            IDCardInfo info = new IDCardInfo
            {
                Name        = Name.ToString().Trim(),
                Gender      = Gender.ToString().Trim(),
                Folk        = Folk.ToString().Trim(),
                BirthDay    = BirthDay.ToString().Trim(),
                Code        = Code.ToString().Trim(),
                Address     = Address.ToString().Trim(),
                Agency      = Agency.ToString().Trim(),
                ExpireStart = ExpireStart.ToString().Trim(),
                ExpireEnd   = ExpireEnd.ToString().Trim(),
            };

            return(info);
        }
コード例 #5
0
        public IDCardInfo IDC_ReadIDC()
        {
            StringBuilder Name           = new StringBuilder(32);
            StringBuilder Gender         = new StringBuilder(4);
            StringBuilder Folk           = new StringBuilder(16);
            StringBuilder BirthDay       = new StringBuilder(16);
            StringBuilder Code           = new StringBuilder(32);
            StringBuilder Address        = new StringBuilder(128);
            StringBuilder Agency         = new StringBuilder(32);
            StringBuilder ExpireStart    = new StringBuilder(16);
            StringBuilder ExpireEnd      = new StringBuilder(16);
            string        _directory     = System.Environment.CurrentDirectory;
            string        _bmp_photo_old = _directory + "\\photo.bmp";
            string        _photo_old     = _directory + "\\photo.jpg";
            string        _front_old     = _directory + "\\1.jpg";
            string        _back_old      = _directory + "\\2.jpg";

            if (File.Exists(_bmp_photo_old))
            {
                File.Delete(_bmp_photo_old);
            }
            if (File.Exists(_photo_old))
            {
                File.Delete(_photo_old);
            }
            if (File.Exists(_front_old))
            {
                File.Delete(_front_old);
            }
            if (File.Exists(_back_old))
            {
                File.Delete(_back_old);
            }


            int intReadBaseInfosRet = ReadBaseInfos(Name, Gender, Folk, BirthDay, Code, Address, Agency, ExpireStart, ExpireEnd);

            if (intReadBaseInfosRet != 1)
            {
                return(null);
            }


            if (File.Exists(_bmp_photo_old) && !File.Exists(_photo_old))
            {
                Image image1 = Image.FromFile(_bmp_photo_old);
                image1.Save(_photo_old, System.Drawing.Imaging.ImageFormat.Jpeg);
            }
            string _photo = _directory + "\\" + Code.ToString() + "_id.jpg";
            string _front = _directory + "\\" + Code.ToString() + "_1.jpg";
            string _back  = _directory + "\\" + Code.ToString() + "_2.jpg";

            if (File.Exists(_photo))
            {
                File.Delete(_photo);
            }
            if (File.Exists(_front))
            {
                File.Delete(_front);
            }
            if (File.Exists(_back))
            {
                File.Delete(_back);
            }

            if (File.Exists(_photo_old))
            {
                File.Move(_photo_old, _photo);
            }
            if (File.Exists(_front_old))
            {
                File.Move(_front_old, _front);
            }
            if (File.Exists(_back_old))
            {
                File.Move(_back_old, _back);
            }

            IDCardInfo info = new IDCardInfo
            {
                Name        = Name.ToString().Trim(),
                Gender      = Gender.ToString().Trim(),
                Folk        = Folk.ToString().Trim(),
                BirthDay    = BirthDay.ToString().Trim(),
                Code        = Code.ToString().Trim(),
                Address     = Address.ToString().Trim(),
                Agency      = Agency.ToString().Trim(),
                ExpireStart = ExpireStart.ToString().Trim(),
                ExpireEnd   = ExpireEnd.ToString().Trim(),
                directory   = _directory.ToString().Trim(),
                photo       = _photo,
                front       = _front,
                back        = _back
            };

            return(info);
        }