コード例 #1
0
        private void buttonCleanIncorrectRomPlatform_Click(object sender, EventArgs e)
        {
            if (comboBoxPlatform.Text == "" || comboBoxPlatform.Text == "none")
            {
                FormCustomMessage.ShowError("Select a platform");
            }

            var json = RomFunctions.GetPlatformJson(comboBoxPlatform.Text);

            if (json == "")
            {
                return;
            }

            var        roms       = RomBusiness.GetAll(PlatformBusiness.Get(comboBoxPlatform.Text));
            int        count      = 0;
            List <Rom> romsUpdate = new List <Rom>();

            foreach (var rom in roms)
            {
                if (string.IsNullOrEmpty(rom.Id))
                {
                    continue;
                }

                if (!json.Contains("\"id\": " + rom.Id + ","))
                {
                    rom.Id           = "";
                    rom.Name         = rom.FileNameNoExt;
                    rom.DBName       = "";
                    rom.Description  = "";
                    rom.IdLocked     = false;
                    rom.Publisher    = "";
                    rom.YearReleased = "";
                    rom.Developer    = "";
                    rom.Rating       = 0;

                    romsUpdate.Add(rom);

                    count++;
                    Updated = true;
                }
            }

            RomBusiness.SetRom(romsUpdate);

            FormCustomMessage.ShowSuccess("Roms updated successfully! " + count.ToString() + " roms cleaned");
        }
コード例 #2
0
        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();
            }
        }
コード例 #3
0
        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 = "";
            }
        }
コード例 #4
0
        private void showIncorrectPlatformAuditToolStripMenuItem_Click(object sender, EventArgs e)
        {
            try
            {
                if (!showIncorrectPlatformAuditToolStripMenuItem.Checked)
                {
                    ColumnIncorrectPlatform.Visible = false;
                    return;
                }

                if (comboBoxPlatform.Text == "" || comboBoxPlatform.Text == "none")
                {
                    FormCustomMessage.ShowError("Select a platform");
                }

                var json = RomFunctions.GetPlatformJson(comboBoxPlatform.Text);

                if (json == "")
                {
                    FormCustomMessage.ShowError("Json not found. Sync platform first");
                    showIncorrectPlatformAuditToolStripMenuItem.Checked = false;
                    ColumnIncorrectPlatform.Visible = false;
                    return;
                }


                dataGridView.SuspendLayout();

                foreach (DataGridViewRow row in dataGridView.Rows)
                {
                    Rom rom = (Rom)row.Tag;

                    if (string.IsNullOrEmpty(rom.Id))
                    {
                        row.Cells[ColumnIncorrectPlatform.Name].Style.BackColor = Color.Yellow;
                        continue;
                    }

                    if (json.Contains("\"id\": " + rom.Id + ","))
                    {
                        row.Cells[ColumnIncorrectPlatform.Name].Style.BackColor = Color.Green;
                        row.Cells[ColumnIncorrectPlatform.Name].Value           = "OK";
                    }
                    else
                    {
                        row.Cells[ColumnIncorrectPlatform.Name].Style.BackColor = Color.Red;
                        row.Cells[ColumnIncorrectPlatform.Name].Value           = "NOT OK";
                    }
                }

                dataGridView.ResumeLayout();

                ColumnIncorrectPlatform.Visible = showIncorrectPlatformAuditToolStripMenuItem.Checked;

                if (updating)
                {
                    return;
                }
            }
            catch (OperationCanceledException ioex)
            {
                return;
            }
            catch (Exception ex)
            {
                FormCustomMessage.ShowError(ex.Message);
            }
        }