public void GetGamesListByPlatform_Test() { GenreBusiness.Fill(); var games = APIFunctions.GetGamesListByPlatform("6", "", ""); Assert.IsNotNull(games); }
private void buttonShowMissingRoms_Click(object sender, EventArgs e) { try { if (comboBoxPlatform.Text == "" || comboBoxPlatform.Text == "none") { FormCustomMessage.ShowError("Select a platform"); } Platform platform = PlatformBusiness.Get(comboBoxPlatform.Text); var json = RomFunctions.GetPlatformJson(comboBoxPlatform.Text); if (string.IsNullOrEmpty(json)) { FormCustomMessage.ShowError("Json not found. Sync platform first"); } var games = APIFunctions.GetGamesListByPlatform(platform.Id, json, platform.Name); var roms = RomBusiness.GetAll(platform); StringBuilder builder = new StringBuilder(""); foreach (var game in games) { if (!roms.Any(x => x.Id == game.Id)) { builder.Append(game.Id + "-" + game.DBName + Environment.NewLine); } } FormInfo info = new FormInfo(builder.ToString()); info.Show(); Updated = true; } catch (Exception ex) { //FormWait.CloseWait(); FormCustomMessage.ShowError(ex.Message); } finally { //FormWait.CloseWait(); } }
private void buttonSync_Click(object sender, EventArgs e) { try { comboBoxPlatform.Enabled = false; buttonSync.Enabled = false; platformId = comboBoxPlatform.SelectedValue.ToString(); textBoxLog.Text = ""; progressBar.Value = 0; if (checkBoxBasicSync.Checked) { notSyncedRoms = Roms.Where(x => !x.IdLocked && (string.IsNullOrEmpty(x.Id))).ToList(); } else { notSyncedRoms = Roms.Where(x => !x.IdLocked && (string.IsNullOrEmpty(x.Id) || string.IsNullOrEmpty(x.YearReleased) || string.IsNullOrEmpty(x.DBName))).ToList(); } LogMessage("GETTING GAMES LIST..."); Updated = true; if (comboBoxPlatform.SelectedValue == null || string.IsNullOrEmpty(comboBoxPlatform.SelectedValue.ToString()) || comboBoxPlatform.SelectedValue.ToString() == "0") { FormCustomMessage.ShowInfo(string.Format("The platform {0} doesn't have an associated TheGamesDB.net Id. Update the platform Id in the Platform screen first.", comboBoxPlatform.SelectedText)); comboBoxPlatform.Enabled = true; buttonSync.Enabled = true; return; } var json = RomFunctions.GetPlatformJson(comboBoxPlatform.Text); games = APIFunctions.GetGamesListByPlatform(comboBoxPlatform.SelectedValue.ToString(), json, comboBoxPlatform.Text); if (games == null) { FormCustomMessage.ShowError("An Error ocurred"); comboBoxPlatform.Enabled = true; buttonSync.Enabled = true; return; } LogMessage(string.Format("{0} games found at online DB for the {1} platform", games.Count, comboBoxPlatform.Text)); progressBar.Maximum = notSyncedRoms.Count * 2; new Thread(() => { if (radioButtonSyncAll.Checked) { //threadSetIdAndYear.Start(); SetIdAndYear(); } int count = 0; int count2 = 0; int count3 = 0; count = syncRomsCount; if (!checkBoxBasicSync.Checked) { if (radioButtonSyncAll.Checked) { //threadSetOtherProperties.Start(); SetOtherProperties(); count2 = syncRomsCount; } SetPictures(); count3 = syncRomsCount; } progressBar.Invoke((MethodInvoker) delegate { progressBar.Value = progressBar.Maximum; }); LogMessage(count.ToString() + " roms Id/Year updated successfully!"); LogMessage(count2.ToString() + " roms details updated successfully!"); LogMessage(count3.ToString() + " roms images updated successfully!"); FormCustomMessage.ShowSuccess(count.ToString() + " roms Id/Year updated successfully!" + Environment.NewLine + count2.ToString() + " roms details updated successfully!" + Environment.NewLine + count3.ToString() + " roms images updated successfully!" ); comboBoxPlatform_SelectedIndexChanged(sender, e); comboBoxPlatform.Invoke((MethodInvoker) delegate { comboBoxPlatform.Enabled = true; }); buttonSync.Invoke((MethodInvoker) delegate { buttonSync.Enabled = true; }); }).Start(); } catch (Exception ex) { FormCustomMessage.ShowError(ex.Message); buttonStopProcess_Click(null, e); textBoxLog.Text = ""; } }