// --------------------------------------------- private void OnPerformUserInteractiveUpdate(ApplicationDeployUpdateInfo info) { // Require User to confirm update // --------------------- bool updateCancelled = false; if (info.IsUpdateRequired) { // Display a message that the app MUST reboot. Display the minimum required version. _dialog.Info( string.Format("{0} has detected a mandatory update from your current version to version {1}. {0} will now install the update and restart.", ProductName, info.MinimumRequiredVersion), "Update Available"); } else { if (_dialog.Question(string.Format("An update is available. Would you like to update {0} now?", ProductName), "Update Available") != true) { // _log.Warn("User has refused to update."); updateCancelled = true; } else { // _log.Info("User agreed to update"); } } // Require User to confirm update // --------------------- if (!updateCancelled) { // _log.Info("Performing update"); bool res = DoUpdate(_deploymentWrapper); if (res) { //_log.Info("Application updated succesfully"); if (RestartAfterUpdate) { _dialog.Info("The application has been upgraded and will now restart."); AppRestart(); } else { _dialog.Info("The application has been upgraded and the new version will be available after restart."); } } } }
/// <summary> /// Verifica ed aggiorna l'applicazione corrente /// </summary> public void Update() { try { if (_deploymentWrapper.IsNetworkDeployed) { ApplicationDeployUpdateInfo info = OnCheckUpdates(_deploymentWrapper); if (info == null) { //_log.Warn("Checking for application updates failed: Connection failed"); //_log.WarnFormat(" - ActivationURI: {0}", _deploymentWrapper.ActivationUri); //_log.WarnFormat(" - UpdateLocation: {0}", _deploymentWrapper.UpdateLocation); return; } if (info.UpdateAvailable) { //_log.WarnFormat("A new version of {0} is available", ProductName); //_log.InfoFormat(" - Version: {0} )", info.AvailableVersion); //_log.InfoFormat(" - Size: {0} bytes)", info.UpdateSizeBytes); if (RequireUserInteraction) { // _log.Info("Performing update"); OnPerformUserInteractiveUpdate(info); } else { // _log.Info("Performing update in silent mode"); OnPerformSilentUpdate(); } } else { // _log.InfoFormat("{0} is up to date.", ProductName); } } else { // _log.Info("This is a debug version and cannot be updated automatically."); } } catch (Exception ex) { // _log.Error("Update Failed.", ex); OnError(ex); } }