private void CheckUpdate()
        {
            if (!Directory.Exists(workingDirectory))
            {
                Directory.CreateDirectory(workingDirectory);
            }

            SoftwareUpdater.CheckVersion();
        }
        private void CheckUpdate()
        {
            if (!Directory.Exists(_folder))
            {
                Directory.CreateDirectory(_folder);
            }

            SoftwareUpdater.CheckVersion();

            foreach (TranslationFile filename in Enum.GetValues(typeof(TranslationFile)))
            {
                var current = "0.0.0";
                var path    = _folder + $"\\{filename}.xml";
                if (File.Exists(path))
                {
                    var translationfile = XDocument.Load(path);
                    current = translationfile.Root.Attribute("Version").Value;
                }
                var latest = current;

                if (filename == TranslationFile.Equipment)
                {
                    latest = SoftwareUpdater.EqVer;
                }
                if (filename == TranslationFile.EquipmentTypes)
                {
                    latest = SoftwareUpdater.EqTypeVer;
                }
                if (filename == TranslationFile.Expeditions)
                {
                    latest = SoftwareUpdater.ExpVer;
                }
                if (filename == TranslationFile.Operations)
                {
                    latest = SoftwareUpdater.OpVer;
                }
                if (filename == TranslationFile.Quests)
                {
                    latest = SoftwareUpdater.QuestVer;
                }
                if (filename == TranslationFile.Ships)
                {
                    latest = SoftwareUpdater.ShipVer;
                }
                if (filename == TranslationFile.ShipTypes)
                {
                    latest = SoftwareUpdater.ShipTypeVer;
                }

                if (current != latest)
                {
                    SoftwareUpdater.DownloadTranslation(filename, latest);
                }
            }
        }
        private static void DownloadStringCompleted(object sender, System.Net.DownloadStringCompletedEventArgs e)
        {
            if (e.Error != null)
            {
                Utility.ErrorReporter.SendErrorReport(e.Error, "Failed to obtain update data.");
                return;
            }

            if (e.Result.StartsWith("<!DOCTYPE html>"))
            {
                Utility.Logger.Add(3, "Invalid update URL.");
                return;
            }


            try
            {
                var      json        = DynamicJson.Parse(e.Result);
                DateTime date        = DateTimeHelper.CSVStringToTime(json.bld_date);
                string   version     = json.ver;
                string   description = json.note.Replace("<br>", "\r\n");

                if (UpdateTime < date)
                {
                    Utility.Logger.Add(3, Resources.NewVersionFound + version);
                    Task.Run(() => SoftwareUpdater.UpdateSoftware());

                    var result = System.Windows.Forms.MessageBox.Show(
                        string.Format(Resources.AskForUpdate,
                                      version, description),
                        Resources.Update, System.Windows.Forms.MessageBoxButtons.YesNoCancel, System.Windows.Forms.MessageBoxIcon.Information,
                        System.Windows.Forms.MessageBoxDefaultButton.Button1);


                    if (result == System.Windows.Forms.DialogResult.Yes)
                    {
                        System.Diagnostics.Process.Start("https://github.com/silfumus/ElectronicObserver/releases/latest");
                    }
                    else if (result == System.Windows.Forms.DialogResult.Cancel)
                    {
                        Utility.Configuration.Config.Life.CheckUpdateInformation = false;
                    }
                }
                else
                {
                    Utility.Logger.Add(1, "You are currently using the latest version (" + date.ToString("yyyy/MM/dd") + " release).");
                }
            }
            catch (Exception ex)
            {
                Utility.ErrorReporter.SendErrorReport(ex, Resources.UpdateConnectionFailed);
            }
        }
Esempio n. 4
0
        private void CheckUpdate()
        {
            if (!Directory.Exists(_folder))
            {
                Directory.CreateDirectory(_folder);
            }

            SoftwareUpdater.CheckVersion();

            Parallel.ForEach((TranslationFile[])Enum.GetValues(typeof(TranslationFile)), filename =>
            {
                var current = SoftwareUpdater.CheckDataVersion(filename);
                var latest  = current;

                if (filename == TranslationFile.Equipment)
                {
                    latest = SoftwareUpdater.EqVer;
                }
                if (filename == TranslationFile.EquipmentTypes)
                {
                    latest = SoftwareUpdater.EqTypeVer;
                }
                if (filename == TranslationFile.Expeditions)
                {
                    latest = SoftwareUpdater.ExpVer;
                }
                if (filename == TranslationFile.Operations)
                {
                    latest = SoftwareUpdater.OpVer;
                }
                if (filename == TranslationFile.Quests)
                {
                    latest = SoftwareUpdater.QuestVer;
                }
                if (filename == TranslationFile.Ships)
                {
                    latest = SoftwareUpdater.ShipVer;
                }
                if (filename == TranslationFile.ShipTypes)
                {
                    latest = SoftwareUpdater.ShipTypeVer;
                }

                if (current != latest)
                {
                    SoftwareUpdater.DownloadData(filename);
                }
                LoadFile(filename);
            });
        }