Пример #1
0
        static void UpdateTrackedGameSystemData(Dictionary <string, string> checkedGamesData)
        {
            string[] fileArray = Directory.GetFiles(gameSystemDataDirectory, "*.json");
            foreach (var filename in fileArray)
            {
                string     urlSuffix;
                GameSystem newGameSystem;
                GameSystem oldGameSystem;

                try
                {
                    using (StreamReader r = new StreamReader(Path.Combine(gameDataDirectory, filename)))
                    {
                        var json = r.ReadToEnd();
                        oldGameSystem = JsonConvert.DeserializeObject <GameSystem>(json);
                        urlSuffix     = oldGameSystem.UrlSuffix;
                        newGameSystem = new GameSystem(urlSuffix, checkedGamesData);
                    }
                    if (!oldGameSystem.Equals(newGameSystem))
                    {
                        newGameSystem.WriteDifferencesInGames(oldGameSystem);
                        newGameSystem.SaveData();
                    }
                }
                catch (FileNotFoundException)
                {
                    FileNotFoundHandler.AbortProgramToDueMissingCriticalFile(filename, gameDataDirectory);
                }
            }
        }
Пример #2
0
        private bool IsCachedMissingFileRequest()
        {
            object o = Get <ICacheWrapper>()[FileNotFoundHandler.GetMissingFileCacheKey(new HttpRequestWrapper(Request))];

            if (o != null)
            {
                Context.Items[CachedMissingItemKey] = true;
                Context.ApplicationInstance.CompleteRequest();
                return(true);
            }
            return(false);
        }
Пример #3
0
        static void UpdateTrackedGameData(ref Dictionary <string, string> checkedGamesData,
                                          ref Dictionary <string, string> changedGamesData)
        {
            string[] fileArray = Directory.GetFiles(gameDataDirectory, "*.json");
            foreach (var absoluteFileName in fileArray)
            {
                var  urlNumber    = absoluteFileName.Split(' ').Last().Replace(".json", "");
                var  baseFileName = Path.GetFileName(absoluteFileName);
                var  url          = $"/Game/{urlNumber}";
                var  newGame      = new Game(url);
                Game oldGame;

                try
                {
                    using (StreamReader r = new StreamReader(Path.Combine(gameDataDirectory, absoluteFileName)))
                    {
                        var json = r.ReadToEnd();
                        oldGame = JsonConvert.DeserializeObject <Game>(json);
                    }
                    if (!oldGame.Equals(newGame))
                    {
                        var newFileLocation = Path.Combine(gameDataDirectory, "outdated", baseFileName);
                        if (File.Exists(newFileLocation))
                        {
                            File.Delete(newFileLocation);
                            Console.WriteLine($"The file {newFileLocation} has been updated, even though it should no " +
                                              $"longer be relevant. Please ensure that this file is not relevant.");
                        }
                        File.Move(absoluteFileName, newFileLocation);
                        newGame.WriteDifferencesInGames(oldGame);
                        changedGamesData[url] = newGame.Name;
                        newGame.SaveData();
                    }
                    else if (newGame.TotalRetroRatioPoints != oldGame.TotalRetroRatioPoints)
                    {
                        newGame.SaveData();
                    }
                }
                catch (FileNotFoundException)
                {
                    FileNotFoundHandler.AbortProgramToDueMissingCriticalFile(absoluteFileName, gameDataDirectory);
                }

                checkedGamesData[url] = newGame.Name;
            }
        }
Пример #4
0
        private bool IsCachedMissingFileRequest()
        {
            string missingFile =
                Convert.ToString(
                    Get <ICacheWrapper>()[FileNotFoundHandler.GetMissingFileCacheKey(new HttpRequestWrapper(Request))]);

            if (!string.IsNullOrWhiteSpace(missingFile))
            {
                Context.Items[CachedMissingItemKey] = true;
                Context.Response.Clear();
                Context.Response.StatusCode             = 404;
                Context.Response.TrySkipIisCustomErrors = true;
                Context.Response.Write(missingFile);
                Context.ApplicationInstance.CompleteRequest();
                return(true);
            }
            return(false);
        }