/// <summary> /// Destroys latest version from history. Called when the "Destroy version" button is pressed. /// Expects the CreateVersionedObject method to be run first. /// </summary> private bool DestroyVersion() { // Get the css stylesheet CssStylesheetInfo stylesheet = CssStylesheetInfoProvider.GetCssStylesheetInfo("MyNewVersionedStylesheet"); if (stylesheet != null) { // Get the latest version ObjectVersionHistoryInfo version = ObjectVersionManager.GetLatestVersion(stylesheet.ObjectType, stylesheet.StylesheetID); if (version != null) { // Destroy the latest version ObjectVersionManager.DestroyObjectVersion(version.VersionID); return(true); } } return(false); }
protected void gridHistory_OnAction(string actionName, object actionArgument) { int versionHistoryId = ValidationHelper.GetInteger(actionArgument, 0); actionName = actionName.ToLowerCSafe(); switch (actionName.ToLowerCSafe()) { case "rollback": case "fullrollback": if (versionHistoryId > 0) { // Check permissions if (CheckPermissions && !AllowModify) { ShowError(GetString("History.ErrorNotAllowedToModify")); } else { try { var newVersionId = ObjectVersionManager.RollbackVersion(versionHistoryId, (actionName == "fullrollback")); ObjectVersionHistoryInfo newVersion = ObjectVersionHistoryInfo.Provider.Get(newVersionId); // Set object to null because after rollback it doesn't contain current data Object = null; gridHistory.ReloadData(); if (OnAfterRollback != null) { OnAfterRollback(this, null); } ShowConfirmation(GetString("objectversioning.rollbackOK")); ScriptHelper.RegisterStartupScript(this, typeof(string), "RefreshContent", ScriptHelper.GetScript("RefreshRelatedContent_" + ClientID + "();")); ScriptHelper.RefreshTabHeader(Page, newVersion.VersionObjectDisplayName); } catch (CodeNameNotUniqueException ex) { ShowError(String.Format(GetString("objectversioning.restorenotuniquecodename"), (ex.Object != null) ? "('" + ex.Object.ObjectCodeName + "')" : null)); } catch (Exception ex) { ShowError(GetString("objectversioning.recyclebin.restorationfailed") + " " + GetString("general.seeeventlog")); // Log to event log Service.Resolve <IEventLogService>().LogException("Object version list", "OBJECTRESTORE", ex); } } } break; case "destroy": if (versionHistoryId > 0) { // Check permissions if (CheckPermissions && !AllowDestroy) { ShowError(GetString("History.ErrorNotAllowedToDestroy")); } else { ObjectVersionManager.DestroyObjectVersion(versionHistoryId); ShowConfirmation(GetString("objectversioning.destroyOK")); } } break; } }
protected void gridHistory_OnAction(string actionName, object actionArgument) { int versionHistoryId = ValidationHelper.GetInteger(actionArgument, 0); actionName = actionName.ToLower(); switch (actionName.ToLower()) { case "rollback": case "fullrollback": if (versionHistoryId > 0) { try { ObjectVersionManager.RollbackVersion(versionHistoryId, (actionName == "fullrollback") ? true : false); lblInfo.Text = GetString("objectversioning.rollbackOK"); // Set object to null bacause after rollback it doesn't contain current data Object = null; gridHistory.ReloadData(); if (OnAfterRollback != null) { OnAfterRollback(this, null); } ScriptHelper.RegisterStartupScript(this, typeof(string), "RefreshContent", ScriptHelper.GetScript("RefreshRelatedContent_" + ClientID + "();")); } catch (CodeNameNotUniqueException ex) { lblError.Visible = true; lblError.Text = String.Format(GetString("objectversioning.restorenotuniquecodename"), (ex.Object != null) ? "('" + ex.Object.ObjectCodeName + "')" : null); } catch (Exception ex) { lblError.Visible = true; lblError.Text = GetString("objectversioning.recyclebin.restorationfailed") + " " + GetString("general.seeeventlog"); // Log to event log EventLogProvider.LogException("Object version list", "OBJECTRESTORE", ex); } } break; case "destroy": if (versionHistoryId > 0) { // Check permissions if (CheckPermissions && !AllowDestroy) { lblError.Text = GetString("History.ErrorNotAllowedToDestroy"); } else { ObjectVersionManager.DestroyObjectVersion(versionHistoryId); lblInfo.Text = GetString("objectversioning.destroyOK"); } } break; } plcLabels.Visible = true; }