示例#1
0
        private static void HandleCheckForUpdateCompleted(object sender, CheckForUpdateCompletedEventArgs e)
        {
            if (e.UpdateAvailable)
            {
                ApplicationDeployment.CurrentDeployment.Update();

                StringBuilder sb = new StringBuilder();
                sb.AppendLine("An update was found and installed. The application needs to be restarted to use the new version.");
                sb.AppendLine();
                sb.AppendLine("Current version: " + GetVersion());
                sb.AppendLine("New version: " + ToVersionString(e.AvailableVersion));
                sb.AppendLine("Update size: " + e.UpdateSizeBytes + " bytes");
                sb.AppendLine();
                sb.AppendLine("Do you want to restart the application to update now?");

                // Get a form so we can invoke on the thread
                Form form = Application.OpenForms.Count > 0 ? Application.OpenForms[0] : null;
                if (form != null)
                {
                    form.Invoke((Action)(() =>
                    {
                        if (MessageBox.Show(form, sb.ToString(), "Update available!", MessageBoxButtons.YesNo) == DialogResult.Yes)
                            Application.Restart();
                    }));
                }
            }
        }
示例#2
0
文件: Form1.cs 项目: jpoehls/snippets
        private void CheckForUpdateCompleted(object sender, CheckForUpdateCompletedEventArgs e)
        {
            if (e.Error != null)
            {
                MessageBox.Show("ERROR: Could not retrieve new version of the application. Reason: \n" + e.Error.Message + "\nPlease report this error to the system administrator.");
                return;
            }

            if (e.Cancelled)
            {
                MessageBox.Show("The update was cancelled.");
            }

            // Ask the user if they would like to update the application now.
            if (e.UpdateAvailable)
            {
                string sizeText = e.UpdateSizeBytes/1024/1024 + "MB";

                if (!e.IsUpdateRequired)
                {
                    DialogResult dr = MessageBox.Show("An update is available. Would you like to update the application now?\n\nThe download size is: " + sizeText, "Update Available", MessageBoxButtons.OKCancel);
                    if (DialogResult.OK == dr)
                    {
                        BeginUpdate();
                    }
                }
                else
                {
                    MessageBox.Show("A mandatory update is available for your application. We will install the update now, after which we will save all of your in-progress data and restart your application.");
                    BeginUpdate();
                }
            }
        }
 void ad_CheckForUpdateCompleted(object sender, CheckForUpdateCompletedEventArgs e)
 {
     if (e.UpdateAvailable)
     {
         ad.CheckForUpdateAsync();
     }
 }
 private void currentDeploy_CheckForUpdateCompleted(object sender, CheckForUpdateCompletedEventArgs e)
 {
     if (e.UpdateAvailable)
     {
         ApplicationDeployment current = ApplicationDeployment.CurrentDeployment;
         current.UpdateAsync();
     }
 }
示例#5
0
		static void ad_CheckForUpdateCompleted (object sender, CheckForUpdateCompletedEventArgs e)
		{
			if (e.UpdateAvailable) {
				Application.Instance.AsyncInvoke (() => {
					var ad = ApplicationDeployment.CurrentDeployment;
					MessageBox.Show (Application.Instance.MainForm, string.Format ("An update to version {0} is available (you have {1}). Restart the app to install!", e.AvailableVersion, ad.CurrentVersion));
				});
			}
		}
示例#6
0
 /// <summary>
 /// Handles the CheckForUpdateCompleted event.
 /// </summary>
 /// <param name="sender">The source of the event.</param>
 /// <param name="e">A CheckForUpdateCompletedEventArgs that contains the event data.</param>
 private void CheckForUpdateCompleted(object sender, CheckForUpdateCompletedEventArgs e)
 {
     if (ApplicationDeployment.IsNetworkDeployed)
     {
         if (e.UpdateAvailable)
         {
             this.uxUpdate.Text = "Update available.";
             this.uxUpdate.Visible = true;
         }
     }
 }
