internal List <PhraseInputStat> GetUserData(int userid)
        {
            string sqlExpression = string.Format("SELECT * FROM password_entries WHERE userid = {0} ;",
                                                 userid);

            connection.Open();
            MySqlCommand           command     = new MySqlCommand(sqlExpression, connection);
            MySqlDataReader        reader      = command.ExecuteReader();
            List <PhraseInputStat> data_sample = new List <PhraseInputStat>();

            while (reader.Read())
            {
                PhraseInputStat phrase_entry = new PhraseInputStat();
                int[]           tau_vecktor  = SplitIntString(reader.GetString(6));
                int[]           t_vecktor    = SplitIntString(reader.GetString(5));
                phrase_entry.press_data  = DecodeVectors(tau_vecktor, t_vecktor);
                phrase_entry.Entry_time  = reader.GetDateTime(4);
                phrase_entry.PressTime   = reader.GetInt32(3);
                phrase_entry.TypeSpeed   = reader.GetFloat(2);
                phrase_entry.type1_impos = reader.GetInt16(7);
                phrase_entry.type2_impos = reader.GetInt16(8);
                phrase_entry.type3_impos = reader.GetInt16(9);
                phrase_entry.bio_vecktor = SplitFloatString(reader.GetString(10));
                data_sample.Add(phrase_entry);
            }
            connection.Close();
            return(data_sample);
        }
        internal int VerifyUser(PhraseInputStat entry)
        {
            int    code          = 0;
            string sqlExpression = string.Format(
                "SELECT * FROM users WHERE login = '******'"
                , entry.login);

            connection.Open();
            MySqlCommand    command = new MySqlCommand(sqlExpression, connection);
            MySqlDataReader reader  = command.ExecuteReader();

            if (reader.HasRows)
            {
                reader.Read();
                float  exp_speed = reader.GetFloat(4);
                string password  = reader.GetString(2);
                if ((Math.Abs(exp_speed - entry.TypeSpeed) < 0.5f) && (password == entry.password))
                {
                    code = 1;
                }
                else
                {
                    code = -2;
                }
            }
            else
            {
                code = -1;
            }
            connection.Close();
            return(code);
        }
 public bool SetPassword(string passw)
 {
     password  = passw;
     cur_entry = new PhraseInputStat();
     //DataControl.AddNewUser(passw);
     log_manager.NewSession(passw);
     return(true);
 }
예제 #4
0
 private void pass_entry_button_Click(object sender, EventArgs e)
 {
     if (controller.Enter_button(pass_enter_textbox.Text, pass_set_button.Text))
     {
         PhraseInputStat stat = controller.CurrentPhraseStat;
     }
     pass_enter_textbox.Text = "";
     controller.Reset();
     pass_enter_textbox.Focus();
 }
 public MainController()
 {
     pressed_keys   = new Dictionary <Keys, KeyPressData>();
     data_samples   = new List <PhraseInputStat>();
     timer          = new Stopwatch();
     log_manager    = new LogController(Directory.GetCurrentDirectory());
     expected_speed = 0;
     password       = "";
     last_key       = 0;
     press_count    = 0;
     DataControl    = new DBController();
     cur_entry      = new PhraseInputStat();
 }
예제 #6
0
        private void pass_entry_button_Click(object sender, EventArgs e)
        {
            if (controller.Enter_button(pass_enter_textbox.Text))
            {
                PhraseInputStat stat = controller.CurrentPhraseStat;
                logbox.Text += String.Format("typing time - {0} ms, speed -  {1:f3} keys/sec",
                                             stat.PressTime, stat.TypeSpeed);

                exp_speed.Text    = String.Format("exp speed: {0:f3} keys /sec.", controller.Expected_speed);
                dispersion_l.Text = String.Format("dispersion: {0:f3} keys/sec.", controller.Dispersion);
                label1.Text       = string.Format("Наложения 1-го рода: {0}", controller.CurrentPhraseStat.type1_impos);
                label2.Text       = string.Format("Наложения 2-го рода: {0}", controller.CurrentPhraseStat.type2_impos);
                label3.Text       = string.Format("Наложения 3-го рода: {0}", controller.CurrentPhraseStat.type3_impos);
            }
            pass_enter_textbox.Text = "";
            controller.ClearCurEntry();
            pass_enter_textbox.Focus();
        }
        internal void AddPasswordEntry(PhraseInputStat cur_entry, int userid)
        {
            string t_vecktor     = GetTVector(cur_entry.press_data);
            string tau_vecktor   = GetTauVector(cur_entry.press_data);
            string date          = cur_entry.Entry_time.ToString("yyyy-MM-dd hh:mm:ss");
            string speed         = cur_entry.TypeSpeed.ToString("F4", new CultureInfo("en-US", false));
            string bio_vector    = GetBioVector(cur_entry.bio_vecktor);
            string sqlExpression = string.Format(
                "INSERT INTO password_entries(userid, speed, total_time, entry_date, t_vecktor, tau_vecktor, type1_imp, type2_imp, type3_imp, bio_vector)" +
                " Values({0},{1:f4},{2},'{3}','{4}','{5}',{6},{7},{8},'{9}');",
                userid, speed, cur_entry.PressTime, date, t_vecktor, tau_vecktor,
                cur_entry.type1_impos, cur_entry.type2_impos, cur_entry.type3_impos, bio_vector);

            connection.Open();
            MySqlCommand command = new MySqlCommand(sqlExpression, connection);
            int          i       = command.ExecuteNonQuery();

            connection.Close();
        }
        internal int FindUser(PhraseInputStat entry)
        {
            int    userid        = 0;
            string speed         = entry.TypeSpeed.ToString("F4", new CultureInfo("en-US", false));
            string sqlExpression = string.Format(
                "SELECT id FROM users WHERE password = '******' AND (ABS(expected_speed-{1})<0.5);"
                , entry.password, speed);

            connection.Open();
            MySqlCommand    command = new MySqlCommand(sqlExpression, connection);
            MySqlDataReader reader  = command.ExecuteReader();

            if (reader.HasRows)
            {
                reader.Read();
                userid = reader.GetInt32(0);
            }
            else
            {
                userid = -1;
            }
            connection.Close();
            return(userid);
        }
 public void ClearCurEntry()
 {
     timer.Reset();
     pressed_keys.Clear();
     cur_entry = new PhraseInputStat();
 }
 public void ClearCurEntry()
 {
     timer.Reset();
     cur_entry = new PhraseInputStat();
 }