Example #1
0
        /// <summary>
        /// Installs the version.
        /// </summary>
        /// <returns></returns>
        /// <exception cref="Rock.Update.Exceptions.PackageNotFoundException">Target Release ${targetRelease} was not found.</exception>
        public RockRelease InstallVersion()
        {
            VersionValidationHelper.ValidateVersionInstall(_targetVersion);

            var releases      = _rockUpdateService.GetReleasesList(_installedVersion);
            var targetRelease = releases?.Where(r => r.SemanticVersion == _targetVersion.ToString()).FirstOrDefault();

            if (targetRelease == null)
            {
                throw new PackageNotFoundException($"Target Release ${targetRelease} was not found.");
            }

            var targetPackagePath = DownloadPackage(targetRelease);

            InstallPackage(targetPackagePath);

            // Record the current version to the database
            Web.SystemSettings.SetValue(Rock.SystemKey.SystemSetting.ROCK_INSTANCE_ID, _targetVersion.ToString());

            // register any new REST controllers
            try
            {
                RestControllerService.RegisterControllers();
            }
            catch (Exception ex)
            {
                ExceptionLogService.LogException(ex);
            }

            return(targetRelease);
        }
Example #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)
        {
            IEnumerable <string> errors = Enumerable.Empty <string>();

            try
            {
                var update    = NuGetService.SourceRepository.FindPackage(_rockPackageId, (version != null) ? SemanticVersion.Parse(version) : null, false, false);
                var installed = NuGetService.GetInstalledPackage(_rockPackageId);

                if (installed == null)
                {
                    errors = NuGetService.InstallPackage(update);
                }
                else
                {
                    errors = NuGetService.UpdatePackage(update);
                }

                CheckForManualFileMoves(version);

                nbSuccess.Text       = ConvertToHtmlLiWrappedUl(update.ReleaseNotes).ConvertCrLfToHtmlBr();
                lSuccessVersion.Text = update.Title;

                // Record the current version to the database
                Rock.Web.SystemSettings.SetValue(SystemSettingKeys.ROCK_INSTANCE_ID, version);

                // register any new REST controllers
                try
                {
                    RestControllerService.RegisterControllers();
                }
                catch (Exception ex)
                {
                    errors = errors.Concat(new[] { string.Format("The update was installed but there was a problem registering any new REST controllers. ({0})", ex.Message) });
                    LogException(ex);
                }
            }
            catch (InvalidOperationException 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;
                rptPackageVersions.Visible = false;
                return(true);
            }
        }
 /// <summary>
 /// Executes this instance.
 /// </summary>
 /// <param name="message"></param>
 public override void Execute(Message message)
 {
     RestControllerService.RegisterControllers();
 }
Example #4
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)
        {
            IEnumerable <string> errors = Enumerable.Empty <string>();

            try
            {
                var update    = NuGetService.SourceRepository.FindPackage(_rockPackageId, (version != null) ? SemanticVersion.Parse(version) : null, false, false);
                var installed = NuGetService.GetInstalledPackage(_rockPackageId);

                if (installed == null)
                {
                    errors = NuGetService.InstallPackage(update);
                }
                else
                {
                    errors = NuGetService.UpdatePackageAndBackup(update, installed);
                }

                CheckForManualFileMoves(version);

                nbSuccess.Text       = ConvertToHtmlLiWrappedUl(update.ReleaseNotes).ConvertCrLfToHtmlBr();
                lSuccessVersion.Text = update.Title;

                // Record the current version to the database
                Rock.Web.SystemSettings.SetValue(SystemSettingKeys.ROCK_INSTANCE_ID, version);

                // register any new REST controllers
                try
                {
                    RestControllerService.RegisterControllers();
                }
                catch (Exception ex)
                {
                    LogException(ex);
                }
            }
            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 (System.IO.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 (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;
                rptPackageVersions.Visible = false;
                return(true);
            }
        }
        public bool EnsureRestControllers()
        {
            RestControllerService.RegisterControllers();

            return(true);
        }
 /// <summary>
 /// Executes this instance.
 /// </summary>
 public void Execute()
 {
     RestControllerService.RegisterControllers();
 }
 private void RefreshControllerList()
 {
     RestControllerService.RegisterControllers();
 }
        /// <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(IPackage update)
        {
            IEnumerable <string> errors = Enumerable.Empty <string>();
            string version = update.Version.ToString();

            try
            {
                var             field          = NuGetService.GetType().GetField("_projectManager", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance);
                IProjectManager projectManager = ( IProjectManager )field.GetValue(NuGetService);
                projectManager.UpdatePackageReference(update, false, false);

                CheckForManualFileMoves(version);

                lSuccessVersion.Text = GetRockVersion(update.Version);

                // Record the current version to the database
                Rock.Web.SystemSettings.SetValue(SystemSettingKeys.ROCK_INSTANCE_ID, version);

                // register any new REST controllers
                try
                {
                    RestControllerService.RegisterControllers();
                }
                catch (Exception ex)
                {
                    LogException(ex);
                }
            }
            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 (System.IO.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 (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
            {
                pnlUpload.Visible        = false;
                pnlUpdateSuccess.Visible = true;
                return(true);
            }
        }