コード例 #1
0
        public void CheckVersion()
        {
            var  updater = new ApplicationUpdater(typeof(MainWindow));
            bool result  = updater.IsNewVersionAvailable(false);

            Console.WriteLine("New Version is available: " + result);
        }
コード例 #2
0
        /// <summary>
        /// アップデートのダウンロード進捗表示ビューモデルを初期化する
        /// </summary>
        /// <param name="applicationUpdater">アップデート機能</param>
        public UpdateDownloadProgressViewModel(ApplicationUpdater applicationUpdater)
        {
            _ApplicationUpdater = applicationUpdater;
            CancelCommand       = new ReactiveCommand().WithSubscribe(Cancel);

            // ダウンロードが終わり次第アプリケーションを終了し、更新を適用する
            _ = applicationUpdater.UpdateAfterDownloading();
        }
コード例 #3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="UpdateInformationForm"/> class.
        /// </summary>
        /// <param name="updater">The updater.</param>
        public UpdateInformationForm(ApplicationUpdater updater)
        {
            InitializeComponent();
            UpdateInfo latest = updater.UpdateInfoList[updater.UpdateInfoList.GetLatestVersion(  )];

            this.infoLabel.Text      = string.Format(Properties.Strings.UpdatesAvailableMessage, latest.Version.ToString(), updater.UpdateName);
            this.changeComments.Text = this.removeHtmlFromUpdateMessage(latest.Comments);
        }
コード例 #4
0
        private async void CheckForApplicationUpdate()
        {
            var updater = new ApplicationUpdater(
                "NSwagStudio.msi",
                GetType().Assembly,
                "http://rsuter.com/Projects/NSwagStudio/updates.php");

            await updater.CheckForUpdate(this);
        }
コード例 #5
0
        private async void CheckForApplicationUpdate()
        {
            var updater = new ApplicationUpdater(
                "ProjectDependencyBrowser.msi",
                GetType().Assembly,
                "http://rsuter.com/Projects/ProjectDependencyBrowser/updates.xml");

            await updater.CheckForUpdate(this);
        }
コード例 #6
0
        public void DownloadFileWithEvents()
        {
            var updater = new ApplicationUpdater(typeof(Program));
            updater.DownloadProgressChanged += updater_DownloadProgressChanged;

            File.Delete(updater.DownloadStoragePath);

            Assert.IsTrue(updater.Download());
            Assert.IsTrue(File.Exists(updater.DownloadStoragePath));
        }
コード例 #7
0
        public async Task DownloadFile()
        {
            var updater = new ApplicationUpdater(typeof(Program));
            updater.DownloadProgressChanged += updater_DownloadProgressChanged;

            File.Delete(updater.DownloadStoragePath);

            Assert.IsTrue(await updater.DownloadAsync());
            Assert.IsTrue(File.Exists(updater.DownloadStoragePath));
        }
