示例#1
0
        public void ChangeLanguage(StoreLanguage language)
        {
            if (Program.Database == null)
            {
                return;
            }

            if (dbLanguage == language)
            {
                return;
            }

            dbLanguage = language;

            foreach (DatabaseEntry entry in Games.Values)
            {
                if (entry.Id <= 0)
                {
                    continue;
                }

                entry.Clear();
            }

            List <int> toUpdate = new List <int>();

            if (FormMain.CurrentProfile != null)
            {
                foreach (GameInfo game in FormMain.CurrentProfile.GameData.Games.Values)
                {
                    if (game.Id > 0)
                    {
                        toUpdate.Add(game.Id);
                    }
                }

                using (ScrapeDialog dialog = new ScrapeDialog(toUpdate))
                {
                    dialog.ShowDialog();
                }
            }

            Save("GameDB.xml.gz");
        }
示例#2
0
        private void ScrapeGames(ICollection <ScrapeJob> scrapeJobs)
        {
            if (scrapeJobs.Count <= 0)
            {
                AddStatusMsg(GlobalStrings.DBEditDlg_NoGamesToScrape);
                return;
            }

            using (ScrapeDialog dialog = new ScrapeDialog(scrapeJobs))
            {
                DialogResult result = dialog.ShowDialog();

                if (dialog.Error != null)
                {
                    AddStatusMsg(GlobalStrings.DBEditDlg_ErrorUpdatingGames);
                    MessageBox.Show(string.Format(CultureInfo.CurrentCulture, GlobalStrings.DBEditDlg_ErrorWhileUpdatingGames, dialog.Error.Message), GlobalStrings.DBEditDlg_Error, MessageBoxButtons.OK, MessageBoxIcon.Error);
                }

                switch (result)
                {
                case DialogResult.Cancel:
                    AddStatusMsg(GlobalStrings.DBEditDlg_UpdateCanceled);
                    break;

                case DialogResult.Abort:
                    AddStatusMsg(string.Format(CultureInfo.CurrentCulture, GlobalStrings.DBEditDlg_AbortedUpdate, dialog.JobsCompleted, dialog.TotalJobs));
                    break;

                default:
                    AddStatusMsg(string.Format(CultureInfo.CurrentCulture, GlobalStrings.DBEditDlg_UpdatedEntries, dialog.JobsCompleted));
                    break;
                }

                if (dialog.JobsCompleted <= 0)
                {
                    return;
                }

                UnsavedChanges = true;
                RebuildDisplayList();
            }
        }
示例#3
0
        private void ScrapeGames(IList <int> appIds)
        {
            if (appIds.Count <= 0)
            {
                AddStatusMsg(GlobalStrings.DBEditDlg_NoGamesToScrape);

                return;
            }

            using (ScrapeDialog dialog = new ScrapeDialog(appIds))
            {
                DialogResult result = dialog.ShowDialog();

                if (dialog.Error != null)
                {
                    AddStatusMsg(GlobalStrings.DBEditDlg_ErrorUpdatingGames);
                    MessageBox.Show(string.Format(GlobalStrings.DBEditDlg_ErrorWhileUpdatingGames, dialog.Error.Message), GlobalStrings.DBEditDlg_Error, MessageBoxButtons.OK, MessageBoxIcon.Error);
                }

                if (result == DialogResult.Cancel)
                {
                    AddStatusMsg(GlobalStrings.DBEditDlg_UpdateCanceled);
                }
                else if (result == DialogResult.Abort)
                {
                    AddStatusMsg(string.Format(GlobalStrings.DBEditDlg_AbortedUpdate, dialog.CompletedJobs, dialog.TotalJobs));
                }
                else
                {
                    AddStatusMsg(string.Format(GlobalStrings.DBEditDlg_UpdatedEntries, dialog.CompletedJobs));
                }

                if (dialog.CompletedJobs <= 0)
                {
                    return;
                }

                UnsavedChanges = true;
                RebuildDisplayList();
            }
        }
示例#4
0
        /// <summary>
        ///     Performs a web scrape on the given games.
        /// </summary>
        /// <param name="gamesToScrape">List of id's to scrape</param>
        private void ScrapeGames(List <int> gamesToScrape)
        {
            if (gamesToScrape.Count > 0)
            {
                ScrapeDialog dlg = new ScrapeDialog(gamesToScrape);
                DialogResult res = dlg.ShowDialog();

                if (dlg.Error != null)
                {
                    AddStatusMsg(GlobalStrings.DBEditDlg_ErrorUpdatingGames);
                    MessageBox.Show(string.Format(GlobalStrings.DBEditDlg_ErrorWhileUpdatingGames, dlg.Error.Message), GlobalStrings.DBEditDlg_Error, MessageBoxButtons.OK, MessageBoxIcon.Error);
                }

                if (res == DialogResult.Cancel)
                {
                    AddStatusMsg(GlobalStrings.DBEditDlg_UpdateCanceled);
                }
                else if (res == DialogResult.Abort)
                {
                    AddStatusMsg(string.Format(GlobalStrings.DBEditDlg_AbortedUpdate, dlg.CompletedJobs, dlg.TotalJobs));
                }
                else
                {
                    AddStatusMsg(string.Format(GlobalStrings.DBEditDlg_UpdatedEntries, dlg.CompletedJobs));
                }

                if (dlg.CompletedJobs > 0)
                {
                    UnsavedChanges = true;
                    RebuildDisplayList();
                }
            }
            else
            {
                AddStatusMsg(GlobalStrings.DBEditDlg_NoGamesToScrape);
            }
        }
