Пример #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);
            }
        }
Пример #2
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;
                }
            }
        }