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("");
            }
        }
        static void Main(string[] args)
        {
            try
            {
                var corConsoleDefault = Console.ForegroundColor;
                var repositorio       = new DigitaisRepositorio();
                var handler           = new IdentificarBiometriaHandler();

                var numeroTotalBiometrias = repositorio.RecuperarNumeroTotalBiometrias();
                var biometriasPorPagina   = (numeroTotalBiometrias / Environment.ProcessorCount) + 10;
                for (int pagina = 1; pagina <= Environment.ProcessorCount; pagina++)
                {
                    var biometriasRecuperadas = repositorio.RecuperarPagina(pagina, biometriasPorPagina);
                    handler.AdicionarMecanismoBuscaPara(biometriasRecuperadas);
                }

                // Captura da digital (trocar para o que vem da catraca posteriormente)
                var nitgenMainApi = new NBioAPI();

                var possoSair = false;
                while (!possoSair)
                {
                    Console.WriteLine("Informe a digital");

                    NBioAPI.Type.HFIR template;
                    var window = new NBioAPI.Type.WINDOW_OPTION();
                    nitgenMainApi.OpenDevice(NBioAPI.Type.DEVICE_ID.AUTO);
                    nitgenMainApi.Capture(out template, 0, window);
                    nitgenMainApi.CloseDevice(NBioAPI.Type.DEVICE_ID.AUTO);

                    var relogio = new Stopwatch();
                    relogio.Start();
                    Console.ForegroundColor = ConsoleColor.Green;
                    Console.WriteLine("Identificando.....");
                    Console.ForegroundColor = corConsoleDefault;
                    var resultado = handler.IdentificarBiometria(template);
                    relogio.Stop();
                    Console.ForegroundColor = ConsoleColor.Green;
                    Console.WriteLine($"Id digital encontrada {resultado} em {relogio.Elapsed.TotalSeconds} segundos");
                    Console.ForegroundColor = corConsoleDefault;

                    Console.WriteLine();

                    Console.WriteLine("\nCapturar nova digital?");
                    var tecla = Console.ReadKey();
                    if (tecla.Key == ConsoleKey.N)
                    {
                        possoSair = true;
                    }
                }
            }
            catch (Exception ex)
            {
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine($"ERRO {ex.Message} - {ex.StackTrace}");
                throw;
            }
        }
        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;
        }
        public string Identificar(string Digital)
        {
            NBioAPI m_NBioAPI = new NBioAPI();

            NBioAPI.Type.FIR_TEXTENCODE m_textFIR = new NBioAPI.Type.FIR_TEXTENCODE();
            //NBioAPI.Type.HFIR NewFIR;
            NBioAPI.IndexSearch           m_IndexSearch = new NBioAPI.IndexSearch(m_NBioAPI);
            NBioAPI.Type.HFIR             hCapturedFIR;
            NBioAPI.IndexSearch.FP_INFO[] fpInfo;


            NBioAPI.Type.WINDOW_OPTION m_WinOption = new NBioAPI.Type.WINDOW_OPTION();
            m_WinOption.WindowStyle = (uint)NBioAPI.Type.WINDOW_STYLE.NO_WELCOME;

            uint ID = 1;

            m_textFIR.TextFIR = Digital;
            m_IndexSearch.AddFIR(m_textFIR, ID, out fpInfo);

            uint dataCount;

            m_IndexSearch.GetDataCount(out dataCount);

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

            if (ret != NBioAPI.Error.NONE)
            {
                //DisplayErrorMsg(ret);
                m_NBioAPI.CloseDevice(NBioAPI.Type.DEVICE_ID.AUTO);
                m_NBioAPI.GetTextFIRFromHandle(hCapturedFIR, out m_textFIR, true);
            }

            m_NBioAPI.CloseDevice(NBioAPI.Type.DEVICE_ID.AUTO);


            NBioAPI.IndexSearch.FP_INFO         fpInfo2;
            NBioAPI.IndexSearch.CALLBACK_INFO_0 cbInfo0 = new NBioAPI.IndexSearch.CALLBACK_INFO_0();
            cbInfo0.CallBackFunction = new NBioAPI.IndexSearch.INDEXSEARCH_CALLBACK(myCallback);

            // Identify FIR to IndexSearch DB
            ret = m_IndexSearch.IdentifyData(hCapturedFIR, NBioAPI.Type.FIR_SECURITY_LEVEL.NORMAL, out fpInfo2, cbInfo0);
            if (ret != NBioAPI.Error.NONE)
            {
                //DisplayErrorMsg(ret);
                //return fpInfo2.ID.ToString();
                return(m_textFIR.TextFIR);
            }

            return("");
        }
Example #5
0
        public string CapturarDigitalParaVerificacao()
        {
            NBioAPI.Type.HFIR template = new NBioAPI.Type.HFIR();

            uint retorno = api.Capture(out template);

            if (retorno == NBioAPI.Error.NONE)
            {
                NBioAPI.Type.FIR_TEXTENCODE binario = new NBioAPI.Type.FIR_TEXTENCODE();
                api.GetTextFIRFromHandle(template, out binario, false);
                return(binario.TextFIR);
            }

            throw new Exception("Erro ao capturar a digital.");
        }
        public string Capturar()
        {
            NBioAPI m_NBioAPI = new NBioAPI();

            NBioAPI.Type.HFIR           hCapturedFIR = new NBioAPI.Type.HFIR();
            NBioAPI.Type.FIR_TEXTENCODE texto        = new NBioAPI.Type.FIR_TEXTENCODE();
            // Get FIR data

            m_NBioAPI.OpenDevice(255);

            m_NBioAPI.Capture(out hCapturedFIR);
            m_NBioAPI.GetTextFIRFromHandle(hCapturedFIR, out texto, true);


            return(texto.TextFIR);
        }
