Пример #1
0
 public static Profile VerifyBiometricsData(byte[] data)
 {
     try
     {
         string          _result = string.Empty;
         string          _Finger = string.Empty;
         Profile         _info   = new Profile();
         dcProfile_OleDb _dc     = new dcProfile_OleDb();
         //DPFP.Template _template = null;
         Stream      _msSample = new MemoryStream(data);
         DPFP.Sample _sample   = new DPFP.Sample();
         //deserialize
         _sample.DeSerialize(_msSample);
         OleDbCommand _cmd = new OleDbCommand("select * from Profiles", _dc.DBConn);
         _dc.DBConn.Open();
         OleDbDataReader _dr     = _cmd.ExecuteReader();
         bool            IsFound = false;
         if (_dr.HasRows)
         {
             while (_dr.Read())
             {
                 if (_dr[2] != DBNull.Value)
                 {
                     IsFound = Verify(_dr, _sample);
                 }
                 if (IsFound == true)
                 {
                     _info.ProfileId = Convert.ToInt64(_dr["ProfileId"]);
                     _info.FullName  = Convert.ToString(_dr["FullName"]);
                     _info.FrontImg  = (byte[])_dr["ProfileImg"];
                     if (_info.FrontImg == null)
                     {
                         _info.FrontImg = Util.ImageToByte(zsi.PhotoFingCapture.Util.GetNoPhoto());
                     }
                     _info.ClientEmployeeId = Convert.ToInt32(_dr["ClientEmployeeId"]);
                     if (_dr["EmployeeNo"] != DBNull.Value)
                     {
                         _info.EmployeeNo = _dr["EmployeeNo"].ToString();
                     }
                     _info.ShiftId = Convert.ToInt32(_dr["ShiftId"]);
                     break;
                 }
             }
         }
         else
         {
             _info.ProfileId = 0;
             _info.FullName  = "";
         }
         return(_info);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Пример #2
0
        private void UpdateLastUpdate()
        {
            dcProfile_OleDb _dc  = new dcProfile_OleDb();
            OleDbCommand    _cmd = new OleDbCommand("select * from updatelog", _dc.DBConn);

            _dc.DBConn.Open();
            OleDbDataReader _dr = _cmd.ExecuteReader();

            if (!_dr.HasRows)
            {
                _cmd = new OleDbCommand(
                    "Insert Into UpdateLog(ProfileLastUpdate) values(?)", _dcProfile_OleDb.DBConn, Trans);
                _cmd.Parameters.AddWithValue("?", GetDbDate().ToString());
                _cmd.ExecuteNonQuery();
            }
            else
            {
                _cmd = new OleDbCommand(
                    "Update UpdateLog set ProfileLastUpdate=?", _dcProfile_OleDb.DBConn, Trans);
                _cmd.Parameters.AddWithValue("?", GetDbDate().ToString());
                _cmd.ExecuteNonQuery();
            }
            _dc.DBConn.Close();
        }
Пример #3
0
        public static Profile VerifyBiometricsData(int FingNo, byte[] data)
        {
            try
            {
                string          _result   = string.Empty;
                string          _Finger   = string.Empty;
                Profile         _info     = new Profile();
                dcProfile_OleDb _dc       = new dcProfile_OleDb();
                DPFP.Template   _template = null;
                Stream          _msSample = new MemoryStream(data);
                DPFP.Sample     _sample   = new DPFP.Sample();
                //deserialize
                _sample.DeSerialize(_msSample);
                // _list = _dc.GetDataSource();
                switch (FingNo)
                {
                case 9: _Finger = "LeftSF"; break;

                case 8: _Finger = "LeftRF"; break;

                case 7: _Finger = "LeftMF"; break;

                case 6: _Finger = "LeftIF"; break;

                case 5: _Finger = "LeftTF"; break;

                case 4: _Finger = "RightSF"; break;

                case 3: _Finger = "RightRF"; break;

                case 2: _Finger = "RightMF"; break;

                case 1: _Finger = "RightIF"; break;

                case 0: _Finger = "RightTF"; break;

                default: break;
                }
                OleDbCommand _cmd = new OleDbCommand("select * from Profiles", _dc.DBConn);
                _dc.DBConn.Open();
                OleDbDataReader _dr     = _cmd.ExecuteReader();
                bool            IsFound = false;
                if (_dr.HasRows)
                {
                    while (_dr.Read())
                    {
                        if (_dr[2] != DBNull.Value)
                        {
                            _template = ProcessDBTemplate((byte[])_dr[_Finger]);
                            IsFound   = Verify(_sample, _template);
                        }
                        if (IsFound == true)
                        {
                            _info.ProfileId        = Convert.ToInt64(_dr["ProfileId"]);
                            _info.FullName         = Convert.ToString(_dr["FullName"]);
                            _info.FrontImg         = (byte[])_dr["ProfileImg"];
                            _info.ClientEmployeeId = Convert.ToInt32(_dr["ClientEmployeeId"]);
                            _info.EmployeeNo       = Convert.ToString(_dr["EmployeeNo"]);
                            _info.ShiftId          = Convert.ToInt32(_dr["ShiftId"]);
                            _info.UserId           = (_dr["UserId"] == DBNull.Value ? 0 : Convert.ToInt32(_dr["UserId"]));

                            break;
                        }
                    }
                }
                else
                {
                    _info.ProfileId = 0;
                    _info.FullName  = "";
                }
                return(_info);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Пример #4
0
        public void FingerTemplatesUpdate()
        {
            try
            {
                //if (Util.IsOnline==false )return;
                ConsoleApp.WriteLine(Application.ProductName, "Start uploading data to server.");

                DateTime _ProfileLastUpdate;
                _dcProfile_OleDb = new dcProfile_OleDb();
                _dcProfile_OleDb.DBConn.Open();
                OleDbCommand    _cmd2 = new OleDbCommand("select * from updatelog", _dcProfile_OleDb.DBConn);
                OleDbDataReader _dr2  = _cmd2.ExecuteReader(CommandBehavior.CloseConnection);

                Trans = _dcProfile_OleDb.DBConn.BeginTransaction();
                if (_dr2.HasRows == false)
                {
                    this.SelectParameters.Add("p_ClientId", ClientSettings.ClientWorkStationInfo.ClientId);
                    this.SelectParameters.Add("p_ApplicationId", ClientSettings.ClientWorkStationInfo.ApplicationId);

                    this.CountParameters.Add("p_ClientId", ClientSettings.ClientWorkStationInfo.ClientId);
                    this.CountParameters.Add("p_ApplicationId", ClientSettings.ClientWorkStationInfo.ApplicationId);
                    this.CountParameters.Add("p_RecordCount", SqlDbType.Int, ParameterDirection.Output);
                    this.CountParameters.Add("p_IsCount", true);
                    this.DataRowPosition.TotalRecords = this.GetRecordCount("p_RecordCount");

                    this.GetDataSource();
                    ConsoleApp.WriteLine(Application.ProductName, "Get new records from the live server");
                    this.InsertNewDataLocalDB(this.List);
                    UpdateLastUpdate();
                }
                else
                {
                    _dr2.Read();
                    _ProfileLastUpdate = Convert.ToDateTime(_dr2["ProfileLastUpdate"]);

                    ConsoleApp.WriteLine(Application.ProductName, "Get newest created and updated records from the live server");
                    List <Profile> _NewList     = this.GetNewDataFromServer(_ProfileLastUpdate);
                    List <Profile> _UpdatedList = this.GetUpdatedDataFromServer(_ProfileLastUpdate);

                    this.InsertNewDataLocalDB(_NewList);
                    this.UpdateLocalDB(_UpdatedList);

                    if (_NewList.Count > 0 || _UpdatedList.Count > 0)
                    {
                        UpdateLastUpdate();
                    }
                }
                Trans.Commit();
                _dcProfile_OleDb.DBConn.Close();
                ConsoleApp.WriteLine(Application.ProductName, "Migrating finger templates has been done.");
            }
            catch (Exception ex)
            {
                try
                {
                    Trans.Rollback();
                }
                catch {}
                ConsoleApp.WriteLine(Application.ProductName, "[Error]," + ex.ToString());
                zsi.PhotoFingCapture.Util.LogError(ex.ToString());
            }
        }