Esempio n. 1
0
 private List <RockRelease> GetOrderedReleaseList(RockUpdateService rockUpdateService, Version installedVersion)
 {
     return(rockUpdateService
            .GetReleasesList(installedVersion)
            .OrderByDescending(p => new Version(p.SemanticVersion))
            .ToList());
 }
Esempio n. 2
0
        /// <summary>
        /// Updates an existing Rock package to the given version and returns true if successful.
        /// </summary>
        /// <returns>true if the update was successful; false if errors were encountered</returns>
        protected bool UpdateRockPackage(string version)
        {
            var errors            = Enumerable.Empty <string>();
            var rockUpdateService = new RockUpdateService();

            try
            {
                var rockInstaller = new RockInstaller(rockUpdateService, new Version(version), _installedVersion);

                var installedRelease = rockInstaller.InstallVersion();

                nbSuccess.Text       = ConvertToHtmlLiWrappedUl(installedRelease.ReleaseNotes).ConvertCrLfToHtmlBr();
                lSuccessVersion.Text = GetRockVersion(installedRelease.SemanticVersion);
            }
            catch (OutOfMemoryException ex)
            {
                errors = errors.Concat(new[] { string.Format("There is a problem installing v{0}. It looks like your website ran out of memory. Check out <a href='http://www.rockrms.com/Rock/UpdateIssues#outofmemory'>this page for some assistance</a>", version) });
                LogException(ex);
            }
            catch (System.Xml.XmlException ex)
            {
                errors = errors.Concat(new[] { string.Format("There is a problem installing v{0}. It looks one of the standard XML files ({1}) may have been customized which prevented us from updating it. Check out <a href='http://www.rockrms.com/Rock/UpdateIssues#customizedxml'>this page for some assistance</a>", version, ex.Message) });
                LogException(ex);
            }
            catch (IOException ex)
            {
                errors = errors.Concat(new[] { string.Format("There is a problem installing v{0}. We were not able to replace an important file ({1}) after the update. Check out <a href='http://www.rockrms.com/Rock/UpdateIssues#unabletoreplacefile'>this page for some assistance</a>", version, ex.Message) });
                LogException(ex);
            }
            catch (VersionValidationException ex)
            {
                errors = errors.Concat(new[] { ex.Message });
                LogException(ex);
            }
            catch (Exception ex)
            {
                errors = errors.Concat(new[] { string.Format("There is a problem installing v{0}: {1}", version, ex.Message) });
                LogException(ex);
            }

            if (errors != null && errors.Count() > 0)
            {
                pnlError.Visible = true;
                nbErrors.Text    = errors.Aggregate(new StringBuilder("<ul class='list-padded'>"), (sb, s) => sb.AppendFormat("<li>{0}</li>", s)).Append("</ul>").ToString();
                return(false);
            }
            else
            {
                pnlUpdateSuccess.Visible       = true;
                nbMoreUpdatesAvailable.Visible = GetOrderedReleaseList(rockUpdateService, new Version(version)).Count > 0;
                rptPackageVersions.Visible     = false;
                return(true);
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Invoked on page load.
        /// </summary>
        /// <param name="e">An <see cref="T:System.EventArgs" /> object that contains the event data.</param>
        protected override void OnLoad(EventArgs e)
        {
            var rockUpdateService = new RockUpdateService();

            // Set timeout for up to 15 minutes (just like installer)
            Server.ScriptTimeout = 900;
            ScriptManager.GetCurrent(Page).AsyncPostBackTimeout = 900;

            _isEarlyAccessOrganization = rockUpdateService.IsEarlyAccessInstance();
            _installedVersion          = new Version(VersionInfo.GetRockSemanticVersionNumber());

            if (rockUpdateService.GetRockReleaseProgram() != RockReleaseProgram.Production)
            {
                nbRepoWarning.Visible = true;
            }

            DisplayRockVersion();
            if (!IsPostBack)
            {
                btnIssues.NavigateUrl = rockUpdateService.GetRockEarlyAccessRequestUrl();

                if (_isEarlyAccessOrganization)
                {
                    hlblEarlyAccess.LabelType = Rock.Web.UI.Controls.LabelType.Success;
                    hlblEarlyAccess.Text      = "Early Access: Enabled";

                    pnlEarlyAccessNotEnabled.Visible = false;
                    pnlEarlyAccessEnabled.Visible    = true;
                }

                var checkFrameworkVersionResultResult = VersionValidationHelper.CheckFrameworkVersion();

                _isOkToProceed = true;

                if (checkFrameworkVersionResultResult == DotNetVersionCheckResult.Fail)
                {
                    // Starting with v13, .NET 4.7.2 is required. So, show a warning if they haven't updated yet.
                    nbVersionIssue.Visible  = true;
                    nbVersionIssue.Text    += "<p>You will need to upgrade your hosting server in order to proceed with the v13 update.</p>";
                    nbBackupMessage.Visible = false;
                }
                else if (checkFrameworkVersionResultResult == DotNetVersionCheckResult.Unknown)
                {
                    // Starting with v13, .NET 4.7.2 is required. So, show a warning if can't determine if they have updated yet.
                    nbVersionIssue.Visible  = true;
                    nbVersionIssue.Text    += "<p>You may need to upgrade your hosting server in order to proceed with the v13 update. We were <b>unable to determine which Framework version</b> your server is using.</p>";
                    nbVersionIssue.Details += "<div class='alert alert-warning'>We were unable to check your server to verify that the .Net 4.7.2 Framework is installed! <b>You MUST verify this manually before you proceed with the update</b> otherwise your Rock application will be broken until you update the server.</div>";
                    nbBackupMessage.Visible = false;
                }

                _hasSqlServer14OrHigher = VersionValidationHelper.CheckSqlServerVersionGreaterThenSqlServer2012();

                if (!_hasSqlServer14OrHigher)
                {
                    nbSqlServerVersionIssue.Visible = true;
                }

                _releases = GetOrderedReleaseList(rockUpdateService, _installedVersion);

                if (_releases.Count > 0)
                {
                    if (checkFrameworkVersionResultResult != DotNetVersionCheckResult.Pass && new Version(_releases.Last().SemanticVersion) >= new Version("1.13.0"))
                    {
                        // if VersionIssue is visible, and they are updating to v13 or later, show the version Warning as an Danger instead.
                        nbVersionIssue.NotificationBoxType = Rock.Web.UI.Controls.NotificationBoxType.Danger;
                    }

                    pnlUpdatesAvailable.Visible = true;
                    pnlUpdates.Visible          = true;
                    pnlNoUpdates.Visible        = false;
                    cbIncludeStats.Visible      = true;
                    BindGrid();
                }

                FileManagementHelper.CleanUpDeletedFiles();
            }
        }