コード例 #8
0
        /// <summary>
        ///     Method to check if there is a new application version available.
        /// </summary>
        private async void UpdateAsync()
        {
            try
            {
                var update = await ApplicationUpdater.CheckForRemoteUpdateAsync().ConfigureAwait(true);

                if (update.CanUpdate)
                {
                    var boxType = update.Update.Type == UpdateType.Standard ? BoxType.Default : BoxType.Warning;
                    var boxText = update.Update.Type == UpdateType.Standard
                                                ? LocalizationEx.GetUiString("dialog_message_update_standard_text",
                                                                             Thread.CurrentThread.CurrentCulture)
                                                : LocalizationEx.GetUiString("dialog_message_update_critical_text",
                                                                             Thread.CurrentThread.CurrentCulture);
                    var boxTitle = update.Update.Type == UpdateType.Standard
                                                ? LocalizationEx.GetUiString("dialog_message_update_standard_title",
                                                                             Thread.CurrentThread.CurrentCulture)
                                                : LocalizationEx.GetUiString("dialog_message_update_critical_title",
                                                                             Thread.CurrentThread.CurrentCulture);
                    var userResult =
                        _windowManager.ShowMetroMessageBox(
                            string.Format(boxText, update.Update.Version), boxTitle,
                            MessageBoxButton.YesNo, boxType);

                    if (userResult != MessageBoxResult.Yes)
                    {
                        return;
                    }
                    var updateViewModel = new UpdateViewModel(update.Update)
                    {
                        DisplayName =
                            LocalizationEx.GetUiString("window_update_title", Thread.CurrentThread.CurrentCulture)
                    };
                    dynamic settings = new ExpandoObject();
                    settings.WindowStartupLocation = WindowStartupLocation.CenterOwner;
                    settings.Owner = GetView();
                    var result = _windowManager.ShowDialog(updateViewModel, null, settings);
                    if (!result)
                    {
                        return;
                    }
                    if (!File.Exists(updateViewModel.InstallerPath))
                    {
                        return;
                    }
                    // start the installer
                    Process.Start(updateViewModel.InstallerPath);
                    // kill running application
                    Process.GetCurrentProcess().Kill();
                }
            }
            catch (Exception)
            {
            }
        }
コード例 #9
0
        public async Task CheckForRemoteUpdateTest()
        {
            _remoteUpdate = await ApplicationUpdater.CheckForRemoteUpdateAsync().ConfigureAwait(false);

            Assert.AreNotEqual(_remoteUpdate, null);
            Assert.AreNotEqual(_remoteUpdate.Update, null);
            Assert.AreNotEqual(_remoteUpdate.Update.Installer, null);
            Assert.AreNotEqual(_remoteUpdate.Update.Signature, null);
            Assert.AreEqual(_remoteUpdate.Update.Publickey, Global.ApplicationUpdatePublicKey);
            Assert.AreEqual(_remoteUpdate.Update.Installer.Name, "SimpleDNSCrypt.msi");
        }
コード例 #10
0
ファイル: ApplicationUpdaterTests.cs プロジェクト: fzfy6/ktv
        public void DownloadFileWithEvents()
        {
            var updater = new ApplicationUpdater(typeof(Program));

            updater.DownloadProgressChanged += updater_DownloadProgressChanged;

            File.Delete(updater.DownloadStoragePath);

            Assert.IsTrue(updater.Download());
            Assert.IsTrue(File.Exists(updater.DownloadStoragePath));
        }
コード例 #11
0
        public void DownloadFileAndRun()
        {
            var updater = new ApplicationUpdater(typeof(Program));

            File.Delete(updater.DownloadStoragePath);

            Assert.IsTrue(updater.Download());
            Assert.IsTrue(File.Exists(updater.DownloadStoragePath));

            updater.ExecuteDownloadedFile();
        }
コード例 #12
0
ファイル: ApplicationUpdaterTests.cs プロジェクト: fzfy6/ktv
        public void DownloadFileAndRun()
        {
            var updater = new ApplicationUpdater(typeof(Program));

            File.Delete(updater.DownloadStoragePath);

            Assert.IsTrue(updater.Download());
            Assert.IsTrue(File.Exists(updater.DownloadStoragePath));

            updater.ExecuteDownloadedFile();
        }
コード例 #13
0
ファイル: ApplicationUpdaterTests.cs プロジェクト: fzfy6/ktv
        public async Task DownloadFile()
        {
            var updater = new ApplicationUpdater(typeof(Program));

            updater.DownloadProgressChanged += updater_DownloadProgressChanged;

            File.Delete(updater.DownloadStoragePath);

            Assert.IsTrue(await updater.DownloadAsync());
            Assert.IsTrue(File.Exists(updater.DownloadStoragePath));
        }
