Exemple #1
0
        private void CheckUpdate()
        {
            UpdateCheckInfo info = null;

            if (!ApplicationDeployment.IsNetworkDeployed)
            {
                //MessageBox.Show("NOT DEPLOYED !!! USING CLICKONCE PLEASE");
            }
            else
            {
                ApplicationDeployment appDeployment = ApplicationDeployment.CurrentDeployment;
                info = appDeployment.CheckForDetailedUpdate();
                if (info.UpdateAvailable)
                {
                    bool doUpdate = true;
                    if (doUpdate)
                    {
                        appDeployment.Update();
                        MessageBox.Show("프로그램이 업그레이드되어서 재시작합니다.");
                        this.Close();
                        Application.Restart();
                    }
                }
            }
        }
Exemple #2
0
        public static void Update()
        {
            try
            {
                ApplicationDeployment ad = ApplicationDeployment.CurrentDeployment;

                if (IsAsync)
                {
                    ad.UpdateCompleted       -= CurrentDeployment_UpdateCompleted;
                    ad.UpdateProgressChanged -= CurrentDeployment_UpdateProgressChanged;

                    ad.UpdateCompleted       += CurrentDeployment_UpdateCompleted;
                    ad.UpdateProgressChanged += CurrentDeployment_UpdateProgressChanged;
                    ad.UpdateAsync();
                }
                else
                {
                    IsDownloading = true;
                    ad.Update();
                    IsDownloading = false;
                    OnUpdateChecked(UpdateStateType.Updated);
                }
            }
            catch (DeploymentDownloadException dde)
            {
                OnUpdateChecked(
                    new Exception(
                        "Cannot install the latest version of the application. \n\nPlease check your network connection, or try again later. Error: " +
                        dde));
                IsDownloading = false;
                return;
            }
        }
Exemple #3
0
 public static void InstallUpdate()
 {
     if (ApplicationDeployment.IsNetworkDeployed)
     {
         ApplicationDeployment ad = ApplicationDeployment.CurrentDeployment;
         if (info.UpdateAvailable)
         {
             try
             {
                 ad.Update();
                 if (OnUpdateSuccess != null)
                 {
                     OnUpdateSuccess();
                     OnUpdateFail    = null;
                     OnUpdateSuccess = null;
                 }
             }
             catch (DeploymentDownloadException dde)
             {
                 LoggerManager.Error(dde, "Update deployement failed");
                 if (OnUpdateFail != null)
                 {
                     OnUpdateFail();
                     OnUpdateFail    = null;
                     OnUpdateSuccess = null;
                 }
             }
         }
     }
 }
