public Game GetGame(int GameID)
{
//Same as above, but this time try to get the game via the ID
LogInstance.WriteToFile(1, "Trying to fetch the game with ID " + GameID + " from the database.", LogSource);
if (!connectionopen)
{
DBConnector.Open();
connectionopen = true;
}
FbTransaction DBTransaction = DBConnector.BeginTransaction();
FbCommand DBCommand = new FbCommand("SELECT * FROM games WHERE ID=" + GameID, DBConnector, DBTransaction);
FbDataReader DBReader = DBCommand.ExecuteReader();
int x = 0;
Game Result = new Game();
Result.ID = GameID;
Result.InfoXML = new XmlDocument();
while (DBReader.Read())
{
x++;
if (x == 1)
{
Result.Name = DBReader.GetString(1);
Result.InfoXML.LoadXml(DBReader.GetString(2));
Result.ReleaseDate = DateTime.Parse(DBReader.GetString(6));
Result.InstallPath = DBReader.GetString(7);
Result.scraper_gdb_id = DBReader.GetInt32(8);
Result.Platform = DBReader.GetString(9);
if (DBReader.GetInt32(3) != 0)
Result.Downloaded = true;
else
Result.Downloaded = false;
if (DBReader.GetInt32(4) != 0)
Result.Snatched = true;
else
Result.Snatched = false;
if (DBReader.GetInt32(5) != 0)
Result.Wanted = true;
else
Result.Wanted = false;
}
}
if (x == 0)
return null;
DBConnector.Close();
connectionopen = false;
return Result;
}