コード例 #14
0
        /// <summary>
        ///     Download the given signature file.
        /// </summary>
        /// <param name="remoteSignature">The signature to download.</param>
        /// <returns></returns>
        public async Task DownloadSignatureAsync(Signature remoteSignature)
        {
            _signature =
                await ApplicationUpdater.DownloadRemoteSignatureAsync(remoteSignature.Uri).ConfigureAwait(false);

            if (!string.IsNullOrEmpty(_signature))
            {
                IsSignatureDownloaded = true;
            }
            IsUpdatingSignature = false;
        }
コード例 #15
0
        /// <summary>
        ///     Download the given installer file.
        /// </summary>
        /// <param name="remoteInstaller">The installer to download.</param>
        /// <returns></returns>
        public async Task DownloadInstallerAsync(Installer remoteInstaller)
        {
            _installer =
                await ApplicationUpdater.DownloadRemoteInstallerAsync(remoteInstaller.Uri).ConfigureAwait(false);

            if (_installer != null)
            {
                IsInstallerDownloaded = true;
            }
            IsUpdatingInstaller = false;
        }
コード例 #16
0
        internal static async Task <int> MainAsync(CommandLineArguments cmd)
        {
            var updater = new ApplicationUpdater("https://api.github.com/repos/DavidMoore/ElvUI.Updater/releases");

            switch (cmd.Command)
            {
            case Command.None:
                break;

            case Command.Cleanup:
                var cleanupArgs = new CleanupArgs();
                cleanupArgs.Target = cmd.Target;
                await updater.CleanupAsync(cleanupArgs);

                break;

            case Command.Install:
                await updater.InstallAsync();

                break;

            case Command.Update:
                // Check, download and launch an update, then return immediately so the update can run.
                var updateArgs = new UpdateCheckArgs();
                updateArgs.AllowPreRelease = true;
                await updater.UpdateAsync(updateArgs);

                return(0);

            case Command.ApplyUpdate:
                // We enter here when a downloaded update is running so it can overwrite the old exe
                var applyUpdateArgs = new ApplyUpdateArgs();
                applyUpdateArgs.Launch = cmd.Launch;
                await updater.ApplyUpdateAsync(applyUpdateArgs);

                break;

            case Command.Uninstall:
                var uninstallArgs = new UninstallArgs();
                uninstallArgs.Silent = cmd.Silent;
                await updater.UninstallAsync(uninstallArgs);

                return(0);

            case Command.Service:
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }

            return(1);
        }
コード例 #17
0
        /// <summary>
        /// Checks for updates.
        /// </summary>
        /// <param name="owner">The owner.</param>
        public void Check(IWin32Window owner)
        {
            try {
                _owner = owner;

                ApplicationUpdater applicationUpdater = new ApplicationUpdater();
                applicationUpdater.UpdateAvailable += new EventHandler <UpdatesAvailableEventArgs> (applicationUpdater_UpdateAvailable);
                applicationUpdater.Version          = new Version(Application.ProductVersion);
                applicationUpdater.CheckForUpdate(CCNetConfig.Core.Util.UserSettings.UpdateSettings.UpdateCheckType);
            } catch {
            }
        }
コード例 #18
0
        public void Check(IWin32Window owner, Uri url)
        {
            try {
                _owner = owner;

                ApplicationUpdater applicationUpdater = new ApplicationUpdater();
                applicationUpdater.UpdateAvailable += new EventHandler <UpdatesAvailableEventArgs> (applicationUpdater_UpdateAvailable);
                applicationUpdater.Version          = new Version(Application.ProductVersion);
                applicationUpdater.CheckForUpdatesByUrl(url);
            } catch {
            }
        }
コード例 #19
0
        public void DownloadInstallerTest()
        {
            var updater = new ApplicationUpdater("0.11");

            Console.WriteLine(updater.DownloadStoragePath);

            if (File.Exists(updater.DownloadStoragePath))
            {
                File.Delete(updater.DownloadStoragePath);
            }

            updater.Download();

            Assert.IsTrue(File.Exists(updater.DownloadStoragePath), "File should have been downloaded to download path");
        }
