protected override void DefWndProc(ref Message m) { ExAttDBRepo exAttDBRepo = new ExAttDBRepo(); switch (m.Msg) { case MESSAGE_CAPTURED_OK: { parentForm.statusBar.Visible = false; if (!bIdentify2 || !bIdentify) { DisplayFingerPrintImage(); } if (IsRegister) { #region -------- IF REGISTERED FINGERPRINT -------- int ret = zkfp.ZKFP_ERR_OK; int fid = 0, score = 0; ret = fpInstance.Identify(CapTmp, ref fid, ref score); if (zkfp.ZKFP_ERR_OK == ret) { int deleteCode = fpInstance.DelRegTemplate(fid); // <---- REMOVE FINGERPRINT if (deleteCode != zkfp.ZKFP_ERR_OK) { DisplayMessage(MessageManager.msg_FP_CurrentFingerAlreadyRegistered + fid, false); return; } } if (RegisterCount > 0 && fpInstance.Match(CapTmp, RegTmps[RegisterCount - 1]) <= 0) { DisplayMessage("Please press the same finger " + REGISTER_FINGER_COUNT + " times for enrollment", true); return; } Array.Copy(CapTmp, RegTmps[RegisterCount], cbCapTmp); if (RegisterCount == 0) { btnEnroll.Enabled = false; } RegisterCount++; if (RegisterCount >= REGISTER_FINGER_COUNT) { RegisterCount = 0; ret = GenerateRegisteredFingerPrint(); // <--- GENERATE FINGERPRINT TEMPLATE if (zkfp.ZKFP_ERR_OK == ret) { ret = AddTemplateToMemory(); // <--- LOAD TEMPLATE TO MEMORY if (zkfp.ZKFP_ERR_OK == ret) // <--- ENROLL SUCCESSFULL { string fingerPrintTemplate = string.Empty; zkfp.Blob2Base64String(RegTmp, regTempLen, ref fingerPrintTemplate); Utilities.EnableControls(true, button1, btnVerify, btnIdentify); Utilities.EnableControls(false, btnEnroll); MySqlConnection connection = null; try { var registerUSerId = "0"; registerUSerId = textBox1_SocialID.Text; const String SERVER = "sql248.main-hosting.eu"; const String DATABASE = "u842190477_Exattend"; const String UID = "u842190477_Admin"; const String PASSWORD = "******"; MySqlConnection dbConn; String query = @"INSERT INTO u842190477_Exattend.fingerprint(Uni_ID, Fin_Code, FingerTemplate)VALUES(" + registerUSerId + ", " + 0 + ", '" + fingerPrintTemplate + "'); "; MySqlConnectionStringBuilder builder = new MySqlConnectionStringBuilder(); builder.Server = SERVER; builder.UserID = UID; builder.Password = PASSWORD; builder.Database = DATABASE; String connString = builder.ToString(); builder = null; Console.WriteLine(connString); dbConn = new MySqlConnection(connString); MySqlCommand cmd = new MySqlCommand(query, dbConn); dbConn.Open(); cmd.ExecuteNonQuery(); cmd.Connection = connection; dbConn.Close(); } finally { if (connection != null) { connection.Close(); } } //var zz = exAttDBRepo.GetAllEmployees(); //exAttDBRepo.inserFingerPrintToDB(textBox1_SocialID.Text, fingerPrintTemplate); // GET THE TEMPLATE HERE : fingerPrintTemplate DisplayMessage(MessageManager.msg_FP_EnrollSuccessfull, true); DisconnectFingerPrintCounter(); } else { DisplayMessage(MessageManager.msg_FP_FailedToAddTemplate, false); } } else { DisplayMessage(MessageManager.msg_FP_UnableToEnrollCurrentUser + ret, false); } IsRegister = false; return; } else { int remainingCont = REGISTER_FINGER_COUNT - RegisterCount; lblFingerPrintCount.Text = remainingCont.ToString(); string message = "Please provide your fingerprint " + remainingCont + " more time(s)"; DisplayMessage(message, true); } #endregion } else if (!bIdentify2 || !bIdentify) { #region ------- IF RANDOM FINGERPRINT ------- // If unidentified random fingerprint is applied //if (regTempLen <= 0) //{ // DisplayMessage(MessageManager.msg_FP_UnidentifiedFingerPrint, false); // return; //} if ((bIdentify && userType == 1) || (bIdentify2 && userType == 2)) { int ret = zkfp.ZKFP_ERR_OK; int fid = 0, score = 0; ret = fpInstance.Identify(CapTmp, ref fid, ref score); //check if if (zkfp.ZKFP_ERR_OK == ret) { DisplayMessage(MessageManager.msg_FP_IdentificationSuccess + ret, true); return; } else { DisplayMessage(MessageManager.msg_FP_IdentificationFailed + ret, false); return; } } else { ExAttDBRepo eR = new ExAttDBRepo(); ExUniDBRepo eU = new ExUniDBRepo(); var allFingers = eR.GetAllFingers(); if (userType == 1) { var x = eU.GetAllStudents().Select(e => e.Stu_ID).ToList(); allFingers = allFingers.Where(e => x.Contains(e.Uni_ID)).ToList(); } else if (userType == 2) { var x = eU.GetAllEmployees().Select(e => e.Emp_ID).ToList(); allFingers = allFingers.Where(e => x.Contains(e.Uni_ID)).ToList(); } Finger selectedStudent = new Finger(); foreach (var item in allFingers.ToList()) { var base46Registerd = zkfp.Base64String2Blob(item.FingerTemplate); var r = fpInstance.Match(CapTmp, base46Registerd); if (r > 0) { selectedStudent = item; bool checkIsSavedthroughOneHour = eR.CheckIsSavedthroughOneHour(selectedStudent.Uni_ID, userType); if (!checkIsSavedthroughOneHour) { eR.inserAttendanceLogToDB(selectedStudent.Uni_ID); } break; } } //if id for student match the his fingerprint then show message if (selectedStudent.Uni_ID > 0) { DisplayMessage(MessageManager.msg_FP_MatchSuccess + selectedStudent.Uni_ID, true); return; } //if the match is failed then show error message else { DisplayMessage(MessageManager.msg_FP_MatchFailed /*+ ret*/, false); return; } } #endregion } } break; default: base.DefWndProc(ref m); break; } }
protected override void DefWndProc(ref Message m) { switch (m.Msg) { case MESSAGE_CAPTURED_OK: { #region casoMach if (textBox1.Text == "") { textBox1.Text = "0"; } int CEDULA = int.Parse(textBox1.Text); // Can be the users unique ID Person = SqliteDataAccess.BuscaCedula(CEDULA); byte[] regTemplate = zkfp.Base64String2Blob(Person[0].HUELLA); int ret2 = fpInstance.Match(CapTmp, regTemplate); // MACH CASE REVISAR ########################### if (0 < ret2) { textBox2.Text = Person[0].NOMBRE; textBox3.Text = Person[0].FECHA_INSC; DisplayFingerPrintImage(); MessageBox.Show("SI HACE MACHT FUNCIONA"); DisplayMessage(MessageManager.msg_FP_machtcase, true); return; } else { MessageBox.Show("NO HACE MACHT"); } #endregion parentForm.statusBar.Visible = false; DisplayFingerPrintImage(); if (IsRegister) { #region -------- IF REGISTERED FINGERPRINT -------- int ret = zkfp.ZKFP_ERR_OK; int fid = 0, score = 0; ret = fpInstance.Identify(CapTmp, ref fid, ref score); if (zkfp.ZKFP_ERR_OK == ret) { int deleteCode = fpInstance.DelRegTemplate(fid); // <---- REMOVE FINGERPRINT if (deleteCode != zkfp.ZKFP_ERR_OK) { DisplayMessage(MessageManager.msg_FP_CurrentFingerAlreadyRegistered + fid, false); return; } } if (RegisterCount > 0 && fpInstance.Match(CapTmp, RegTmps[RegisterCount - 1]) <= 0) { DisplayMessage("Please press the same finger " + REGISTER_FINGER_COUNT + " times for enrollment", true); return; } Array.Copy(CapTmp, RegTmps[RegisterCount], cbCapTmp); if (RegisterCount == 0) { btnEnroll.Enabled = false; } RegisterCount++; if (RegisterCount >= REGISTER_FINGER_COUNT) { RegisterCount = 0; ret = GenerateRegisteredFingerPrint(); // <--- GENERATE FINGERPRINT TEMPLATE if (zkfp.ZKFP_ERR_OK == ret) { ret = AddTemplateToMemory(); // <--- LOAD TEMPLATE TO MEMORY if (zkfp.ZKFP_ERR_OK == ret) // <--- ENROLL SUCCESSFULL { MessageBox.Show(RegTmp.ToString()); string fingerPrintTemplate = string.Empty; zkfp.Blob2Base64String(RegTmp, regTempLen, ref fingerPrintTemplate); Utilities.EnableControls(true, btnVerify, btnIdentify); Utilities.EnableControls(false, btnEnroll); // GET THE TEMPLATE HERE : fingerPrintTemplate string HUELLA = fingerPrintTemplate; int CEDU = int.Parse(textBox1.Text); string NOMBRE = textBox2.Text; int STATUS = 0; string FEHA_INSC = textBox3.Text; string TIPO_INSC = "GF"; SqliteDataAccess.CargaHuella(CEDU, NOMBRE, HUELLA, STATUS, FEHA_INSC, TIPO_INSC); MessageBox.Show("INSCRIPCION EXITOSA!!"); textBox1.Text = ""; textBox2.Text = ""; textBox3.Text = ""; textBox4.Text = ""; checkBox1.Checked = false; DisplayMessage(MessageManager.msg_FP_EnrollSuccessfull, true); DisconnectFingerPrintCounter(); } else { DisplayMessage(MessageManager.msg_FP_FailedToAddTemplate, false); } } else { DisplayMessage(MessageManager.msg_FP_UnableToEnrollCurrentUser + ret, false); } IsRegister = false; return; } else { int remainingCont = REGISTER_FINGER_COUNT - RegisterCount; lblFingerPrintCount.Text = remainingCont.ToString(); string message = "Please provide your fingerprint " + remainingCont + " more time(s)"; DisplayMessage(message, true); } #endregion } else { #region ------- IF RANDOM FINGERPRINT ------- // If unidentified random fingerprint is applied if (regTempLen <= 0) { DisplayMessage(MessageManager.msg_FP_UnidentifiedFingerPrint, false); return; } if (bIdentify) { int ret = zkfp.ZKFP_ERR_OK; int fid = 0, score = 0; ret = fpInstance.Identify(CapTmp, ref fid, ref score); if (zkfp.ZKFP_ERR_OK == ret) { DisplayMessage(MessageManager.msg_FP_IdentificationSuccess + ret, true); return; } else { DisplayMessage(MessageManager.msg_FP_IdentificationFailed + ret, false); return; } } else { int ret = fpInstance.Match(CapTmp, RegTmp); // MACH CASE REVISAR ########################### if (0 < ret) { DisplayMessage(MessageManager.msg_FP_MatchSuccess + ret, true); return; } else { DisplayMessage(MessageManager.msg_FP_MatchFailed + ret, false); return; } } #endregion } } break; default: base.DefWndProc(ref m); break; } }
protected override void DefWndProc(ref Message m) { switch (m.Msg) { case MESSAGE_CAPTURED_OK: { parentForm.statusBar.Visible = false; DisplayFingerPrintImage(); if (IsRegister) { #region -------- IF REGISTERED FINGERPRINT -------- int ret = zkfp.ZKFP_ERR_OK; int fid = 0, score = 0; ret = fpInstance.Identify(CapTmp, ref fid, ref score); if (zkfp.ZKFP_ERR_OK == ret) { int deleteCode = fpInstance.DelRegTemplate(fid); // <---- REMOVE FINGERPRINT if (deleteCode != zkfp.ZKFP_ERR_OK) { DisplayMessage(MessageManager.msg_FP_CurrentFingerAlreadyRegistered + fid, false); return; } } if (RegisterCount > 0 && fpInstance.Match(CapTmp, RegTmps[RegisterCount - 1]) <= 0) { DisplayMessage("Please press the same finger " + REGISTER_FINGER_COUNT + " times for enrollment", true); return; } Array.Copy(CapTmp, RegTmps[RegisterCount], cbCapTmp); if (RegisterCount == 0) { btnEnroll.Enabled = false; } RegisterCount++; if (RegisterCount >= REGISTER_FINGER_COUNT) { RegisterCount = 0; ret = GenerateRegisteredFingerPrint(); // <--- GENERATE FINGERPRINT TEMPLATE if (zkfp.ZKFP_ERR_OK == ret) { ret = AddTemplateToMemory(); // <--- LOAD TEMPLATE TO MEMORY if (zkfp.ZKFP_ERR_OK == ret) // <--- ENROLL SUCCESSFULL { string fingerPrintTemplate = string.Empty; zkfp.Blob2Base64String(RegTmp, regTempLen, ref fingerPrintTemplate); Utilities.EnableControls(true, btnVerify, btnIdentify); Utilities.EnableControls(false, btnEnroll); // GET THE TEMPLATE HERE : fingerPrintTemplate DisplayMessage(MessageManager.msg_FP_EnrollSuccessfull, true); DisconnectFingerPrintCounter(); } else { DisplayMessage(MessageManager.msg_FP_FailedToAddTemplate, false); } } else { DisplayMessage(MessageManager.msg_FP_UnableToEnrollCurrentUser + ret, false); } IsRegister = false; return; } else { int remainingCont = REGISTER_FINGER_COUNT - RegisterCount; lblFingerPrintCount.Text = remainingCont.ToString(); string message = "Please provide your fingerprint " + remainingCont + " more time(s)"; DisplayMessage(message, true); } #endregion } else { #region ------- IF RANDOM FINGERPRINT ------- // If unidentified random fingerprint is applied if (regTempLen <= 0) { DisplayMessage(MessageManager.msg_FP_UnidentifiedFingerPrint, false); return; } if (bIdentify) { int ret = zkfp.ZKFP_ERR_OK; int fid = 0, score = 0; ret = fpInstance.Identify(CapTmp, ref fid, ref score); if (zkfp.ZKFP_ERR_OK == ret) { DisplayMessage(MessageManager.msg_FP_IdentificationSuccess + ret, true); return; } else { DisplayMessage(MessageManager.msg_FP_IdentificationFailed + ret, false); return; } } else { int ret = fpInstance.Match(CapTmp, RegTmp); if (0 < ret) { DisplayMessage(MessageManager.msg_FP_MatchSuccess + ret, true); return; } else { DisplayMessage(MessageManager.msg_FP_MatchFailed + ret, false); return; } } #endregion } } break; default: base.DefWndProc(ref m); break; } }