Example #7
0
        private void Button1_Click(object sender, EventArgs e)
        {
            m_WinOption.WindowStyle = NBioAPI.Type.WINDOW_STYLE.INVISIBLE;
            retorno_para_exportar   = new NBioAPI.Type.HFIR();
            m_hNewFIR = new NBioAPI.Type.HFIR();
            m_NBioAPI.OpenDevice(255);
            uint ret = m_NBioAPI.Capture(NBioAPI.Type.FIR_PURPOSE.VERIFY, out m_hNewFIR, -1, retorno_para_exportar, m_WinOption);

            m_NBioAPI.GetTextFIRFromHandle(m_hNewFIR, out m_textFIR, true);
            Console.WriteLine("texto com m_new1 " + m_textFIR.TextFIR);
            m_textFIR = null;
            m_NBioAPI.GetTextFIRFromHandle(retorno_para_exportar, out m_textFIR, true);
            Console.WriteLine("text com retorno com retorno_para_exportar " + m_textFIR.TextFIR);
            bmp          = utils.Conversor(m_textFIR);
            ptb_fp.Image = bmp;
        }
        private void btnIdentify_Click(object sender, System.EventArgs e)
        {
            NBioAPI.Type.HFIR hCapturedFIR;

            listResult.Items.Clear();

            // Get FIR data
            m_NBioAPI.OpenDevice(NBioAPI.Type.DEVICE_ID.AUTO);
            uint ret = m_NBioAPI.Capture(out hCapturedFIR);

            if (ret != NBioAPI.Error.NONE)
            {
                DisplayErrorMsg(ret);
                m_NBioAPI.CloseDevice(NBioAPI.Type.DEVICE_ID.AUTO);
                return;
            }

            m_NBioAPI.CloseDevice(NBioAPI.Type.DEVICE_ID.AUTO);


            uint nMax;

            m_IndexSearch.GetDataCount(out nMax);
            progressIdentify.Minimum = 0;
            progressIdentify.Maximum = Convert.ToInt32(nMax);

            NBioAPI.IndexSearch.CALLBACK_INFO_0 cbInfo0 = new NBioAPI.IndexSearch.CALLBACK_INFO_0();
            cbInfo0.CallBackFunction = new NBioAPI.IndexSearch.INDEXSEARCH_CALLBACK(myCallback);

            // Identify FIR to IndexSearch DB
            NBioAPI.IndexSearch.FP_INFO fpInfo;
            ret = m_IndexSearch.IdentifyData(hCapturedFIR, NBioAPI.Type.FIR_SECURITY_LEVEL.NORMAL, out fpInfo, cbInfo0);
            if (ret != NBioAPI.Error.NONE)
            {
                DisplayErrorMsg(ret);
                return;
            }

            // Add item to list of result
            ListViewItem listItem = new ListViewItem();

            listItem.Text = fpInfo.ID.ToString();
            listItem.SubItems.Add(fpInfo.FingerID.ToString());
            listItem.SubItems.Add(fpInfo.SampleNumber.ToString());
            listResult.Items.Add(listItem);
        }
