private void btnRegist_Click(object sender, System.EventArgs e) { NBioAPI.Type.HFIR hNewFIR; uint nUserID = 0; // Get User ID try { int test = Convert.ToInt32(textUserID.Text, 10); if (test == 0) { throw(new Exception()); } } catch { MessageBox.Show("User ID must be have numeric type and greater than 0.", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } nUserID = Convert.ToUInt32(textUserID.Text, 10); // Get FIR data m_NBioAPI.OpenDevice(NBioAPI.Type.DEVICE_ID.AUTO); uint ret = m_NBioAPI.Enroll(out hNewFIR, null); if (ret != NBioAPI.Error.NONE) { DisplayErrorMsg(ret); m_NBioAPI.CloseDevice(NBioAPI.Type.DEVICE_ID.AUTO); return; } m_NBioAPI.CloseDevice(NBioAPI.Type.DEVICE_ID.AUTO); // Regist FIR to IndexSearch DB NBioAPI.IndexSearch.FP_INFO[] fpInfo; ret = m_IndexSearch.AddFIR(hNewFIR, nUserID, out fpInfo); if (ret != NBioAPI.Error.NONE) { DisplayErrorMsg(ret); return; } // Add item to list of SearchDB foreach (NBioAPI.IndexSearch.FP_INFO sampleInfo in fpInfo) { ListViewItem listItem = new ListViewItem(); listItem.Text = sampleInfo.ID.ToString(); listItem.SubItems.Add(sampleInfo.FingerID.ToString()); listItem.SubItems.Add(sampleInfo.SampleNumber.ToString()); listSearchDB.Items.Add(listItem); } textUserID.Text = Convert.ToString(Convert.ToInt32(textUserID.Text) + 1); }
public uint AbrirDispositoPeloID(DeviceName id) { uint Retorno = m_NBioAPI.OpenDevice((short)id); if (Retorno == NBioAPI.Error.NONE) { throw new Exception("Não foi possível abrir o dispositivo informado."); } return(Retorno); }
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(""); } }
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) { 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 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; }
public void Inicializar() { uint ret = nBioApi.OpenDevice(NBioAPI.Type.DEVICE_ID.AUTO); if (ret == NBioAPI.Error.NONE) { return; } else { MessageBox.Show("Nenhum dispositivo conectado.", "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
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(""); }
private void abreDispositivo() { //Abre o dispositivo uint ret3 = m_NBioAPI.OpenDevice(iDeviceID); if (ret3 == NBioAPI.Error.NONE) { m_OpenedDeviceID = iDeviceID; } else { MessageBox.Show("Erro ao acessar dispositivo:\n" + ret3); } }
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); }
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; }
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; } } }
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 Enroll(int id) { NBioAPI m_NBioAPI = new NBioAPI(); NBioAPI.Type.FIR_TEXTENCODE m_textFIR; NBioAPI.Type.HFIR NewFIR; NBioAPI.IndexSearch m_IndexSearch = new NBioAPI.IndexSearch(m_NBioAPI); NBioAPI.Type.WINDOW_OPTION m_WinOption = new NBioAPI.Type.WINDOW_OPTION(); m_WinOption.WindowStyle = (uint)NBioAPI.Type.WINDOW_STYLE.NO_WELCOME; string Retorno = ""; m_NBioAPI.OpenDevice(NBioAPI.Type.DEVICE_ID.AUTO); uint ret = m_NBioAPI.Enroll(out NewFIR, null); //uint ret = m_NBioAPI.Enroll(null, out NewFIR, null, NBioAPI.Type.TIMEOUT.DEFAULT, null, m_WinOption); if (ret != NBioAPI.Error.NONE) { m_NBioAPI.CloseDevice(NBioAPI.Type.DEVICE_ID.AUTO); } if (NewFIR != null) { m_NBioAPI.GetTextFIRFromHandle(NewFIR, out m_textFIR, true); if (m_textFIR.TextFIR != null) { m_NBioAPI.CloseDevice(NBioAPI.Type.DEVICE_ID.AUTO); Retorno = m_textFIR.TextFIR.ToString(); } } return(Retorno); }
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); } }
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(); } } }
private void btnRegist_Click(object sender, System.EventArgs e) { NBioAPI.Type.HFIR hNewFIR; uint nUserID = 0; nUserID = Convert.ToUInt32(textUserID.Text, 10); // Get FIR data m_NBioAPI.OpenDevice(NBioAPI.Type.DEVICE_ID.AUTO); uint ret = m_NBioAPI.Enroll(out hNewFIR, null); if (ret != NBioAPI.Error.NONE) { DisplayErrorMsg(ret); m_NBioAPI.CloseDevice(NBioAPI.Type.DEVICE_ID.AUTO); return; } m_NBioAPI.CloseDevice(NBioAPI.Type.DEVICE_ID.AUTO); // Regist FIR to IndexSearch DB NBioAPI.IndexSearch.FP_INFO[] fpInfo; ret = m_IndexSearch.AddFIR(hNewFIR, nUserID, out fpInfo); if (ret != NBioAPI.Error.NONE) { DisplayErrorMsg(ret); return; } // Add item to list of SearchDB foreach (NBioAPI.IndexSearch.FP_INFO sampleInfo in fpInfo) { string config = "server=localhost; database=lanche; userid=root; password=vertrigo;"; MySqlConnection conexao = new MySqlConnection(config); string query = "SELECT apelido FROM users where id =" + sampleInfo.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 msg = "Usuário " + leitor["apelido"] + " adicionado com sucesso!"; ListViewItem listItem = new ListViewItem(); listItem.Text = sampleInfo.ID.ToString(); listItem.SubItems.Add(sampleInfo.FingerID.ToString()); listItem.SubItems.Add(leitor["apelido"].ToString()); listSearchDB.Items.Add(listItem); //fecho conexão conexao.Close(); } MessageBox.Show(msg); btnSaveFile_Click(sender, e); }
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); } }
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 Leitura(string Arquivo, string PathSalvamento) { NBioAPI HandleBio; uint Retorno = NBioAPI.Error.NONE; uint NenhumErro = NBioAPI.Error.NONE; NBioAPI.Type.MINCONV_DATA_TYPE importType; NBioAPI.Export m_Export; NBioAPI.Type.HFIR processedFIR; NBioAPI.Type.INIT_INFO_0 initInfo0; uint nSize = 0; byte[] minData = null; //----------------------- try { FileStream fs = new FileStream(PathSalvamento + Arquivo, FileMode.Open, FileAccess.Read); BinaryReader fr = new BinaryReader(fs); nSize = (uint)fs.Length; minData = new byte[nSize]; fr.Read(minData, 0, (int)nSize); fr.Close(); fs.Close(); } catch (FileNotFoundException e) { MessageBox.Show("Erro localizar arquivo biometrico\n" + e.Message, "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } HandleBio = new NBioAPI(); HandleBio.OpenDevice(NBioAPI.Type.DEVICE_ID.AUTO); if (Retorno != NenhumErro) { MessageBox.Show("Erro ao verificar digital", "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error); HandleBio.Dispose(); return; } importType = NBioAPI.Type.MINCONV_DATA_TYPE.MINCONV_TYPE_FDU; m_Export = new NBioAPI.Export(HandleBio); Retorno = m_Export.FDxToNBioBSPEx(minData, nSize, importType, NBioAPI.Type.FIR_PURPOSE.VERIFY, out processedFIR); if (Retorno != NenhumErro) { MessageBox.Show("Erro ao verificar digital", "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error); HandleBio.CloseDevice(NBioAPI.Type.DEVICE_ID.AUTO); 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; } Boolean bResult; Retorno = HandleBio.Verify(processedFIR, out bResult, null); if (Retorno != NenhumErro) { MessageBox.Show("Erro ao verificar digital", "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { if (!bResult) { MessageBox.Show("Vendedor não autenticado", "Falha ao autenticar", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { try { MessageBox.Show("Autenticação realizada com sucesso", "Sucesso!!", MessageBoxButtons.OK, MessageBoxIcon.None); FileStream validacao = new FileStream(Path.GetTempPath() + "Result_" + Arquivo, FileMode.CreateNew, FileAccess.Write); BinaryWriter fw = new BinaryWriter(validacao); fw.Write("#$&%&$*%¨$*$¨%$*&($$)$)$¨$&¨%$*$&¨#%%(*%)"); fw.Close(); validacao.Close(); } catch (FileNotFoundException e) { MessageBox.Show("Erro localizar arquivo biometrico\n" + e.Message, "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } } } HandleBio.CloseDevice(NBioAPI.Type.DEVICE_ID.AUTO); }
private void ISOV1_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.Enroll(null, out hFIR, null, 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("ExportRawToISOV1 start..."); nRet = NBioBSPISO4.ExportRawToISOV1(exportData, 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 = "ExportRawToISOV1 Error: " + nRet; listRet.Items.Add(szTemp); } } else { szTemp = "NBioBSPToImage Error: " + nRet; listRet.Items.Add(szTemp); } hFIR.Dispose(); hAuditFIR.Dispose(); } else { szTemp = "Enroll Error: " + nRet; listRet.Items.Add(szTemp); } m_NBioAPI.CloseDevice(NBioAPI.Type.DEVICE_ID.AUTO); } else { szTemp = "CloseDevice Error: " + nRet; listRet.Items.Add(szTemp); } }
public Biometria() { api = new NBioAPI(); api.OpenDevice(NBioAPI.Type.DEVICE_ID.AUTO); }
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>"); } }
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>"); } }