Exemple #1
0
        }/// <summary>

        /// 更新指纹仪内部指纹数据
        /// </summary>
        public void LoadFinger()
        {
            _userList = _server.GetStationUserList(Guid.Parse(LocalData.Context.CurrentDepartmentID));
            fpInstance.Clear();
            Thread.Sleep(40);
            if (_userList != null && _userList.Count > 0)
            {
                foreach (StationUserInfo sui in _userList)
                {
                    try
                    {
                        RegTmp = zkfp.Base64String2Blob(sui.FingerTemp);
                        fpInstance.AddRegTemplate(sui.FingerNo, RegTmp);
                        Thread.Sleep(20);
                    }catch (Exception ex)
                    {
                        continue;
                    }
                }
            }
        }
Exemple #2
0
        protected override void DefWndProc(ref Message m)
        {
            switch (m.Msg)
            {
            case MESSAGE_CAPTURED_OK:
            {
                MemoryStream ms = new MemoryStream();
                BitmapFormat.GetBitmap(FPBuffer, fpInstance.imageWidth, fpInstance.imageHeight, ref ms);
                Bitmap bmp = new Bitmap(ms);
                this.picFPImg.Image = bmp;

                if (IsRegister)
                {
                    int ret = zkfp.ZKFP_ERR_OK;
                    int fid = 0, score = 0;
                    ret = fpInstance.Identify(CapTmp, ref fid, ref score);
                    if (zkfp.ZKFP_ERR_OK == ret)
                    {
                        textRes.Text = "This finger was already register by " + fid + "!";
                        return;
                    }
                    if (RegisterCount > 0 && fpInstance.Match(CapTmp, RegTmps[RegisterCount - 1]) <= 0)
                    {
                        textRes.Text = "Please press the same finger 3 times for the enrollment";
                        return;
                    }
                    Array.Copy(CapTmp, RegTmps[RegisterCount], cbCapTmp);
                    RegisterCount++;
                    if (RegisterCount >= REGISTER_FINGER_COUNT)
                    {
                        RegisterCount = 0;
                        if (zkfp.ZKFP_ERR_OK == (ret = fpInstance.GenerateRegTemplate(RegTmps[0], RegTmps[1], RegTmps[2], RegTmp, ref cbRegTmp)) &&
                            zkfp.ZKFP_ERR_OK == (ret = fpInstance.AddRegTemplate(iFid, RegTmp)))
                        {
                            iFid++;
                            textRes.Text = "enroll succ";
                        }
                        else
                        {
                            textRes.Text = "enroll fail, error code=" + ret;
                        }
                        IsRegister = false;
                        return;
                    }
                    else
                    {
                        textRes.Text = "You need to press the " + (REGISTER_FINGER_COUNT - RegisterCount) + " times fingerprint";
                    }
                }
                else
                {
                    if (cbRegTmp <= 0)
                    {
                        textRes.Text = "Please register your finger first!";
                        return;
                    }
                    if (bIdentify)
                    {
                        int ret = zkfp.ZKFP_ERR_OK;
                        int fid = 0, score = 0;
                        ret = fpInstance.Identify(CapTmp, ref fid, ref score);
                        if (zkfp.ZKFP_ERR_OK == ret)
                        {
                            textRes.Text = "Identify succ, fid= " + fid + ",score=" + score + "!";
                            return;
                        }
                        else
                        {
                            textRes.Text = "Identify fail, ret= " + ret;
                            return;
                        }
                    }
                    else
                    {
                        int ret = fpInstance.Match(CapTmp, RegTmp);
                        if (0 < ret)
                        {
                            textRes.Text = "Match finger succ, score=" + ret + "!";
                            return;
                        }
                        else
                        {
                            textRes.Text = "Match finger fail, ret= " + ret;
                            return;
                        }
                    }
                }
            }
            break;

            default:
                base.DefWndProc(ref m);
                break;
            }
        }
 /// <summary>
 /// Add A Registered Fingerprint Template To Memory | params: (FingerPrint ID, Registered Template)
 /// </summary>
 /// <returns></returns>
 private int AddTemplateToMemory()
 {
     return(fpInstance.AddRegTemplate(iFid, RegTmp));
 }
Exemple #4
0
        static public void DoCapture()
        {
            try
            {
                while (!bIsTimeToDie)
                {
                    int ret = fpInstance.AcquireFingerprint(FPBuffer, CapTmp, ref cbCapTmp);

                    if (ret == zkfp.ZKFP_ERR_OK)
                    {
                        Array.Copy(CapTmp, RegTmps[RegisterCount], cbCapTmp);
                        RegisterCount++;

                        if (RegisterCount >= REGISTER_FINGER_COUNT)
                        {
                            RegisterCount = 0;
                            ret           = GenerateRegisteredFingerPrint();
                            if (zkfp.ZKFP_ERR_OK == ret)
                            {
                                ret = fpInstance.AddRegTemplate(iFid, RegTmp);
                                if (zkfp.ZKFP_ERR_OK == ret)
                                {
                                    string sql;
                                    zkfp.Blob2Base64String(RegTmp, regTempLen, ref fingerPrintTemplate);

                                    OracleConnection conn = new OracleConnection(String.Format("Data Source=Neptune; User Id={0}; Password={1}", TestConnection.oracelUser, TestConnection.oracelPass));
                                    conn.Open();

                                    if (FingerTap == 0)
                                    {
                                        OracleCommand     cmd   = new OracleCommand("SELECT f_id, u_id FROM user_t", conn);
                                        OracleDataAdapter da    = new OracleDataAdapter(cmd);
                                        DataTable         dt    = new DataTable();
                                        string            text1 = string.Empty;
                                        da.Fill(dt);
                                        conn.Close();
                                        foundUserid = 0;
                                        foreach (DataRow dr in dt.Rows)
                                        {
                                            text1  = Convert.ToString(dr["f_id"]);
                                            CapTmp = new byte[2048];
                                            CapTmp = zkfp.Base64String2Blob(text1);

                                            ret = fpInstance.Match(RegTmp, CapTmp);
                                            if (0 < ret)
                                            {
                                                userid      = Convert.ToString(dr["u_id"]);
                                                foundUserid = 1;
                                            }
                                        }
                                        if (foundUserid == 0)
                                        {
                                            DisconnectDevice();
                                            connect();
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception ex) {
                DeviceConnected = 0;
            }
        }