コード例 #1
0
        private void LoadGameVersionAsync()
        {
            //Settings MySettings = null;

/*            bool noSave = false;
 *          if (Program.Settings == null )
 *          {
 *              //MySettings = Commons.GetSettings();
 *          } else
 *          {
 *
 *              noSave = true;
 *          }*/
            VersionInfoImport Import = WGAPI.GetVersionInfo();

            if (Import.Status.Equals("ok"))
            {
                VersionInfo Info      = Import.VersionInfo;
                long        UpdatedAt = Info.Updated;
                string      Version   = Info.GameVersion;
                this.GameDate    = Commons.ConvertToDate(UpdatedAt);
                this.GameVersion = Version;
                if (Program.Settings != null)
                {
                    Program.Settings.GameUpdated = GameDate;
                    Program.Settings.GameVersion = Version;
                }
            }
        }
コード例 #2
0
        private void VersionChecker()
        {
            LOG.Debug("VersionChecker()");
            if (Program.Settings == null)
            {
                return;
            }
            if (Program.Settings.GameVersion == null)
            {
                LOG.Debug("No version stored. Getting new version.");
                LoadGameVersionAsync();
            }
            if (Program.Settings.Server == null || Program.Settings.Server.Equals(""))
            {
                return;
            }

            DateTime Today     = DateTime.Now;
            DateTime LastCheck = Program.Settings.LastChecked;

            if (LastCheck == null || DateTime.Compare(LastCheck.AddHours(23), Today) <= 0)
            {
                LOG.Debug("Last check not performed or more than 23 hours ago. Perform new check!");
                Program.Settings.LastChecked = Today;
                if (Program.Settings.UserID != 0)
                {
                    LOG.Debug("Loading users ships");
                    loadUserShipsInPort(Program.Settings.UserID, true);
                }

                VersionInfoImport Import = WGAPI.GetVersionInfo();
                if (Import.Status.Equals("ok"))
                {
                    VersionInfo Info = Import.VersionInfo;
                    GameVersion = Info.GameVersion;
                    GameDate    = Commons.ConvertToDate(Info.Updated);
                    LOG.Info("Gameversion: " + Info.GameVersion);
                    if (Program.Settings.GameVersion != null && Program.Settings.GameVersion.Equals(Info.GameVersion))
                    {
                        if (DateTime.Compare(Program.Settings.GameUpdated, GameDate) != 0)
                        {
                            LOG.Info("Game data needs to be updated. Not same game date.");
                            UpdateNeeded = true;
                        }
                    }
                    else
                    {
                        LOG.Info("Game data needs to be updated. Not same game version");
                        UpdateNeeded = true;
                    }
                }
            }
            else
            {
                Program.Settings.LastChecked = Today;
            }
        }
コード例 #3
0
        public static VersionInfoImport GetVersionInfo()
        {
            try { Setup(); } catch (Exception) { }
            string path           = $"encyclopedia/info/?application_id={APP_ID}&fields=ships_updated_at%2Cgame_version";
            string responseString = "";
            var    response       = Client.GetAsync(path).Result;

            if (response.IsSuccessStatusCode)
            {
                var responseContent = response.Content;
                responseString = responseContent.ReadAsStringAsync().Result;
            }
            VersionInfoImport Import = JsonConvert.DeserializeObject <VersionInfoImport>(responseString);

            return(Import);
        }