Beispiel #1
0
        private void OnEnrollCompleted(IAsyncResult r)
        {
            try
            {
                if (InvokeRequired)
                {
                    BeginInvoke(new AsyncCallback(OnEnrollCompleted), r);
                }
                else
                {
                    var task   = _biometricClient.EndPerformTask(r);
                    var status = task.Status;

                    // Check if extraction was canceled
                    if (status == NBiometricStatus.Canceled)
                    {
                        return;
                    }

                    if (status == NBiometricStatus.Ok)
                    {
                        lblQuality.Text = $"Quality: {_subjectFinger.Objects[0].Quality}";

                        _template = _subject.Save();

                        ShowMessage(@"Please wait while your fingerprint is being processed...");
                        UpdateStateToParent(ApplicationController.State.Captured_Good);
                    }
                    else
                    {
                        lblQuality.Text = string.Empty;

                        ShowMessage(@"Fingerprint image is of low quality");
                        UpdateStateToParent(ApplicationController.State.Captured_Bad);
                    }
                }
            }
            catch (Exception ex)
            {
                ShowMessage(string.Format("Extraction error: {0}", ex.Message));
                Logger.logToFile(ex, AppSettings.ErrorLogPath);
            }
        }
Beispiel #2
0
        private void OnEnrollCompleted(IAsyncResult r)
        {
            Invoke(new Action(() =>
            {
                if (InvokeRequired)
                {
                    BeginInvoke(new AsyncCallback(OnEnrollCompleted), r);
                }
                else
                {
                    var task = _biometricClient.EndPerformTask(r);
                    EnableButtons(false);
                    var status = task.Status;

                    // Check if extraction was canceled
                    if (status == NBiometricStatus.Canceled)
                    {
                        return;
                    }

                    if (status == NBiometricStatus.Ok)
                    {
                        lblQuality.Text = $"Quality: {_subjectFinger.Objects[0].Quality}";

                        decimal.TryParse(_subjectFinger.Objects[0].Quality.ToString(), out recordQuality);

                        //Send the FingerImage and Extracted Template with FingerIdentifyer to MainForm
                        //CaptureFingerNotifyer(image.ToBitmap(), _template.ToArray(),_FingerDescription, true);
                        //This will only be done when the OK button is clicked

                        //AUTOMATICALLY CLICKING THE OK BUTTON
                        var fingerQuality = Settings.Default.FQualityThreshold;
                        if (recordQuality >= fingerQuality)
                        {
                            CancelWork();
                            DisposeNLComponents();

                            try
                            {
                                //var status = CaptureFingerNotifyer(_imageShow.ToBitmap(), fMs.ToArray(), _template.ToArray(), _fingerDescription, true);
                                var saveStatus = _formSingleScanFinger.SaveBioRecord(_subjectFinger, _subject, _fingerDescription, true);

                                if (saveStatus)
                                {
                                    if (_fingerprintScanPosition == 10)
                                    {
                                        ParentForm.Dispose();
                                    }
                                    else
                                    {
                                        _formSingleScanFinger.InitNextFingerScan(_fingerDescription, 0);
                                        Dispose();
                                    }
                                }
                                else
                                {
                                    _formSingleScanFinger.InitNextFingerScan(_fingerDescription, _fingerprintScanPosition);
                                    Dispose();
                                }
                            }
                            catch (Exception ex)
                            {
                                MessageBox.Show(ex.ToString());
                            }
                        }
                    }
                    else
                    {
                        MessageBox.Show($"The template was not extracted: {status}.", Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
                        _subject       = null;
                        _subjectFinger = null;
                        EnableButtons(false);
                    }
                }

                if (_subjectFinger == null)
                {
                    EnableButtons(false);
                }
                else
                {
                    EnableButtons(true);
                }
            }));
        }
Beispiel #3
0
        private void OnEnrollCompleted(IAsyncResult r)
        {
            if (InvokeRequired)
            {
                BeginInvoke(new AsyncCallback(OnEnrollCompleted), r);
            }
            else
            {
                var task = _biometricClient.EndPerformTask(r);

                var status = task.Status;

                // Check if extraction was canceled
                if (status == NBiometricStatus.Canceled)
                {
                    return;
                }

                if (status == NBiometricStatus.Ok)
                {
                    lblQuality.Text = $"Quality: {_subjectFinger.Objects[0].Quality}";

                    if (_nfView.Finger.Image != null)
                    {
                        _nfView.Finger.Image.Dispose();
                        _nfView.Finger.Image = null;
                    }
                    if (_nfView.Finger.Objects[0].Template != null)
                    {
                        _nfView.Finger.Objects[0].Template.Dispose();
                        _nfView.Finger.Objects[0].Template = null;
                    }
                    lblQuality.Text = string.Empty;

                    OnIsScanningChanged(false);

                    _template = _subject.Save();

                    _nfView.Finger.Objects[0].Template = _subject.Fingers[0].Objects[0].Template;
                    SaveTemplateForVerification(_template);
                    SaveUserIdForVerification(textBoxIDNumber.Text);
                    UpdateStateToParent(ApplicationController.State.Captured_Good);

                    NImage image = _subjectFinger.Image;
                    if (image == null)
                    {
                        return;
                    }

                    _nfView.Width        = (int)image.Width;
                    _nfView.Height       = (int)image.Height;
                    _nfView.Finger.Image = image;
                    _nfView.Refresh();
                }
                else
                {
                    MessageBox.Show($"Fingerprint image is of low quality OR The template was not extracted: {status}.", Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    _subject       = null;
                    _subjectFinger = null;
                }
            }
        }