using System; using System.Collections.Generic; using System.Diagnostics; using Mono.Data.Sqlite; using System.Linq; using System.Text; using System.Threading.Tasks; namespace SabreTools { class UIHelper { private static string _dbName = "DATabase.sqlite"; private static string _connectionString = "Data Source=" + _dbName + ";Version = 3;"; public static object[] GetAllSystems() { List objs = new List(); Process.Start("DATabase.exe", "--skip"); string query = @" SELECT DISTINCT systems.id, systems.manufacturer, systems.system FROM systems JOIN games ON systems.id=games.system ORDER BY systems.manufacturer, systems.system"; using (SqliteConnection dbc = new SqliteConnection(_connectionString)) { dbc.Open(); using (SqliteCommand slc = new SqliteCommand(query, dbc)) { using (SqliteDataReader sldr = slc.ExecuteReader()) { // If nothing is found, tell the user and exit if (sldr.HasRows) { while (sldr.Read()) { objs.Add(sldr.GetString(1) + " - " + sldr.GetString(2) + " (" + sldr.GetInt32(0) + ")"); } } } } } return objs.ToArray(); } public static object[] GetAllSources() { List objs = new List(); Process.Start("DATabase.exe", "--skip"); string query = @" SELECT DISTINCT sources.id, sources.name FROM sources JOIN games on sources.id=games.source ORDER BY sources.name COLLATE NOCASE"; using (SqliteConnection dbc = new SqliteConnection(_connectionString)) { dbc.Open(); using (SqliteCommand slc = new SqliteCommand(query, dbc)) { using (SqliteDataReader sldr = slc.ExecuteReader()) { // If nothing is found, tell the user and exit if (sldr.HasRows) { while (sldr.Read()) { objs.Add(sldr.GetString(1) + " (" + sldr.GetInt32(0) + ")"); } } } } } return objs.ToArray(); } } }