public void GetGameDetails_Test() { GenreBusiness.Fill(); var access = ""; var games = APIFunctions.GetGameDetails("136", new Platform(), out access); Assert.IsNotNull(games); }
private void buttonOpenDB_Click(object sender, EventArgs e) { if (textBoxId.Text == string.Empty) { FormCustomMessage.ShowError("TheGameDB Id is empty."); return; } var access = ""; var game = APIFunctions.GetGameDetails(textBoxId.Text, SelectedRom.Platform, out access); game.Id = textBoxId.Text; StringBuilder text = new StringBuilder(""); text.Append("ID" + Environment.NewLine); text.Append(game.Id + Environment.NewLine + Environment.NewLine); text.Append("NAME" + Environment.NewLine); text.Append(game.DBName + Environment.NewLine + Environment.NewLine); text.Append("PLATFORM" + Environment.NewLine); text.Append(game.Platform.Id + " - " + game.Platform.Name + Environment.NewLine + Environment.NewLine); text.Append("PUBLISHER" + Environment.NewLine); text.Append(game.Publisher + Environment.NewLine + Environment.NewLine); text.Append("DEVELOPER" + Environment.NewLine); text.Append(game.Developer + Environment.NewLine + Environment.NewLine); text.Append("DESCRIPTION" + Environment.NewLine); text.Append(game.Description + Environment.NewLine + Environment.NewLine); text.Append("YEAR RELEASED" + Environment.NewLine); text.Append(game.YearReleased + Environment.NewLine + Environment.NewLine); text.Append("GENRE" + Environment.NewLine); text.Append(game.Genre != null ? game.Genre.Name + Environment.NewLine + Environment.NewLine : "" + Environment.NewLine + Environment.NewLine); text.Append("RATING" + Environment.NewLine); text.Append(game.Rating != 0 ? game.Rating.ToString("#.#") : "" + Environment.NewLine + Environment.NewLine); text.Append("remaining access to api" + Environment.NewLine); text.Append(access); FormInfo info = new FormInfo(text.ToString()); info.Show(); }
private void SetOtherProperties() { var notSyncedRoms = Roms.Where(x => !string.IsNullOrEmpty(x.Id) && (string.IsNullOrEmpty(x.DBName) || string.IsNullOrEmpty(x.Publisher) || string.IsNullOrEmpty(x.Developer))).ToList(); bool updated = false; syncRomsCount = 0; ThreadStopped = false; List <Rom> romList = new List <Rom>(); foreach (var rom in notSyncedRoms) { if (StopThread) { StopThread = false; RomBusiness.SetRom(romList); Thread.CurrentThread.Abort(); comboBoxPlatform_SelectedIndexChanged(null, new EventArgs()); } if (progressBar.Maximum > progressBar.Value) { progressBar.Invoke((MethodInvoker) delegate { progressBar.Value++; }); } var access = ""; LogMessage("UPDATING - " + rom.Name); var game = APIFunctions.GetGameDetails(rom.Id, rom.Platform, out access); labelAccessLeftCount.Text = access; if (game == null) { continue; } if (string.IsNullOrEmpty(rom.DBName) && !string.IsNullOrEmpty(game.DBName)) { rom.DBName = game.DBName; updated = true; } if (string.IsNullOrEmpty(rom.Publisher) && !string.IsNullOrEmpty(game.Publisher)) { rom.Publisher = game.Publisher; updated = true; } if (string.IsNullOrEmpty(rom.Developer) && !string.IsNullOrEmpty(game.Developer)) { rom.Developer = game.Developer; updated = true; } if (string.IsNullOrEmpty(rom.Description) && !string.IsNullOrEmpty(game.Description)) { rom.Description = game.Description; updated = true; } if (rom.Genre == null && game.Genre != null) { rom.Genre = game.Genre; updated = true; } if ((rom.Rating == null || rom.Rating == 0) && (game.Rating != null && game.Rating > 0)) { rom.Rating = game.Rating; updated = true; } if (updated) { syncRomsCount++; romList.Add(rom); updated = false; } } RomBusiness.SetRom(romList); ThreadStopped = true; }
private void buttonGetRomData_Click(object sender, EventArgs e) { try { //FormWait.ShowWait(this); if (textBoxId.Text == string.Empty) { textBoxId.Text = SyncDataFunctions.DiscoverGameId(SelectedRom); if (string.IsNullOrEmpty(textBoxId.Text)) { FormCustomMessage.ShowError("Could not discover TheGamesDB Id"); return; } } var access = ""; var game = APIFunctions.GetGameDetails(textBoxId.Text, SelectedRom.Platform, out access); if (game == null) { FormCustomMessage.ShowError("Could not get rom data"); return; } textBoxDBName.Text = game.DBName; if (radioButtonOnlyMissing.Checked) { if (string.IsNullOrEmpty(textBoxPublisher.Text)) { textBoxPublisher.Text = game.Publisher; } if (string.IsNullOrEmpty(textBoxDeveloper.Text)) { textBoxDeveloper.Text = game.Developer; } if (string.IsNullOrEmpty(textBoxDescription.Text)) { textBoxDescription.Text = game.Description; } if (string.IsNullOrEmpty(textBoxYearReleased.Text)) { textBoxYearReleased.Text = game.YearReleased; } if (string.IsNullOrEmpty(textBoxRating.Text)) { textBoxRating.Text = game.Rating.ToString("#.#"); } if (string.IsNullOrEmpty(comboBoxGenre.Text)) { comboBoxGenre.SelectedValue = game.Genre != null ? game.Genre.Name : string.Empty; } } else { if (!string.IsNullOrEmpty(game.Publisher)) { textBoxPublisher.Text = game.Publisher; } if (!string.IsNullOrEmpty(game.Developer)) { textBoxDeveloper.Text = game.Developer; } if (!string.IsNullOrEmpty(game.Description)) { textBoxDescription.Text = game.Description; } if (!string.IsNullOrEmpty(game.YearReleased)) { textBoxYearReleased.Text = game.YearReleased; } if (game.Rating != 0) { textBoxRating.Text = game.Rating.ToString("#.#"); } } var box = RomFunctions.GetRomPicture(SelectedRom, Values.BoxartFolder); var title = RomFunctions.GetRomPicture(SelectedRom, Values.TitleFolder); var gameplay = RomFunctions.GetRomPicture(SelectedRom, Values.GameplayFolder); bool missingBox = string.IsNullOrEmpty(box); bool missingTitle = string.IsNullOrEmpty(title); bool missingGameplay = string.IsNullOrEmpty(gameplay); if (!missingBox && !missingTitle && !missingGameplay) { //FormWait.CloseWait(); return; } string boxUrl = string.Empty; string titleUrl = string.Empty; string gameplayUrl = string.Empty; var found = APIFunctions.GetGameArtUrls(textBoxId.Text, out boxUrl, out titleUrl, out gameplayUrl, out access); if (!found) { //FormWait.CloseWait(); return; } if (missingBox) { Functions.SavePictureFromUrl(SelectedRom, boxUrl, Values.BoxartFolder, checkBoxSaveAsJpg.Checked); boxToDeleteIfCanceled = RomFunctions.GetRomPicture(SelectedRom, Values.BoxartFolder); } if (missingTitle && !string.IsNullOrEmpty(titleUrl)) { Functions.SavePictureFromUrl(SelectedRom, titleUrl, Values.TitleFolder, checkBoxSaveAsJpg.Checked); titleToDeleteIfCanceled = RomFunctions.GetRomPicture(SelectedRom, Values.TitleFolder); } if (missingGameplay && !string.IsNullOrEmpty(gameplayUrl)) { Functions.SavePictureFromUrl(SelectedRom, gameplayUrl, Values.GameplayFolder, checkBoxSaveAsJpg.Checked); gameplayToDeleteIfCanceled = RomFunctions.GetRomPicture(SelectedRom, Values.GameplayFolder); } MessageBox.Show("Remaining access: " + access); } catch (Exception ex) { //FormWait.CloseWait(); FormCustomMessage.ShowError(ex.Message); } finally { //FormWait.CloseWait(); } }