Example #9
0
        public string Capturar()
        {
            NBioAPI.Type.HFIR           hCapturedFIR      = new NBioAPI.Type.HFIR();
            NBioAPI.Type.HFIR           hCapturedFIRaudit = new NBioAPI.Type.HFIR();
            NBioAPI.Type.FIR_TEXTENCODE texto             = new NBioAPI.Type.FIR_TEXTENCODE();
            //Get FIR data
            uint device = m_NBioAPI.OpenDevice(255);

            if (device != NBioAPI.Error.NONE)
            {
                return(null);
            }
            m_NBioAPI.Capture(NBioAPI.Type.FIR_PURPOSE.VERIFY, out hCapturedFIR, -1, hCapturedFIRaudit, null);
            m_NBioAPI.GetTextFIRFromHandle(hCapturedFIR, out texto, true);
            m_NBioAPI.CloseDevice(255);
            return(texto.TextFIR);
        }
        static void Main(string[] args)
        {
            var repositorio       = new DigitaisRepositorio();
            var nitgenMainApi     = new NBioAPI();
            var handler           = new IdentificarBiometriaHandler();
            var corConsoleDefault = Console.ForegroundColor;

            var biometrias = repositorio.RecuperarPagina(1, 8000);

            Console.WriteLine($"{biometrias.Count()} biometrias recuperadas...");
            handler.CarregarBiometrias(biometrias);

            var possoSair = false;

            while (!possoSair)
            {
                Console.WriteLine("Informe a digital");

                NBioAPI.Type.HFIR template;
                var window = new NBioAPI.Type.WINDOW_OPTION();
                nitgenMainApi.OpenDevice(NBioAPI.Type.DEVICE_ID.AUTO);
                nitgenMainApi.Capture(out template, 0, window);
                nitgenMainApi.CloseDevice(NBioAPI.Type.DEVICE_ID.AUTO);

                var relogio = new Stopwatch();
                relogio.Start();
                Console.ForegroundColor = ConsoleColor.Green;
                Console.WriteLine("Identificando.....");
                Console.ForegroundColor = corConsoleDefault;
                var resultado = handler.IdentificarBiometria(template);
                relogio.Stop();
                Console.ForegroundColor = ConsoleColor.Green;
                Console.WriteLine($"Id digital encontrada {resultado} em {relogio.Elapsed.TotalSeconds} segundos");
                Console.ForegroundColor = corConsoleDefault;

                Console.WriteLine();

                Console.WriteLine("\nCapturar nova digital?");
                var tecla = Console.ReadKey();
                if (tecla.Key == ConsoleKey.N)
                {
                    possoSair = true;
                }
            }
        }
        //Captura uma digital e verifica se bate com alguma FIR cadastrada no banco, caso sim, retorna o ID do usuário.
        //@return ID do usuário.
        public long verificaIdentidade()
        {
            //Variavel que vai estar com o template capturado pelo leitor
            NBioAPI.Type.HFIR digitalCapturada;

            //Captura a digital do promotor
            m_NBioAPI.Capture(out digitalCapturada, NBioAPI.Type.TIMEOUT.INFINITE, m_WinOption);

            //Cria variável do callback
            NBioAPI.IndexSearch.CALLBACK_INFO_0 cbInfo0 = new NBioAPI.IndexSearch.CALLBACK_INFO_0();

            //Cria variável que vai receber as informações da digital
            NBioAPI.IndexSearch.FP_INFO fpInfo;

            //Pega a digital capturada, e compara para ver se é encontrada uma digital compatível no banco
            m_IndexSearch.IdentifyData(digitalCapturada, NBioAPI.Type.FIR_SECURITY_LEVEL.NORMAL, out fpInfo, cbInfo0);

            //retorna o id do usuário como inteiro
            return(Convert.ToUInt32(fpInfo.ID));
        }
        public Byte[] Capturar(int id)
        {
            NBioAPI m_NBioAPI = new NBioAPI();

            NBioAPI.Type.INIT_INFO_0 initInfo0;
            uint ret = m_NBioAPI.GetInitInfo(out initInfo0);

            Console.WriteLine("passeiaqui");
            if (ret == NBioAPI.Error.NONE)
            {
                initInfo0.EnrollImageQuality = Convert.ToUInt32(50);
                initInfo0.VerifyImageQuality = Convert.ToUInt32(30);
                initInfo0.DefaultTimeout     = Convert.ToUInt32(10000);
                initInfo0.SecurityLevel      = (int)NBioAPI.Type.FIR_SECURITY_LEVEL.NORMAL - 1;
            }

            NBioAPI.IndexSearch         m_IndexSearch = new NBioAPI.IndexSearch(m_NBioAPI);
            NBioAPI.Type.HFIR           hCapturedFIR;
            NBioAPI.Type.HFIR           AuditData = new NBioAPI.Type.HFIR();
            NBioAPI.Type.FIR_TEXTENCODE texto;
            // Get FIR data
            m_NBioAPI.OpenDevice(NBioAPI.Type.DEVICE_ID.AUTO);
            m_NBioAPI.Capture(NBioAPI.Type.FIR_PURPOSE.DENTIFY, out hCapturedFIR, -1, AuditData, null);
            //Console.WriteLine(Encoding.Default.GetString(getfingerImage(AuditData)));

            try
            {
                if (hCapturedFIR != null)
                {
                    return(getfingerImage(AuditData));
                }
                return(null);
            }
            catch (Exception ex)
            {
                throw new Exception("ERRO:... " + ex.Message);
            }
        }
        public string Capturar(int id)
        {
            NBioAPI m_NBioAPI = new NBioAPI();

            NBioAPI.Type.INIT_INFO_0 initInfo0;
            uint ret = m_NBioAPI.GetInitInfo(out initInfo0);

            if (ret == NBioAPI.Error.NONE)
            {
                initInfo0.EnrollImageQuality = Convert.ToUInt32(50);
                initInfo0.VerifyImageQuality = Convert.ToUInt32(30);
                initInfo0.DefaultTimeout     = Convert.ToUInt32(10000);
                initInfo0.SecurityLevel      = (int)NBioAPI.Type.FIR_SECURITY_LEVEL.NORMAL - 1;
            }

            NBioAPI.IndexSearch         m_IndexSearch = new NBioAPI.IndexSearch(m_NBioAPI);
            NBioAPI.Type.HFIR           hCapturedFIR;
            NBioAPI.Type.FIR_TEXTENCODE texto;
            // Get FIR data
            m_NBioAPI.OpenDevice(NBioAPI.Type.DEVICE_ID.AUTO);
            m_NBioAPI.Capture(out hCapturedFIR);

            try
            {
                if (hCapturedFIR != null)
                {
                    m_NBioAPI.GetTextFIRFromHandle(hCapturedFIR, out texto, true);
                    return(texto.TextFIR);
                }
                return(null);
            }
            catch (Exception ex)
            {
                throw new Exception("ERRO:... " + ex.Message);
            }
        }
