Exemplo n.º 1
0
        /// <summary>
        /// Attempts to listen for a single fingerprint read.
        /// Returns true on a successful listen, or false if something went wrong
        /// </summary>
        public bool Listen()
        {
            Debug("Identifying user...");
            try
            {
                WinBioIdentity         identity;
                WinBioBiometricSubType subFactor;
                WinBioRejectDetail     rejectDetail;
                WinBio.Identify(_session, out identity, out subFactor, out rejectDetail);
                Debug(string.Format("Identity: {0}", identity));
                Debug(identity.TemplateGuid.ToString());
                onIdentify(identity.AccountSid.ToString());
                return(true);
            }
            catch (WinBioException ex)
            {
                if (ex.ErrorCode == WinBioErrorCode.UnknownID)
                {
                    onUnknownIdentity();
                    return(true);
                }

                Debug(ex);
            }
            catch (Exception ex)
            {
                Debug(ex.Message);
            }

            return(false);
        }
Exemplo n.º 2
0
        private WinBioIdentity AddEnrollment(WinBioSessionHandle session, int unitId, WinBioBiometricSubType subType)
        {
            WriteLog(string.Format("Beginning enrollment of {0}:", subType));
            WinBio.EnrollBegin(session, subType, unitId);
            var code = WinBioErrorCode.MoreData;
            WinBioRejectDetail rejectDetail;

            int good = 0;

            for (var swipes = 1; code != WinBioErrorCode.Ok; swipes++)
            {
                code = WinBio.EnrollCapture(session, out rejectDetail);
                switch (code)
                {
                case WinBioErrorCode.MoreData:
                    WriteLog(string.Format("Swipe {0} was good", swipes));
                    good++;
                    break;

                case WinBioErrorCode.BadCapture:
                    WriteLog(string.Format("Swipe {0} was bad: {1}", swipes, rejectDetail));
                    break;

                case WinBioErrorCode.Ok:
                    WriteLog(string.Format("Enrollment complete with {0} swipes", swipes));
                    break;

                default:
                    throw new WinBioException(code, "WinBioEnrollCapture failed");
                }
                Progress(good);
            }
            WriteLog("Committing enrollment..");
            bool           isNewTemplate;
            WinBioIdentity identity = null;

            try
            {
                isNewTemplate = WinBio.EnrollCommit(session, out identity);
                WriteLog(isNewTemplate ? "New template committed." : "Template already existing.");
                if (!isNewTemplate)
                {
                    WinBio.Identify(session, out identity, out subType, out rejectDetail);
                }

                EnableDisableOk(true);
            }
            catch (Exception e)
            {
                WriteLog("Error on AddEnrollment. Error:" + e.Message);
            }

            return(identity);
        }
Exemplo n.º 3
0
        public void Identify()
        {
            WinBioIdentity         identity;
            WinBioBiometricSubType subFactor;
            WinBioRejectDetail     rejectDetail;
            var unitId = WinBio.Identify(_handle, out identity, out subFactor, out rejectDetail);

            Console.WriteLine("Unit Id: {0}", unitId);
            Console.WriteLine("Identity: {0}", identity);
            Console.WriteLine("Sub factor: {0}", subFactor);
            Console.WriteLine("Reject details: {0}", rejectDetail);
        }
Exemplo n.º 4
0
        protected override void OnShown(EventArgs e)
        {
            base.OnShown(e);

            if (StartEnrollment)
            {
                ThreadPool.QueueUserWorkItem(delegate
                {
                    try
                    {
                        OpenBiometricSession();
                        var identity       = AddEnrollment(_session, _unitId, WinBioBiometricSubType.RhIndexFinger);
                        TemplateFingerGuid = identity.TemplateGuid;
                    }
                    catch (WinBioException ex)
                    {
                        WriteLog(ex.Message);
                    }
                });
            }
            else
            {
                ThreadPool.QueueUserWorkItem(delegate
                {
                    OpenBiometricSession();
                    for (int i = 0; i < 5; i++)
                    {
                        try
                        {
                            WinBioIdentity identity;
                            WinBioBiometricSubType subFactor;
                            WinBioRejectDetail rejectDetail;
                            WinBio.Identify(_session, out identity, out subFactor, out rejectDetail);

                            TemplateFingerGuid = identity.TemplateGuid;
                            this.Invoke(new Action(CloseWindow));
                            return;
                        }
                        catch (WinBioException ex)
                        {
                            WriteLog("Please retry!! Error:" + ex.Message);
                        }
                    }
                });
            }
        }
Exemplo n.º 5
0
 private void buttonIdentify_Click(object sender, EventArgs e)
 {
     ThreadPool.QueueUserWorkItem(delegate
     {
         Log("Identifying user...");
         try
         {
             WinBioIdentity identity;
             WinBioBiometricSubType subFactor;
             WinBioRejectDetail rejectDetail;
             WinBio.Identify(_session, out identity, out subFactor, out rejectDetail);
             Log(string.Format("Identity: {0}", identity));
         }
         catch (WinBioException ex)
         {
             Log(ex);
         }
     });
 }
Exemplo n.º 6
0
        private void buttonEnroll_Click(object sender, EventArgs e)
        {
            WinBioBiometricSubType subType = (WinBioBiometricSubType)comboBoxFp.SelectedIndex;

            if (subType == WinBioBiometricSubType.Unknown)
            {
                Log("Please select a finger index, not Unknown.");
                return;
            }
            ThreadPool.QueueUserWorkItem(delegate
            {
                try
                {
                    Log("Put your finger on sensor...");
                    WinBioBiometricSubType subFactor;
                    WinBioRejectDetail rejectDetail;
                    while (true)
                    {
                        _unitId = WinBio.Identify(_session, out _identity, out subFactor, out rejectDetail);
                        Log("No. This finger has been enrolled before. Change another one...");
                    }
                }
                catch (WinBioException ex)
                {
                    Log("OK. This finger not yet be enrolled before.");
                }


                try
                {
                    _identity = AddEnrollment(_session, _unitId, subType);
                    Log(string.Format("Identity: {0}", _identity));
                }
                catch (WinBioException ex)
                {
                    Log(ex);
                    if (ex.ErrorCode == WinBioErrorCode.DuplicateEnrollment)
                    {
                        Log(string.Format("Please select another finger index or just delete it for a new one."));
                    }
                }
            });
        }
Exemplo n.º 7
0
 private void buttonIdentify_Click(object sender, EventArgs e)
 {
     ThreadPool.QueueUserWorkItem(delegate
     {
         Log("Identifying user...");
         try
         {
             WinBioBiometricSubType subFactor;
             WinBioRejectDetail rejectDetail;
             _unitId = WinBio.Identify(_session, out _identity, out subFactor, out rejectDetail);
             setComboxSelectedIndex(comboUnitId, comboUnitId.Items.IndexOf(_unitId));
             Log(string.Format("Sensor used: unit id {0}", _unitId));
             Log(string.Format("Identity = {0}", _identity));
             updateCurNameFromIdentity();
             Log(string.Format("Identity Name = {0}", _name));
             Log(string.Format("SubFactor= {0}", subFactor));
         }
         catch (WinBioException ex)
         {
             Log(ex);
         }
     });
 }