/// <summary> /// Restores the original. /// </summary> private void RestoreOriginal() { if (!Directory.Exists(_versionBackupPath)) { return; } var filesToRestore = Directory.GetFiles(_versionBackupPath, "*.*", SearchOption.AllDirectories); foreach (var file in filesToRestore) { try { var originalPath = Path.Combine(FileManagementHelper.ROOT_PATH, file.Replace(_versionBackupPath.EnsureTrailingBackslash(), string.Empty)); var backupDirectory = Path.GetDirectoryName(originalPath); if (!Directory.Exists(backupDirectory)) { Directory.CreateDirectory(backupDirectory); } FileManagementHelper.RenameFile(originalPath); File.Move(file, originalPath); } catch (Exception ex) { ExceptionLogService.LogException(ex); } } FileManagementHelper.CleanUpDeletedFiles(); }
/// <summary> /// Installs the package. /// </summary> /// <param name="targetPackagePath">The target package path.</param> private void InstallPackage(string targetPackagePath) { OfflinePageHelper.CreateOfflinePage(); try { using (ZipArchive packageZip = ZipFile.OpenRead(targetPackagePath)) { ClearPreviousBackups(); ProcessTransformFiles(packageZip); ProcessContentFiles(packageZip); ProcessDeleteFiles(packageZip); FileManagementHelper.CleanUpDeletedFiles(); } } catch { RestoreOriginal(); throw; } finally { OfflinePageHelper.RemoveOfflinePage(); } }
/// <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(); } }