Ejemplo n.º 1
0
        /// <summary>
        /// Checks for updates
        /// </summary>
        public void CheckForUpdates()
        {
            updater.currentVersion = new Version(Application.ProductVersion);
            updater.updateInfoURL  = new Uri(Constants.UpdateXMLUrl);
            updater.SaveName       = Main.StartupPath + @"\Wnmp-Upgrade-Installer.exe";

            updater.CheckForUpdate();

            if (updater.UpdateAvailable)
            {
                UpdatePrompt updatePrompt = new UpdatePrompt();
                updatePrompt.StartPosition       = FormStartPosition.CenterParent;
                updatePrompt.currentversion.Text = updater.currentVersion.ToString();
                updatePrompt.newversion.Text     = updater.newVersion.ToString();
                if (updatePrompt.ShowDialog() == DialogResult.Yes)
                {
                    mainForm.Enabled = false;
                    updater.Update(UpdateCanceled, UpdateDownloaded);
                }
            }
            else
            {
                Log.wnmp_log_notice("Your version: " + updater.currentVersion + " is up to date.", Log.LogSection.WNMP_MAIN);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Checks for updates
        /// </summary>
        public static void CheckForUpdates(bool AutoUpdate)
        {
            if (!ReadUpdateXML())
            {
                return;
            }

            if (WNMP_VER.CompareTo(NEW_WNMP_VERSION) < 0)   // If it returns less than 0 than theres a new version
            {
                var CV = new UpdatePrompt();
                CV.StartPosition   = FormStartPosition.CenterScreen;
                CV.cversion.Text   = WNMP_VER.ToString();
                CV.newversion.Text = NEW_WNMP_VERSION.ToString();
                if (CV.ShowDialog() == DialogResult.Yes)
                {
                    DownloadWnmpUpdate(Wnmp_Upgrade_URL, UpdateExe);
                }
            }
            else
            {
                Log.wnmp_log_notice("Your version: " + WNMP_VER + " is up to date.", Log.LogSection.WNMP_MAIN);
            }

            if (AutoUpdate)
            {
                Options.settings.Lastcheckforupdate = DateTime.Now;
                Options.settings.UpdateSettings();
            }
        }
Ejemplo n.º 3
0
        private void Initialize()
        {
            //enable login menu option
            m_cellLogin.IsEnabled = true;

            //initialize the condor helper
            CondorAPI.getInstance().Initialize(m_config.Address);
            CondorAPI.getInstance().Token = m_config.Token;

            //display the home page
            DisplayHome();

            //check for updates
            string addr;
            string version;
            string description;

            if (Updater.CheckForUpdates(out addr, out version, out description))
            {
                UpdatePrompt p = new UpdatePrompt()
                {
                    Text = description, Version = version
                };
                p.OnPromptSaved += new Prompt.PromptClosedEventListener(() =>
                {
                    Device.OpenUri(new Uri(addr));
                });
                p.Show(this);
            }

            //try restoring the login, only if a token is set
            if (m_config.Token == "")
            {
                return;
            }
            APICommand cmd = new RestoreLoginCommand()
            {
                Token = m_config.Token
            };

            cmd.OnResponseReceived += new APICommand.ResponseReceivedHandler((response) =>
            {
                if (response.GetValue("username") == null)
                { //token was invalid
                    DependencyService.Get <INotification>().ShortAlert("Session timed out or server unavailable, please log in again");
                    CondorAPI.getInstance().Token = "";
                    m_config.Token = "";
                    return;
                }
                //set my username and complete the login
                m_myusername = (string)response.GetValue("username");
                CompleteLogin();
            });
            CondorAPI.getInstance().Execute(cmd);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Checks for updates
        /// </summary>
        public static void CheckForUpdates(bool AutoUpdate)
        {
            var FoundWnmpUpdate = false; // Since were checking for two updates we have to check if it found the main one.

            if (!ReadUpdateXML())
            {
                return;
            }

            if (WNMP_VER.CompareTo(NEW_WNMP_VERSION) < 0)   // If it returns less than 0 than theres a new version
            {
                FoundWnmpUpdate = true;
                var CV = new UpdatePrompt();
                CV.StartPosition   = FormStartPosition.CenterScreen;
                CV.cversion.Text   = WNMP_VER.ToString();
                CV.newversion.Text = NEW_WNMP_VERSION.ToString();
                if (CV.ShowDialog() == DialogResult.Yes)
                {
                    DownloadWnmpUpdate(Wnmp_Upgrade_URL, UpdateExe);
                }
            }
            else
            {
                Log.wnmp_log_notice("Your version: " + WNMP_VER + " is up to date.", Log.LogSection.WNMP_MAIN);
            }
            if (FoundWnmpUpdate != true)
            {
                if (Main.GetCPVER.CompareTo(NEW_CP_VERSION) < 0)
                {
                    var CV = new UpdatePrompt();
                    CV.StartPosition   = FormStartPosition.CenterScreen;
                    CV.cversion.Text   = Main.GetCPVER.ToString();
                    CV.newversion.Text = NEW_CP_VERSION.ToString();

                    if (CV.ShowDialog() == DialogResult.Yes)
                    {
                        DownloadCPUpdate(CP_UPDATE_URL, WNMP_NEW);
                    }
                }
                else
                {
                    Log.wnmp_log_notice("Your control panel version: " + Main.GetCPVER + " is up to date.", Log.LogSection.WNMP_MAIN);
                }
            }
            if (AutoUpdate)
            {
                Options.settings.Lastcheckforupdate = DateTime.Now;
                Options.settings.UpdateSettings();
            }
        }
Ejemplo n.º 5
0
        private static void CheckForUpdates(UpdateCheckInfo info, bool auto)
        {
            try
            {
                if (!ApplicationDeployment.IsNetworkDeployed)
                {
                    if (!auto)
                    {
                        Popup.Show(
                            $"{Resources.AppName} was not installed via ClickOnce and cannot be updated automatically.",
                            image: MessageBoxImage.Error);
                    }
                    return;
                }

                if (info == null)
                {
                    if (!auto)
                    {
                        Popup.Show(
                            "An error occurred while trying to check for updates.", image: MessageBoxImage.Error);
                    }
                    return;
                }

                Settings.Default.LastUpdateCheck = DateTime.Now;
                if (info.UpdateAvailable && !(Settings.Default.UpdateBranch != UpdateBranch.Beta &&
                                              info.AvailableVersion.Minor == Settings.Default.BetaVersion) &&
                    !(AssemblyInfo.Version.Major != ForgetUpdateVersion.Major &&
                      ForgetUpdateVersion.Major == info.AvailableVersion.Major))
                {
                    if (auto && info.AvailableVersion == ForgetUpdateVersion)
                    {
                        return;
                    }
                    var ad = ApplicationDeployment.CurrentDeployment;
                    ad.UpdateCompleted += delegate
                    {
                        var args = new List <string>();
                        if (auto && Settings.Default.AutoUpdate)
                        {
                            args.Add("updatingsilent");
                        }
                        else
                        {
                            args.Add("updating");
                        }
                        AppHelper.RestartApplication(args);
                    };
                    if (auto && Settings.Default.AutoUpdate)
                    {
                        try
                        {
                            ad.UpdateAsync();
                        }
                        catch
                        {
                            // ignored
                        }
                        return;
                    }

                    if (auto)
                    {
                        if (Settings.Default.UpdateWaiting != info.AvailableVersion)
                        {
                            Settings.Default.UpdateWaiting = info.AvailableVersion;
                            TrayIconHelper.ShowBalloon(
                                $"Update available ({info.AvailableVersion})\nClick to view details",
                                BalloonIcon.Info);
                        }
                    }
                    else
                    {
                        App.UpdateScheduler?.Stop();

                        var updateDialog = new UpdatePrompt(info.AvailableVersion, info.IsUpdateRequired);
                        updateDialog.ShowDialog();
                        updateDialog.Activate();

                        switch (updateDialog.SelectedUpdateMode)
                        {
                        case UpdatePrompt.UpdateMode.RemindNever:
                            Settings.Default.ForgetUpdateVersion = info.AvailableVersion;
                            break;

                        case UpdatePrompt.UpdateMode.UpdateNow:
                            try
                            {
                                var progressDialog = new UpdateProgress(info.AvailableVersion);
                                ad.UpdateProgressChanged +=
                                    delegate(object sender, DeploymentProgressChangedEventArgs args)
                                {
                                    if (args.State == DeploymentProgressState.DownloadingApplicationFiles)
                                    {
                                        progressDialog.CurrentProgress = args.ProgressPercentage;
                                    }
                                };
                                progressDialog.Show();
                                progressDialog.Activate();
                                ad.UpdateAsync();
                            }
                            catch (DeploymentDownloadException dde)
                            {
                                Popup.Show(
                                    $"Failed to download the latest version.\nPlease check your network connection, or try again later.\n\nError: {dde}",
                                    image: MessageBoxImage.Error);
                            }
                            break;
                        }

                        App.UpdateScheduler?.Start();
                    }
                }
                else
                {
                    if (!auto)
                    {
                        Popup.Show($"You have the latest version ({AssemblyInfo.Version}).");
                    }
                }
            }
            catch (Exception)
            {
                if (!auto)
                {
                    throw;
                }
            }
        }
Ejemplo n.º 6
0
        private static void CheckForUpdates(UpdateCheckInfo info, bool auto)
        {
            try
            {
                if (!ApplicationDeployment.IsNetworkDeployed)
                {
                    if (!auto)
                        Popup.Show(
                            "This application was not installed via ClickOnce and cannot be updated automatically.");
                    return;
                }

                if (info == null)
                {
                    if (!auto)
                        Popup.Show(
                            "An error occurred while trying to check for updates.", image: MessageBoxImage.Error);
                    return;
                }

                Settings.Default.LastUpdateCheck = DateTime.Now;
                if (info.UpdateAvailable && !(Settings.Default.UpdateBranch != UpdateBranch.Beta &&
                                              info.AvailableVersion.Minor == Settings.Default.BetaVersion) &&
                    !(AssemblyInfo.Version.Major != ForgetUpdateVersion.Major &&
                      ForgetUpdateVersion.Major == info.AvailableVersion.Major))
                {
                    if (auto && info.AvailableVersion == ForgetUpdateVersion)
                        return;
                    var ad = ApplicationDeployment.CurrentDeployment;
                    ad.UpdateCompleted += delegate
                    {
                        var args = new List<string>();
                        if (auto && Settings.Default.AutoUpdate)
                            args.Add("updatingsilent");
                        else
                            args.Add("updating");
                        AppHelper.RestartApplication(args);
                    };
                    if (auto && Settings.Default.AutoUpdate)
                    {
                        try
                        {
                            ad.UpdateAsync();
                        }
                        catch
                        {
                            // ignored
                        }
                        return;
                    }

                    if (auto)
                    {
                        if (Settings.Default.UpdateWaiting != info.AvailableVersion)
                        {
                            Settings.Default.UpdateWaiting = info.AvailableVersion;
                            TrayIconHelper.ShowBalloon(
                                $"Update available ({info.AvailableVersion})\nClick to view details",
                                BalloonIcon.Info);
                        }
                    }
                    else
                    {
                        App.UpdateScheduler?.Stop();

                        var updateDialog = new UpdatePrompt(info.AvailableVersion, info.IsUpdateRequired);
                        updateDialog.ShowDialog();
                        updateDialog.Activate();

                        switch (updateDialog.SelectedUpdateMode)
                        {
                            case UpdatePrompt.UpdateMode.RemindNever:
                                Settings.Default.ForgetUpdateVersion = info.AvailableVersion;
                                break;
                            case UpdatePrompt.UpdateMode.UpdateNow:
                                try
                                {
                                    var progressDialog = new UpdateProgress(info.AvailableVersion);
                                    ad.UpdateProgressChanged +=
                                        delegate(object sender, DeploymentProgressChangedEventArgs args)
                                        {
                                            if (args.State == DeploymentProgressState.DownloadingApplicationFiles)
                                                progressDialog.CurrentProgress = args.ProgressPercentage;
                                        };
                                    progressDialog.Show();
                                    progressDialog.Activate();
                                    ad.UpdateAsync();
                                }
                                catch (DeploymentDownloadException dde)
                                {
                                    Popup.Show(
                                        "Cannot download the latest version of this application.\n\nPlease check your network connection, or try again later.\n\nError: " +
                                        dde, image: MessageBoxImage.Error);
                                }
                                break;
                        }

                        App.UpdateScheduler?.Start();
                    }
                }
                else
                {
                    if (!auto)
                        Popup.Show(
                            $"You have the latest version ({AssemblyInfo.Version}).");
                }
            }
            catch (Exception)
            {
                if (!auto)
                    throw;
            }
        }