public AllGamesByPlatform ( string Platform ) : List |
||
Platform | string | |
return | List |
public List<Game> AllGamesByPlatform(string Platform)
{
//Just return all games we have stored in the db
if (!connectionopen)
{
DBConnector.Open();
connectionopen = true;
}
FbTransaction DBTransaction = DBConnector.BeginTransaction();
FbCommand DBCommand = new FbCommand("SELECT * FROM games WHERE platform='" + Platform + "'", DBConnector, DBTransaction);
FbDataReader DBReader = DBCommand.ExecuteReader();
//We'll deal with the fact that we might reach the limit of 50 later
List<Game> Result = new List<Game>();
while (DBReader.Read())
{
Game SingleResult = new Game();
SingleResult.Name = DBReader.GetString(1);
SingleResult.ID = DBReader.GetInt32(0);
SingleResult.InfoXML = new XmlDocument();
SingleResult.InfoXML.LoadXml(DBReader.GetString(2));
SingleResult.ReleaseDate = DateTime.Parse(DBReader.GetString(6));
SingleResult.InstallPath = DBReader.GetString(7);
SingleResult.scraper_gdb_id = DBReader.GetInt32(8);
SingleResult.Platform = DBReader.GetString(9);
if (DBReader.GetInt32(3) != 0)
SingleResult.Downloaded = true;
else
SingleResult.Downloaded = false;
if (DBReader.GetInt32(4) != 0)
SingleResult.Snatched = true;
else
SingleResult.Snatched = false;
if (DBReader.GetInt32(5) != 0)
SingleResult.Wanted = true;
else
SingleResult.Wanted = false;
Result.Add(SingleResult);
}
if (Result.Count == 0)
{
DBConnector.Close();
connectionopen = false;
return null;
}
DBConnector.Close();
connectionopen = false;
return Result;
}
public MainWin(bool debug) { LogInstance = new Logger(debug); DBConnection = new DatabaseConnector(LogInstance); SearchInstance = new Searcher(LogInstance); LogInstance.WriteToFile(1, "Starting Application", LogSource); LogInstance.WriteToFile(1, "Initializing Cache", LogSource); DBConnection.InitializeCache(); LogInstance.WriteToFile(1, "Fetching all PC-games from the DB", LogSource); CurGameList = DBConnection.AllGamesByPlatform("PC"); //Start the searcher in it's own thread, it shouldn't interfere with anything LogInstance.WriteToFile(1, "Starting Searcher-Thread", LogSource); SearchThread = new Thread(() => { SearchInstance.IntervallSearchFromDB(30); }); SearchThread.Start(); LogInstance.WriteToFile(1, "Loading Form", LogSource); InitializeComponent(); LogInstance.WriteToFile(1, "Welcome To FreakOut!", LogSource); btAddGame.Enabled = false; btAddGame.Visible = false; cBSearchResultPicker.Enabled = false; cBSearchResultPicker.Visible = false; bs_games.DataSource = DBConnection.FillDataTable(); dataGridView1.DataSource = bs_games; dataGridView1.Refresh(); if (CurGameList != null) { for (int x = 0; x < CurGameList.Count; x++) { if (CurGameList[x] != null) lboxGameList.Items.Add((x+1) + ". " + CurGameList[x].Name.Replace(":", "-") + " (ID: " + CurGameList[x].ID + ")"); } } else { lblNameOfGame.Visible = false; lblPublisher.Visible = false; lblPlayers.Visible = false; lblCoOp.Visible = false; lblRelease.Visible = false; lblContent.Visible = false; lblYoutube.Visible = false; lblGenres.Visible = false; pbGamePic.Hide(); lboxGameList.Items.Add("No games currently to display."); } this.FillPlatformBox(); lboxGameList.SelectedIndex = 0; }