Ejemplo n.º 1
0
 /// <summary>
 /// 加载指纹dat文件
 /// </summary>
 /// <param name="entity"></param>
 private void LoadFingerDat(CmcsFinger entity)
 {
     if (!IsConnect)
     {
         ShowInfomation("请先打开设备...");
         return;
     }
     ret = Fingerdll.ZAZDownCharFromFile(hHandle, nDevAddr, 1, entity.FingerUrl);
     ret = Fingerdll.ZAZDownCharFromFile(hHandle, nDevAddr, 2, entity.FingerUrl);
     if (ret == 0)
     {
         byte[] ImgData = new byte[ImageSize];
         int[]  ImgLen  = new int[1];
         ret = Fingerdll.ZAZUpImage(hHandle, nDevAddr, ImgData, ImgLen);                  //上传图象
         if (ret != 0)
         {
             ShowInfomation(Fingerdll.ZAZErr2Strt(ret));
             return;
         }
         strFile = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "ZAZFinger.bmp");
         ret     = Fingerdll.ZAZImgData2BMP(ImgData, strFile);
         if (ret != 0)
         {
             ShowInfomation(Fingerdll.ZAZErr2Strt(ret), eOutputType.Error);
             return;
         }
         ShowImage(strFile);
     }
 }
Ejemplo n.º 2
0
        /// <summary>
        /// 关闭设备
        /// </summary>
        public void CloseHardware()
        {
            int ret = 0;

            ret = Fingerdll.ZAZCloseDeviceEx(hHandle);
            if (ret == 0)
            {
                this.IsConnect = true;
                ShowInfomation("设备关闭成功");
            }
            else
            {
                this.IsConnect = false;
                ShowInfomation(Fingerdll.ZAZErr2Strt(ret));
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 初始化外接设备
        /// </summary>
        public void InitHardware()
        {
            int ret = 0;

            ret = Fingerdll.ZAZOpenDeviceEx(ref hHandle, 2, 0, 0, 2, 0);
            if (ret == 0)
            {
                this.IsConnect = true;
                ShowInfomation("设备打开成功");
                btn_eroll_Click(null, null);
            }
            else
            {
                this.IsConnect = false;
                ShowInfomation(Fingerdll.ZAZErr2Strt(ret));
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 获取指纹
        /// </summary>
        /// <param name="buffer">指纹在设备中临时存放位置 1 2</param>
        /// <returns></returns>
        int GetFinger(int buffer)
        {
            TimeOut = 20;
            int ret = 0;

            byte[] ImgData = new byte[ImageSize];
            int[]  ImgLen  = new int[1];
            int    iBuffer = buffer;

BEIG1:
            ret = Fingerdll.ZAZGetImage(hHandle, nDevAddr);              //获取图象
            if (ret == 0)
            {
                ShowInfomation("获取图像成功...");
            }
            else if (ret == 2)
            {
                //超时判断
                ShowInfomation("等待手指平放在传感器上-" + TimeOut.ToString() + "秒");
                if (TimeOut < 0)
                {
                    ShowInfomation("等待超时");
                    return(0);
                }
                TimeOut--;
                Thread.Sleep(1000);
                goto BEIG1;
            }
            else
            {
                ShowInfomation(Fingerdll.ZAZErr2Strt(ret));
                return(0);
            }

            //////////////////////////////////////////////////////////////////////////
            //不涉及图像,下面可以省略
            /****************上传图像*********/

            ShowInfomation("正在上传图像请等待...");
            ret = Fingerdll.ZAZUpImage(hHandle, nDevAddr, ImgData, ImgLen);              //上传图象
            if (ret != 0)
            {
                ShowInfomation(Fingerdll.ZAZErr2Strt(ret));
                return(0);
            }
            //strFile = System.Windows.Forms.Application.StartupPath + "\\ZAZFinger.bmp";
            strFile = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "ZAZFinger.bmp");
            ret     = Fingerdll.ZAZImgData2BMP(ImgData, strFile);
            if (ret != 0)
            {
                ShowInfomation(Fingerdll.ZAZErr2Strt(ret));
                return(0);
            }
            ShowImage(strFile);
            //ret = Fingerdll.ZAZShowFingerData(fpbmp.Handle, ref ImgData[0]);
            //////////////////////////////////////////////////////////////////////////
            /****************生成特征 *********/
            ret = Fingerdll.ZAZGenChar(hHandle, nDevAddr, iBuffer);              //生成模板
            if (ret != 0)
            {
                ShowInfomation(Fingerdll.ZAZErr2Strt(ret));
                return(0);
            }
            else
            {
                ShowInfomation("生成指纹特征" + buffer.ToString());
            }
            Thread.Sleep(10);
BEIG2:
            if (ret == 0)
            {
                ret = Fingerdll.ZAZGetImage(hHandle, nDevAddr);                  //获取图象
                ShowInfomation("等待手指拿开-");
                goto BEIG2;
            }
            else if (ret == 1)
            {
                ShowInfomation(Fingerdll.ZAZErr2Strt(ret));
                return(0);
            }
            return(1);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// 注册指纹
        /// </summary>
        private void RegistFinger()
        {
            if (!IsConnect)
            {
                ShowInfomation("请先打开设备...");
                return;
            }
            //生成特征A
            if (GetFinger(1) != 1)
            {
                return;
            }
            Thread.Sleep(200);
            //生成特征B
            if (GetFinger(2) != 1)
            {
                return;
            }

            Thread.Sleep(200);
            /****************合成模板*********/
            ret = Fingerdll.ZAZRegModule(hHandle, nDevAddr);              //合并特征
            if (ret != 0)
            {
                ShowInfomation(Fingerdll.ZAZErr2Strt(ret));
                return;
            }
            else
            {
                ShowInfomation("合成指纹模板成功");
            }
            Thread.Sleep(200);

            //本例以存在在指纹设备库中进行
            //ret = Fingerdll.ZAZStoreChar(hHandle, nDevAddr, 1, FingerIndex);    //存放模板

            //StrFile = System.Windows.Forms.Application.StartupPath + "\\FTmpelet.dat";
            #region 存储指纹到服务器
            CmcsFinger userfinger = new CmcsFinger();
            InvokeEx(() =>
            {
                StrFile    = commonDAO.GetCommonAppletConfigString("指纹识别数据存放路径");
                userfinger = fingerIdentifyDAO.GetFinerByFingerName(this.User.PartyId, cmbFingerName.Text);
                if (userfinger == null)
                {
                    userfinger            = new CmcsFinger();
                    userfinger.FingerName = cmbFingerName.Text;
                }
                StrFile = Path.Combine(StrFile, this.User.UserAccount);

                if (!File.Exists(StrFile))
                {
                    Directory.CreateDirectory(StrFile);
                }
                StrFile = Path.Combine(StrFile, userfinger.Id + ".dat");
                userfinger.FingerUrl = StrFile;

                #endregion
                //将指纹信息写入到dat文件
                ret = Fingerdll.ZAZUpChar2File(hHandle, nDevAddr, 1, strFile);
                if (ret != 0)
                {
                    ShowInfomation(Fingerdll.ZAZErr2Strt(ret));
                    return;
                }
                else
                {
                    if (fingerIdentifyDAO.InsertFinger(this.User, userfinger) && File.Exists(StrFile))
                    {
                        ShowInfomation("存储指纹成功");
                        //showFpdb();显示当前设备指纹存储信息
                        FingerIndex++;
                        BindData();
                        return;
                    }
                }
            });
        }
Ejemplo n.º 6
0
        /// <summary>
        /// 获取指纹
        /// </summary>
        /// <param name="buffer">指纹在设备中临时存放位置 1 2</param>
        /// <returns></returns>
        int GetFinger(int buffer)
        {
            TimeOut = 20;
            int ret = 0;

            byte[] ImgData = new byte[ImageSize];
            int[]  ImgLen  = new int[1];
            int    iBuffer = 1;

BEIG1:
            ret = Fingerdll.ZAZGetImage(hHandle, nDevAddr);              //获取图象
            if (ret == 0)
            {
                ShowToolTip("获取图像成功...");
            }
            else if (ret == 2)
            {
                //超时判断
                ShowToolTip("等待手指平放在传感器上-" + TimeOut.ToString() + "秒");
                if (TimeOut < 0)
                {
                    ShowToolTip("等待超时");
                    return(0);
                }
                TimeOut--;
                Thread.Sleep(1000);
                goto BEIG1;
            }
            else
            {
                //ShowToolTip(Fingerdll.ZAZErr2Strt(ret));
                return(0);
            }

            //////////////////////////////////////////////////////////////////////////
            //不涉及图像,下面可以省略
            /****************上传图像*********/

            ShowToolTip("正在上传图像请等待...");
            ret = Fingerdll.ZAZUpImage(hHandle, nDevAddr, ImgData, ImgLen);              //上传图象
            if (ret != 0)
            {
                ShowToolTip(Fingerdll.ZAZErr2Strt(ret));
                return(0);
            }

            ret = Fingerdll.ZAZGenChar(hHandle, nDevAddr, iBuffer);              //生成模板
            if (ret != 0)
            {
                ShowToolTip(Fingerdll.ZAZErr2Strt(ret));
                return(0);
            }
            else
            {
                ShowToolTip("生成指纹特征" + buffer.ToString());
                return(1);
            }
BEIG2:
            if (ret == 0)
            {
                ret = Fingerdll.ZAZGetImage(hHandle, nDevAddr);                  //获取图象
                ShowToolTip("等待手指拿开-");

                goto BEIG2;
            }
            else if (ret == 1)
            {
                ShowToolTip(Fingerdll.ZAZErr2Strt(ret));
                return(0);
            }
            return(1);
        }