private void OnCaptured(CaptureResult captureResult) { try { if (!fingerprint.CheckCaptureResult(captureResult)) { return; } DataResult <Fmd> resultConversion = FeatureExtraction.CreateFmdFromFid(captureResult.Data, Constants.Formats.Fmd.ANSI); if (captureResult.ResultCode != Constants.ResultCode.DP_SUCCESS) { fingerprint.CurrentReader.Reset(); Application.Current.Dispatcher.Invoke((Action) delegate { TxtBlock_FingerprintMessage.Text = "Error. Please try again. Place your finger on the device."; }); throw new Exception(captureResult.ResultCode.ToString()); } if (studentInfo.Firstfinger == null) { studentInfo.Firstfinger = resultConversion.Data; Application.Current.Dispatcher.Invoke((Action) delegate { TxtBlock_FingerprintMessage.Text = "Finger was captured. Now Place the same finger on the device."; }); } else { if (studentInfo.Lastfinger == null) { studentInfo.Lastfinger = resultConversion.Data; Fmd[] fmds = new Fmd[1]; fmds[0] = studentInfo.Firstfinger; // See the SDK documentation for an explanation on threshold scores. int thresholdScore = DPFJ_PROBABILITY_ONE * 1 / 100000; IdentifyResult identifyResult = Comparison.Identify(studentInfo.Lastfinger, 0, fmds, thresholdScore, 1); if (identifyResult.ResultCode != Constants.ResultCode.DP_SUCCESS) { throw new Exception(identifyResult.ResultCode.ToString()); } if (identifyResult.Indexes.Length <= 0) { Application.Current.Dispatcher.Invoke((Action) delegate { TxtBlock_FingerprintMessage.Text = "Failed, first finger and second finger not matched. Please try again, place any finger on the device."; studentInfo.Firstfinger = null; studentInfo.Lastfinger = null; }); } else { Application.Current.Dispatcher.Invoke((Action) delegate { SaveStudentToDatabase(); TxtBlock_FingerprintMessage.Text = "Success, your fingerprint data was saved. Please click the next button to finish."; Btn_ProceedLast.IsEnabled = true; fingerprint.CancelCaptureAndCloseReader(this.OnCaptured); }); } } } } catch (Exception ex) { MessageBox.Show("Error while capturing the fingerprint.\nPlease try again later." + ex, "Error Fingerprint", MessageBoxButton.OK, MessageBoxImage.Error); Application.Current.Dispatcher.Invoke((Action) delegate { fingerprint.CurrentReader.Dispose(); fingerprint.CurrentReader = null; this.Close(); }); } }
private void OnCaptured(CaptureResult captureResult) { try { if (!fingerprintReader.CheckCaptureResult(captureResult)) { return; } DataResult <Fmd> resultConversion = FeatureExtraction.CreateFmdFromFid(captureResult.Data, Constants.Formats.Fmd.ANSI); if (captureResult.ResultCode != Constants.ResultCode.DP_SUCCESS) { fingerprintReader.CurrentReader.Reset(); Application.Current.Dispatcher.Invoke((Action) delegate { richTextBox.Document.Blocks.Clear(); richTextBox.AppendText("\nError\nPlease try again.\nPlace your finger on the device."); }); throw new Exception(captureResult.ResultCode.ToString()); } if (isFingerprintDataExist(resultConversion.Data)) { firstFinger = null; secondFinger = null; MessageBox.Show("It seems that there's slightly the same fingerprint data as yours.\n\nPlease use your other fingers.", "Warning", MessageBoxButton.OK, MessageBoxImage.Warning); Application.Current.Dispatcher.Invoke((Action) delegate { richTextBox.Document.Blocks.Clear(); richTextBox.AppendText("\nPlace any finger on the device."); }); } else { if (firstFinger == null) { firstFinger = resultConversion.Data; Application.Current.Dispatcher.Invoke((Action) delegate { richTextBox.Document.Blocks.Clear(); richTextBox.AppendText("\nFinger was captured\nNow Place the same finger on the device."); }); } else { if (secondFinger == null) { secondFinger = resultConversion.Data; Fmd[] fmds = new Fmd[1]; fmds[0] = firstFinger; // See the SDK documentation for an explanation on threshold scores. int thresholdScore = DPFJ_PROBABILITY_ONE * 1 / 100000; IdentifyResult identifyResult = Comparison.Identify(secondFinger, 0, fmds, thresholdScore, 1); if (identifyResult.ResultCode != Constants.ResultCode.DP_SUCCESS) { throw new Exception(identifyResult.ResultCode.ToString()); } if (identifyResult.Indexes.Length <= 0) { Application.Current.Dispatcher.Invoke((Action) delegate { richTextBox.Document.Blocks.Clear(); richTextBox.AppendText("\nFailed, first finger and second finger not matched.\nPlease try again, place any finger on the device."); firstFinger = null; secondFinger = null; }); } else { Application.Current.Dispatcher.Invoke((Action) delegate { richTextBox.Document.Blocks.Clear(); richTextBox.AppendText("\nSuccess, please submit your registration now."); btn_submit.IsEnabled = true; }); fingerprintReader.CancelCaptureAndCloseReader(this.OnCaptured); } } } } } catch (Exception ex) { MessageBox.Show("Error while capturing the fingerprint.\nPlease try again later." + ex, "Error Fingerprint", MessageBoxButton.OK, MessageBoxImage.Error); Application.Current.Dispatcher.Invoke((Action) delegate { fingerprintReader.CurrentReader.Dispose(); fingerprintReader.CurrentReader = null; this.Close(); }); } }
private void OnCaptured(CaptureResult captureResult) { try { if (!fingerprintReader.CheckCaptureResult(captureResult)) { return; } DataResult <Fmd> resultConversion = FeatureExtraction.CreateFmdFromFid(captureResult.Data, Constants.Formats.Fmd.ANSI); if (captureResult.ResultCode != Constants.ResultCode.DP_SUCCESS) { fingerprintReader.CurrentReader.Reset(); throw new Exception(captureResult.ResultCode.ToString()); } // See the SDK documentation for an explanation on threshold scores. int thresholdScore = DPFJ_PROBABILITY_ONE * 1 / 100000; if (isAdminLogin) { IdentifyResult identifyResult = Comparison.Identify(resultConversion.Data, 0, AdminFingerPrints.ToArray(), thresholdScore, AdminFingerPrints.Count); if (identifyResult.ResultCode != Constants.ResultCode.DP_SUCCESS) { throw new Exception(identifyResult.ResultCode.ToString()); } if (identifyResult.Indexes.Length > 0) { fingerprintReader.CancelCaptureAndCloseReader(this.OnCaptured); Application.Current.Dispatcher.Invoke((Action) delegate { AdminDashboard adminDashboard = new AdminDashboard(); adminDashboard.CurrentAdminId = AdminId.ElementAt(identifyResult.Indexes[0][0]); adminDashboard.Show(); fingerprintReader.CurrentReader.Dispose(); fingerprintReader.CurrentReader = null; this.Close(); }); } } else { IdentifyResult identifyResult = Comparison.Identify(resultConversion.Data, 0, StudenFingerPrints.ToArray(), thresholdScore, StudenFingerPrints.Count); if (identifyResult.ResultCode != Constants.ResultCode.DP_SUCCESS) { throw new Exception(identifyResult.ResultCode.ToString()); } if (identifyResult.Indexes.Length > 0) { fingerprintReader.CancelCaptureAndCloseReader(this.OnCaptured); Application.Current.Dispatcher.Invoke((Action) delegate { StudentDashboard studentDash = new StudentDashboard(StudentId.ElementAt(identifyResult.Indexes[0][0]).ToString(), database); studentDash.Show(); fingerprintReader.CurrentReader.Dispose(); fingerprintReader.CurrentReader = null; this.Close(); }); } } } catch (Exception) { Application.Current.Dispatcher.Invoke((Action) delegate { ErrorHeader1.Text = "Fingerprint device error"; ErrorContent1.Text = "Error while capturing the fingerprint."; DialogMessage1.IsOpen = true; }); } }
private void OnCaptured(CaptureResult captureResult) { Application.Current.Dispatcher.Invoke((Action) delegate { Snackbar_Recorded.IsActive = false; }); try { if (!fingerprintReader.CheckCaptureResult(captureResult)) { return; } DataResult <Fmd> resultConversion = FeatureExtraction.CreateFmdFromFid(captureResult.Data, Constants.Formats.Fmd.ANSI); if (captureResult.ResultCode != Constants.ResultCode.DP_SUCCESS) { fingerprintReader.CurrentReader.Reset(); Application.Current.Dispatcher.Invoke((Action) delegate { Snackbar_Recorded.IsActive = true; SnackBar_Message.Text = "Sorry, please try again."; }); throw new Exception(captureResult.ResultCode.ToString()); } // See the SDK documentation for an explanation on threshold scores. int thresholdScore = DPFJ_PROBABILITY_ONE * 1 / 100000; IdentifyResult identifyResult = Comparison.Identify(resultConversion.Data, 0, studentFmds.ToArray(), thresholdScore, studentFmds.Count); if (identifyResult.ResultCode != Constants.ResultCode.DP_SUCCESS) { throw new Exception(identifyResult.ResultCode.ToString()); } if (identifyResult.Indexes.Length > 0) { Application.Current.Dispatcher.Invoke((Action) delegate { string findStudentId = studentIds.ElementAt(identifyResult.Indexes[0][0]); UpdateStudentInformation(findStudentId); if (IsAttendedAlready(findStudentId)) { SnackBar_Message.Text = "Your attendance is already recorded."; Snackbar_Recorded.IsActive = true; } else { if (SaveAttendancetoDatabase(findStudentId)) { SnackBar_Message.Text = "Successful, your attendance is recorded."; Snackbar_Recorded.IsActive = true; AttendedIds.AddFirst(findStudentId); } else { SnackBar_Message.Text = "Sorry, that doesn't work. Please try again."; Snackbar_Recorded.IsActive = true; } } }); } else { Application.Current.Dispatcher.Invoke((Action) delegate { TxtBox_StudentID.Clear(); TxtBox_Name.Clear(); TxtBox_Course.Clear(); TxtBox_Year.Clear(); SnackBar_Message.Text = "Sorry, that doesn't work. Please try again."; Snackbar_Recorded.IsActive = true; }); } } catch (Exception ex) { MessageBox.Show("Error while capturing the fingerprint.\nPlease try again later." + ex, "Error Fingerprint", MessageBoxButton.OK, MessageBoxImage.Error); Application.Current.Dispatcher.Invoke((Action) delegate { this.Close(); }); } }