Exemple #4
0
 private void InstallUpdateSyncWithInfo2()
 {
     if (ApplicationDeployment.IsNetworkDeployed == true)
     {
         ApplicationDeployment thisDeployment = ApplicationDeployment.CurrentDeployment;
         //this.Text = "正在检测更新...";
         if (thisDeployment.CheckForUpdate() == true)
         {
             if (MessageBox.Show("检测到有新的版本可以进行更新,现在需要更新吗?", "选择是否要进行更新", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes)
             {
                 // this.Text = "正在更新中";
                 thisDeployment.Update();
                 MessageBox.Show("更新完毕,将要重启程序!");
                 Application.Restart();
             }
             else
             {
                 //  this.Text = Application.ProductName + " " + Application.ProductVersion;
             }
         }
         else
         {
             MessageBox.Show("并没有新的版本进行更新!");
         }
     }
     else
     {
         MessageBox.Show("这不是网络发布的程序");
     }
 }
        private void CheckUpdate()
        {
            UpdateCheckInfo info = null;

            if (!ApplicationDeployment.IsNetworkDeployed)  // 로컬실행
            {
                Log.WriteInfo("배포된 버젼이 아닙니다.");
            }
            else
            {
                ApplicationDeployment AppDeploy = ApplicationDeployment.CurrentDeployment;

                info = AppDeploy.CheckForDetailedUpdate();

                if (info.UpdateAvailable)
                {
                    bool doUpdate = true;

                    if (doUpdate)
                    {
                        AppDeploy.Update();
                        MessageBox.Show(Resources.ProgramUpdateMsg, Resources.MsgBoxTitleUpdate);
                        this.Close();
                        Application.Restart();
                    }
                }
            }
        }
        private void UpdateTimer_Elapsed(object sender, ElapsedEventArgs e)
        {
            if (ApplicationDeployment.IsNetworkDeployed)
            {
                ApplicationDeployment current = ApplicationDeployment.CurrentDeployment;

                try
                {
                    if (current.CheckForUpdate())
                    {
                        Trace.WriteLine("VScan: Check for update");

                        current.Update();

                        DialogResult result = MessageBox.Show("Update downloaded, restart application?",
                                                              Application.ProductName, MessageBoxButtons.YesNo, MessageBoxIcon.Question);

                        if (result == DialogResult.Yes)
                        {
                            Application.Restart();
                        }
                    }
                }
                catch
                {
                    ms_updateTimer.Stop();
                    MessageBox.Show("ClickOnce connection failed.", Application.ProductName,
                                    MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
Exemple #7
0
 private void ToolStripMenuItem2Click(object sender, EventArgs e)
 {
     try
     {
         ApplicationDeployment updater = ApplicationDeployment.CurrentDeployment;
         bool verDepServer             = updater.CheckForUpdate();
         if (verDepServer) // Update available
         {
             DialogResult res = MessageBox.Show(
                 Resources.NewVersionYes,
                 Resources.Updater, MessageBoxButtons.YesNo);
             if (res == DialogResult.Yes)
             {
                 updater.Update();
                 MessageBox.Show(Resources.RestartMsg);
             }
         }
         else
         {
             MessageBox.Show(Resources.NewVersionNo, Resources.Updater);
         }
     } catch
     {
         MessageBox.Show(Resources.NewVersionNo, Resources.Updater);
     }
 }
Exemple #8
0
        private void CheckUpdate()
        {
            UpdateCheckInfo info = null;

            if (!ApplicationDeployment.IsNetworkDeployed)  // 로컬실행
            {
                Program.Log.WriteInfo("배포된 버젼이 아닙니다.");
            }
            else
            {
                ApplicationDeployment AppDeploy = ApplicationDeployment.CurrentDeployment;

                info = AppDeploy.CheckForDetailedUpdate();

                if (info.UpdateAvailable)
                {
                    bool doUpdate = true;

                    if (doUpdate)
                    {
                        AppDeploy.Update();
                        MessageBox.Show("최신버젼의 업데이트가 있습니다.\n업데이트 적용을 위해 프로그램을 재시작합니다.");
                        this.Close();
                        Application.Restart();
                    }
                }
            }
        }
Exemple #9
0
        private void UpdateApp()
        {
            ApplicationDeployment updater = ApplicationDeployment.CurrentDeployment;
            bool verDepServer             = updater.CheckForUpdate();

            if (verDepServer) // Update disponible
            {
                DialogResult res = MessageBox.Show(
                    String.Format("Une nouvelle version est disponible{0}Mettre à jour maintenant ?",
                                  Environment.NewLine),
                    "Mise à jour",
                    MessageBoxButtons.YesNo);

                if (res == DialogResult.Yes)
                {
                    updater.Update();

                    MessageBox.Show("Attention, l'application va redémarrer", "Redémarrage",
                                    MessageBoxButtons.OK, MessageBoxIcon.Information);

                    Application.Restart();
                }
            }
            else
            {
                MessageBox.Show("Pas de nouvelle version disponible");
            }
        }
Exemple #10
0
        private void CheckUpdate()
        {
            UpdateCheckInfo info = null;

            if (!ApplicationDeployment.IsNetworkDeployed)  // 로컬실행
            {
                Program.Log.WriteInfo("배포된 버젼이 아닙니다.");
            }
            else
            {
                ApplicationDeployment AppDeploy = ApplicationDeployment.CurrentDeployment;

                info = AppDeploy.CheckForDetailedUpdate();

                if (info.UpdateAvailable)
                {
                    bool doUpdate = true;

                    if (doUpdate)
                    {
                        AppDeploy.Update();
                        CustomMessageBox.ShowDialog(Properties.Resources.MsgUpdateResultHeader,
                                                    Properties.Resources.MsgUpdateResultContent, MessageBoxIcon.Information, MessageBoxButtons.OK);
                        Close();
                        Application.Restart();
                    }
                }
            }
        }
        public static void InstallUpdateSyncWithInfo()
        {
            if (alreadyCheckingForUpdate)
            {
                return;
            }
            else
            {
                alreadyCheckingForUpdate = true;
            }

            var daysSinceLastUpdate = (DateTime.Now - _lastUpdateCheck).Days;

            if (ApplicationDeployment.IsNetworkDeployed)
            {
                if (updateAvailable)
                {
                    UpdateCheckInfo       info = null;
                    ApplicationDeployment ad   = ApplicationDeployment.CurrentDeployment;

                    try
                    {
                        info = ad.CheckForDetailedUpdate();
                    }
                    catch
                    {
                        return;
                    }
                    finally
                    {
                        _lastUpdateCheck = DateTime.Now;
                    }

                    if (info.UpdateAvailable || true)
                    {
                        try
                        {
                            ad.Update();
                            System.Windows.Application.Current.Shutdown();
                            System.Windows.Forms.Application.Restart();
                        }
                        catch
                        {
                            return;
                        }
                    }
                }
                else
                {
                    ApplicationDeployment ad = ApplicationDeployment.CurrentDeployment;

                    ad.CheckForUpdateCompleted += new CheckForUpdateCompletedEventHandler(CheckForUpdateCompleted);
                    ad.CheckForUpdateAsync();

                    _lastUpdateCheck = DateTime.Now;
                }
            }
        }
Exemple #12
0
        public static void InstallUpdateSyncWithInfo()
        {
            if (!ApplicationDeployment.IsNetworkDeployed)
            {
                return;
            }
            ApplicationDeployment currentDeployment = ApplicationDeployment.CurrentDeployment;
            UpdateCheckInfo       updateCheckInfo;

            try
            {
                updateCheckInfo = currentDeployment.CheckForDetailedUpdate();
            }
            catch (DeploymentDownloadException ex)
            {
                int num = (int)MessageBox.Show("The new version of the application cannot be downloaded at this time. \n\nPlease check your network connection, or try again later. Error: " + ex.Message);
                return;
            }
            catch (InvalidDeploymentException ex)
            {
                int num = (int)MessageBox.Show("Cannot check for a new version of the application. The ClickOnce deployment is corrupt. Please redeploy the application and try again. Error: " + ex.Message);
                return;
            }
            catch (InvalidOperationException ex)
            {
                int num = (int)MessageBox.Show("This application cannot be updated. It is likely not a ClickOnce application. Error: " + ex.Message);
                return;
            }
            if (updateCheckInfo.UpdateAvailable)
            {
                bool flag = true;
                if (!updateCheckInfo.IsUpdateRequired)
                {
                    if (DialogResult.OK != MessageBox.Show("An update is available. Would you like to update the application now?", "Update Available", MessageBoxButtons.OKCancel))
                    {
                        flag = false;
                    }
                }
                else
                {
                    int num1 = (int)MessageBox.Show("This application has detected a mandatory update from your current version to version " + updateCheckInfo.MinimumRequiredVersion.ToString() + ". The application will now install the update and restart.", "Update Available", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                }
                if (flag)
                {
                    try
                    {
                        currentDeployment.Update();
                        int num2 = (int)MessageBox.Show("The application has been upgraded, and will now restart.");
                        Application.Restart();
                    }
                    catch (DeploymentDownloadException ex)
                    {
                        int num2 = (int)MessageBox.Show("Cannot install the latest version of the application. \n\nPlease check your network connection, or try again later. Error: " + (object)ex);
                    }
                }
            }
        }
Exemple #13
0
 private void Update_Click(object sender, RoutedEventArgs e)
 {
     if (DXMessageBox.Show((string)Application.Current.Resources["teReOk"], (string)Application.Current.Resources["tePrompt"], MessageBoxButton.OKCancel, MessageBoxImage.Question) == MessageBoxResult.OK)
     {
         appd.Update();
         System.Windows.Forms.Application.Restart();
         Application.Current.Shutdown();
     }
 }
        private static bool InstallUpdateSyncWithInfo()
        {
            UpdateCheckInfo info = null;

            if (ApplicationDeployment.IsNetworkDeployed)
            {
                ApplicationDeployment AD = ApplicationDeployment.CurrentDeployment;
                try
                {
                    info = AD.CheckForDetailedUpdate();
                }
                catch (DeploymentDownloadException dde)
                {
                    MessageUtil.ErrorMessage(
                        "The new version of the application cannot be downloaded at this time."
                        + Environment.NewLine + Environment.NewLine +
                        "Please check your network connection, or try again later. Error:" + dde.Message);
                }
                catch (InvalidOperationException ioe)
                {
                    MessageUtil.ErrorMessage(
                        "The application cannot be updated.It is likely not a ClickOnce application."
                        +
                        "Error:" + ioe.Message);
                }

                if (info.UpdateAvailable)
                {
                    bool doUpdate = true;
                    if (!info.IsUpdateRequired)
                    {
                    }
                    if (doUpdate)
                    {
                        try
                        {
                            AD.Update();
                            MessageUtil.InformationMessage("The application has been upgraded, and will now restart.");
                            Application.Restart();
                        }
                        catch (DeploymentDownloadException dde)
                        {
                            MessageUtil.ErrorMessage(
                                "Cannot install the latest version of the application."
                                + Environment.NewLine + Environment.NewLine +
                                "Please check your network connection, or try again later. Error:" + dde.Message);

                            return(false);
                        }
                    }
                }
            }

            return(true);
        }
Exemple #15
0
        private string checkForApplicationUpdates(bool silent = false)
        {
            if (!ApplicationDeployment.IsNetworkDeployed)
            {
                if (!silent)
                {
                    MessageBox.Show("Sorry, portable version can't check for updates.");
                }
                return(this.ProductVersion.TrimEnd(new char[] { '0', '.' }) + " Portable");
            }

            ApplicationDeployment ad   = null;
            UpdateCheckInfo       info = null;

            try {
                ad   = ApplicationDeployment.CurrentDeployment;
                info = ad.CheckForDetailedUpdate();
            }
            catch (InvalidDeploymentException ide) {
                MessageBox.Show("Cannot check for a new version of the application. The ClickOnce deployment is corrupt. Please redeploy the application and try again. Error: " + ide.Message);
                return(this.ProductVersion.TrimEnd(new char[] { '0', '.' }) + " CO Deployment Corrupt");
            }
            catch (DeploymentDownloadException dde) {
                MessageBox.Show("The new version of the application cannot be downloaded at this time. \n\nPlease check your network connection, or try again later. Error: " + dde.Message);
                return(this.ProductVersion.TrimEnd(new char[] { '0', '.' }) + "-d");
            }
            catch (InvalidOperationException ex) {
                // There's probably just no update out
                if (!silent)
                {
                    MessageBox.Show("Nope, no update out. Latest version is still just " + info.AvailableVersion);
                }
                return(ad.CurrentVersion.ToString(ad.CurrentVersion.Revision == 0 ? 3 : 4));
            }
            if (info == null)
            {
                return(this.ProductVersion.TrimEnd(new char[] { '0', '.' }) + "-?");
            }
            else if (info.UpdateAvailable)
            {
                if (silent || MessageBox.Show("New update: v" + info.AvailableVersion + ", update?", Application.ProductName + " Updater", MessageBoxButtons.OKCancel) == System.Windows.Forms.DialogResult.OK)
                {
                    ad.Update();
                    Application.Restart();
                    Environment.Exit(0);                     // Needed on startup...
                }
            }
            else if (!silent)
            {
                MessageBox.Show("Nope, no update. Latest version is still just " + ad.CurrentVersion);
            }
            return(ad.CurrentVersion.ToString(ad.CurrentVersion.Revision == 0 ? 3 : 4));
        }
        public int CheckForUpdateAndInstallIt()
        {
            int retVal = -1;

            UpdateCheckInfo info = null;

            if (ApplicationDeployment.IsNetworkDeployed)
            {
                ApplicationDeployment ad = ApplicationDeployment.CurrentDeployment;

                try
                {
                    info = ad.CheckForDetailedUpdate();
                }
                catch (DeploymentDownloadException dde)
                {
                    MessageBox.Show("The new version of the application cannot be downloaded at this time. \n\nPlease check your network connection, or try again later. Error: " + dde.Message);
                    return(-101);
                }
                catch (InvalidDeploymentException ide)
                {
                    MessageBox.Show("Cannot check for a new version of the application. The ClickOnce deployment is corrupt. Please redeploy the application and try again. Error: " + ide.Message);
                    return(-102);
                }
                catch (InvalidOperationException ioe)
                {
                    MessageBox.Show("This application cannot be updated. It is likely not a ClickOnce application. Error: " + ioe.Message);
                    return(-103);
                }

                if (info.UpdateAvailable)
                {
                    try
                    {
                        ad.Update();
                        //MessageBox.Show("The application has been upgraded, and will now restart.");
                        this.afterUpdate = true;
                        return(0);
                    }
                    catch (DeploymentDownloadException dde)
                    {
                        MessageBox.Show("Nemoze sa nainstalovat najnovsia verzia programu. \n\nProsim zavolajte testovacieho inziniera.\n\n" + dde);
                        return(-200);
                    }
                }
                else
                {
                    return(retVal);
                }
            }
            return(retVal);
        }
Exemple #17
0
 /// <summary>
 /// Actualiza la Version mediante la API de ClickOnce
 /// </summary>
 private void UpdateVersion()
 {
     if (ApplicationDeployment.IsNetworkDeployed)
     {
         ApplicationDeployment updateCheck = ApplicationDeployment.CurrentDeployment;
         UpdateCheckInfo       info        = updateCheck.CheckForDetailedUpdate();
         if (info.UpdateAvailable)
         {
             updateCheck.Update();
             CloseThisWin();
         }
     }
 }
Exemple #18
0
        public static void InstallUpdateSyncWithInfo()
        {
            UpdateCheckInfo info = null;

            if (ApplicationDeployment.IsNetworkDeployed)
            {
                ApplicationDeployment ad = ApplicationDeployment.CurrentDeployment;

                try
                {
                    info = ad.CheckForDetailedUpdate();
                }
                catch (DeploymentDownloadException dde)
                {
                    System.Windows.MessageBox.Show("The new version of the application cannot be downloaded at this time. \n\nPlease check your network connection, or try again later. Error: " + dde.Message);
                    return;
                }
                catch (InvalidDeploymentException ide)
                {
                    System.Windows.MessageBox.Show("Cannot check for a new version of the application. The ClickOnce deployment is corrupt. Please redeploy the application and try again. Error: " + ide.Message);
                    return;
                }
                catch (InvalidOperationException ioe)
                {
                    System.Windows.MessageBox.Show("This application cannot be updated. It is likely not a ClickOnce application. Error: " + ioe.Message);
                    return;
                }

                if (info.UpdateAvailable)
                {
                    Boolean doUpdate = true;

                    if (!info.IsUpdateRequired)
                    {
                        try
                        {
                            ad.Update();
                            System.Windows.MessageBox.Show("The application has been upgraded, and will now restart.");
                            //Process.GetCurrentProcess().Kill();
                            System.Windows.Forms.Application.Restart();
                            System.Windows.Application.Current.Shutdown();
                        }
                        catch (DeploymentDownloadException dde)
                        {
                            System.Windows.MessageBox.Show("Cannot install the latest version of the application. \n\nPlease check your network connection, or try again later. Error: " + dde);
                            return;
                        }
                    }
                }
            }
        }
Exemple #19
0
        /// <summary>
        ///
        /// </summary>
        private void NainstalujAktualizaci()
        {
            UpdateCheckInfo info = null;

            if (ApplicationDeployment.IsNetworkDeployed)
            {
                ApplicationDeployment ad = ApplicationDeployment.CurrentDeployment;

                try
                {
                    info = ad.CheckForDetailedUpdate();
                }
                catch (DeploymentDownloadException exc)
                {
                    Vyjimky.VypisVyjimek("Nepodařilo se stáhnout novou verzi. Zkontroluj připojení k internetu", exc);
                    return;
                }
                catch (InvalidDeploymentException exc)
                {
                    Vyjimky.VypisVyjimek("Nepodařilo se stáhnout novou verzi.", exc);
                    Nastaveni.ZapisChybovySoubor(DateTime.Now.ToString("d.M.yyyy H:mm:ss") + ": Chybně sestavený soubor (deployment). Detaily: " + exc.Message);
                    return;
                }
                catch (InvalidOperationException exc)
                {
                    Vyjimky.VypisVyjimek("Nepodařilo se aktualizovat novou verzi.", exc);
                    Nastaveni.ZapisChybovySoubor(DateTime.Now.ToString("d.M.yyyy H:mm:ss") + ": Nezdařená aktualizace. Detaily: " + exc.Message);
                    return;
                }

                if (info.UpdateAvailable)
                {
                    MessageBox.Show("Byla nalezena aktualizace a nyní bude provedena její instalace.", "Aktualizace k dispozici", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    try
                    {
                        ad.Update();
                        MessageBox.Show("Aplikace byla aktualizována a nyní bude restartována.");
                        Nastaveni.NastavStavAplikace((int)Nastaveni.StavyAplikace.koncici); // Vynucené okamžité ukončení aplikace
                        Application.Restart();
                        this.Close();
                        return;
                    }
                    catch (DeploymentDownloadException exc)
                    {
                        Vyjimky.VypisVyjimek("Nepodařilo se nainstalovat aktualizaci. Zkontorluj si připojení k internetu nebo zkus později", exc);
                        return;
                    }
                }
            }
        }
Exemple #20
0
        public static Boolean CheckForUpdates()
        {
            Boolean returnValue = default(Boolean);

            try
            {
                // First check to see if we are running in a ClickOnce context
                if (ApplicationDeployment.IsNetworkDeployed)
                {
                    // Get an instance of the deployment
                    ApplicationDeployment deployment = ApplicationDeployment.CurrentDeployment;

                    // Check to see if updates are available
                    if (deployment.CheckForUpdate())
                    {
                        DialogResult res = MessageBox.Show("A new version of the application is available, do you want to update?", "Application Updater", MessageBoxButtons.YesNo);
                        if (res == DialogResult.Yes)
                        {
                            // Do the update
                            deployment.Update();
                            DialogResult res2 = MessageBox.Show("Update complete, do you want to restart the application to apply the update?", "Application Updater", MessageBoxButtons.YesNo);
                            if (res2 == DialogResult.Yes)
                            {
                                // Restart the application to apply the update
                                System.Windows.Forms.Application.Restart();
                            }
                        }
                    }
                    else
                    {
                        MessageBox.Show("No updates available.", "Application Updater");
                    }
                }
                else
                {
                    MessageBox.Show("Updates not allowed unless you are launched through ClickOnce.");
                }

                returnValue = true;
            }
            catch (Exception ex)
            {
                Log.Write(
                    ex,
                    MethodBase.GetCurrentMethod(),
                    EventLogEntryType.Error);
            }
            return(returnValue);
        }
Exemple #21
0
 private void UpdateApplication()
 {
     try
     {
         ApplicationDeployment updateCheck = ApplicationDeployment.CurrentDeployment;
         updateCheck.Update();
         MessageBox.Show(Resources.ApplicationUpdated);
         Application.Restart();
     }
     catch (DeploymentDownloadException dde)
     {
         MessageBox.Show(string.Format(Resources.DeploymentDownloadExceptionMessage, dde));
         return;
     }
 }
 protected override void OnStartup(StartupEventArgs e)
 {
     try
     {
         RegisterComponents();
         if (CheckForUpdateVersion())
         {
             ApplicationDeployment applicationDevelopement = ApplicationDeployment.CurrentDeployment;
             bool result = applicationDevelopement.Update();
         }
     }
     catch (Exception)
     {
     }
 }
 private static void UpdateApplication()
 {
     try
     {
         ApplicationDeployment updateCheck = ApplicationDeployment.CurrentDeployment;
         updateCheck.Update();
         MessageBox.Show("The application has been upgraded, and will now restart.");
         Application.Restart();
     }
     catch (DeploymentDownloadException dde)
     {
         MessageBox.Show("Cannot install the latest version of the application. nnPlease check your network connection, or try again later. Error: " + dde);
         return;
     }
 }
Exemple #24
0
        private void simpleButton2_Click(object sender, EventArgs e)
        {
            UpdateCheckInfo info;

            if (ApplicationDeployment.IsNetworkDeployed)
            {
                ApplicationDeployment ad = ApplicationDeployment.CurrentDeployment;
                try
                {
                    info = ad.CheckForDetailedUpdate();
                }
                catch (DeploymentDownloadException dde)
                {
                    MessageBox.Show("DeploymentDownloadException: " + dde.Message);
                    return;
                }
                catch (InvalidDeploymentException ide)
                {
                    MessageBox.Show("InvalidDeploymentException: " + ide.Message);
                    return;
                }
                catch (InvalidOperationException ioe)
                {
                    MessageBox.Show("InvalidOperationException: " + ioe.Message);
                    return;
                }
                if (info.UpdateAvailable)
                {
                    if (MessageBox.Show("Do you want to update?", "Message", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                    {
                        try
                        {
                            ad.Update();
                            Application.Restart();
                        }
                        catch (Exception ex)
                        {
                            MessageBox.Show("Exception: " + ex.Message);
                            return;
                        }
                    }
                }
                else
                {
                    MessageBox.Show("Updated with new version!");
                }
            }
        }
Exemple #25
0
        public static bool Check()
        {
            UpdateCheckInfo info = null;

            if (ApplicationDeployment.IsNetworkDeployed)
            {
                ApplicationDeployment ad = ApplicationDeployment.CurrentDeployment;

                try
                {
                    info = ad.CheckForDetailedUpdate();
                }
                catch (DeploymentDownloadException)
                {
                    // No network connection
                    return(false);
                }
                catch (InvalidDeploymentException)
                {
                    return(false);
                }
                catch (InvalidOperationException)
                {
                    return(false);
                }

                if (info.UpdateAvailable)
                {
                    try
                    {
                        ad.Update();
                        Application.Restart();
                        Environment.Exit(0);
                    }
                    catch (DeploymentDownloadException)
                    {
                        // No network connection
                    }

                    return(false);
                }
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemple #26
0
        //</SNIPPET4>

        //<SNIPPET5>
        private void InstallUpdateSync()
        {
            if (ApplicationDeployment.IsNetworkDeployed)
            {
                Boolean updateAvailable  = false;
                ApplicationDeployment ad = ApplicationDeployment.CurrentDeployment;

                try
                {
                    updateAvailable = ad.CheckForUpdate();
                }
                catch (DeploymentDownloadException dde)
                {
                    // This exception occurs if a network error or disk error occurs
                    // when downloading the deployment.
                    MessageBox.Show("The application cannt check for the existence of a new version at this time. \n\nPlease check your network connection, or try again later. Error: " + dde);
                    return;
                }
                catch (InvalidDeploymentException ide)
                {
                    MessageBox.Show("The application cannot check for an update. The ClickOnce deployment is corrupt. Please redeploy the application and try again. Error: " + ide.Message);
                    return;
                }
                catch (InvalidOperationException ioe)
                {
                    MessageBox.Show("This application cannot check for an update. This most often happens if the application is already in the process of updating. Error: " + ioe.Message);
                    return;
                }

                if (updateAvailable)
                {
                    try
                    {
                        ad.Update();
                        MessageBox.Show("The application has been upgraded, and will now restart.");
                        Application.Restart();
                    }
                    catch (DeploymentDownloadException dde)
                    {
                        MessageBox.Show("Cannot install the latest version of the application. Either the deployment server is unavailable, or your network connection is down. \n\nPlease check your network connection, or try again later. Error: " + dde.Message);
                    }
                    catch (TrustNotGrantedException tnge)
                    {
                        MessageBox.Show("The application cannot be updated. The system did not grant the application the appropriate level of trust. Please contact your system administrator or help desk for further troubleshooting. Error: " + tnge.Message);
                    }
                }
            }
        }
Exemple #27
0
        private void lnkActualizaciones_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            this.Cursor = Cursors.Hand;

            try
            {
                ApplicationDeployment updateCheck = ApplicationDeployment.CurrentDeployment;

                UpdateCheckInfo updateCheckInfo = updateCheck.CheckForDetailedUpdate();

                if (updateCheckInfo.UpdateAvailable)
                {
                    DialogResult result = MessageBox.Show(this, "Se encontró una nueva versión. ¿Desea actualizar la aplicación?", this.Text, MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1);

                    if (result == System.Windows.Forms.DialogResult.Yes)
                    {
                        try
                        {
                            updateCheck.Update();

                            MessageBox.Show(this, "La aplicación ha sido actualizada. se reiniciara para poder aplicar los cambios.", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
                            Application.Restart();
                        }
                        catch (System.Deployment.Application.TrustNotGrantedException)
                        {
                            MessageBox.Show(this, "No tiene permisos para realizar esta operación", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        }
                        catch (System.Deployment.Application.DeploymentException ex)
                        {
                            MessageBox.Show(this, "Se produjo un error al intentar actualizar la aplicación. Error: " + ex.Message, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                    }
                }
                else
                {
                    MessageBox.Show(this, "No existen actualizaciones disponibles.", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(this, "Se produjo un error intentando comprobar las actualizaciones. Error: " + ex.Message, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                this.Cursor = Cursors.Default;
            }
        }
Exemple #28
0
        private void Button1_Click(object sender, EventArgs e)
        {
            UpdateCheckInfo info;

            if (ApplicationDeployment.IsNetworkDeployed)
            {
                ApplicationDeployment ad = ApplicationDeployment.CurrentDeployment;
                try
                {
                    info = ad.CheckForDetailedUpdate();
                }
                catch (DeploymentDownloadException dde)
                {
                    MessageBox.Show("The new version of the application can't be downloaded at this time.\n\n Please check your network connection or try again later. Error:" + dde.Message, "Message", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                catch (InvalidDeploymentException ide)
                {
                    MessageBox.Show("Can't check for a new version of the application. The ClickOnce deployment is carrupt. Please redeploy the application and try again. Error:" + ide.Message, "Message", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                catch (InvalidOperationException ioe)
                {
                    MessageBox.Show("This application can't be updated. It's likely not a ClicOnce application. Error: " + ioe.Message, "Message", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                if (info.UpdateAvailable)
                {
                    if (MessageBox.Show("A newer version is available. Would you like to update it now?", "Message", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                    {
                        try
                        {
                            ad.Update();
                            Application.Restart();
                        }
                        catch (Exception ex)
                        {
                            MessageBox.Show(ex.Message, "Message", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                    }
                }
                else
                {
                    MessageBox.Show("You are running the latest version.", "Message", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
        }
Exemple #29
0
        private void checkForUpdateToolStripMenuItem_Click(object sender, EventArgs e)
        {
            ApplicationDeployment updateCheck = ApplicationDeployment.CurrentDeployment;
            UpdateCheckInfo       info;

            try
            {
                info = updateCheck.CheckForDetailedUpdate();

                if (info.UpdateAvailable)
                {
                    DialogResult dialogResult = MessageBox.Show("An update is available. Would you like to update the application now?", "Update available", MessageBoxButtons.OKCancel);

                    if (dialogResult == DialogResult.OK)
                    {
                        updateCheck.Update();
                        MessageBox.Show("The application has been upgraded, and will now restart.");
                        Application.Restart();
                    }
                }
                else
                {
                    MessageBox.Show("No updates are available for the moment.");
                }
            }
            catch (DeploymentDownloadException dde)
            {
                MessageBox.Show(dde.Message + "\n" + dde.InnerException);
                return;
            }
            catch (InvalidDeploymentException ide)
            {
                MessageBox.Show(ide.Message + "\n" + ide.InnerException);
                return;
            }
            catch (InvalidOperationException ioe)
            {
                MessageBox.Show(ioe.Message + "\n" + ioe.InnerException);
                return;
            }
            catch (Exception e10)
            {
                MessageBox.Show(e10.Message);
                return;
            }
        }
Exemple #30
0
        private void button1_Click(object sender, EventArgs e)
        {
            UpdateCheckInfo info = null;

            if (ApplicationDeployment.IsNetworkDeployed)
            {
                ApplicationDeployment ad = ApplicationDeployment.CurrentDeployment;

                try
                {
                    info = ad.CheckForDetailedUpdate();
                }
                catch (DeploymentDownloadException dde)
                {
                    MessageBox.Show("A nova versão do aplicativo não pode ser baixada no momento. \n\nVerifique sua conexão de rede ou tente novamente mais tarde. Error: " + dde.Message);
                    return;
                }
                catch (InvalidDeploymentException ide)
                {
                    MessageBox.Show("Não é possível procurar por uma nova versão do aplicativo. A implantação do ClickOnce está corrompida. Por favor, reimplemente o aplicativo e tente novamente. Error: " + ide.Message);
                    return;
                }
                catch (InvalidOperationException ioe)
                {
                    MessageBox.Show("Este aplicativo não pode ser atualizado. Provavelmente não é um aplicativo ClickOnce. Error: " + ioe.Message);
                    return;
                }

                if (doUpdate)
                {
                    try
                    {
                        ad.Update();
                        MessageBox.Show("O aplicativo foi atualizado e agora será reiniciado.");
                        Application.Restart();
                        Environment.Exit(0);
                    }
                    catch (DeploymentDownloadException dde)
                    {
                        MessageBox.Show("Não é possível instalar a versão mais recente do aplicativo. \n\nPor favor, verifique sua conexão de rede ou tente novamente mais tarde. Error: " + dde);
                        return;
                    }
                }
            }
        }