Exemplo n.º 1
0
 public FOServerJson(string configUrl, string statusUrl, string combinedUrl, ILogger logger)
 {
     this.configUrl = configUrl;
     this.statusUrl = statusUrl;
     this.combinedUrl = combinedUrl;
     jsonFetch = new JsonFetcher(logger);
 }
Exemplo n.º 2
0
        public void Update(string savePath, string logoUrl)
        {
            JsonFetcher jsonFetcher = new JsonFetcher(new NLogWrapper("FOQuery"));
            JObject o = jsonFetcher.DownloadJson(logoUrl);

            if (o == null)
            {
                logger.Error("Returned JSON node is null.");
                return;
            }

            foreach (JToken serverName in o["fonline"]["logo"].Children())
            {
                FOLogoInfo logo = JsonConvert.DeserializeObject<FOLogoInfo>(serverName.First.ToString());
                string id = ((JProperty)serverName).Name;
                if (this.logoInfo.ContainsKey(id))
                {
                    if (!File.Exists(this.logoInfo[id].Path))
                    {
                        this.logger.Error("{0} not found.", this.logoInfo[id].Path);
                    }
                    else
                    {
                        if (this.logoInfo[id].Hash == logo.Hash)
                            continue;
                    }
                }
                if (!Directory.Exists(savePath))
                    Directory.CreateDirectory(savePath);

                string imagePath = savePath + Path.DirectorySeparatorChar + Utils.GetFilenameFromUrl("http://" + logo.Path);
                this.DownloadLogo("http://fodev.net/status/" + logo.Path, imagePath);
                logo.Path = imagePath;
                this.logoInfo[id] = logo;
            }

            this.SaveSettings(this.logoInfo);
        }
Exemplo n.º 3
0
        void bw_DoWork(object sender, DoWorkEventArgs e)
        {
            JsonFetcher jsonFetch = new JsonFetcher(new NLogWrapper("FOQuery"));
            FOJsonDeserializer jsonDeserialize = new FOJsonDeserializer();

            this.view.UpdateStatusBar("Downloading data...");

            var jsonNode = jsonFetch.DownloadJson(this.settings.InstallUrl);
            this.installHandler = new InstallHandler(jsonDeserialize.GetInstallData(jsonNode), settings.Games, settings.Dependencies);
            this.logger.Debug("Installhandler initialized.");
            this.logoManager = new LogoManager(this.settings.Paths.Logos, this.settings.LogoUrl);
            this.logger.Debug("Logos initialized.");
            this.serverManager = new ServerManager(
                new FOServerJson(settings.ConfigUrl, settings.StatusUrl, settings.CombinedUrl, new NLogWrapper("FOQuery")),
                this.installHandler);
            this.logger.Debug("Servermanager initialized.");
            this.VerifyInstalledGames();
            this.logger.Debug("Verified installed games.");
            this.view.UpdateStatusBar("Updating game list...");
            this.UpdateGameList();
            this.logger.Debug("Games updated.");
        }