Esempio n. 1
0
        public Resultado <Digital, Falha> IdentificarDigital(byte[] digitalLida, Digital digitalParaComparar)
        {
            var encontrou = false;
            var payload   = new NBioAPI.Type.FIR_PAYLOAD();

            NBioAPI.Type.HFIR digitalLidaConvertida;
            _apiConversor.FDxToNBioBSPEx(digitalLida, (uint)digitalLida.Length, NBioAPI.Type.MINCONV_DATA_TYPE.MINCONV_TYPE_ISO, NBioAPI.Type.FIR_PURPOSE.ENROLL_FOR_IDENTIFICATION_ONLY, out digitalLidaConvertida);

            NBioAPI.Type.HFIR digitalParaCompararConvertida;
            _apiConversor.FDxToNBioBSPEx(digitalParaComparar.TemplateIso, (uint)digitalParaComparar.TemplateIso.Length, NBioAPI.Type.MINCONV_DATA_TYPE.MINCONV_TYPE_ISO, NBioAPI.Type.FIR_PURPOSE.ENROLL_FOR_IDENTIFICATION_ONLY, out digitalParaCompararConvertida);

            var retorno = _api.VerifyMatch(digitalLidaConvertida, digitalParaCompararConvertida, out encontrou, payload);

            if (encontrou)
            {
                var cbInfo = new NBioAPI.IndexSearch.CALLBACK_INFO_0();
                NBioAPI.IndexSearch.FP_INFO[] informacaoBiometria;
                NBioAPI.IndexSearch.FP_INFO   nitgenBiometria;

                var resultadoAddFir = _apiBusca.AddFIR(digitalLidaConvertida, (uint)digitalParaComparar.Id, out informacaoBiometria);
                retorno = _apiBusca.IdentifyData(digitalLidaConvertida, NBioAPI.Type.FIR_SECURITY_LEVEL.HIGHEST, out nitgenBiometria, cbInfo);

                var idEncontrado = nitgenBiometria.ID;
                _apiBusca.RemoveUser((uint)digitalParaComparar.Id);
                if (idEncontrado > 0)
                {
                    return(digitalParaComparar);
                }
            }
            Debug.WriteLine($"digital {digitalParaComparar.Id}");
            return(Falha.Nova(404, "Digital não encontrada"));
        }
Esempio n. 2
0
        private void Button1_Click_2(object sender, EventArgs e)
        {
            bool result;

            NBioAPI.Type.FIR_PAYLOAD myPayload = new NBioAPI.Type.FIR_PAYLOAD();
            m_NBioAPI.GetTextFIRFromHandle(m_hNewFIR, out m_textFIR, true);
            Console.WriteLine("verify " + m_textFIR.TextFIR);
            NBioAPI.Type.FIR_PURPOSE firpurpose;

            NBioAPI.Type.FIR_TEXTENCODE textencode = new NBioAPI.Type.FIR_TEXTENCODE();


            bool result2;

            m_NBioAPI.GetTextFIRFromHandle(m_hNewFIR, out textencode, true);
            m_NBioAPI.VerifyMatch(textencode, textencode, out result2, null);
            uint gui = m_NBioAPI.VerifyMatch(textencode, textencode, out result, null);

            Console.WriteLine("resultado " + result2);


            if (result)
            {
                Console.WriteLine("ok");
            }
            else
            {
                Console.WriteLine("notok");
            }
        }
        private string CompararDigital(string Digital)
        {
            uint    ret;
            bool    result;
            NBioAPI m_NBioAPI = new NBioAPI();

            NBioAPI.Type.HFIR           hCapturedFIR = new NBioAPI.Type.HFIR();
            NBioAPI.Type.FIR_TEXTENCODE m_textFIR    = new NBioAPI.Type.FIR_TEXTENCODE();
            NBioAPI.Type.FIR_PAYLOAD    myPayload    = new NBioAPI.Type.FIR_PAYLOAD();

            m_textFIR.TextFIR = Digital.ToString();

            m_NBioAPI.OpenDevice(NBioAPI.Type.DEVICE_ID.AUTO);
            m_NBioAPI.Capture(out hCapturedFIR);

            ret = m_NBioAPI.VerifyMatch(hCapturedFIR, m_textFIR, out result, myPayload);


            if (result == true)
            {
                return("OK");
            }
            else
            {
                return("");
            }
        }