コード例 #20
0
        public void DetectExeUpdate()
        {
            var config = new ApplicationUpdaterConfig
            {
                FullFileName = @"D:\Apps\MyApp\MyApp.update.exe",
            };

            var updater = new ApplicationUpdater(config);

            var context = updater.GetUpdateContext();

            Assert.True(context.IsUpdate);
            Assert.Equal(PackageType.Executable, context.PackageType);
            Assert.Equal(@"D:\Apps\MyApp\MyApp.exe", context.UpdateDestination.FullName);
            Assert.Equal(@"D:\Apps\MyApp\MyApp.update.exe", context.UpdateSource.FullName);
        }
コード例 #21
0
        public void CheckForNewVersion()
        {
            var updater = new ApplicationUpdater("0.01");           
            Assert.IsTrue(updater.NewVersionAvailable());

            updater = new ApplicationUpdater("1.0"); 
            updater.CurrentVersion = "9999.00";
            Assert.IsFalse(updater.NewVersionAvailable());


            updater = new ApplicationUpdater("0.78");
            Console.WriteLine(updater.NewVersionAvailable());

            updater = new ApplicationUpdater(typeof(Program));
            Console.WriteLine(updater.NewVersionAvailable());
        }
コード例 #22
0
ファイル: App.xaml.cs プロジェクト: Brainc3ll/WowUp
        private void HandlePendingUpdate()
        {
            if (!ApplicationUpdater.UpdateFileExists)
            {
                return;
            }

            try
            {
                ApplicationUpdater.ProcessUpdateFile();
            }
            catch (Exception ex)
            {
                Log.Error(ex, "Failed to process update file.");
            }
        }
コード例 #23
0
        public void CheckAndDownloadInstallerTest()
        {
            mmApp.Configuration.ApplicationUpdates.LastUpdateCheck = DateTime.Now.AddDays(-8);
            mmApp.Configuration.ApplicationUpdates.UpdateFrequency = 3;

            var updater = new ApplicationUpdater("0.11");

            if (File.Exists(updater.DownloadStoragePath))
            {
                File.Delete(updater.DownloadStoragePath);
            }

            updater.CheckDownloadExecute(true);

            Assert.IsTrue(File.Exists(updater.DownloadStoragePath), "File should have been downloaded to download path");
        }
コード例 #24
0
        public void DetectDownloadsFolder()
        {
            var config = new ApplicationUpdaterConfig
            {
                FullFileName = Environment.ExpandEnvironmentVariables(@"%USERPROFILE%\Downloads\MyApp.exe")
            };

            var updater = new ApplicationUpdater(config);

            var context = updater.GetUpdateContext();

            Assert.False(context.IsUpdate);
            Assert.False(context.IsDeployed);
            Assert.Equal(PackageType.Executable, context.PackageType);
            Assert.Equal(Environment.ExpandEnvironmentVariables(@"%LocalAppData%\Programs\MyApp"), context.UpdateDestination.FullName);
            Assert.Equal(Environment.ExpandEnvironmentVariables(@"%USERPROFILE%\Downloads\MyApp.exe"), context.UpdateSource.FullName);
        }
コード例 #25
0
        public void DetectArchiveTemp()
        {
            var config = new ApplicationUpdaterConfig
            {
                FullFileName = Environment.ExpandEnvironmentVariables(@"%TEMP%\TempZip\MyApp.exe")
            };

            var updater = new ApplicationUpdater(config);

            var context = updater.GetUpdateContext();

            Assert.False(context.IsUpdate);
            Assert.False(context.IsDeployed);
            Assert.Equal(PackageType.Archive, context.PackageType);
            Assert.Equal(Environment.ExpandEnvironmentVariables(@"%LocalAppData%\Programs\MyApp"), context.UpdateDestination.FullName);
            Assert.Equal(Environment.ExpandEnvironmentVariables(@"%TEMP%\TempZip"), context.UpdateSource.FullName);
        }
