Пример #1
0
        private void btn_update_Click(object sender, RoutedEventArgs e)
        {
            if (ApplicationDeployment.IsNetworkDeployed)
            {
                ApplicationDeployment ad = ApplicationDeployment.CurrentDeployment;
                System.Deployment.Application.UpdateCheckInfo info = null;
                try
                {
                    ad.UpdateCompleted += new System.ComponentModel.AsyncCompletedEventHandler(ad_UpdateCompleted);
                    //ad_UpdateCompleted is a private method which handles what happens after the update is done
                    //tb_log.Text += "MinimumRequiredVersion" + info.MinimumRequiredVersion;
                    //tb_log.Text += "ActivationUri" + ad.ActivationUri;
                    tb_log.Text += "UpdateLocation" + ad.UpdateLocation;

                    info = ad.CheckForDetailedUpdate();

                    tb_log.Text += "AvailableVersion" + info.AvailableVersion;
                    tb_log.Text += "UpdateAvailable " + info.UpdateAvailable;
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.ToString());
                }
                finally
                {
                    if (info.UpdateAvailable)
                    {
                        //You can create a dialog or message that prompts the user that there's an update. Make sure the user knows that your are updating the application.
                        ad.UpdateAsync();//Updates the application asynchronously
                    }
                }
            }
        }
Пример #2
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();
                    }
                }
            }
        }
Пример #3
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();
                    }
                }
            }
        }
Пример #4
0
        public void UpdateTimerLoop(object sender, EventArgs e)
        {
            _UpdateTimer.Stop();
            try
            {
                ApplicationDeployment ad = ApplicationDeployment.CurrentDeployment;
                if ((DateTime.Now - ad.TimeOfLastUpdateCheck).Hours > 6)
                {
                    Helpers.DebugInfo("Trying to get updates...");

                    var checkinfo = ad.CheckForDetailedUpdate();
                    if (checkinfo != null)
                    {
                        string shown_version = (string)Properties.Settings.Default["UpdateLastShownVersion"];
                        string new_version   = checkinfo.AvailableVersion.ToString();
                        Helpers.DebugInfo("Available version: " + new_version);
                        if (new_version != shown_version)
                        {
                            Properties.Settings.Default["UpdateLastShownVersion"] = new_version;
                            Properties.Settings.Default.Save();
                            MessageBox.Show(
                                "New version is available (" + new_version + ") at" + Environment.NewLine +
                                ApplicationDeployment.CurrentDeployment.UpdateLocation,
                                "TimeReporting " + ApplicationDeployment.CurrentDeployment.CurrentVersion.ToString(),
                                MessageBoxButtons.OK);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Helpers.DebugInfo("Exception during updating: " + ex.Message);
            }
            _UpdateTimer.Start();
        }
Пример #5
0
        public static String CheckforNewVersion()
        {
            String latestVersion = String.Empty;

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

                UpdateCheckInfo info = null;
                try
                {
                    info = ad.CheckForDetailedUpdate();
                }
                catch
                {
                    return(latestVersion);
                }

                if (info.UpdateAvailable)
                {
                    latestVersion = String.Format("{0}", info.AvailableVersion);
                }
            }
            return(latestVersion);
        }
        protected override async Task <bool> CheckUpdateCore()
        {
            UpdateCheckInfo       info = null;
            ApplicationDeployment ad   = ApplicationDeployment.CurrentDeployment;

            try {
                info = ad.CheckForDetailedUpdate();
            }
            catch (DeploymentDownloadException) {
                return(false);
            }
            catch (InvalidDeploymentException) {
                return(false);
            }
            catch (InvalidOperationException) {
                return(false);
            }
            if (!info.UpdateAvailable)
            {
                return(false);
            }
            bool handled = false;
            AsyncCompletedEventHandler handler = (sender, e) => {
                handled = true;
            };

            ad.UpdateCompleted += handler;
            ad.UpdateAsync();
            while (!handled)
            {
                await Task.Delay(100);
            }
            ad.UpdateCompleted -= handler;
            return(true);
        }
Пример #7
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();
                    }
                }
            }
        }
