public string[] SelectAllSessions(string filterName) { if (type == DatabaseType.DEFAULT) { return(SqliteSession.SelectAllSessions(filterName)); } else { SqliteGeneral sqliteGeneral = new SqliteGeneral(databasePath); if (!sqliteGeneral.IsOpened) { List <string> emptyResult = new List <string> (); return(emptyResult.ToArray()); } SqliteConnection dbcon = sqliteGeneral.connection; string[] allSessions = SqliteSession.SelectAllSessions(filterName, dbcon); // Filtered sessions will contain all sessions but not the "SIMULATED" List <string> filteredSessions = new List <string> (); foreach (string session in allSessions) { if (session.Split(':') [1] != "SIMULATED") { filteredSessions.Add(session); } } return(filteredSessions.ToArray()); } }
public Session Select(string myUniqueID) { if (type == DatabaseType.DEFAULT) { return(SqliteSession.Select(myUniqueID)); } else { // This code could be refactored from existing code in SqliteSession::Select() SqliteGeneral sqliteGeneral = new SqliteGeneral(databasePath); SqliteCommand dbcommand = sqliteGeneral.command(); dbcommand.CommandText = "SELECT * FROM Session WHERE uniqueID == @myUniqueID"; dbcommand.Parameters.Add(new SqliteParameter("@myUniqueID", myUniqueID)); SqliteDataReader reader = dbcommand.ExecuteReader(); // Copied from a non-callable (yet) static method: SqliteSession::Select() string [] values = new string[9]; while (reader.Read()) { values[0] = reader[0].ToString(); values[1] = reader[1].ToString(); values[2] = reader[2].ToString(); values[3] = reader[3].ToString(); values[4] = reader[4].ToString(); values[5] = reader[5].ToString(); values[6] = reader[6].ToString(); values[7] = reader[7].ToString(); values[8] = reader[8].ToString(); } Session mySession = new Session(values[0], values[1], values[2], UtilDate.FromSql(values[3]), Convert.ToInt32(values[4]), Convert.ToInt32(values[5]), Convert.ToInt32(values[6]), values[7], Convert.ToInt32(values[8])); return(mySession); } }