コード例 #26
0
        public void DetectArchiveUpdateWithCustomSuffix()
        {
            var config = new ApplicationUpdaterConfig
            {
                FullFileName = @"D:\Apps\MyApp\.tmp\MyApp.exe",
                UpdateSuffix = ".tmp"
            };

            var updater = new ApplicationUpdater(config);

            var context = updater.GetUpdateContext();

            Assert.True(context.IsUpdate);
            Assert.Equal(PackageType.Archive, context.PackageType);
            Assert.Equal(@"D:\Apps\MyApp", context.UpdateDestination.FullName);
            Assert.Equal(@"D:\Apps\MyApp\.tmp", context.UpdateSource.FullName);
        }
コード例 #27
0
ファイル: ApplicationUpdaterTests.cs プロジェクト: fzfy6/ktv
        public void CheckForNewVersion()
        {
            var updater = new ApplicationUpdater("0.01");

            Assert.IsTrue(updater.NewVersionAvailable());

            updater = new ApplicationUpdater("1.0");
            updater.CurrentVersion = "9999.00";
            Assert.IsFalse(updater.NewVersionAvailable());


            updater = new ApplicationUpdater("0.78");
            Console.WriteLine(updater.NewVersionAvailable());

            updater = new ApplicationUpdater(typeof(Program));
            Console.WriteLine(updater.NewVersionAvailable());
        }
コード例 #28
0
        /// <summary>
        /// Prevents a default instance of the <see cref="MainViewModel" /> class from being created.
        /// </summary>
        private MainViewModel() : base()
        {
            // Attach the logger view model to the engine's output
            Logger.Subscribe(OutputViewModel.GetInstance());

            ApplicationUpdater.UpdateApp();

            Squalr.Engine.Projects.Compiler.Compile(true);

            if (Vectors.HasVectorSupport)
            {
                Logger.Log(LogLevel.Info, "Hardware acceleration enabled (vector size: " + Vector <Byte> .Count + ")");
            }

            Logger.Log(LogLevel.Info, "Squalr started");

            // this.DisplayChangeLogCommand = new RelayCommand(() => ChangeLogViewModel.GetInstance().DisplayChangeLog(new Content.ChangeLog().TransformText()), () => true);
        }
コード例 #29
0
        /// <summary>
        /// Handles the UpdateAvailable event of the applicationUpdater control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="UpdatesAvailableEventArgs"/> instance containing the event data.</param>
        void applicationUpdater_UpdateAvailable(object sender, UpdatesAvailableEventArgs e)
        {
            ApplicationUpdater ai = (ApplicationUpdater)sender;

            if (ai.UpdatesAvailable)
            {
                // hide the splash if its visible
                Util.HideSplashScreen( );
                UpdateInformationForm uif = new UpdateInformationForm(ai);
                if (uif.ShowDialog(_owner) == DialogResult.OK)
                {
                    string thisPath   = this.GetType( ).Assembly.Location;
                    string attrString = string.Format(CCNetConfig.Core.Util.UserSettings.UpdateSettings.LaunchArgumentsFormat, CCNetConfig.Core.Util.UserSettings.UpdateSettings.UpdateCheckType, thisPath, ai.UpdateInfoList.GetLatestVersion( ), string.Empty);
                    Console.WriteLine(attrString);
                    Process.Start(Path.Combine(Application.StartupPath, CCNetConfig.Core.Util.UserSettings.UpdateSettings.UpdaterApplication), attrString);
                    Application.Exit( );
                }
            }
        }
コード例 #30
0
        public void CheckVersionFrequencyTest()
        {
            var updates = new ApplicationUpdates();

            updates.LastUpdateCheck =

                mmApp.Configuration.ApplicationUpdates.LastUpdateCheck = DateTime.Now.AddDays(-8);
            mmApp.Configuration.ApplicationUpdates.UpdateFrequency     = 3;

            var updater = new ApplicationUpdater("0.11");

            Assert.IsTrue(updater.IsNewVersionAvailable(true), "Should show a new version");

            mmApp.Configuration.ApplicationUpdates.LastUpdateCheck = DateTime.Now.AddDays(-2);
            mmApp.Configuration.ApplicationUpdates.UpdateFrequency = 8;

            updater = new ApplicationUpdater("0.11");
            Assert.IsFalse(updater.IsNewVersionAvailable(true), "Should not show a new version because not time to check yet");
        }
