Beispiel #1
0
        public void GetGameByName_Test()
        {
            GenreBusiness.Fill();
            var access = "";
            var games  = APIFunctions.GetGameByName("136", "Super Mario World", out access);

            Assert.IsNotNull(games);
        }
Beispiel #2
0
        private void SetIdAndYear()
        {
            syncRomsCount = 0;

            bool updated = false;

            ThreadStopped = false;
            bool       found            = false;
            string     gameNameToDelete = string.Empty;
            List <Rom> romList          = new List <Rom>();

            foreach (var rom in notSyncedRoms)
            {
                if (found && !string.IsNullOrEmpty(gameNameToDelete))
                {
                    games.RemoveAll(x => x.DBName == gameNameToDelete);
                    gameNameToDelete = string.Empty;
                }

                if (progressBar.Maximum > progressBar.Value)
                {
                    labelProgress.Invoke((MethodInvoker) delegate
                    {
                        progressBar.Value++;
                    });
                }

                if (StopThread)
                {
                    StopThread = false;
                    RomBusiness.SetRom(romList);
                    Thread.CurrentThread.Abort();
                    comboBoxPlatform_SelectedIndexChanged(null, new EventArgs());
                }

                var romName = RomFunctions.TrimRomName(rom.Name);
                found = false;

                foreach (var game in games)
                {
                    var gameName = RomFunctions.TrimRomName(game.DBName);

                    if (romName == gameName)
                    {
                        gameNameToDelete = game.DBName;
                        found            = true;

                        if (string.IsNullOrEmpty(rom.Id) && !string.IsNullOrEmpty(game.Id))
                        {
                            rom.Id  = game.Id;
                            updated = true;
                        }

                        if (string.IsNullOrEmpty(rom.YearReleased) && !string.IsNullOrEmpty(game.YearReleased))
                        {
                            rom.YearReleased = game.YearReleased;
                            updated          = true;
                        }

                        if (string.IsNullOrEmpty(rom.DBName) && !string.IsNullOrEmpty(game.DBName))
                        {
                            rom.DBName = game.DBName;
                            updated    = true;
                        }

                        if (updated)
                        {
                            syncRomsCount++;
                            LogMessage("ID AND YEAR SET - " + rom.Name);
                            romList.Add(rom);
                            updated = false;
                        }

                        break;
                    }
                }

                if (!found)
                {
                    LogMessage("NOT FOUND - " + rom.Name);

                    if (!checkBoxBasicSync.Checked)
                    {
                        LogMessage("TRYING BY NAME - " + rom.Name);
                        var gameName = Functions.RemoveSubstring(rom.Name, '(', ')');
                        gameName = Functions.RemoveSubstring(gameName, '[', ']').Trim();
                        string acessos = "";
                        var    game    = APIFunctions.GetGameByName(platformId, gameName, out acessos);

                        if (game == null)
                        {
                            LogMessage("REALLY NOT FOUND - " + rom.Name);
                            continue;
                        }

                        found = true;

                        if (string.IsNullOrEmpty(rom.Id) && !string.IsNullOrEmpty(game.Id))
                        {
                            rom.Id  = game.Id;
                            updated = true;
                        }

                        if (string.IsNullOrEmpty(rom.YearReleased) && !string.IsNullOrEmpty(game.YearReleased))
                        {
                            rom.YearReleased = game.YearReleased;
                            updated          = true;
                        }

                        if (string.IsNullOrEmpty(rom.DBName) && !string.IsNullOrEmpty(game.DBName))
                        {
                            rom.DBName = game.DBName;
                            updated    = true;
                        }

                        if (updated)
                        {
                            syncRomsCount++;
                            LogMessage("ID AND YEAR SET - " + rom.Name);
                            romList.Add(rom);
                            updated = false;
                        }
                    }
                }
            }

            RomBusiness.SetRom(romList);
            ThreadStopped = true;
        }