public static CorsiData getCorsiToUpload(int log_id) { CorsiData temp = null; _dbc = new SqliteConnection(_constr); _dbc.Open(); _dbcm = _dbc.CreateCommand(); sql = "SELECT * FROM corsi_data WHERE log_id = " + log_id + ";"; _dbcm.CommandText = sql; _idr = _dbcm.ExecuteReader(); if (_idr.Read()) { temp = new CorsiData(); temp.log_id = _idr.GetInt32(_idr.GetOrdinal("log_id")); temp.correct_length = _idr.GetInt32(_idr.GetOrdinal("correct_length")); temp.correct_trials = _idr.GetInt32(_idr.GetOrdinal("correct_trials")); temp.seq_length = _idr.GetInt32(_idr.GetOrdinal("seq_length")); temp.trial_count = _idr.GetInt32(_idr.GetOrdinal("trial_count")); } _idr.Close(); _idr = null; _dbcm.Dispose(); _dbcm = null; _dbc.Close(); _dbc = null; return(temp); }
public CorsiData getBestCorsi() { CorsiData bestCorsi = null; _dbc = new SqliteConnection(_constr); _dbc.Open(); _dbcm = _dbc.CreateCommand(); sql = "SELECT C.log_id, C.correct_trials, C.correct_length, C.seq_length, C.trial_count " + "FROM corsi_data C, player_logs P " + "WHERE P.game_progress = 'FINISHED' " + "AND P.log_id = C.log_id " + "AND C.correct_length != 0 " + "ORDER BY C.trial_count DESC, C.correct_trials DESC, C.seq_length DESC, C.correct_length DESC LIMIT 1; "; _dbcm.CommandText = sql; _idr = _dbcm.ExecuteReader(); if (_idr.Read()) { bestCorsi = new CorsiData(); bestCorsi.log_id = _idr.GetInt32(_idr.GetOrdinal("log_id")); bestCorsi.correct_length = _idr.GetInt32(_idr.GetOrdinal("correct_length")); bestCorsi.correct_trials = _idr.GetInt32(_idr.GetOrdinal("correct_trials")); bestCorsi.seq_length = _idr.GetInt32(_idr.GetOrdinal("seq_length")); bestCorsi.trial_count = _idr.GetInt32(_idr.GetOrdinal("trial_count")); } _idr.Close(); _idr = null; _dbcm.Dispose(); _dbcm = null; _dbc.Close(); _dbc = null; return(bestCorsi); }
public CorsiData[] getLastCorsi() { CorsiData[] lastCorsi = new CorsiData[3]; CorsiData corsiData; int count = 0; _dbc = new SqliteConnection(_constr); _dbc.Open(); _dbcm = _dbc.CreateCommand(); sql = "SELECT C.log_id, C.correct_trials, C.correct_length, C.seq_length, C.trial_count " + "FROM corsi_data C, player_logs P " + "WHERE P.game_progress = 'FINISHED' " + "AND P.log_id = C.log_id " + "ORDER BY C.log_id DESC; "; _dbcm.CommandText = sql; _idr = _dbcm.ExecuteReader(); while (_idr.Read() && count < 3) { corsiData = new CorsiData(); corsiData.log_id = _idr.GetInt32(_idr.GetOrdinal("log_id")); corsiData.correct_length = _idr.GetInt32(_idr.GetOrdinal("correct_length")); corsiData.correct_trials = _idr.GetInt32(_idr.GetOrdinal("correct_trials")); corsiData.seq_length = _idr.GetInt32(_idr.GetOrdinal("seq_length")); corsiData.trial_count = _idr.GetInt32(_idr.GetOrdinal("trial_count")); lastCorsi[count] = corsiData; count++; } _idr.Close(); _idr = null; _dbcm.Dispose(); _dbcm = null; _dbc.Close(); _dbc = null; return(lastCorsi); }
public void uploadPlayerLogs() { MySqlCommand cmd; if (OpenConnection() == true) { List <PlayerLogs> uploadList = SQLiteDatabase.getLogsToUpload(); int player_id = SQLiteDatabase.getPlayer().player_id; foreach (PlayerLogs log in uploadList) { string sql = ""; sql = "INSERT INTO player_logs (player_id, test_id, time_start, time_end) VALUES(" + player_id + ", " + log.test_id + ", '" + log.time_start + "', '" + log.time_end + "');"; cmd = new MySqlCommand(sql, conn); cmd.ExecuteNonQuery(); sql = "SELECT LAST_INSERT_ID();"; cmd.CommandText = sql; int last_log_id = Convert.ToInt32(cmd.ExecuteScalar()); switch (log.test_id) { case 1: GoNoGoData temp1 = SQLiteDatabase.getGoNoGoToUpload(log.log_id); sql = "INSERT INTO gonogo_data (log_id, correct_go_count, correct_nogo_count, mean_time, go_count, trial_count) VALUES (" + last_log_id + ", " + temp1.correct_go_count + ", " + temp1.correct_nogo_count + ", " + temp1.mean_time + ", " + temp1.go_count + ", " + temp1.trial_count + ");"; break; case 2: CorsiData temp2 = SQLiteDatabase.getCorsiToUpload(log.log_id); sql = "INSERT INTO corsi_data (log_id, correct_trials, correct_length, seq_length, trial_count) VALUES (" + last_log_id + ", " + temp2.correct_trials + ", " + temp2.correct_length + ", " + temp2.seq_length + ", " + temp2.trial_count + ");"; break; case 3: NBackData temp3 = SQLiteDatabase.getNBackToUpload(log.log_id); sql = "INSERT INTO nback_data (log_id, mean_time, correct_count, n_count, element_count, trial_count) VALUES (" + last_log_id + ", " + temp3.mean_time + ", " + temp3.correct_count + ", " + temp3.n_count + ", " + temp3.element_count + ", " + temp3.trial_count + ");"; break; case 4: EriksenData temp4 = SQLiteDatabase.getEriksenToUpload(log.log_id); sql = "INSERT INTO eriksen_data (log_id, correct_congruent, time_congruent, correct_incongruent, time_incongruent, congruent_count, trial_count) VALUES (" + last_log_id + ", " + temp4.correct_congruent + ", " + temp4.time_congruent + ", " + temp4.correct_incongruent + ", " + temp4.time_incongruent + ", " + temp4.congruent_count + ", " + temp4.trial_count + ");"; break; } cmd = new MySqlCommand(sql, conn); cmd.ExecuteNonQuery(); SQLiteDatabase.updateUploadedLog(log.log_id); } CloseConnection(); } }