コード例 #1
0
        private static bool Splash_CheckUpdate(Action <bool> SetIndeterminate, Action <string> SetDisplayText, Action <double> SetProgress)
        {
            //ToDo: Fix cert issue causes appclose
            var doShutdown = false;

            SetIndeterminate(true);
            SetDisplayText(Properties.Localization.Splash_CheckingForToolUpdates);
            SetProgress(1);
            Logger.Info("Checking for tool updates...");
            if (ConfigHost.App.EnableAutoToolUpdates)
            {
                (Application.Current as App).UpdateDownloadInfo = UpdateHelper.GetDownloadInfoAsync().Result;
                if ((Application.Current as App).UpdateDownloadInfo.available)
                {
                    SetIndeterminate(false);
                    SetDisplayText(Properties.Localization.Splash_UpdateAvailable);
                    Logger.Info($"Update {(Application.Current as App).UpdateDownloadInfo.version} is available.");
                    Application.Current.Dispatcher.Invoke(() =>
                    {
                        var msgboxresult = MessageBox.Show(
                            string.Format(Properties.Localization.SoftwareUpdateAvailable_Body, App.CurrentVersion, (Application.Current as App).UpdateDownloadInfo.version),
                            string.Format(Properties.Localization.SoftwareUpdateAvailable_Title, (Application.Current as App).UpdateDownloadInfo.version),
                            MessageBoxButton.YesNo,
                            MessageBoxImage.Information
                            );
                        if (msgboxresult == MessageBoxResult.Yes)
                        {
                            Logger.Info("Applying update.");
                            App.Shutdown(App.ExitCodes.Updating);
                            doShutdown = true;
                        }
                        else
                        {
                            Logger.Info("Ignoring update.");
                        }
                    });
                }
                else
                {
                    Logger.Info("No update available.");
                }
            }
            if (ConfigHost.App.EnableAutoPluginsUpdate)
            {
                var updatingPlugins = from plugin in App.Plugins where plugin is IUpdatingPlugin select plugin as IUpdatingPlugin;
                if (updatingPlugins.Any())
                {
                    var list = new List <IUpdatingPlugin>();
                    Logger.Info("Checking for plugin updates.");
                    foreach (var p in updatingPlugins)
                    {
                        Logger.Info($"Checking plugin {p.Name} for updates...");
                        SetDisplayText(string.Format(Properties.Localization.Splash_CheckingForPluginXUpdate, p.Name));
                        bool result = p.CheckUpdateAvailable();
                        if (result)
                        {
                            Logger.Info($"{p.Name} has an update available.");
                            list.Add(p);
                        }
                        else
                        {
                            Logger.Info($"{p.Name} has no update.");
                        }
                    }
                    if (list.Any())
                    {
                        Application.Current.Dispatcher.Invoke(() =>
                        {
                            var msgboxresult = MessageBox.Show(
                                string.Format(Properties.Localization.SoftwareUpdateAvailable_Body, App.CurrentVersion, (Application.Current as App).UpdateDownloadInfo.version),
                                string.Format(Properties.Localization.SoftwareUpdateAvailable_Title, (Application.Current as App).UpdateDownloadInfo.version),
                                MessageBoxButton.YesNo,
                                MessageBoxImage.Information
                                );
                            if (msgboxresult == MessageBoxResult.Yes)
                            {
                                Logger.Info("Applying plugin updates.");
                                var dlgdc     = new Dialogs.DownloadPluginUpdateDialogDataContext(list);
                                var dlg       = new Dialogs.DownloadPluginUpdateDialog(dlgdc);
                                var dlgResult = dlg.ShowDialog();
                                if (dlgResult.HasValue && dlgResult.Value)
                                {
                                    doShutdown = true;
                                    App.Shutdown(App.ExitCodes.RestartPluginUpdate);
                                }
                                else
                                {
                                    Logger.Info("Ignoring plugin updates.");
                                }
                            }
                            else
                            {
                                Logger.Info("Ignoring plugin updates.");
                            }
                        });
                    }
                }
            }
            return(doShutdown);
        }
コード例 #2
0
 public DownloadPluginUpdateDialog(DownloadPluginUpdateDialogDataContext dc)
 {
     this.DataContext = dc;
     this.InitializeComponent();
 }