Пример #8
0
        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();
                    }
                }
            }
        }
        /// <summary>
        /// Verifica si existe una nueva version de la aplicacion a través de ClickOnce
        /// </summary>
        /// <returns>True = Existe nueva version</returns>
        private static bool UpdateApp()
        {
            bool result = false;

            if (ApplicationDeployment.IsNetworkDeployed)
            {
                try
                {
                    ApplicationDeployment updateCheck = ApplicationDeployment.CurrentDeployment;
                    UpdateCheckInfo       info        = updateCheck.CheckForDetailedUpdate();

                    if (info.UpdateAvailable)
                    {
                        result = true;
                        Application.EnableVisualStyles();
                        Application.SetCompatibleTextRenderingDefault(false);
                        Application.Run(new frmProgressBar());
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
            return(result);
        }
Пример #10
0
        private void Timer_Elapsed(object sender, ElapsedEventArgs e)
        {
            if (processing)
            {
                return;
            }

            timer.Stop();
            processing = true;
            try
            {
                var info = applicationDeployment.CheckForDetailedUpdate();

                if (info.UpdateAvailable)
                {
                    Status = VersionStatus.UpdateAvailable;
                }
                else
                {
                    Status = VersionStatus.UpToDate;
                }
            }
            catch (Exception)
            {
                Status = VersionStatus.UpdateUnknown;
            }

            processing = false;
            timer.Start();
        }
Пример #11
0
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            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 (info.UpdateAvailable)
                {
                    Boolean doUpdate = true;
                    if (!info.IsUpdateRequired && IsAppAlreadyRunning() == false)
                    {
                        var peq = new frm_Versao(doUpdate);
                        if (Application.OpenForms.OfType <frm_Versao>().Count() > 0)
                        {
                            Application.OpenForms[peq.Name].Focus();
                        }
                        else
                        {
                            peq.ShowDialog();
                        }
                    }
                }
            }
            if (IsAppAlreadyRunning() == false)
            {
                Application.Run(new frm_Principal());
            }
            else
            {
                string       msg = "O Sistema de RM já está aberto";
                frm_Mensagem mg  = new frm_Mensagem(msg);
                mg.ShowDialog();
            }
        }
        public static bool CheckForUpdates(out AppVersionList versionList)
        {
            try
            {
                if (ApplicationDeployment.IsNetworkDeployed)
                {
                    ApplicationDeployment deployment = ApplicationDeployment.CurrentDeployment;

                    UpdateCheckInfo info = deployment.CheckForDetailedUpdate();

                    versionList = new AppVersionList();

                    if (info.UpdateAvailable)
                    {
                        versionList.Latest   = new AppVersion(null, info.AvailableVersion, null, true);
                        versionList.Versions = new AppVersion[] { versionList.Latest };
                    }

                    return(info.UpdateAvailable);
                }
                else
                {
                    versionList = DownloadVersions();

                    if (UpdateAvailable(versionList))
                    {
                        return(true);
                    }
                }
            }
            catch (DeploymentDownloadException dde)
            {
                SystemSounds.Beep.Play();
                Console.WriteLine("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);
                versionList = null;
            }
            catch (InvalidDeploymentException ide)
            {
                SystemSounds.Beep.Play();
                Console.WriteLine("Cannot check for a new version of the application. The ClickOnce deployment is corrupt. Please redeploy the application and try again. Error: " + ide.Message);
                versionList = null;
            }
            catch (InvalidOperationException ioe)
            {
                SystemSounds.Beep.Play();
                Console.WriteLine("This application cannot be updated. It is likely not a ClickOnce application. Error: " + ioe.Message);
                versionList = null;
            }
            catch (Exception e)
            {
                SystemSounds.Beep.Play();
                Console.WriteLine("Unable to check for update: " + e.Message);

                versionList = null;
            }

            return(false);
        }
Пример #13
0
        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;
                }
            }
        }
Пример #14
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);
                    }
                }
            }
        }
Пример #15
0
        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);
        }
Пример #16
0
        private bool UpdateAvailable()
        {
            if (ApplicationDeployment.IsNetworkDeployed)
            {
                ApplicationDeployment updateCheck = ApplicationDeployment.CurrentDeployment;
                UpdateCheckInfo       info        = updateCheck.CheckForDetailedUpdate();

                return(info.UpdateAvailable);
            }

            return(false);
        }
Пример #17
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));
        }
Пример #18
0
        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);
        }
Пример #19
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();
         }
     }
 }
Пример #20
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;
                        }
                    }
                }
            }
        }
Пример #21
0
 private void InstallUpdateSyncWithInfo()
 {
     UpdateCheckInfo info;
     ApplicationDeployment applicationDeployment = ApplicationDeployment.CurrentDeployment;
     info = applicationDeployment.CheckForDetailedUpdate();
     if (!applicationDeployment.IsFirstRun)
     {
         if (info.UpdateAvailable)
         {
             applicationDeployment.UpdateCompleted += applicationDeployment_UpdateCompleted;
             applicationDeployment.UpdateAsync();
         }
     }
 }
Пример #22
0
        /// <summary>
        /// Updates the ClickOnce application.
        /// </summary>
        /// <param name="currentDeployment">The current deployment.</param>
        /// <returns></returns>
        protected virtual UpdateResult UpdateApplication(ApplicationDeployment currentDeployment)
        {
            var info = currentDeployment.CheckForDetailedUpdate();

            if (!info.UpdateAvailable)
            {
                return(NoUpdateNeededResult());
            }

            var message = string.Empty;

            return(UpdateCurrentDeployment(currentDeployment, ref message) ?
                   SuccessResult(info) : FailResult(message));
        }
Пример #23
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;
                    }
                }
            }
        }
        private static void bgWorker_DoWork(object sender, DoWorkEventArgs e)
        {
            UpdateCheckInfo info = null;

            // Check if the application was deployed via ClickOnce.
            if (!ApplicationDeployment.IsNetworkDeployed)
            {
                e.Result = UpdateStatuses.NotDeployedViaClickOnce;
                return;
            }

            ApplicationDeployment updateCheck = ApplicationDeployment.CurrentDeployment;

            try
            {
                info = updateCheck.CheckForDetailedUpdate();
            }
            catch (DeploymentDownloadException dde)
            {
                e.Result = UpdateStatuses.DeploymentDownloadException;
                return;
            }
            catch (InvalidDeploymentException ide)
            {
                e.Result = UpdateStatuses.InvalidDeploymentException;
                return;
            }
            catch (InvalidOperationException ioe)
            {
                e.Result = UpdateStatuses.InvalidOperationException;
                return;
            }

            if (info.UpdateAvailable)
            {
                if (info.IsUpdateRequired)
                {
                    e.Result = UpdateStatuses.UpdateRequired;
                }
                else
                {
                    e.Result = UpdateStatuses.UpdateAvailable;
                }
            }
            else
            {
                e.Result = UpdateStatuses.NoUpdateAvailable;
            }
        }
Пример #25
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!");
                }
            }
        }
Пример #26
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);
            }
        }
Пример #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;
            }
        }
Пример #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);
                }
            }
        }
Пример #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;
            }
        }
Пример #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;
                    }
                }
            }
        }