/* * * public async void StartGameScrape(ProgressDialogController controller) * { * if (controller == null) * { * // create UI dialog * var mySettings = new MetroDialogSettings() * { * NegativeButtonText = "Cancel Scraping", * AnimateShow = false, * AnimateHide = false * }; * controller = await mw.ShowProgressAsync("Scraping Data", "Initialising...", true, settings: mySettings); * controller.SetCancelable(true); * await Task.Delay(100); * } * * await Task.Run(() => * { * ScrapeGame(controller); * }); */ /* * await controller.CloseAsync(); * * if (controller.IsCanceled) * { * await mw.ShowMessageAsync("MedLaunch Scraper", "Scraping Cancelled"); * } * else * { * await mw.ShowMessageAsync("MedLaunch Scraper", "Scraping Completed"); * } * * await Task.Delay(300); */ //GamesLibraryVisualHandler.RefreshGamesLibrary(); // } /// <summary> /// Extension method to handle no controller being passed /// </summary> /// /* * public void StartGameScrape() * { * StartGameScrape(null); * } */ /// <summary> /// Creates a new entry in the GDBLink table (linking MedLaunch gameId to scraped data (thegamesdb.net) ID) /// also deletes any rows that have the same GameId (so that duplicates are not possible) /// </summary> /// <param name="gameId"></param> /// <param name="gamesDbId"></param> /// /* * public static void CreateDatabaseLink(int gameId, int gamesDbId) * { * GDBLink link = new GDBLink(); * link.GameId = gameId; * link.GdbId = gamesDbId; * // delete any existing links with the same GameId * GDBLink l = GDBLink.GetRecord(gameId); * if (l != null) * { * GDBLink.DeleteRecord(l); * } * GDBLink.SaveToDatabase(link); * PopulateLibraryData(link); * GameListBuilder.UpdateFlag(); * } */ /// <summary> /// create data in the LibraryDataGDBLink table /// </summary> /// <param name="link"></param> public static void PopulateLibraryData(int gameId, int gdbId) { var data = LibraryDataGDBLink.GetLibraryData(gdbId); if (data == null) { data = new LibraryDataGDBLink(); } GamesLibraryScrapedContent gd = new GamesLibraryScrapedContent(); ScrapedGameObject o = gd.GetScrapedGameObject(gameId, gdbId); data.GDBId = o.GdbId; data.Coop = o.Data.Coop; data.Developer = o.Data.Developer; data.ESRB = o.Data.ESRB; data.Players = o.Data.Players; data.Publisher = o.Data.Publisher; data.Year = o.Data.Released; // save library data LibraryDataGDBLink.SaveToDataBase(data); // set isScraped flag in Game table Game ga = Game.GetGame(gameId); ga.isScraped = true; ga.gdbId = gdbId; Game.SetGame(ga); }
/* * * public async void StartGameScrape(ProgressDialogController controller) * { * if (controller == null) * { * // create UI dialog * var mySettings = new MetroDialogSettings() * { * NegativeButtonText = "Cancel Scraping", * AnimateShow = false, * AnimateHide = false * }; * controller = await mw.ShowProgressAsync("Scraping Data", "Initialising...", true, settings: mySettings); * controller.SetCancelable(true); * await Task.Delay(100); * } * * await Task.Run(() => * { * ScrapeGame(controller); * }); */ /* * await controller.CloseAsync(); * * if (controller.IsCanceled) * { * await mw.ShowMessageAsync("MedLaunch Scraper", "Scraping Cancelled"); * } * else * { * await mw.ShowMessageAsync("MedLaunch Scraper", "Scraping Completed"); * } * * await Task.Delay(300); */ //GamesLibraryVisualHandler.RefreshGamesLibrary(); // } /// <summary> /// Extension method to handle no controller being passed /// </summary> /// /* * public void StartGameScrape() * { * StartGameScrape(null); * } */ /// <summary> /// Creates a new entry in the GDBLink table (linking MedLaunch gameId to scraped data (thegamesdb.net) ID) /// also deletes any rows that have the same GameId (so that duplicates are not possible) /// </summary> /// <param name="gameId"></param> /// <param name="gamesDbId"></param> /// /* * public static void CreateDatabaseLink(int gameId, int gamesDbId) * { * GDBLink link = new GDBLink(); * link.GameId = gameId; * link.GdbId = gamesDbId; * // delete any existing links with the same GameId * GDBLink l = GDBLink.GetRecord(gameId); * if (l != null) * { * GDBLink.DeleteRecord(l); * } * GDBLink.SaveToDatabase(link); * PopulateLibraryData(link); * GameListBuilder.UpdateFlag(); * } */ /// <summary> /// create data in the LibraryDataGDBLink table /// </summary> /// <param name="link"></param> public static void PopulateLibraryData(int gameId, int gdbId) { var data = LibraryDataGDBLink.GetLibraryData(gdbId); if (data == null) { data = new LibraryDataGDBLink(); } //ScrapeDB gd = new ScrapeDB(); ScrapedGameObject o = ScrapeDB.GetScrapedGameObject(gameId, gdbId); data.GDBId = o.GdbId; data.Coop = o.Data.Coop; data.Developer = o.Data.Developer; data.ESRB = o.Data.ESRB; data.Players = o.Data.Players; data.Publisher = o.Data.Publisher; data.Year = o.Data.Released; // save library data LibraryDataGDBLink.SaveToDataBase(data); // set isScraped flag in Game table Game ga = Game.GetGame(gameId); // ignore if manual editing is set if (ga.ManualEditSet == true) { return; } ga.isScraped = true; ga.gdbId = gdbId; // populate new extended fields ga.Coop = o.Data.Coop; ga.Developer = o.Data.Developer; ga.ESRB = o.Data.ESRB; ga.Overview = o.Data.Overview; ga.Players = o.Data.Players; ga.Publisher = o.Data.Publisher; ga.Year = o.Data.Released; StringBuilder sbAT = new StringBuilder(); for (int i = 0; i < o.Data.AlternateTitles.Count(); i++) { sbAT.Append(o.Data.AlternateTitles[i]); if (i < (o.Data.AlternateTitles.Count() - 1)) { sbAT.Append(", "); } } ga.AlternateTitles = sbAT.ToString(); StringBuilder sbGE = new StringBuilder(); for (int i = 0; i < o.Data.AlternateTitles.Count(); i++) { sbGE.Append(o.Data.AlternateTitles[i]); if (i < (o.Data.AlternateTitles.Count() - 1)) { sbGE.Append(", "); } } ga.AlternateTitles = sbGE.ToString(); Game.SetGame(ga); }