Esempio n. 4
0
        private void btnBiometria_Click(object sender, EventArgs e)
        {
            if (txtUsername.Text == "")
            {
                MessageBox.Show("Favor, preencher o campo de usuário", "Projeto Biometria", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                txtUsername.Focus();
            }
            else
            {
                uint reta = m_NBioAPI.OpenDevice(NBioAPI.Type.DEVICE_ID.AUTO);

                user  = new User();
                userC = new UserController();
                user  = userC.selectUser(txtUsername.Text);
                bool result;
                if (user != null)
                {
                    NBioAPI.Type.HFIR bNewFIR = new NBioAPI.Type.HFIR();

                    NBioAPI.Type.FIR         m_biFIR   = new NBioAPI.Type.FIR();
                    NBioAPI.Type.FIR_PAYLOAD myPayload = new NBioAPI.Type.FIR_PAYLOAD();

                    m_biFIR.Format            = (uint)user.Format;
                    m_biFIR.Data              = user.Digital;
                    m_biFIR.Header.DataLength = (uint)user.DataLength;
                    m_biFIR.Header.DataType   = (ushort)user.DataType;
                    m_biFIR.Header.Length     = (uint)user.Length;
                    m_biFIR.Header.Purpose    = (ushort)user.Purpose;
                    m_biFIR.Header.Quality    = (ushort)user.Quality;
                    m_biFIR.Header.Reserved   = (uint)user.Reserved;
                    m_biFIR.Header.Version    = (ushort)user.Version;


                    uint ret = m_NBioAPI.Verify(m_biFIR, out result, myPayload);

                    if (result)
                    {
                        MessageBox.Show("Verificação bem Sucedida!!", "Projeto Biometria", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        this.Hide();
                        this.ShowIcon      = false;
                        this.ShowInTaskbar = false;
                        frmMain main = new frmMain(user);
                        main.ShowDialog();
                        this.ShowIcon      = true;
                        this.ShowInTaskbar = true;
                        this.Show();
                    }
                    else
                    {
                        MessageBox.Show("Verificação Incorreta! Tente novamente", "´Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
                m_NBioAPI.CloseDevice(NBioAPI.Type.DEVICE_ID.AUTO);
            }
        }
        private dynamic buscar(dynamic dados)
        {
            JObject objJson;


            //string url = "http://localhost:3200/api/biometrico";

            //var json = new WebClient().DownloadString(url);
            // dynamic m = JsonConvert.DeserializeObject( dados );

            uint    ret;
            bool    result;
            NBioAPI m_NBioAPI = new NBioAPI();

            NBioAPI.Type.HFIR           hCapturedFIR = new NBioAPI.Type.HFIR();
            NBioAPI.Type.FIR_TEXTENCODE m_textFIR    = new NBioAPI.Type.FIR_TEXTENCODE();
            NBioAPI.Type.FIR_PAYLOAD    myPayload    = new NBioAPI.Type.FIR_PAYLOAD();

            //m_textFIR.TextFIR = Digital.ToString();

            m_NBioAPI.OpenDevice(NBioAPI.Type.DEVICE_ID.AUTO);
            m_NBioAPI.Capture(out hCapturedFIR);
            dynamic retorno      = "-";
            int     idx          = -1;
            int     idxEncontrou = -1;

            foreach (dynamic obj in dados)
            {
                idx++;
                m_textFIR.TextFIR = obj.digital;
                ret = m_NBioAPI.VerifyMatch(hCapturedFIR, m_textFIR, out result, myPayload);
                if (result == true)
                {
                    idxEncontrou = idx;
                    break;
                }
            }
            if (idxEncontrou > -1)
            {
                string str1 = "{status: true, msg: 'Digital encontrada', indice: " + idxEncontrou + "}";
                objJson = JObject.Parse(str1);
                return(objJson);
            }
            string str = "{status: false, msg: 'Digital não encontrada'}";

            objJson = JObject.Parse(str);
            return(objJson);



            //return m;
        }
Esempio n. 6
0
        public Boolean ComparaFIR(String Text1, String Text2)
        {
            bool retorno;
            uint ret;

            NBioAPI.Type.FIR_TEXTENCODE texto1 = new NBioAPI.Type.FIR_TEXTENCODE();
            texto1.TextFIR = Text1;
            NBioAPI.Type.FIR_TEXTENCODE texto2 = new NBioAPI.Type.FIR_TEXTENCODE();
            texto2.TextFIR = Text2;
            NBioAPI.Type.FIR_PAYLOAD myPayload = new NBioAPI.Type.FIR_PAYLOAD();
            ret = m_NBioAPI.VerifyMatch(texto1, texto2, out retorno, myPayload);
            return(retorno);
        }
Esempio n. 7
0
        public bool VerificarDigitais(String digitalCapturada, String digitaisSalvas)
        {
            bool resultado = false;

            NBioAPI.Type.FIR_TEXTENCODE salvas    = ToFIR_TextEncode(digitaisSalvas);
            NBioAPI.Type.FIR_TEXTENCODE capturada = ToFIR_TextEncode(digitalCapturada);

            var  payload = new NBioAPI.Type.FIR_PAYLOAD();
            uint retorno = api.VerifyMatch(capturada, salvas, out resultado, payload);

            if (retorno == NBioAPI.Error.NONE)
            {
                return(resultado);
            }

            throw new Exception("Erro ao verificar digital: " + retorno);
        }
        public Task <int> CriarTaskParaIdentificacaoBiometrica(NBioAPI.Type.HFIR template, NBioAPI.IndexSearch mecanismoConfirmacao)
        {
            var contextoIdentificacao = new ContextoParaIndentificacaoBiometrica(Id, MecanismoBusca, mecanismoConfirmacao, Conversor, template, Biometrias);

            CancellationSource = new CancellationTokenSource();
            var token = CancellationSource.Token;

            return(new Task <int>((parametroState) =>
            {
                var contexto = parametroState as ContextoParaIndentificacaoBiometrica;

                if (token.IsCancellationRequested)
                {
                    return 0;
                }

                var encontrou = false;
                var relogio = new Stopwatch();
                relogio.Start();
                foreach (var biometria in contexto.Biometrias)
                {
                    if (token.IsCancellationRequested)
                    {
                        relogio.Stop();
                        Console.WriteLine($"{contexto.Id} - cancelado pois encontrado em outra thread {relogio.Elapsed.TotalSeconds}");
                        return 0;
                    }


                    var payload = new NBioAPI.Type.FIR_PAYLOAD();

                    NBioAPI.Type.HFIR handler;
                    contexto.Conversor.FDxToNBioBSPEx(biometria.TemplateISO, (uint)biometria.TemplateISO.Length, NBioAPI.Type.MINCONV_DATA_TYPE.MINCONV_TYPE_ISO,
                                                      NBioAPI.Type.FIR_PURPOSE.ENROLL_FOR_IDENTIFICATION_ONLY, out handler);

                    var retorno = contexto.MecanismoBusca.VerifyMatch(contexto.TemplateLido, handler, out encontrou, payload);
                    if (encontrou)
                    {
                        contexto.MecanismoConfirmacao.InitEngine();
                        NBioAPI.IndexSearch.FP_INFO[] informacaoBiometria;
                        var ret = contexto.MecanismoConfirmacao.AddFIR(handler, (uint)biometria.Id, out informacaoBiometria);

                        var cbInfo = new NBioAPI.IndexSearch.CALLBACK_INFO_0();
                        NBioAPI.IndexSearch.FP_INFO nitgenBiometria;
                        retorno = contexto.MecanismoConfirmacao.IdentifyData(contexto.TemplateLido, NBioAPI.Type.FIR_SECURITY_LEVEL.HIGH,
                                                                             out nitgenBiometria, cbInfo);

                        var idEncontrado = nitgenBiometria.ID;
                        contexto.MecanismoConfirmacao.RemoveUser((uint)biometria.Id);
                        if (idEncontrado > 0)
                        {
                            relogio.Stop();
                            Console.WriteLine($"{contexto.Id} - Localizado {biometria.Id} em {relogio.Elapsed.TotalSeconds}");
                            return (int)idEncontrado;
                        }
                    }
                }
                relogio.Stop();
                Console.WriteLine($"{contexto.Id} - Nenhuma biometria encontrada em {relogio.Elapsed.TotalSeconds}");
                return 0;
            }, contextoIdentificacao, token));
        }
        private void button1_Click_1(object sender, EventArgs e)
        {
            //code to capture the fingerprint data and then verify with the database record.
            //  call this method to set Window_option
            // m_BioAPI.SetWindowStyle(pbVerify.Handle.ToInt32(),true,false,false,false );
            SetInitValue(pbVerify.Handle.ToInt32());
            NBioAPI.Type.HFIR m_FIR;
            NBioAPI.Type.FIR_TEXTENCODE m1_textFIR;
            //validation for txtName textbox
            if (txtUserId.Text == "")
            {
                MessageBox.Show("Please Enter User Id to verify ", "Verifcation", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            //capture the fingerprint and then store the result in m_FIR and return ret as output
            uint ret = m_BioAPI.Capture(out m_FIR, NBioAPI.Type.TIMEOUT.DEFAULT, m_WinOption);
            if (ret == BioAPI.Error.NONE) //if no errors then extract the values from the DB and then match
            {

                m_BioAPI.GetTextFIRFromHandle(m_FIR, out m1_textFIR, true);
                lblMessage.Text = "Capture Successful !!";
                try
                {
                    //create a Sql Command
                    if (lblEType.Text.Equals("Doctor"))
                    {
                        SqlCommand cmd = new SqlCommand("Select * from doctor where DocId ='" + txtUserId.Text + "'");
                        cmd.Connection = con; //initilize the cmd object with the connection made
                        con.Open();//opens the connection
                        SqlDataReader reader = cmd.ExecuteReader(); //execute the command and then store the result in the reader object
                        string userID = "";
                        string Fpdata = "";
                        while (reader.Read())
                        {
                            userID = reader["DocId"].ToString();
                            Fpdata = reader["fingerprint"].ToString();

                        }
                        con.Close();//close the connection
                        //create a FIR_TextEncode object and then store the encoded image data in it
                        NBioAPI.Type.FIR_TEXTENCODE textFIR = new NBioAPI.Type.FIR_TEXTENCODE();
                        textFIR.TextFIR = Fpdata;
                        bool result;
                        //create a payload
                        NBioAPI.Type.FIR_PAYLOAD payload = new NBioAPI.Type.FIR_PAYLOAD();
                        m_BioAPI.VerifyMatch(textFIR, m1_textFIR, out result, payload); //verify
                        if (result) //if result is true then verified success else failed
                        {
                            DoctorMainForm bl = new DoctorMainForm();
                            bl.Show();
                            this.Close();

                        }
                        else
                            MessageBox.Show("Verification Failed !!! Try Again ");
                        //pbVerify.Image = null;

                        cmd.Dispose();
                    }

                    else if (lblEType.Text.Equals("Employee"))
                    {
                        SqlCommand cmd = new SqlCommand("Select * from Employee where EmpId ='" + txtUserId.Text + "'");
                        cmd.Connection = con; //initilize the cmd object with the connection made
                        con.Open();//opens the connection
                        SqlDataReader reader = cmd.ExecuteReader(); //execute the command and then store the result in the reader object
                        string userID = "";
                        string Fpdata = "";
                        while (reader.Read())
                        {
                            userID = reader["EmpId"].ToString();
                            Fpdata = reader["fingerprint"].ToString();

                        }
                        con.Close();//close the connection
                        //create a FIR_TextEncode object and then store the encoded image data in it
                        NBioAPI.Type.FIR_TEXTENCODE textFIR = new NBioAPI.Type.FIR_TEXTENCODE();
                        textFIR.TextFIR = Fpdata;
                        bool result;
                        //create a payload
                        NBioAPI.Type.FIR_PAYLOAD payload = new NBioAPI.Type.FIR_PAYLOAD();
                        m_BioAPI.VerifyMatch(textFIR, m1_textFIR, out result, payload); //verify
                        if (result) //if result is true then verified success else failed
                        {
                            EmployeeMainForm bl = new EmployeeMainForm();
                            bl.Show();
                            this.Close();
                        }
                        else
                            MessageBox.Show("Verification Failed !!! Try Again ");
                        //pbVerify.Image = null;

                        cmd.Dispose();
                    }
                    else
                    {
                        SqlCommand cmd = new SqlCommand("Select * from Administrator where AdminId ='" + txtUserId.Text + "'");
                        cmd.Connection = con; //initilize the cmd object with the connection made
                        con.Open();//opens the connection
                        SqlDataReader reader = cmd.ExecuteReader(); //execute the command and then store the result in the reader object
                        string userID = "";
                        string Fpdata = "";
                        while (reader.Read())
                        {
                            userID = reader["AdminId"].ToString();
                            Fpdata = reader["fingerprint"].ToString();

                        }
                        con.Close();//close the connection
                        //create a FIR_TextEncode object and then store the encoded image data in it
                        NBioAPI.Type.FIR_TEXTENCODE textFIR = new NBioAPI.Type.FIR_TEXTENCODE();
                        textFIR.TextFIR = Fpdata;
                        bool result;
                        //create a payload
                        NBioAPI.Type.FIR_PAYLOAD payload = new NBioAPI.Type.FIR_PAYLOAD();
                        m_BioAPI.VerifyMatch(textFIR, m1_textFIR, out result, payload); //verify
                        if (result) //if result is true then verified success else failed
                        {
                            AdminMainForm bl = new AdminMainForm();
                            bl.Show();
                            this.Close();
                        }
                        else
                            MessageBox.Show("Verification Failed !!! Try Again ");
                        //pbVerify.Image = null;

                        cmd.Dispose();
                    }

                }

                catch (Exception ex)
                {
                    lblMessage.Text = "Database Exceptiom occured..";
                }
            }
            else
            {
                MessageBox.Show("Capture process Failed !!!");
            }
        }