/* Constructors */ /// <summary> /// Instantiate class with a specific platform game entry based on gdbId /// </summary> /// <param name="gdbId"></param> public ScraperHandler(int gdbId, int gameId) { SSearch = new ScraperSearch(); MasterRecord = ScraperMaster.GetMasterList().Where(a => a.gid == gdbId).FirstOrDefault(); _GlobalSettings = SSearch._GlobalSettings; mw = Application.Current.Windows.OfType <MainWindow>().FirstOrDefault(); GameId = gameId; }
public ScraperSearch() { _GlobalSettings = GlobalSettings.GetGlobals(); PlatformGames = ScraperMaster.GetMasterList(); LocalGameFound = false; LocalIterationCount = 0; ManualIterator = 0; SearchCollection = new List <ScraperMaster>(); WorkingSearchCollection = new List <ScraperMaster>(); }
public static List <ScraperMaster> GetMasterList() { List <ScraperMaster> mList = new List <ScraperMaster>(); // get from masterview List <MasterView> mv = ScrapeDB.AllScrapeData; //MasterView.GetMasterView(); // get gamedocs List <Game_Doc> docs = Game_Doc.GetDocs(); // iterate through foreach (var entry in mv) { ScraperMaster sm = new ScraperMaster(); sm.gid = entry.gid; sm.pid = entry.pid; sm.mid = entry.mid; sm.GDBTitle = entry.GDBTitle; sm.GDBPlatformName = entry.PlatformName; sm.GDBPlatformAlias = entry.PlatformAlias; sm.GDBYear = entry.GDBYear; sm.MOBYTitle = entry.MOBYTitle; sm.MOBYAlias = entry.MOBYAlias; sm.MOBYPlatformName = entry.MOBYPlatformName; sm.MOBYPlatformAlias = entry.MOBYPlatformAlias; sm.MOBYYear = entry.MOBYYear; List <string> ds = (from a in docs where a.gid == sm.gid select a.downloadUrl).ToList(); if (ds.Count > 0) { sm.Game_Docs.AddRange(ds); } mList.Add(sm); } return(mList); }
public ICollection <ScraperMaster> SearchGameLocal(string gameName, int systemId, int gameId) { SearchString = gameName; LocalIterationCount = 0; WorkingSearchCollection = new List <ScraperMaster>(); SearchCollection = new List <ScraperMaster>(); if (gameName == null || gameName.Trim() == "") { return(SearchCollection); } if (systemId == 0 || gameId == 0) { return(SearchCollection); } if (SearchString.Contains("[PD]") || SearchString.Contains("(PD)") || SearchString.Contains("SC-3000") || SearchString.Contains("BIOS")) { // ignore public domain games return(SearchCollection); } // convert pce-cd systemid if (systemId == 18) { systemId = 7; } // get a list with all games for this system Game gam = Game.GetGame(gameId); if (gam.subSystemId != null && gam.subSystemId > 0) { // sub found var sub = GSystem.GetSubSystems().Where(a => a.systemId == gam.subSystemId.Value).FirstOrDefault(); SystemCollection = PlatformGames.Where(a => a.pid == sub.theGamesDBPlatformId.First()).ToList(); } else { //sub not found SystemCollection = PlatformGames.Where(a => GSystem.GetMedLaunchSystemIdFromGDBPlatformId(a.pid) == systemId).ToList(); } // genesis/megadrive region selection if (gam.systemId == 4) { if ( gam.Country != null && ( gam.Country.ToUpper() == "US" || gam.Country.ToUpper() == "USA" || gam.Country.ToUpper() == "U" ) ) { SystemCollection = SystemCollection.Where(a => a.pid == 18).ToList(); } else if ( gam.Country != null && ( gam.Country.ToUpper() == "EU" || gam.Country.ToUpper() == "EUR" || gam.Country.ToUpper() == "EUROPE" || gam.Country.ToUpper() == "JP" || gam.Country.ToUpper() == "JAP" || gam.Country.ToUpper() == "J" || gam.Country.ToUpper() == "JPN" ) ) { SystemCollection = SystemCollection.Where(a => a.pid == 36).ToList(); } else { // Region not detected - use globalsettings choice if (_GlobalSettings.preferGenesis == true) { SystemCollection = SystemCollection.Where(a => a.pid == 18).ToList(); } else { SystemCollection = SystemCollection.Where(a => a.pid == 36).ToList(); } } } // Match all words and return a list ordered by higest matches List <SearchOrdering> searchResult = OrderByMatchedWords(StripSymbols(gameName.ToLower())); // get max value in the list var maxValueRecord = searchResult.OrderByDescending(v => v.Matches).FirstOrDefault(); if (maxValueRecord == null) { SearchCollection = (from a in searchResult select a.Game).ToList(); } else { int maxValue = maxValueRecord.Matches; // select all records that have the max value List <SearchOrdering> matches = (from a in searchResult where (a.Matches == maxValue) // || a.Matches == maxValue - 1) select a).ToList(); SearchCollection = (from a in matches select a.Game).ToList(); if (matches.Count == 1) { // single entry returned List <ScraperMaster> single = (from a in matches select a.Game).ToList(); return(single); } if (matches.Count == 0) { return(null); } } // Multiple records returned - continue // match order of words starting with the first and incrementing List <ScraperMaster> m = MatchOneWordAtATime(SearchCollection, StripSymbols(gameName.ToLower())); if (m.Count == 1) { return(m); } if (m.Count > 1) { SearchCollection = m; } if (SearchCollection.Count == 2 && _GlobalSettings.preferGenesis == true) { // 2 records returned - check whether they match exactly string first = (from a in SearchCollection select a.GDBTitle).First(); string last = (from a in SearchCollection select a.GDBTitle).Last(); if (first == last) { // looks like the same game - perhaps different systems on the games db (ie - Megadrive / Genesis) - return the first result ScraperMaster pg = (from a in SearchCollection select a).First(); List <ScraperMaster> l = new List <ScraperMaster>(); l.Add(pg); return(l); } } // still no definiate match found // run levenshetein fuzzy search on SearchCollection - 10 iterations List <ScraperMaster> lg = LevenIteration(SearchCollection, StripSymbols(gameName.ToLower())); return(lg); }