コード例 #31
0
        /// <summary>
        /// Initializes a new instance of the <see cref="MainForm"/> class.
        /// </summary>
        public MainForm( )
        {
            InitializeComponent( );
            this.progressBar1.Maximum = 100;
            this.progressBar1.Minimum = 0;
            this.progressBar1.Value   = 0;

            au         = new ApplicationUpdater( );
            au.Version = Program.ProductVersion;
            if (!string.IsNullOrEmpty(Program.CallingApplication))
            {
                au.OwnerApplication = new FileInfo(Program.CallingApplication);
            }

            au.UpdateAvailable         += new EventHandler <UpdatesAvailableEventArgs> (au_UpdateAvailable);
            au.UpdateException         += new EventHandler <ExceptionEventArgs> (au_UpdateException);
            au.DownloadProgressChanged += new EventHandler <DownloadProgressEventArgs> (au_DownloadProgressChanged);
            au.UpdateScriptCreated     += new EventHandler(au_UpdateScriptCreated);
            au.UpdateException         += new EventHandler <ExceptionEventArgs> (au_UpdateException);
        }
コード例 #32
0
        private void updatePlugin_Click(object sender, EventArgs e)
        {
            if (this.pluginsList.SelectedItems.Count > 0)
            {
                AssemblyListViewItem alvi = this.pluginsList.SelectedItems[0] as AssemblyListViewItem;
                ApplicationUpdater   au   = new ApplicationUpdater();
                au.Version = alvi.Version;

                this.pluginUpdateStatus.Text = "Checking updates for " + alvi.Text;

                au.UpdateAvailable += new EventHandler <UpdatesAvailableEventArgs> (delegate(object s, UpdatesAvailableEventArgs uae) {
                    ApplicationUpdater ai        = (ApplicationUpdater)s;
                    ai.UpdateName                = alvi.Text;
                    this.pluginUpdateStatus.Text = "Updates available...";
                    if (ai.UpdatesAvailable)
                    {
                        UpdateInformationForm uif = new UpdateInformationForm(ai);
                        if (uif.ShowDialog(null) == DialogResult.OK)
                        {
                            string thisPath   = this.GetType().Assembly.Location;
                            string attrString = string.Format(CCNetConfig.Core.Util.UserSettings.UpdateSettings.LaunchArgumentsFormat,
                                                              CCNetConfig.Core.Util.UserSettings.UpdateSettings.UpdateCheckType, thisPath,
                                                              ai.UpdateInfoList.GetLatestVersion());
                            Process.Start(Path.Combine(Application.StartupPath, CCNetConfig.Core.Util.UserSettings.UpdateSettings.UpdaterApplication), attrString);
                            Application.Exit();
                        }
                    }
                });

                au.UpdateException += new EventHandler <ExceptionEventArgs> (delegate(object s, ExceptionEventArgs ex) {
                    MessageBox.Show(ex.Exception.Message, "Update of plugin error");
                });

                au.CheckForUpdatesByUrl(alvi.UpdateUrl);
                this.pluginUpdateStatus.Text = string.Empty;
            }
        }