示例#5
0
        private bool ScrapeUnscrapedGames(Profile p, bool doScrape)
        {
            if (!doScrape)
            {
                WriteLine("Skipping game scraping.");
                return(true);
            }

            bool success = false;

            Write("Scraping unscraped games...");
            try
            {
                List <ScrapeJob> scrapeJobs = new List <ScrapeJob>();
                foreach (int appId in p.GameData.Games.Keys.Where(g => !Settings.IgnoreList.Contains(g)))
                {
                    DatabaseEntry entry = null;
                    if (appId > 0 && !Database.Contains(appId, out entry))
                    {
                        scrapeJobs.Add(new ScrapeJob(appId, appId));
                    }
                    else if (entry != null && entry.LastStoreScrape == 0)
                    {
                        scrapeJobs.Add(new ScrapeJob(entry.Id, appId));
                    }
                }

                if (scrapeJobs.Count > 0)
                {
                    using (ScrapeDialog dialog = new ScrapeDialog(scrapeJobs))
                    {
                        DialogResult result = dialog.ShowDialog();

                        if (result == DialogResult.Cancel)
                        {
                            WriteLine("Scraping cancelled.");
                        }
                        else
                        {
                            WriteLine("Scraping complete.");
                            if (dialog.JobsCompleted > 0)
                            {
                                dbModified = true;
                            }
                        }
                    }
                }
                else
                {
                    WriteLine("No unscraped games found.");
                }

                success = true;
            }
            catch (Exception e)
            {
                WriteLine("Error updating database from web: " + e.Message);
                Logger.Exception("Automatic mode: Error updating db from web.", e);
            }

            return(success);
        }
示例#6
0
        public void ChangeLanguage(StoreLanguage lang)
        {
            if (Program.Database == null)
            {
                return;
            }

            StoreLanguage dbLang = StoreLanguage.en;

            if (lang == StoreLanguage.windows)
            {
                CultureInfo currentCulture = Thread.CurrentThread.CurrentCulture;
                if (Enum.GetNames(typeof(StoreLanguage)).ToList().Contains(currentCulture.TwoLetterISOLanguageName))
                {
                    dbLang = (StoreLanguage)Enum.Parse(typeof(StoreLanguage), currentCulture.TwoLetterISOLanguageName);
                }
                else
                {
                    if ((currentCulture.Name == "zh-Hans") || (currentCulture.Parent.Name == "zh-Hans"))
                    {
                        dbLang = StoreLanguage.zh_Hans;
                    }
                    else if ((currentCulture.Name == "zh-Hant") || (currentCulture.Parent.Name == "zh-Hant"))
                    {
                        dbLang = StoreLanguage.zh_Hant;
                    }
                    else if ((currentCulture.Name == "pt-BR") || (currentCulture.Parent.Name == "pt-BR"))
                    {
                        dbLang = StoreLanguage.pt_BR;
                    }
                }
            }
            else
            {
                dbLang = lang;
            }

            if (Language == dbLang)
            {
                return;
            }

            foreach (DatabaseEntry entry in Games.Values)
            {
                if (entry.Id <= 0)
                {
                    continue;
                }

                entry.Tags.Clear();
                entry.Flags.Clear();
                entry.Genres.Clear();
                entry.SteamReleaseDate = null;
                entry.LastStoreScrape  = 1;                //pretend it is really old data
                entry.VRSupport        = new VRSupport();
                entry.LanguageSupport  = new LanguageSupport();
            }

            //Update DB with data in correct language

            if (MainForm.CurrentProfile == null)
            {
                Save("GameDB.xml.gz");
                return;
            }

            SortedSet <int> appIds = new SortedSet <int>();

            foreach (GameInfo game in MainForm.CurrentProfile.GameData.Games.Values)
            {
                if (game.Id <= 0)
                {
                    continue;
                }

                appIds.Add(game.Id);
            }

            using (ScrapeDialog dialog = new ScrapeDialog(appIds))
            {
                dialog.ShowDialog();
            }

            Save("GameDB.xml.gz");
        }