Example #14
0
        private void btnCadastrar_Click(object sender, EventArgs e)
        {
            userC = new UserController();
            user  = new User();

            if (txtUsuario.Text == "")
            {
                MessageBox.Show("Favor, preencher o campo de usuário", "Projeto Biometria", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                txtUsuario.Focus();
            }
            else if (txtNome.Text == "")
            {
                MessageBox.Show("Favor, preencher o campo de nome", "Projeto Biometria", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                txtNome.Focus();
            }
            else if (txtEmail.Text == "")
            {
                MessageBox.Show("Favor, preencher o campo de email", "Projeto Biometria", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                txtEmail.Focus();
            }
            else if (txtSenha.Text == "")
            {
                MessageBox.Show("Favor, preencher o campo de senha", "Projeto Biometria", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                txtSenha.Focus();
            }
            else
            {
                NBioAPI.Type.FIR heFIR = new NBioAPI.Type.FIR();

                m_NBioAPI = new NBioAPI();
                NBioAPI.Type.HFIR NewFIR;

                uint reta = m_NBioAPI.OpenDevice(NBioAPI.Type.DEVICE_ID.AUTO);

                // m_NBioAPI.Enroll(out NewFIR,  null);
                uint ret = m_NBioAPI.Capture(NBioAPI.Type.FIR_PURPOSE.VERIFY, out NewFIR, NBioAPI.Type.TIMEOUT.DEFAULT, null, null);
                if (ret == NBioAPI.Error.NONE)
                {
                    if (NewFIR != null)
                    {
                        m_NBioAPI.GetFIRFromHandle(NewFIR, out m_biFIR);

                        user.NomeCompleto = txtNome.Text;
                        user.Usuario      = txtUsuario.Text;
                        user.Senha        = txtSenha.Text;
                        user.Email        = txtEmail.Text;
                        user.NivelAcesso  = 3;
                        user.Digital      = m_biFIR.Data;
                        user.Imagem       = m_biFIR.Data;
                        user.Format       = Convert.ToInt32(m_biFIR.Format.ToString());
                        user.DataLength   = Convert.ToInt32(m_biFIR.Header.DataLength.ToString());
                        user.DataType     = Convert.ToInt32(m_biFIR.Header.DataType.ToString());
                        user.Purpose      = Convert.ToInt32(m_biFIR.Header.Purpose.ToString());
                        user.Length       = Convert.ToInt32(m_biFIR.Header.Length.ToString());
                        user.Quality      = Convert.ToInt32(m_biFIR.Header.Quality.ToString());
                        user.Reserved     = Convert.ToInt32(m_biFIR.Header.Reserved.ToString());
                        user.Version      = Convert.ToInt32(m_biFIR.Header.Version.ToString());

                        userC.insertUser(user);

                        MessageBox.Show("Usuário Administrador cadastrado com sucesso!", "Projeto Biometria", MessageBoxButtons.OK, MessageBoxIcon.Information);

                        frmLogin login = new frmLogin();
                        this.Hide();
                        this.ShowIcon      = false;
                        this.ShowInTaskbar = false;
                        login.ShowDialog();
                        Application.Exit();
                    }
                }
                else
                {
                    MessageBox.Show("Erro ao cadastrar digital, tente novamente!", "Projeto Biometria", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                m_NBioAPI.CloseDevice(NBioAPI.Type.DEVICE_ID.AUTO);
            }
        }
Example #15
0
        public void Gravar(string Arquivo, string PathSalvamento)
        {
            //Declaracao de variaveis
            NBioAPI HandleBio;
            uint    Retorno     = NBioAPI.Error.NONE;
            uint    NenhumErro  = NBioAPI.Error.NONE;
            short   Dispositivo = NBioAPI.Type.DEVICE_ID.AUTO;

            NBioAPI.Type.HFIR CapturedFir;
            NBioAPI.Export    export;
            NBioAPI.Type.MINCONV_DATA_TYPE tipo;
            NBioAPI.Export.EXPORT_DATA     exportDados;
            NBioAPI.Type.INIT_INFO_0       initInfo0;
            //-----------------------
            //-----------------------
            HandleBio = new NBioAPI();
            Retorno   = HandleBio.OpenDevice(Dispositivo);
            if (Retorno != NenhumErro)
            {
                MessageBox.Show("Erro ao cadastrar biometria", "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error);
                HandleBio.Dispose();
                return;
            }

            Retorno = HandleBio.GetInitInfo(out initInfo0);
            if (Retorno != NenhumErro)
            {
                MessageBox.Show("Erro ao coletar informações do dispositivo", "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error);
                HandleBio.Dispose();
                return;
            }
            initInfo0.EnrollImageQuality = 90;
            initInfo0.VerifyImageQuality = 90;
            initInfo0.SecurityLevel      = 7;
            Retorno = HandleBio.SetInitInfo(initInfo0);
            if (Retorno != NenhumErro)
            {
                MessageBox.Show("Erro ao setar informações iniciais do dispositivo", "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error);
                HandleBio.Dispose();
                return;
            }

            Retorno = HandleBio.Capture(NBioAPI.Type.FIR_PURPOSE.VERIFY, out CapturedFir, NBioAPI.Type.TIMEOUT.DEFAULT, null, null);
            if (Retorno != NenhumErro)
            {
                MessageBox.Show("Erro ao cadastrar biometria", "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error);
                HandleBio.CloseDevice(Dispositivo);
                HandleBio.Dispose();
                return;
            }

            export = new NBioAPI.Export(HandleBio);
            tipo   = NBioAPI.Type.MINCONV_DATA_TYPE.MINCONV_TYPE_FDU;
            export.NBioBSPToFDx(CapturedFir, out exportDados, tipo);

            for (int f = 0; f < exportDados.FingerNum; f++)
            {
                for (int s = 0; s < exportDados.SamplesPerFinger; s++)
                {
                    try
                    {
                        FileStream   fs = new FileStream(PathSalvamento + Arquivo, FileMode.OpenOrCreate, FileAccess.Write);
                        BinaryWriter fw = new BinaryWriter(fs);

                        fw.Write(exportDados.FingerData[f].Template[s].Data);

                        fw.Close();
                        fs.Close();
                    }
                    catch (FileNotFoundException e)
                    {
                        MessageBox.Show("Erro criar template biometrico\n" + e.Message, "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        HandleBio.CloseDevice(Dispositivo);
                        HandleBio.Dispose();
                        return;
                    }
                }
            }
            HandleBio.CloseDevice(Dispositivo);
            HandleBio.Dispose();
        }
    public void Identify_user()
    {
        NBioAPI.Type.HFIR hCapturedFIR;
        // Get FIR data
        m_NBioAPI.OpenDevice(NBioAPI.Type.DEVICE_ID.AUTO);
        uint ret = m_NBioAPI.Capture(out hCapturedFIR);

        if (ret != NBioAPI.Error.NONE)
        {
            Response.Write("" + ret);
            m_NBioAPI.CloseDevice(NBioAPI.Type.DEVICE_ID.AUTO);
            return;
        }

        m_NBioAPI.CloseDevice(NBioAPI.Type.DEVICE_ID.AUTO);


        uint nMax;

        m_IndexSearch.GetDataCount(out nMax);


        NBioAPI.IndexSearch.CALLBACK_INFO_0 cbInfo0 = new NBioAPI.IndexSearch.CALLBACK_INFO_0();
        cbInfo0.CallBackFunction = new NBioAPI.IndexSearch.INDEXSEARCH_CALLBACK(myCallback);

        // Identify FIR to IndexSearch DB
        NBioAPI.IndexSearch.FP_INFO fpInfo;
        ret = m_IndexSearch.IdentifyData(hCapturedFIR, NBioAPI.Type.FIR_SECURITY_LEVEL.NORMAL, out fpInfo, cbInfo0);
        if (ret != NBioAPI.Error.NONE)
        {
            //Response.Write("" + ret);
            lbldest.Text = "The FingerPrint does not match!!";
            return;
        }

        // Add item to list of result
        String    sell = "select * from tbl_userreg where user_username='******'";
        DataTable dt2  = obj.GetDataTable(sell);



        string selq = " select * from tbl_aadhar where userdb_aadharno='" + dt2.Rows[0]["user_aadharno"] + "' ";

        DataTable dtt1  = obj.GetDataTable(selq);
        string    selID = "select max(punch_id) as pid from tbl_punch where punch_aadharno='" + dt2.Rows[0]["user_aadharno"] + "'";
        DataTable dt1   = obj.GetDataTable(selID);
        string    selI  = "select * from tbl_punch where punch_id='" + dt1.Rows[0]["pid"] + "'";
        DataTable dt11  = obj.GetDataTable(selI);

        Session["valid"]    = Convert.ToInt32(dt1.Rows[0]["pid"]);
        Session["aadharno"] = Convert.ToInt32(dtt1.Rows[0]["userdb_aadharno"]);
        String up = "update tbl_punch set punch_dname='" + drpdest.SelectedValue + "' where punch_id='" + Session["valid"] + "'";

        obj.ExecuteCommand(up);

        String    se = "select * from tbl_station where station_no='" + drpdest.SelectedValue + "'";
        DataTable st = obj.GetDataTable(se);

        String    see = "select * from tbl_station where station_no='" + dt11.Rows[0]["punch_sname"] + "'";
        DataTable stt = obj.GetDataTable(see);
        String    sel = "select * from tbl_route where route_from='" + stt.Rows[0]["station_name"] + "' and route_to='" + st.Rows[0]["station_name"] + "'";
        DataTable dt  = obj.GetDataTable(sel);
        Double    r   = Convert.ToDouble(dt.Rows[0]["route_distance"]);

        String    sele = "select * from tbl_rate where distance=" + dt.Rows[0]["route_distance"] + "";
        DataTable dtt  = obj.GetDataTable(sele);
        Double    amt  = Convert.ToInt32(dtt.Rows[0]["rate"]) * Convert.ToInt32(dt11.Rows[0]["punch_tickets"]);

        String    ss  = "select * from tbl_vallet where useradhar_no='" + Session["aadharno"] + "'";
        DataTable val = obj.GetDataTable(ss);
        double    rr  = Convert.ToInt32(val.Rows[0]["val_amount"]);

        rr = rr - amt;

        String upp = "update tbl_punch set punch_dist='" + dt.Rows[0]["route_distance"] + "',punch_amt='" + amt + "' where punch_aadharno='" + Session["aadharno"] + "' and punch_id='" + Session["valid"] + "'";

        obj.ExecuteCommand(upp);
        string    selI2 = "select train_vcapacity from tbl_train where train_id='" + dt11.Rows[0]["punch_trainid"] + "'";
        DataTable dt112 = obj.GetDataTable(selI2);
        Double    a2    = Convert.ToInt32(dt112.Rows[0]["train_vcapacity"]) + Convert.ToInt32(dt11.Rows[0]["punch_tickets"]);
        String    sep   = "update tbl_train set train_vcapacity='" + a2 + "' where train_id='" + dt11.Rows[0]["punch_trainid"] + "'";

        obj.ExecuteCommand(sep);


        if (rr > 0)
        {
            String str = "update tbl_vallet set val_amount='" + rr + "' where useradhar_no='" + Session["aadharno"] + "'";
            obj.ExecuteCommand(str);
            Mail();

            Response.Redirect("thanks.aspx");
            //Response.Write("success");
        }
        else
        {
            Response.Write("<script>alert('Insufficient Balance')</script>");
        }
    }
Example #17
0
        public void Capture(short Dispositivo, PictureBox Pct, Label labelImgQuality, Label LblFinalizacaoSelecionado, TipoDedo Dedo, TipoMao Mao, out NBioAPI.Type.FIR MyFir, out NBioAPI.Type.FIR_TEXTENCODE textFIR, bool Infinito)
        {
            LabelQualidadeSelecionado   = labelImgQuality;
            LabelFinalizacaoSelecionado = LblFinalizacaoSelecionado;

            m_WinOption.WindowStyle            = NBioAPI.Type.WINDOW_STYLE.INVISIBLE;
            m_WinOption.Option2.FPForeColor[0] = Convert.ToByte("00", 16);
            m_WinOption.Option2.FPForeColor[1] = Convert.ToByte("00", 16);
            m_WinOption.Option2.FPForeColor[2] = Convert.ToByte("00", 16);
            m_WinOption.Option2.FPBackColor[0] = Convert.ToByte("FF", 16);
            m_WinOption.Option2.FPBackColor[1] = Convert.ToByte("FF", 16);
            m_WinOption.Option2.FPBackColor[2] = Convert.ToByte("FF", 16);


            m_WinOption.FingerWnd = (uint)Pct.Handle.ToInt32();


            // Callback funtion
            m_WinOption.CaptureCallBackInfo = new NBioAPI.Type.CALLBACK_INFO_0();
            m_WinOption.CaptureCallBackInfo.CallBackFunction = new NBioAPI.Type.WINDOW_CALLBACK_0(MyCaptureCallback);
            m_WinOption.FinishCallBackInfo = new NBioAPI.Type.CALLBACK_INFO_1();
            m_WinOption.FinishCallBackInfo.CallBackFunction = new NBioAPI.Type.WINDOW_CALLBACK_1(MyFinishCallback);


            // Select finger for enrollment
            if (Mao == Biometria.TipoMao.Direita)
            {
                m_WinOption.Option2.DisableFingerForEnroll[0] = (byte)NBioAPI.Type.TRUE;
                m_WinOption.Option2.DisableFingerForEnroll[1] = (byte)NBioAPI.Type.TRUE;
                m_WinOption.Option2.DisableFingerForEnroll[2] = (byte)NBioAPI.Type.TRUE;
                m_WinOption.Option2.DisableFingerForEnroll[3] = (byte)NBioAPI.Type.TRUE;
                m_WinOption.Option2.DisableFingerForEnroll[4] = (byte)NBioAPI.Type.TRUE;
                m_WinOption.Option2.DisableFingerForEnroll[5] = (byte)NBioAPI.Type.TRUE;
                m_WinOption.Option2.DisableFingerForEnroll[6] = (byte)NBioAPI.Type.TRUE;
                m_WinOption.Option2.DisableFingerForEnroll[7] = (byte)NBioAPI.Type.TRUE;
                m_WinOption.Option2.DisableFingerForEnroll[8] = (byte)NBioAPI.Type.TRUE;
                m_WinOption.Option2.DisableFingerForEnroll[9] = (byte)NBioAPI.Type.TRUE;

                switch (Dedo)
                {
                case Biometria.TipoDedo.Anelar:
                {
                    m_WinOption.Option2.DisableFingerForEnroll[3] = NBioAPI.Type.FALSE;
                    break;
                }

                case Biometria.TipoDedo.Indicador:
                {
                    m_WinOption.Option2.DisableFingerForEnroll[1] = NBioAPI.Type.FALSE;
                    break;
                }

                case Biometria.TipoDedo.Médio:
                {
                    m_WinOption.Option2.DisableFingerForEnroll[2] = (byte)NBioAPI.Type.FALSE;
                    break;
                }

                case Biometria.TipoDedo.Mínimo:
                {
                    m_WinOption.Option2.DisableFingerForEnroll[4] = NBioAPI.Type.FALSE;
                    break;
                }

                case Biometria.TipoDedo.Polegar:
                {
                    m_WinOption.Option2.DisableFingerForEnroll[0] = NBioAPI.Type.FALSE;
                    break;
                }
                }
            }
            else
            {
                switch (Dedo)
                {
                case Biometria.TipoDedo.Anelar:
                {
                    m_WinOption.Option2.DisableFingerForEnroll[8] = NBioAPI.Type.FALSE;
                    break;
                }

                case Biometria.TipoDedo.Indicador:
                {
                    m_WinOption.Option2.DisableFingerForEnroll[6] = NBioAPI.Type.FALSE;
                    break;
                }

                case Biometria.TipoDedo.Médio:
                {
                    m_WinOption.Option2.DisableFingerForEnroll[7] = (byte)NBioAPI.Type.FALSE;
                    break;
                }

                case Biometria.TipoDedo.Mínimo:
                {
                    m_WinOption.Option2.DisableFingerForEnroll[9] = NBioAPI.Type.FALSE;
                    break;
                }

                case Biometria.TipoDedo.Polegar:
                {
                    m_WinOption.Option2.DisableFingerForEnroll[5] = NBioAPI.Type.FALSE;
                    break;
                }
                }
            }

            NBioAPI.Type.HFIR hCapturedFIR;
            m_NBioAPI.OpenDevice(NBioAPI.Type.DEVICE_ID.AUTO);
            if (Infinito)
            {
                m_NBioAPI.Capture(out hCapturedFIR, NBioAPI.Type.TIMEOUT.INFINITE, m_WinOption);
            }
            else
            {
                m_NBioAPI.Capture(out hCapturedFIR, NBioAPI.Type.TIMEOUT.DEFAULT, m_WinOption);
            }
            try
            {
                m_NBioAPI.GetFIRFromHandle(hCapturedFIR, out MyFir);
                m_NBioAPI.GetTextFIRFromHandle(hCapturedFIR, out textFIR, true);
                m_NBioAPI.CloseDevice(Dispositivo);
            }
            catch (Exception ex)
            {
                textFIR = null;
                MyFir   = null;
            }
        }
Example #18
0
        private void ISOV2_Click(object sender, EventArgs e)
        {
            string szTemp;

            listRet.Items.Clear();
            listRet.Items.Add("OpenDevice start...");

            uint nRet = m_NBioAPI.OpenDevice(NBioAPI.Type.DEVICE_ID.AUTO);

            if (nRet == NBioAPI.Error.NONE)
            {
                NBioAPI.Type.HFIR hFIR, hAuditFIR;

                hAuditFIR = new NBioAPI.Type.HFIR();

                listRet.Items.Add("Enroll start...");

                m_NBioAPI.Capture(NBioAPI.Type.FIR_PURPOSE.VERIFY, out hFIR, NBioAPI.Type.TIMEOUT.DEFAULT, hAuditFIR, null);

                if (nRet == NBioAPI.Error.NONE)
                {
                    NBioAPI.Export.EXPORT_AUDIT_DATA exportData;

                    listRet.Items.Add("NBioBSPToImage start...");

                    nRet = m_Export.NBioBSPToImage(hAuditFIR, out exportData);

                    if (nRet == NBioAPI.Error.NONE)
                    {
                        byte[] ISOBuf;

                        listRet.Items.Add("ExportRawToISOV2 start...");

                        nRet = NBioBSPISO4.ExportRawToISOV2((byte)NBioAPI.Type.FINGER_ID.LEFT_INDEX, (ushort)exportData.ImageWidth, (ushort)exportData.ImageHeight,
                                                            exportData.AuditData[0].Image[0].Data, false, NBioBSPISO4.COMPRESS_MOD.NONE, out ISOBuf);

                        if (nRet == NBioAPI.Error.NONE)
                        {
                            NBioBSPISO4.NIMPORTRAWSET ImportRawSet;

                            listRet.Items.Add("ImportISOToRaw start...");

                            nRet = NBioBSPISO4.ImportISOToRaw(ISOBuf, out ImportRawSet);

                            if (nRet == NBioAPI.Error.NONE)
                            {
                                listRet.Items.Add("Test result");

                                for (byte i = 0; i < ImportRawSet.nDataCount; i++)
                                {
                                    szTemp = "DataLen: " + ImportRawSet.ImportRawData[i].RawData.Length;
                                    listRet.Items.Add(szTemp);

                                    szTemp = "FingerID: " + ImportRawSet.ImportRawData[i].nFingerID;
                                    listRet.Items.Add(szTemp);

                                    szTemp = "Image Width: " + ImportRawSet.ImportRawData[i].nImgWidth;
                                    listRet.Items.Add(szTemp);

                                    szTemp = "Image Height: " + ImportRawSet.ImportRawData[i].nImgHeight;
                                    listRet.Items.Add(szTemp);
                                }
                            }
                            else
                            {
                                szTemp = "ImportISOToRaw Error: " + nRet;
                                listRet.Items.Add(szTemp);
                            }
                        }
                        else
                        {
                            szTemp = "ExportRawToISOV2 Error: " + nRet;
                            listRet.Items.Add(szTemp);
                        }
                    }
                    else
                    {
                        szTemp = "NBioBSPToImage Error: " + nRet;
                        listRet.Items.Add(szTemp);
                    }

                    hFIR.Dispose();
                    hAuditFIR.Dispose();
                }
                else
                {
                    szTemp = "Capture Error: " + nRet;
                    listRet.Items.Add(szTemp);
                }

                m_NBioAPI.CloseDevice(NBioAPI.Type.DEVICE_ID.AUTO);
            }
            else
            {
                szTemp = "CloseDevice Error: " + nRet;
                listRet.Items.Add(szTemp);
            }
        }
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                var contextosIdentificacao = new List <BiometriaIndentificacaoContexto>();
                _tasks = new ConcurrentBag <DigitalTask>();

                // Captura da digital (trocar para o que vem da catraca posteriormente)
                var nitgenMainApi = new NBioAPI();
                NBioAPI.Type.HFIR template;
                var window = new NBioAPI.Type.WINDOW_OPTION();
                nitgenMainApi.OpenDevice(NBioAPI.Type.DEVICE_ID.AUTO);
                nitgenMainApi.Capture(out template, 0, window);
                nitgenMainApi.CloseDevice(NBioAPI.Type.DEVICE_ID.AUTO);

                var repositorio      = new DigitalRepositorio();
                var digitaisIniciais = repositorio.RecuperarPrimeirosRegistros();
                var digitaisFinais   = repositorio.RecuperarUltimosRegistros();

                var task1 = Create(template, digitaisIniciais);
                var task2 = Create(template, digitaisFinais);

                _tasks.Add(task1);
                _tasks.Add(task2);

                task1.Task.Start();
                Thread.Sleep(500);
                task2.Task.Start();

                var relogio = new Stopwatch();
                relogio.Start();

                var         possoSair = false;
                DigitalTask resultado;
                while (!possoSair)
                {
                    if (_tasks.Any(t => t.Task.IsCompleted))
                    {
                        var completadas = _tasks.Where(t => t.Task.IsCompleted);
                        resultado = completadas.FirstOrDefault(c => c.Task.Result > 0);

                        if (resultado != null)
                        {
                            foreach (var task in _tasks.Where(t => t.Id != resultado.Id))
                            {
                                task.CancellationSource.Cancel();
                            }
                            possoSair = true;
                        }
                    }

                    if (_tasks.All(t => t.Task.IsCompleted))
                    {
                        possoSair = true;
                    }

                    Thread.Sleep(10);
                }

                relogio.Stop();
                MessageBox.Show($"Terminou em {relogio.Elapsed.TotalSeconds}");
            }
            catch (OperationCanceledException ex)
            {
                foreach (var task in _tasks)
                {
                    task.CancellationSource.Dispose();
                }
            }
        }
Example #20
0
        private void btnIdentify_Click(object sender, System.EventArgs e)
        {
            NBioAPI.Type.HFIR hCapturedFIR;

            // Get FIR data
            m_NBioAPI.OpenDevice(NBioAPI.Type.DEVICE_ID.AUTO);
            uint ret = m_NBioAPI.Capture(out hCapturedFIR);

            if (ret != NBioAPI.Error.NONE)
            {
                DisplayErrorMsg(ret);
                m_NBioAPI.CloseDevice(NBioAPI.Type.DEVICE_ID.AUTO);
                return;
            }

            m_NBioAPI.CloseDevice(NBioAPI.Type.DEVICE_ID.AUTO);


            uint nMax;

            m_IndexSearch.GetDataCount(out nMax);

            NBioAPI.IndexSearch.CALLBACK_INFO_0 cbInfo0 = new NBioAPI.IndexSearch.CALLBACK_INFO_0();
            // Identify FIR to IndexSearch DB
            NBioAPI.IndexSearch.FP_INFO fpInfo;
            ret = m_IndexSearch.IdentifyData(hCapturedFIR, NBioAPI.Type.FIR_SECURITY_LEVEL.NORMAL, out fpInfo, cbInfo0);
            if (ret != NBioAPI.Error.NONE)
            {
                DialogResult confirm = MessageBox.Show("Digital não encontrada, tente novamente!",
                                                       "Usuário não identificado", MessageBoxButtons.OK, MessageBoxIcon.Exclamation,
                                                       MessageBoxDefaultButton.Button2);
                if (confirm.ToString().ToUpper() == "OK")
                {
                    btnIdentify_Click(sender, e);
                }

                //DisplayErrorMsg(ret);
                return;
            }

            //instância da conexão
            string          config  = "server=localhost; database=lanche;  userid=root; password=vertrigo;";
            MySqlConnection conexao = new MySqlConnection(config);
            string          query   = "SELECT apelido FROM users where id =" + fpInfo.ID;
            //instância do comando onde passo
            //a query e a conexão
            MySqlCommand cmd = new MySqlCommand(query, conexao);

            //Abro conexão
            conexao.Open();
            //instância do leitor que recebe
            //o comando
            MySqlDataReader leitor = cmd.ExecuteReader();

            leitor.Read();
            //atribuo os valores do bd
            // Add item to list of result
            ListViewItem listItem = new ListViewItem();

            listItem.Text = fpInfo.ID.ToString();
            listItem.SubItems.Add(fpInfo.FingerID.ToString());
            listItem.SubItems.Add(leitor["apelido"].ToString());
            listResult.Items.Add(listItem);

            ////fecho conexão
            conexao.Close();
            Form2 newForm2 = new Form2(fpInfo.ID.ToString());

            newForm2.ShowDialog();

            btnIdentify_Click(sender, e);
        }
Example #21
0
    public void Identify_user()
    {
        NBioAPI.Type.HFIR hCapturedFIR;
        // Get FIR data
        m_NBioAPI.OpenDevice(NBioAPI.Type.DEVICE_ID.AUTO);
        uint ret = m_NBioAPI.Capture(out hCapturedFIR);

        if (ret != NBioAPI.Error.NONE)
        {
            Response.Write("" + ret);
            m_NBioAPI.CloseDevice(NBioAPI.Type.DEVICE_ID.AUTO);
            return;
        }

        m_NBioAPI.CloseDevice(NBioAPI.Type.DEVICE_ID.AUTO);


        uint nMax;

        m_IndexSearch.GetDataCount(out nMax);


        NBioAPI.IndexSearch.CALLBACK_INFO_0 cbInfo0 = new NBioAPI.IndexSearch.CALLBACK_INFO_0();
        cbInfo0.CallBackFunction = new NBioAPI.IndexSearch.INDEXSEARCH_CALLBACK(myCallback);

        // Identify FIR to IndexSearch DB
        NBioAPI.IndexSearch.FP_INFO fpInfo;
        ret = m_IndexSearch.IdentifyData(hCapturedFIR, NBioAPI.Type.FIR_SECURITY_LEVEL.NORMAL, out fpInfo, cbInfo0);
        if (ret != NBioAPI.Error.NONE)
        {
            //Response.Write("" + ret);
            lblsource.Text = "The FingerPrint does not match!!";
            return;
        }

        // Add item to list of result

        String ins = "insert into tbl_punch(punch_trainid,punch_sname,punch_dname,punch_aadharno,punch_dist,punch_tickets,punch_amt,punch_date)values('" + drptrain.SelectedValue + "','" + drpsource.SelectedValue + "','0','" + Session["aadharno"] + "','0','" + txttickets.Text + "','0','" + DateTime.Now.ToShortDateString() + "')";

        obj.ExecuteCommand(ins);
        string    selID = "select max(punch_id) as pid from tbl_punch where punch_aadharno='" + Session["aadharno"] + "'";
        DataTable dt1   = obj.GetDataTable(selID);
        string    sel   = "select * from tbl_punch where punch_aadharno='" + Session["aadharno"] + "' and punch_id='" + dt1.Rows[0]["pid"] + "'";
        DataTable dt    = obj.GetDataTable(sel);
        string    selI  = "select train_vcapacity from tbl_train where train_id='" + dt.Rows[0]["punch_trainid"] + "'";
        DataTable dt11  = obj.GetDataTable(selI);

        if (Convert.ToInt32(dt11.Rows[0]["train_vcapacity"]) > 0)
        {
            Double a  = Convert.ToInt32(dt11.Rows[0]["train_vcapacity"]) - Convert.ToInt32(dt.Rows[0]["punch_tickets"]);
            String se = "update tbl_train set train_vcapacity='" + a + "' where train_id='" + dt.Rows[0]["punch_trainid"] + "'";
            obj.ExecuteCommand(se);
            Session["valid"]  = Convert.ToInt32(dt1.Rows[0]["pid"]);
            Session["source"] = drpsource.SelectedValue;
            Response.Write("success");
            //Label1.Text = Convert.ToString(Session["source"]);
            Response.Redirect("welcome.aspx");
        }
        else
        {
            Response.Write("<script>alert('Insufficient Seats')</script>");
        }
    }