コード例 #33
0
        private async void InitializeApplication()
        {
            try
            {
                if (IsAdministrator())
                {
                    ProgressText =
                        LocalizationEx.GetUiString("loader_administrative_rights_available", Thread.CurrentThread.CurrentCulture);
                }
                else
                {
                    ProgressText =
                        LocalizationEx.GetUiString("loader_administrative_rights_missing", Thread.CurrentThread.CurrentCulture);
                    await Task.Delay(3000).ConfigureAwait(false);

                    Process.GetCurrentProcess().Kill();
                }

                ProgressText = LocalizationEx.GetUiString("loader_redistributable_package_check", Thread.CurrentThread.CurrentCulture);
                if (PrerequisiteHelper.IsRedistributablePackageInstalled())
                {
                    ProgressText = LocalizationEx.GetUiString("loader_redistributable_package_already_installed", Thread.CurrentThread.CurrentCulture);
                }
                else
                {
                    ProgressText = LocalizationEx.GetUiString("loader_redistributable_package_installing", Thread.CurrentThread.CurrentCulture);
                    //minisign needs this (to verify the installer with libsodium)
                    await PrerequisiteHelper.DownloadAndInstallRedistributablePackage();

                    if (PrerequisiteHelper.IsRedistributablePackageInstalled())
                    {
                        ProgressText = LocalizationEx.GetUiString("loader_redistributable_package_ready", Thread.CurrentThread.CurrentCulture);
                        await Task.Delay(1000).ConfigureAwait(false);
                    }
                }

                if (Properties.Settings.Default.AutoUpdate)
                {
                    ProgressText = LocalizationEx.GetUiString("loader_checking_version", Thread.CurrentThread.CurrentCulture);
                    //TODO: remove in future version (for now we only have one channel)
                    Properties.Settings.Default.MinUpdateType = 2;
                    Properties.Settings.Default.Save();
                    var minUpdateType = (UpdateType)Properties.Settings.Default.MinUpdateType;
                    var update        = await ApplicationUpdater.CheckForRemoteUpdateAsync(minUpdateType).ConfigureAwait(false);

                    if (update.CanUpdate)
                    {
                        ProgressText =
                            string.Format(LocalizationEx.GetUiString("loader_new_version_found", Thread.CurrentThread.CurrentCulture),
                                          update.Update.Version);
                        await Task.Delay(200).ConfigureAwait(false);

                        var installer = await StartRemoteUpdateDownload(update).ConfigureAwait(false);

                        if (!string.IsNullOrEmpty(installer) && File.Exists(installer))
                        {
                            ProgressText = LocalizationEx.GetUiString("loader_starting_update", Thread.CurrentThread.CurrentCulture);
                            await Task.Delay(200).ConfigureAwait(false);

                            Process.Start(installer);
                            Process.GetCurrentProcess().Kill();
                        }
                        else
                        {
                            await Task.Delay(500).ConfigureAwait(false);

                            ProgressText = LocalizationEx.GetUiString("loader_update_failed", Thread.CurrentThread.CurrentCulture);
                        }
                    }
                    else
                    {
                        ProgressText = LocalizationEx.GetUiString("loader_latest_version", Thread.CurrentThread.CurrentCulture);
                    }
                }
                else
                {
                    await Task.Delay(500).ConfigureAwait(false);
                }

                ProgressText =
                    string.Format(LocalizationEx.GetUiString("loader_validate_folder", Thread.CurrentThread.CurrentCulture),
                                  Global.DnsCryptProxyFolder);
                var validatedFolder = ValidateDnsCryptProxyFolder();
                if (validatedFolder.Count == 0)
                {
                    ProgressText = LocalizationEx.GetUiString("loader_all_files_available", Thread.CurrentThread.CurrentCulture);
                }
                else
                {
                    var fileErrors = "";
                    foreach (var pair in validatedFolder)
                    {
                        fileErrors += $"{pair.Key}: {pair.Value}\n";
                    }

                    ProgressText =
                        string.Format(
                            LocalizationEx.GetUiString("loader_missing_files", Thread.CurrentThread.CurrentCulture).Replace("\\n", "\n"),
                            Global.DnsCryptProxyFolder, fileErrors, Global.ApplicationName);
                    await Task.Delay(5000).ConfigureAwait(false);

                    Process.GetCurrentProcess().Kill();
                }

                ProgressText = string.Format(LocalizationEx.GetUiString("loader_loading", Thread.CurrentThread.CurrentCulture),
                                             Global.DnsCryptConfigurationFile);
                if (DnscryptProxyConfigurationManager.LoadConfiguration())
                {
                    ProgressText =
                        string.Format(LocalizationEx.GetUiString("loader_successfully_loaded", Thread.CurrentThread.CurrentCulture),
                                      Global.DnsCryptConfigurationFile);
                    _mainViewModel.DnscryptProxyConfiguration = DnscryptProxyConfigurationManager.DnscryptProxyConfiguration;
                }
                else
                {
                    ProgressText =
                        string.Format(LocalizationEx.GetUiString("loader_failed_loading", Thread.CurrentThread.CurrentCulture),
                                      Global.DnsCryptConfigurationFile);
                    await Task.Delay(5000).ConfigureAwait(false);

                    Process.GetCurrentProcess().Kill();
                }

                ProgressText = LocalizationEx.GetUiString("loader_loading_network_cards", Thread.CurrentThread.CurrentCulture);

                List <LocalNetworkInterface> localNetworkInterfaces;
                if (DnscryptProxyConfigurationManager.DnscryptProxyConfiguration.listen_addresses.Contains(Global.GlobalResolver))
                {
                    var dnsServer = new List <string>
                    {
                        Global.DefaultResolverIpv4,
                        Global.DefaultResolverIpv6
                    };
                    localNetworkInterfaces = LocalNetworkInterfaceManager.GetLocalNetworkInterfaces(dnsServer);
                }
                else
                {
                    localNetworkInterfaces = LocalNetworkInterfaceManager.GetLocalNetworkInterfaces(
                        DnscryptProxyConfigurationManager.DnscryptProxyConfiguration.listen_addresses.ToList());
                }
                _mainViewModel.LocalNetworkInterfaces = new BindableCollection <LocalNetworkInterface>();
                _mainViewModel.LocalNetworkInterfaces.AddRange(localNetworkInterfaces);
                _mainViewModel.Initialize();
                ProgressText = LocalizationEx.GetUiString("loader_starting", Thread.CurrentThread.CurrentCulture);

                if (Properties.Settings.Default.TrayMode)
                {
                    Execute.OnUIThread(() => _windowManager.ShowWindow(_systemTrayViewModel));
                    Execute.OnUIThread(() => _systemTrayViewModel.ShowWindow());
                }
                else
                {
                    Execute.OnUIThread(() => _windowManager.ShowWindow(_mainViewModel));
                }

                TryClose(true);
            }
            catch (Exception exception)
            {
                Log.Error(exception);
            }
        }
コード例 #34
0
 public void CheckForNewVersion(bool force = false)
 {
     var updater = new ApplicationUpdater(typeof(Program));
     //updater.LastCheck = DateTime.UtcNow.AddDays(-50);
     if (updater.NewVersionAvailable(!force))
     {
         if (MessageBox.Show(updater.VersionInfo.Detail + "\r\n" +
             "Do you want to download and install this version?",
             updater.VersionInfo.Title,
             MessageBoxButtons.YesNo,
             MessageBoxIcon.Information) == DialogResult.Yes)
         {
             updater.DownloadProgressChanged += updater_DownloadProgressChanged;
             ShowStatus("Downloading Update - Version " + updater.VersionInfo.Version);
             updater.Download();
             updater.ExecuteDownloadedFile();
             ShowStatus("Download completed.");
             Application.Exit();
         }
     }
     App.Configuration.CheckForUpdates.LastUpdateCheck = DateTime.UtcNow.Date;
 }
コード例 #35
0
 private async void CheckForApplicationUpdate()
 {
     var updater = new ApplicationUpdater("VisualJsonEditor.msi", GetType().Assembly,
                                          "http://rsuter.com/Projects/VisualJsonEditor/updates.php");
     await updater.CheckForUpdate(this);
 }