Esempio n. 1
0
        public void ConfigureAdapters()
        {
            connection.Open();
            relays              = new Dictionary <string, TableRelay>();
            users_relay         = new TableRelay(connection, "users");
            passw_entries_relay = new TableRelay(connection, "password_entries");

            users_relay.adapter.InsertCommand             = new MySqlCommand("user_entry", connection);
            users_relay.adapter.InsertCommand.CommandType = CommandType.StoredProcedure;
            users_relay.adapter.InsertCommand.Parameters.Add(new MySqlParameter("login", MySqlDbType.VarString, 40, "login"));
            users_relay.adapter.InsertCommand.Parameters.Add(new MySqlParameter("password", MySqlDbType.VarString, 40, "password"));
            users_relay.adapter.InsertCommand.Parameters.Add(new MySqlParameter("complexity", MySqlDbType.VarString, 40, "complexity"));
            users_relay.adapter.InsertCommand.Parameters.Add(new MySqlParameter("expected_speed", MySqlDbType.Float, 40, "expected_speed"));
            users_relay.adapter.InsertCommand.Parameters.Add(new MySqlParameter("dispersion", MySqlDbType.Float, 40, "dispersion"));
            MySqlParameter passw_parameter = users_relay.adapter.InsertCommand.Parameters.Add("id", MySqlDbType.Int32, 0, "id");

            passw_parameter.Direction = ParameterDirection.Output;
            passw_entries_relay.adapter.InsertCommand             = new MySqlCommand("password_entry", connection);
            passw_entries_relay.adapter.InsertCommand.CommandType = CommandType.StoredProcedure;
            passw_entries_relay.adapter.InsertCommand.Parameters.Add(new MySqlParameter("userid", MySqlDbType.Int32, 50, "userid"));
            passw_entries_relay.adapter.InsertCommand.Parameters.Add(new MySqlParameter("speed", MySqlDbType.Float, 0, "speed"));
            passw_entries_relay.adapter.InsertCommand.Parameters.Add(new MySqlParameter("total_time", MySqlDbType.Int32, 0, "total_time"));
            passw_entries_relay.adapter.InsertCommand.Parameters.Add(new MySqlParameter("entry_date", MySqlDbType.DateTime, 0, "entry_date"));
            passw_entries_relay.adapter.InsertCommand.Parameters.Add(new MySqlParameter("t_vecktor", MySqlDbType.VarString, 300, "t_vecktor"));
            passw_entries_relay.adapter.InsertCommand.Parameters.Add(new MySqlParameter("tau_vecktor", MySqlDbType.VarString, 300, "tau_vecktor"));
            passw_entries_relay.adapter.InsertCommand.Parameters.Add(new MySqlParameter("type1_imp", MySqlDbType.Int16, 0, "type1_imp"));
            passw_entries_relay.adapter.InsertCommand.Parameters.Add(new MySqlParameter("type2_imp", MySqlDbType.Int16, 0, "type2_imp"));
            passw_entries_relay.adapter.InsertCommand.Parameters.Add(new MySqlParameter("type3_imp", MySqlDbType.Int16, 0, "type3_imp"));
            passw_entries_relay.adapter.InsertCommand.Parameters.Add(new MySqlParameter("bio_vector", MySqlDbType.VarString, 300, "bio_vector"));
            MySqlParameter parameter = passw_entries_relay.adapter.InsertCommand.Parameters.Add("id", MySqlDbType.Int32, 0, "id");

            parameter.Direction = ParameterDirection.Output;
            relays.Add("users", users_relay);
            relays.Add("password_entries", passw_entries_relay);
            connection.Close();
        }
        public void ConfigureAdapters()
        {
            connection.Open();
            relays              = new Dictionary <string, TableRelay>();
            users_relay         = new TableRelay(connection, "users");
            passw_entries_relay = new TableRelay(connection, "password_entries");

            //queries for "users" table

            //insert query

            users_relay.adapter.InsertCommand             = new MySqlCommand("user_entry", connection);
            users_relay.adapter.InsertCommand.CommandType = CommandType.StoredProcedure;
            users_relay.adapter.InsertCommand.Parameters.Add(new MySqlParameter("login", MySqlDbType.VarString, 40, "login"));
            users_relay.adapter.InsertCommand.Parameters.Add(new MySqlParameter("password", MySqlDbType.VarString, 40, "password"));
            users_relay.adapter.InsertCommand.Parameters.Add(new MySqlParameter("complexity", MySqlDbType.VarString, 40, "complexity"));
            users_relay.adapter.InsertCommand.Parameters.Add(new MySqlParameter("expected_speed", MySqlDbType.Float, 40, "expected_speed"));
            users_relay.adapter.InsertCommand.Parameters.Add(new MySqlParameter("dispersion", MySqlDbType.Float, 40, "dispersion"));
            MySqlParameter passw_parameter = users_relay.adapter.InsertCommand.Parameters.Add("id", MySqlDbType.Int32, 0, "id");

            passw_parameter.Direction = ParameterDirection.Output;

            //update query

            users_relay.adapter.UpdateCommand = new MySqlCommand("UPDATE users SET login = @login , password = @password , " +
                                                                 "complexity = @complexity , expected_speed = @expected_speed , dispersion = @dispersion WHERE id = @id");
            users_relay.adapter.UpdateCommand.Parameters.Add(new MySqlParameter("@login", MySqlDbType.VarString, 40, "login"));
            users_relay.adapter.UpdateCommand.Parameters.Add(new MySqlParameter("@password", MySqlDbType.VarString, 40, "password"));
            users_relay.adapter.UpdateCommand.Parameters.Add(new MySqlParameter("@complexity", MySqlDbType.VarString, 40, "complexity"));
            users_relay.adapter.UpdateCommand.Parameters.Add(new MySqlParameter("@expected_speed", MySqlDbType.Float, 40, "expected_speed"));
            users_relay.adapter.UpdateCommand.Parameters.Add(new MySqlParameter("@dispersion", MySqlDbType.Float, 40, "dispersion"));
            MySqlParameter user_update_parameter = users_relay.adapter.UpdateCommand.Parameters.Add("@id", MySqlDbType.Int32, 0, "id");

            user_update_parameter.SourceVersion = DataRowVersion.Original;

            //queries for "password_entries" table

            //insert query

            passw_entries_relay.adapter.InsertCommand             = new MySqlCommand("password_entry", connection);
            passw_entries_relay.adapter.InsertCommand.CommandType = CommandType.StoredProcedure;
            passw_entries_relay.adapter.InsertCommand.Parameters.Add(new MySqlParameter("userid", MySqlDbType.Int32, 50, "userid"));
            passw_entries_relay.adapter.InsertCommand.Parameters.Add(new MySqlParameter("speed", MySqlDbType.Float, 0, "speed"));
            passw_entries_relay.adapter.InsertCommand.Parameters.Add(new MySqlParameter("total_time", MySqlDbType.Int32, 0, "total_time"));
            passw_entries_relay.adapter.InsertCommand.Parameters.Add(new MySqlParameter("entry_date", MySqlDbType.DateTime, 0, "entry_date"));
            passw_entries_relay.adapter.InsertCommand.Parameters.Add(new MySqlParameter("t_vecktor", MySqlDbType.VarString, 300, "t_vecktor"));
            passw_entries_relay.adapter.InsertCommand.Parameters.Add(new MySqlParameter("tau_vecktor", MySqlDbType.VarString, 300, "tau_vecktor"));
            passw_entries_relay.adapter.InsertCommand.Parameters.Add(new MySqlParameter("type1_imp", MySqlDbType.Int16, 0, "type1_imp"));
            passw_entries_relay.adapter.InsertCommand.Parameters.Add(new MySqlParameter("type2_imp", MySqlDbType.Int16, 0, "type2_imp"));
            passw_entries_relay.adapter.InsertCommand.Parameters.Add(new MySqlParameter("type3_imp", MySqlDbType.Int16, 0, "type3_imp"));
            passw_entries_relay.adapter.InsertCommand.Parameters.Add(new MySqlParameter("bio_vector", MySqlDbType.VarString, 300, "bio_vector"));
            MySqlParameter parameter = passw_entries_relay.adapter.InsertCommand.Parameters.Add("id", MySqlDbType.Int32, 0, "id");

            parameter.Direction = ParameterDirection.Output;


            //update query

            passw_entries_relay.adapter.UpdateCommand = new MySqlCommand("UPDATE password_entries SET userid = @userid , speed = @speed , " +
                                                                         "total_time = @total_time , entry_date = @entry_date , t_vecktor = @t_vecktor , tau_vecktor = @tau_vecktor , " +
                                                                         " type1_imp =@type1_imp , type2_imp = @type2_imp , type3_imp = @type3_imp , bio_vector = @bio_vector WHERE id = @id");
            passw_entries_relay.adapter.UpdateCommand.Parameters.Add(new MySqlParameter("@userid", MySqlDbType.Int32, 50, "userid"));
            passw_entries_relay.adapter.UpdateCommand.Parameters.Add(new MySqlParameter("@speed", MySqlDbType.Float, 0, "speed"));
            passw_entries_relay.adapter.UpdateCommand.Parameters.Add(new MySqlParameter("@total_time", MySqlDbType.Int32, 0, "total_time"));
            passw_entries_relay.adapter.UpdateCommand.Parameters.Add(new MySqlParameter("@entry_date", MySqlDbType.DateTime, 0, "entry_date"));
            passw_entries_relay.adapter.UpdateCommand.Parameters.Add(new MySqlParameter("@t_vecktor", MySqlDbType.VarString, 300, "t_vecktor"));
            passw_entries_relay.adapter.UpdateCommand.Parameters.Add(new MySqlParameter("@tau_vecktor", MySqlDbType.VarString, 300, "tau_vecktor"));
            passw_entries_relay.adapter.UpdateCommand.Parameters.Add(new MySqlParameter("@type1_imp", MySqlDbType.Int16, 0, "type1_imp"));
            passw_entries_relay.adapter.UpdateCommand.Parameters.Add(new MySqlParameter("@type2_imp", MySqlDbType.Int16, 0, "type2_imp"));
            passw_entries_relay.adapter.UpdateCommand.Parameters.Add(new MySqlParameter("@type3_imp", MySqlDbType.Int16, 0, "type3_imp"));
            passw_entries_relay.adapter.UpdateCommand.Parameters.Add(new MySqlParameter("@bio_vector", MySqlDbType.VarString, 300, "bio_vector"));
            MySqlParameter passw_update_parameter = passw_entries_relay.adapter.UpdateCommand.Parameters.Add("@id", MySqlDbType.Int32, 0, "id");

            user_update_parameter.SourceVersion = DataRowVersion.Original;


            relays.Add("users", users_relay);
            relays.Add("password_entries", passw_entries_relay);
            connection.Close();
        }
 public void ConfigureUserEntriesAdapter(int id)
 {
     connection.Open();
     user_entries = new TableRelay(connection, "password_entries", id);
     connection.Close();
 }