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; } } }
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; } }