Пример #1
0
        private void btnEnroll_Click(object sender, EventArgs e)
        {
            if (!ExtractTemplate(m_Template1, out m_Template1Size))
            {
                return;
            }

            DrawCapturedImage(m_Scanner);

            UserInfoForm dlg = new UserInfoForm(false);
            UFD_STATUS   ufd_res;

            tbxMessage.AppendText("Input user data\r\n");
            if (dlg.ShowDialog(this) != DialogResult.OK)
            {
                tbxMessage.AppendText("User data input is cancelled by user\r\n");
                return;
            }

            ufd_res = m_Database.AddData(dlg.UserID, dlg.FingerIndex, m_Template1, m_Template1Size, null, 0, dlg.Memo);

            if (ufd_res != UFD_STATUS.OK)
            {
                UFDatabase.GetErrorString(ufd_res, out m_strError);
                tbxMessage.AppendText("UFDatabase AddData: " + m_strError + "\r\n");
            }
            else
            {
                cbScanTemplateType.Enabled = false;
            }

            UpdateDatabaseList();
        }
Пример #2
0
        public bool Enroll(string nUserID, string strUserName, int FingerIndex = 1)
        {
            bool bRet = false;

            try
            {
                //ErrorMessage = "";
                UFS_STATUS ufs_status;
                int        nScannerNumber;

                ufs_status = m_ScannerManager.Init();

                nScannerNumber = m_ScannerManager.Scanners.Count;

                if (nScannerNumber <= 0)
                {
                    strLastError = "There are no suprema scanner";
                    Log(strLastError);
                    return(false);
                }

                m_Scanner = m_ScannerManager.Scanners[0];
                // Open database
                m_Database = new UFDatabase();
                //string szDataSource;
                if (m_szConnectionString != string.Empty)
                {
                    m_ufd_res = m_Database.Open(m_szConnectionString, "", "");
                }
                else
                {
                    return(false);
                }
                if (m_ufd_res != UFD_STATUS.OK)
                {
                    return(false);
                }
                // Create matcher
                m_Matcher = new UFMatcher();
                if (!ExtractTemplate(m_bTemplate1, out m_nTemplateSize1))
                {
                    return(false);
                }
                m_ScannerManager.Uninit();

                #region Check if the finger is used before for other user

                byte[][] DBTemplate     = null;
                int[]    DBTemplateSize = null;
                int[]    DBSerial       = null;
                int      DBTemplateNum;
                int      nMatchIndex;
                string   m_strUserID    = "";
                int      m_nFingerIndex = 0;
                string   memo           = "";
                int      x = 0;

                m_ufd_res = m_Database.GetTemplateListWithSerial(out DBTemplate, out DBTemplateSize, out DBTemplateNum, out DBSerial);
                m_ufm_res = m_Matcher.Identify(m_bTemplate1, m_nTemplateSize1, DBTemplate, DBTemplateSize, DBTemplateNum, 5000, out nMatchIndex);

                if (nMatchIndex >= 0 && DBSerial != null)
                {
                    m_ufd_res = m_Database.GetDataBySerial(DBSerial[nMatchIndex], out m_strUserID, out m_nFingerIndex, m_bTemplate1, out m_nTemplateSize1, null, out x, out memo);
                    if (m_strUserID.Replace('\0', ' ').Trim() != nUserID && m_nFingerIndex == FingerIndex)
                    {
                        strLastError = "This fingerprint is used for another person";
                        Log(strLastError);
                        return(false);
                    }
                }

                #endregion

                m_ufd_res = m_Database.AddData(nUserID.ToString(), FingerIndex, m_bTemplate1, m_nTemplateSize1, null, 0, "");
                if (m_ufd_res == UFD_STATUS.OK)
                {
                    bRet = true;
                }
                else if (m_ufd_res == UFD_STATUS.ERR_SAME_FINGER_EXIST)
                {
                    m_ufd_res = m_Database.UpdateDataByUserInfo(nUserID, FingerIndex, m_bTemplate1, m_nTemplateSize1, null, 0, null);
                    if (m_ufd_res == UFD_STATUS.OK)
                    {
                        bRet = true;
                    }
                }
            }
            catch (Exception ex)
            {
                strLastError = "Unkown Error Happened:\n" + ex.Message;
                Log(strLastError);
            }

            return(bRet);
        }