コード例 #1
0
        /// <summary>
        /// Install all downloaded updates
        /// Auto accept Eula
        /// </summary>
        public void BeginInstallation()
        {
            progressWindow = new ProgressWindow();
            progressWindow.Show();
            progressWindow.Title = "Installation...";
            installationJob      = null;

            installCollection = new UpdateCollection();
            foreach (IUpdate update in this.sResult.Updates)
            {
                if (update.IsDownloaded)
                {
                    //testen ob das funktioniert
                    update.AcceptEula();
                }
                // update.InstallationBehavior.RebootBehavior
                installCollection.Add(update);
            }
            installer         = uSession.CreateUpdateInstaller();
            installer.Updates = installCollection;
            installationJob   = installer.BeginInstall(new InstallProgressChangedFunc(this), new InstallCompletedFunc(this), null);
        }
コード例 #2
0
        private void Update_Click(object sender, RoutedEventArgs e)
        {
            // Set the temp file name and create new 0-byte file
            TempFilePath = Path.GetTempFileName();

            progressWindow         = new ProgressWindow();
            progressWindow.Topmost = true;
            progressWindow.Show();
            // Set up WebClient to download file
            webClient = new WebClient();
            webClient.DownloadProgressChanged += new DownloadProgressChangedEventHandler(webClient_DownloadProgressChanged);
            webClient.DownloadFileCompleted   += new AsyncCompletedEventHandler(webClient_DownloadFileCompleted);

            // Set up backgroundworker to hash file
            bgWorker                     = new BackgroundWorker();
            bgWorker.DoWork             += new DoWorkEventHandler(bgWorker_DoWork);
            bgWorker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(bgWorker_RunWorkerCompleted);

            // Download file
            try { webClient.DownloadFileAsync(updateInfo.Uri, TempFilePath); }
            catch (Exception ex) { LogWriter.LogWrite("Application updated failed: " + ex.ToString()); Close(); }
        }