示例#7
0
        private static void ad_CheckForUpdateCompleted( object sender, CheckForUpdateCompletedEventArgs e )
        {
            if(null != e.Error) {
                MessageBox.Show( string.Format( @"Error: Could not update new version of application.  Reason:\n {0}", e.Error.Message ) );
                return;
            } else if(e.Cancelled) {
                return;
            }

            var ad = ApplicationDeployment.CurrentDeployment;
            ad.UpdateCompleted += new AsyncCompletedEventHandler( ad_UpdateCompleted );
            ad.UpdateAsync( );
        }
示例#8
0
        void CurrentDeployment_CheckForUpdateCompleted(object sender, System.Deployment.Application.CheckForUpdateCompletedEventArgs e)
        {
            var handler = CheckForUpdateCompleted;

            if (handler != null)
            {
                handler(this, new AutoFileMover.Desktop.Interfaces.CheckForUpdateCompletedEventArgs(e.UpdateAvailable ? e.AvailableVersion : CurrentVersion,
                                                                                                    e.UpdateAvailable ? e.IsUpdateRequired : false,
                                                                                                    e.UpdateAvailable ? e.MinimumRequiredVersion : CurrentVersion,
                                                                                                    e.UpdateAvailable,
                                                                                                    e.UpdateAvailable ? e.UpdateSizeBytes : 0,
                                                                                                    e.Error, e.Cancelled, e.UserState));
            }
        }
示例#9
0
		private void CurrentDeploymentCheckForUpdateCompleted(object sender, CheckForUpdateCompletedEventArgs e)
		{
			m_isCheckingForUpdate = false;
			if (e.Error != null)
			{
				s_log.Error("Auto update check failed", e.Error);
			}
			else
			{
				if (e.UpdateAvailable && Settings.Default.AutoInstallUpdates)
					Update();
				else
					UpdateAvailable = e.UpdateAvailable;
				s_log.Info("Auto update check succeeded, update available: " + e.UpdateAvailable.ToString());
			}
		}
        private static void AppDeployment_CheckForUpdateCompleted(object sender, CheckForUpdateCompletedEventArgs e)
        {
            UpdateRunning = false;

            if (e.Error != null)
            {
                XtraMessageBox.Show("An Error occurred:\n" + e.Error.Message, "Error", MessageBoxButtons.OK,
                                    MessageBoxIcon.Error);
                return;
            }

            if (!e.UpdateAvailable)
            {
                XtraMessageBox.Show("No updates found!", "AppDeployment", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            if (e.Cancelled)
            {
                XtraMessageBox.Show("Update was cancelled!", "Update Cancelled", MessageBoxButtons.OK,
                                    MessageBoxIcon.Information);
                return;
            }

            if (e.UpdateAvailable)
            {
                if (e.IsUpdateRequired)
                {
                    XtraMessageBox.Show("There is a mandatory update available. Click OK to start installation", "Update Available", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    UpdateRunning = true;
                    AppDeployment.UpdateAsync();
                    OnUpdating();
                }

                if (XtraMessageBox.Show("Update found! Would you like to download and install the update now?", "Update Found", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    UpdateRunning = true;
                    AppDeployment.UpdateAsync();
                    OnUpdating();
                }
            }
        }
示例#11
0
       void deployment_CheckForUpdateCompleted(object sender, CheckForUpdateCompletedEventArgs e)
      {
         if (e.Error == null && e.UpdateAvailable)
         {
            try
            {
               MainWindow w = this.windows[0];
               w.updateProgress.Value = 0;
               w.UpdateAvailableLabel.Visibility = Visibility.Visible;

               deployment.UpdateAsync();
            }
            catch (InvalidOperationException ex)
            {
               Debug.WriteLine(ex.ToString());
               MainWindow w = this.windows[0];
               w.UpdateAvailableLabel.Visibility = Visibility.Hidden;
            }
         }
      }
示例#12
0
        void DeploymentCheckForUpdateCompleted(object sender, CheckForUpdateCompletedEventArgs e) {
            if (e.Error != null) {
                _Logger.WarnException("Check for updates failed!", e.Error);
                return;
            }

            if (!e.UpdateAvailable)
                return;

            NewVersion = e.AvailableVersion;
            IsRequired = e.IsUpdateRequired;

            _Logger.Info(string.Format("A new update is available! Old version: {0}, new version: {1}, mandatory: {2}",
                                       _Deployment.CurrentVersion, NewVersion, IsRequired));

            try {
                _Deployment.UpdateAsync();
            }
            catch (Exception exc) {
                _Logger.WarnException("Update failed!", exc);
            }
        }
 private void CheckForUpdateBindCompletedEventHandler(object sender, BindCompletedEventArgs e)
 {
     Exception error = null;
     DeploymentManager manager = null;
     bool updateAvailable = false;
     Version availableVersion = null;
     bool isUpdateRequired = false;
     Version minimumRequiredVersion = null;
     long updateSize = 0L;
     new NamedPermissionSet("FullTrust").Assert();
     try
     {
         manager = (DeploymentManager) sender;
         if ((e.Error == null) && !e.Cancelled)
         {
             UpdateCheckInfo info = this.DetermineUpdateCheckResult(manager.ActivationDescription);
             if (info.UpdateAvailable)
             {
                 manager.DeterminePlatformRequirements();
                 try
                 {
                     TrustParams trustParams = new TrustParams {
                         NoPrompt = true
                     };
                     manager.DetermineTrust(trustParams);
                 }
                 catch (TrustNotGrantedException)
                 {
                     if (!manager.ActivationDescription.IsUpdateInPKTGroup)
                     {
                         throw;
                     }
                 }
             }
             this.ProcessUpdateCheckResult(info, manager.ActivationDescription);
             if (info.UpdateAvailable)
             {
                 updateAvailable = true;
                 availableVersion = info.AvailableVersion;
                 isUpdateRequired = info.IsUpdateRequired;
                 minimumRequiredVersion = info.MinimumRequiredVersion;
                 updateSize = info.UpdateSizeBytes;
             }
         }
         else
         {
             error = e.Error;
         }
     }
     catch (Exception exception2)
     {
         if (ExceptionUtility.IsHardException(exception2))
         {
             throw;
         }
         error = exception2;
     }
     finally
     {
         CodeAccessPermission.RevertAssert();
         Interlocked.Exchange(ref this._guard, 0);
         CheckForUpdateCompletedEventArgs args = new CheckForUpdateCompletedEventArgs(error, e.Cancelled, null, updateAvailable, availableVersion, isUpdateRequired, minimumRequiredVersion, updateSize);
         CheckForUpdateCompletedEventHandler handler = (CheckForUpdateCompletedEventHandler) this.Events[checkForUpdateCompletedKey];
         if (handler != null)
         {
             handler(this, args);
         }
         if (manager != null)
         {
             manager.ProgressChanged -= new DeploymentProgressChangedEventHandler(this.CheckForUpdateProgressChangedEventHandler);
             manager.BindCompleted -= new BindCompletedEventHandler(this.CheckForUpdateBindCompletedEventHandler);
             new NamedPermissionSet("FullTrust").Assert();
             try
             {
                 manager.Dispose();
             }
             finally
             {
                 CodeAccessPermission.RevertAssert();
             }
         }
     }
 }
示例#14
0
 void deploy_CheckForUpdateCompleted(object sender, CheckForUpdateCompletedEventArgs e)
 {
     upd.Hide();
     MessageBox.Show("Update Completed", Text);
 }
示例#15
0
 private static void deployment_CheckForUpdateCompleted(object sender, CheckForUpdateCompletedEventArgs e)
 {
     if (SettingsData.Instance.Updating)
     {
         if (e.Error != null)
         {
             if (!SettingsData.Instance.QuietUpdating)
             {
                 if (e.Error.GetType() == typeof(DeploymentDownloadException))
                     Messenger.Default.Send<DialogMessage>(new DialogMessage(e.Error.Message, (Action<MessageBoxResult>)(o => { })), (object)DialogType.UpdateDownloadError);
                 else if (e.Error.GetType() == typeof(InvalidDeploymentException))
                     Messenger.Default.Send<DialogMessage>(new DialogMessage(e.Error.Message, (Action<MessageBoxResult>)(o => { })), (object)DialogType.UpdateInstallError);
                 else if (e.Error.GetType() == typeof(InvalidOperationException))
                     Messenger.Default.Send<DialogMessage>(new DialogMessage(e.Error.Message, (Action<MessageBoxResult>)(o => { })), (object)DialogType.UpdateInvalidError);
             }
             SettingsData.Instance.QuietUpdating = false;
         }
         else if (e.UpdateAvailable)
         {
             bool doUpdate = true;
             if (!e.IsUpdateRequired)
                 Messenger.Default.Send<DialogMessage>(new DialogMessage("http://www.metrotwit.com/category/loop-releases/", (Action<MessageBoxResult>)(dr =>
                 {
                     if (MessageBoxResult.Yes == dr)
                         return;
                     doUpdate = false;
                 })), (object)DialogType.UpdateAvailable);
             else
                 Messenger.Default.Send<DialogMessage>(new DialogMessage(((object)e.MinimumRequiredVersion).ToString(), (Action<MessageBoxResult>)(o => { })), (object)DialogType.UpdateMandatory);
             if (doUpdate)
                 Messenger.Default.Send<DialogMessage>(new DialogMessage(string.Empty, (Action<MessageBoxResult>)(o => { })), (object)DialogType.UpdateStart);
         }
         else
         {
             if (!SettingsData.Instance.QuietUpdating)
                 Messenger.Default.Send<DialogMessage>(new DialogMessage(string.Empty, (Action<MessageBoxResult>)(o => { })), (object)DialogType.UpdateNone);
             SettingsData.Instance.QuietUpdating = false;
         }
         SettingsData.Instance.Updating = false;
     }
     ApplicationDeployment.CurrentDeployment.CheckForUpdateCompleted -= new CheckForUpdateCompletedEventHandler(CommonCommands.deployment_CheckForUpdateCompleted);
 }
        private void VersionCheckComplete(object sender, CheckForUpdateCompletedEventArgs e)
        {
            deployment.CheckForUpdateCompleted -= VersionCheckComplete;
            isChecking = false;

            string errMsg = null;
            if (e.Cancelled)
                errMsg = "Update check cancelled";
            else if (e.Error != null)
                errMsg = e.Error.Message;

            if (errMsg != null)
            {
                Status = errMsg;
                LatestVersion = null;
                return;
            }

            if (e.UpdateAvailable)
            {
                LatestVersion = e.AvailableVersion;
                if (e.IsUpdateRequired)
                    Status = STATUS_UPDATEREQUIRED;
                else
                    Status = STATUS_OUTOFDATE;
            }
            else
            {
                LatestVersion = LocalMachineInfo.Current.DayZeroLauncherVersion;
                Status = STATUS_UPTODATE;
            }
        }
示例#17
0
 private void CheckForUpdateCompleted(object sender, CheckForUpdateCompletedEventArgs e)
 {
     if (e.UpdateAvailable)
     {
         MessageBox.Show("An update is available and is now being downloaded.");
         BeginUpdate();
     }
     else
     {
         SetStatusLabel("Ready.");
         SetFormFieldsEnabled(true);
     }
 }
示例#18
0
        void ad_CheckForUpdateCompleted(object sender, CheckForUpdateCompletedEventArgs e)
        {
            ApplicationDeployment ad = ApplicationDeployment.CurrentDeployment;
            ad.CheckForUpdateCompleted -= new CheckForUpdateCompletedEventHandler(ad_CheckForUpdateCompleted);
            if (e.Error != null)
            {
                UpdateCompleted();
                return;
            }
            else if (e.Cancelled == true)
            {
                ShowMessage("The update was cancelled.");
                UpdateCompleted();
                return;
            }

            // Ask the user if they would like to update the application now.
            if (e.UpdateAvailable)
            {
                _sizeOfUpdate = e.UpdateSizeBytes / 1024;

                if (!e.IsUpdateRequired)
                {
                    DialogResult dr = MessageBox.Show("A new version of Witty Twitter is available!\nWould you like to update to the new version?\n\nDownload Size: " + _sizeOfUpdate + "K", "Update Available", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                    if (DialogResult.Yes == dr)
                    {
                        BeginUpdate();
                    }
                    else
                    {
                        // user may not update the application
                        // for whatever reason
                        UpdateCompleted();
                    }
                }
                else
                {
                    ShowMessage("A mandatory update is available for your Witty Twitter.\n\nAfter the update is completed the application will restart.");
                    BeginUpdate();
                }
            }

            if (_showUpdateMessage && e.UpdateAvailable == false)
            {
                ShowMessage("No update found.");
                _showUpdateMessage = false; // don't show it again unless user clicks on the check update.
            }
            else if (e.UpdateAvailable == false)
            {
                _downloadStatusLabel.Text = "No update found.  You have the latest version.";
            }

            UpdateCompleted();
        }
示例#19
0
 void ad_CheckForUpdateCompleted(object sender, CheckForUpdateCompletedEventArgs e)
 {
     InstallUpdateSyncWithInfo();
 }
示例#20
0
        private void AppDeployOnCheckForUpdateCompleted(object sender, CheckForUpdateCompletedEventArgs args)
        {
            if (args.Error != null)
            {
                var messageDialog = new MessageDialog(Properties.Resources.MwDeploymentDownloadException + args.Error.Message)
                {
                    Owner = this,
                    WindowStartupLocation = WindowStartupLocation.CenterOwner
                };
                messageDialog.ShowDialog();
                return;
            }
            if (args.Cancelled)
            {
                _updateDialog.Close();
                return;
            }

            if (args.UpdateAvailable)
            {
                var messageDialog = new MessageDialog(Properties.Resources.MwUpdateDialogContentBeforeVersion +
                                                   args.AvailableVersion +
                                                   Properties.Resources.MwUpdateDialogContentAfterVersion,
                    Properties.Resources.MwUpdateDialogHeader, MessageDialogButtons.YesNo)
                {
                    Owner = this,
                    WindowStartupLocation = WindowStartupLocation.CenterOwner
                };
                messageDialog.ShowDialog();

                if (messageDialog.MessageDialogResult == MessageDialogResult.Yes)
                {
                    _updateDialog.PbDownloadProgress.Value = 0;
                    BeginUpdate();
                }
                else
                {
                    _updateDialog.Close();
                }
            }
            else
            {
                var messageDialog = new MessageDialog(Properties.Resources.MwNoUpdatesText,
                    Properties.Resources.MwNoUpdatesHeader, MessageDialogButtons.Ok)
                {
                    Owner = this,
                    WindowStartupLocation = WindowStartupLocation.CenterOwner
                };
                messageDialog.ShowDialog();
                _updateDialog.Close();
            }
        }
示例#21
0
        private void CheckForUpdateBindCompletedEventHandler(object sender, BindCompletedEventArgs e)
        {
            Exception         error        = null;
            DeploymentManager manager      = null;
            bool    updateAvailable        = false;
            Version availableVersion       = null;
            bool    isUpdateRequired       = false;
            Version minimumRequiredVersion = null;
            long    updateSize             = 0L;

            new NamedPermissionSet("FullTrust").Assert();
            try
            {
                manager = (DeploymentManager)sender;
                if ((e.Error == null) && !e.Cancelled)
                {
                    UpdateCheckInfo info = this.DetermineUpdateCheckResult(manager.ActivationDescription);
                    if (info.UpdateAvailable)
                    {
                        manager.DeterminePlatformRequirements();
                        try
                        {
                            TrustParams trustParams = new TrustParams {
                                NoPrompt = true
                            };
                            manager.DetermineTrust(trustParams);
                        }
                        catch (TrustNotGrantedException)
                        {
                            if (!manager.ActivationDescription.IsUpdateInPKTGroup)
                            {
                                throw;
                            }
                        }
                    }
                    this.ProcessUpdateCheckResult(info, manager.ActivationDescription);
                    if (info.UpdateAvailable)
                    {
                        updateAvailable        = true;
                        availableVersion       = info.AvailableVersion;
                        isUpdateRequired       = info.IsUpdateRequired;
                        minimumRequiredVersion = info.MinimumRequiredVersion;
                        updateSize             = info.UpdateSizeBytes;
                    }
                }
                else
                {
                    error = e.Error;
                }
            }
            catch (Exception exception2)
            {
                if (ExceptionUtility.IsHardException(exception2))
                {
                    throw;
                }
                error = exception2;
            }
            finally
            {
                CodeAccessPermission.RevertAssert();
                Interlocked.Exchange(ref this._guard, 0);
                CheckForUpdateCompletedEventArgs    args    = new CheckForUpdateCompletedEventArgs(error, e.Cancelled, null, updateAvailable, availableVersion, isUpdateRequired, minimumRequiredVersion, updateSize);
                CheckForUpdateCompletedEventHandler handler = (CheckForUpdateCompletedEventHandler)this.Events[checkForUpdateCompletedKey];
                if (handler != null)
                {
                    handler(this, args);
                }
                if (manager != null)
                {
                    manager.ProgressChanged -= new DeploymentProgressChangedEventHandler(this.CheckForUpdateProgressChangedEventHandler);
                    manager.BindCompleted   -= new BindCompletedEventHandler(this.CheckForUpdateBindCompletedEventHandler);
                    new NamedPermissionSet("FullTrust").Assert();
                    try
                    {
                        manager.Dispose();
                    }
                    finally
                    {
                        CodeAccessPermission.RevertAssert();
                    }
                }
            }
        }
示例#22
0
        private static void checkForUpdate_completed(object sender, CheckForUpdateCompletedEventArgs e)
        {
            if (e.Error != null) {
                log.Error("Could not retrieve new version of the application.");
                log.Error(e.Error.Message);
                if (Program.isManualCheck)
                    MessageBox.Show("Could not retrieve new version of the application.\n" + e.Error.Message, "Update Check Failed", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            } else if (e.Cancelled == true) {
                log.Info("The update was cancelled");
                if (Program.isManualCheck)
                    MessageBox.Show("The update was cancelled.", "Update Check Cancelled", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }

            if (e.UpdateAvailable) {
                log.Info("An update is available: v" + e.AvailableVersion);

                if (!e.IsUpdateRequired) {
                    log.Info("This is an optional update.");
                    DialogResult dr = MessageBox.Show("An update for OGCS is available. Would you like to update the application now?", "OGCS Update Available", MessageBoxButtons.YesNo);
                    if (dr == DialogResult.Yes) {
                        beginUpdate();
                    }
                } else {
                    log.Info("This is a mandatory update.");
                    MessageBox.Show("A mandatory update for OGCS is required. The update will be installed now and the application restarted.", "OCGS Update Required", MessageBoxButtons.OK);
                    beginUpdate();
                }
            } else {
                log.Info("Already running the latest version.");
                if (Program.isManualCheck) { //Was a manual check, so give feedback
                    MessageBox.Show("You are already running the latest version.", "Latest Version", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
        }
示例#23
0
        private void CheckForUpdateCompleted(object sender, CheckForUpdateCompletedEventArgs e)
        {
            try
            {
                Delpoyment.CheckForUpdateCompleted -= CheckForUpdateCompleted;
                Delpoyment.CheckForUpdateProgressChanged -= CheckForUpdateProgressChanged;

                if (UpdateManagerProgressEvent != null)
                {
                    UpdateManagerProgressEvent(this, "");
                }

                if (e.UpdateAvailable)
                {
                    if (!e.IsUpdateRequired)
                    {
                        if (MessageBox.Show("Обнаружено, что установленная версия программы является устаревшей. Выполнить обновление?", "Требуется обновление", MessageBoxButton.OKCancel, MessageBoxImage.Information, MessageBoxResult.Cancel) == MessageBoxResult.OK)
                        {
                            BeginUpdate();
                        }
                    }
                    else
                    {
                        MessageBox.Show("Доступно обязательное обновоение для вашего приложения. Обновление будет выполнено автоматически, после чего приложение необходимо будет перезагрузить.", "Требуется обновление", MessageBoxButton.OK, MessageBoxImage.Exclamation, MessageBoxResult.OK);
                        BeginUpdate();
                    }
                }
                else
                {
                    Delpoyment = null;
                    //UpdateTimer.Start();
                }                
            }
            catch (Exception exception)
            {
                if (UpdateManagerProgressEvent != null)
                {
                    UpdateManagerProgressEvent(this, "");
                }
            }            
        }
        void deploy_CheckForUpdateCompleted(object sender, CheckForUpdateCompletedEventArgs e)
        {
            if (MessageBox.Show("找到可用更新,是否立即更新?", "", MessageBoxButton.YesNo) == MessageBoxResult.Yes)
            {
                var detail = deploy.CheckForDetailedUpdate();

                deploy.UpdateProgressChanged += new DeploymentProgressChangedEventHandler(deploy_UpdateProgressChanged);
                deploy.UpdateAsync();
                deploy.UpdateCompleted += new System.ComponentModel.AsyncCompletedEventHandler(deploy_UpdateCompleted);
            }
        }
示例#25
0
        private void CheckForUpdateBindCompletedEventHandler(object sender, BindCompletedEventArgs e)
        {
            Exception         error             = (Exception)null;
            DeploymentManager deploymentManager = (DeploymentManager)null;
            bool    updateAvailable             = false;
            Version availableVersion            = (Version)null;
            bool    isUpdateRequired            = false;
            Version minimumRequiredVersion      = (Version)null;
            long    updateSize = 0;

            new NamedPermissionSet("FullTrust").Assert();
            try
            {
                deploymentManager = (DeploymentManager)sender;
                if (e.Error == null && !e.Cancelled)
                {
                    UpdateCheckInfo updateCheckResult = this.DetermineUpdateCheckResult(deploymentManager.ActivationDescription);
                    if (updateCheckResult.UpdateAvailable)
                    {
                        deploymentManager.DeterminePlatformRequirements();
                        try
                        {
                            deploymentManager.DetermineTrust(new TrustParams()
                            {
                                NoPrompt = true
                            });
                        }
                        catch (TrustNotGrantedException ex)
                        {
                            if (!deploymentManager.ActivationDescription.IsUpdateInPKTGroup)
                            {
                                throw;
                            }
                        }
                    }
                    this.ProcessUpdateCheckResult(updateCheckResult, deploymentManager.ActivationDescription);
                    if (!updateCheckResult.UpdateAvailable)
                    {
                        return;
                    }
                    updateAvailable        = true;
                    availableVersion       = updateCheckResult.AvailableVersion;
                    isUpdateRequired       = updateCheckResult.IsUpdateRequired;
                    minimumRequiredVersion = updateCheckResult.MinimumRequiredVersion;
                    updateSize             = updateCheckResult.UpdateSizeBytes;
                }
                else
                {
                    error = e.Error;
                }
            }
            catch (Exception ex)
            {
                if (ExceptionUtility.IsHardException(ex))
                {
                    throw;
                }
                else
                {
                    error = ex;
                }
            }
            finally
            {
                CodeAccessPermission.RevertAssert();
                Interlocked.Exchange(ref this._guard, 0);
                CheckForUpdateCompletedEventArgs    e1 = new CheckForUpdateCompletedEventArgs(error, e.Cancelled, (object)null, updateAvailable, availableVersion, isUpdateRequired, minimumRequiredVersion, updateSize);
                CheckForUpdateCompletedEventHandler completedEventHandler = (CheckForUpdateCompletedEventHandler)this.Events[ApplicationDeployment.checkForUpdateCompletedKey];
                if (completedEventHandler != null)
                {
                    completedEventHandler((object)this, e1);
                }
                if (deploymentManager != null)
                {
                    deploymentManager.ProgressChanged -= new DeploymentProgressChangedEventHandler(this.CheckForUpdateProgressChangedEventHandler);
                    deploymentManager.BindCompleted   -= new BindCompletedEventHandler(this.CheckForUpdateBindCompletedEventHandler);
                    new NamedPermissionSet("FullTrust").Assert();
                    try
                    {
                        deploymentManager.Dispose();
                    }
                    finally
                    {
                        CodeAccessPermission.RevertAssert();
                    }
                }
            }
        }