protected override void OnLoad(EventArgs e) { base.OnLoad(e); // Check 'Manage objects tasks' permission if (!CurrentUser.IsAuthorizedPerResource("cms.staging", "ManageObjectsTasks")) { RedirectToAccessDenied("cms.staging", "ManageObjectsTasks"); } CurrentMaster.DisplaySiteSelectorPanel = true; // Check enabled servers var isCallback = RequestHelper.IsCallback(); if (!isCallback && !ServerInfoProvider.IsEnabledServer(SiteContext.CurrentSiteID)) { ShowInformation(GetString("ObjectStaging.NoEnabledServer")); CurrentMaster.PanelHeader.Visible = false; plcContent.Visible = false; pnlFooter.Visible = false; return; } // Register script for pendingCallbacks repair ScriptHelper.FixPendingCallbacks(Page); // Setup server dropdown selectorElem.DropDownList.AutoPostBack = true; selectorElem.UniSelector.OnSelectionChanged += UniSelector_OnSelectionChanged; // Set server ID SelectedServerID = ValidationHelper.GetInteger(selectorElem.Value, QueryHelper.GetInteger("serverId", 0)); // All servers if (SelectedServerID == UniSelector.US_ALL_RECORDS) { SelectedServerID = 0; selectorElem.Value = UniSelector.US_ALL_RECORDS; } else { selectorElem.Value = SelectedServerID.ToString(); } ltlScript.Text += ScriptHelper.GetScript("var currentServerId = " + SelectedServerID + ";"); HeaderActions.ActionPerformed += HeaderActions_ActionPerformed; if (!isCallback) { // Check 'Manage object tasks' permission if (!CurrentUser.IsAuthorizedPerResource("cms.staging", "ManageObjectsTasks")) { RedirectToAccessDenied("cms.staging", "ManageObjectsTasks"); } synchronizedSiteId = QueryHelper.GetInteger("siteid", 0); CurrentSiteID = SiteContext.CurrentSiteID; ucDisabledModule.TestSettingKeys = "CMSStagingLogObjectChanges"; ucDisabledModule.ParentPanel = pnlNotLogged; if (synchronizedSiteId == -1) { ucDisabledModule.InfoText = GetString("objectstaging.globalandsitenotlogged"); ucDisabledModule.KeyScope = DisabledModuleScope.CurrentSiteAndGlobal; ucDisabledModule.GlobalButtonText = GetString("objectstaging.enableglobalandsiteobjects"); } else if (synchronizedSiteId == 0) { ucDisabledModule.InfoText = GetString("objectstaging.globalnotlogged"); ucDisabledModule.KeyScope = DisabledModuleScope.Global; ucDisabledModule.GlobalButtonText = GetString("objectstaging.enableglobalobjects"); } else { ucDisabledModule.InfoText = GetString("ObjectStaging.SiteNotLogged"); ucDisabledModule.KeyScope = DisabledModuleScope.Site; ucDisabledModule.SiteButtonText = GetString("objectstaging.enablesiteobjects"); } // Check logging if (!ucDisabledModule.Check()) { CurrentMaster.PanelHeader.Visible = false; plcContent.Visible = false; return; } // Get object type objectType = QueryHelper.GetString("objecttype", string.Empty); // Create "synchronize current" header action for tree root, nodes or objects with database representation if (String.IsNullOrEmpty(objectType) || objectType.StartsWith("##", StringComparison.Ordinal) || (ModuleManager.GetReadOnlyObject(objectType) != null)) { HeaderActions.AddAction(new HeaderAction { Text = GetString("ObjectTasks.SyncCurrent"), EventName = SYNCHRONIZE_CURRENT }); } // Add CSS class to panels wrapper in order it could be stacked CurrentMaster.PanelHeader.AddCssClass("header-container-multiple-panels"); // Setup title ctlAsyncLog.TitleText = GetString("Synchronization.Title"); // Get the selected types ObjectTypeTreeNode selectedNode = StagingTaskInfoProvider.ObjectTree.FindNode(objectType, (synchronizedSiteId > 0)); objectType = (selectedNode != null) ? selectedNode.GetObjectTypes(true) : string.Empty; if (!ControlsHelper.CausedPostBack(HeaderActions, btnSyncSelected, btnSyncAll)) { // Register the dialog script ScriptHelper.RegisterDialogScript(this); plcContent.Visible = true; // Initialize buttons btnDeleteAll.OnClientClick = "return confirm(" + ScriptHelper.GetString(GetString("Tasks.ConfirmDeleteAll")) + ");"; btnDeleteSelected.OnClientClick = "return confirm(" + ScriptHelper.GetString(GetString("general.confirmdelete")) + ");"; btnSyncSelected.OnClientClick = "return !" + gridTasks.GetCheckSelectionScript(); // Initialize grid gridTasks.ZeroRowsText = GetString("Tasks.NoTasks"); gridTasks.OnDataReload += gridTasks_OnDataReload; gridTasks.ShowActionsMenu = true; gridTasks.Columns = "TaskID, TaskSiteID, TaskDocumentID, TaskNodeAliasPath, TaskTitle, TaskTime, TaskType, TaskObjectType, TaskObjectID, TaskRunning, (SELECT COUNT(*) FROM Staging_Synchronization WHERE SynchronizationTaskID = TaskID AND SynchronizationErrorMessage IS NOT NULL AND (SynchronizationServerID = @ServerID OR (@ServerID = 0 AND (@TaskSiteID = 0 OR SynchronizationServerID IN (SELECT ServerID FROM Staging_Server WHERE ServerSiteID = @TaskSiteID AND ServerEnabled=1))))) AS FailedCount"; StagingTaskInfo ti = new StagingTaskInfo(); gridTasks.AllColumns = SqlHelper.MergeColumns(ti.ColumnNames); pnlLog.Visible = false; TaskTypeCategories = TaskHelper.TASK_TYPE_CATEGORY_GENERAL + ";" + TaskHelper.TASK_TYPE_CATEGORY_OBJECTS + ";" + TaskHelper.TASK_TYPE_CATEGORY_DATA; } } }
protected void Page_Load(object sender, EventArgs e) { // Register script for pendingCallbacks repair ScriptHelper.FixPendingCallbacks(Page); // Initialize current user for the async actions currentUser = MembershipContext.AuthenticatedUser; HeaderActions.ActionPerformed += HeaderActions_ActionPerformed; if (!RequestHelper.IsCallback()) { // Check 'Manage object tasks' permission if (!currentUser.IsAuthorizedPerResource("cms.staging", "ManageObjectsTasks")) { RedirectToAccessDenied("cms.staging", "ManageObjectsTasks"); } siteId = QueryHelper.GetInteger("siteid", 0); currentSiteId = SiteContext.CurrentSiteID; currentSiteName = SiteContext.CurrentSiteName; serverId = QueryHelper.GetInteger("serverid", 0); ucDisabledModule.SettingsKeys = "CMSStagingLogObjectChanges"; ucDisabledModule.InfoTexts.Add(GetString("StagingChanges.NotLogged") + "<br/>"); ucDisabledModule.ParentPanel = pnlNotLogged; if (siteId == -1) { ucDisabledModule.InfoTexts.Add(GetString("objectstaging.globalandsitenotlogged")); ucDisabledModule.SiteObjects = "CMSStagingLogObjectChanges"; ucDisabledModule.GlobalObjects = "CMSStagingLogObjectChanges"; } else if (siteId == 0) { ucDisabledModule.InfoTexts.Add(GetString("objectstaging.globalnotlogged")); ucDisabledModule.GlobalObjects = "CMSStagingLogObjectChanges"; } else { ucDisabledModule.InfoTexts.Add(GetString("ObjectStaging.SiteNotLogged")); ucDisabledModule.SiteObjects = "CMSStagingLogObjectChanges"; } // Check logging if (!ucDisabledModule.Check()) { plcContent.Visible = false; return; } // Get object type objectType = QueryHelper.GetString("objecttype", string.Empty); // Create "synchronize current" header action only for objects with database representation if (ModuleManager.GetReadOnlyObject(objectType) != null) { HeaderActions.AddAction(new HeaderAction { Text = GetString("ObjectTasks.SyncCurrent"), EventName = SYNCHRONIZE_CURRENT }); } // Setup title titleElem.TitleText = GetString("Synchronization.Title"); // Get the selected types ObjectTypeTreeNode selectedNode = StagingTaskInfoProvider.ObjectTree.FindNode(objectType, (siteId > 0)); objectType = (selectedNode != null) ? selectedNode.GetObjectTypes(true) : string.Empty; if (!ControlsHelper.CausedPostBack(HeaderActions, btnSyncSelected, btnSyncAll)) { // Register the dialog script ScriptHelper.RegisterDialogScript(this); plcContent.Visible = true; // Initialize buttons btnCancel.Attributes.Add("onclick", ctlAsync.GetCancelScript(true) + "return false;"); btnCancel.Text = GetString("General.Cancel"); btnDeleteAll.OnClientClick = "return confirm(" + ScriptHelper.GetString(GetString("Tasks.ConfirmDeleteAll")) + ");"; btnDeleteSelected.OnClientClick = "return confirm(" + ScriptHelper.GetString(GetString("general.confirmdelete")) + ");"; btnSyncSelected.OnClientClick = "return !" + gridTasks.GetCheckSelectionScript(); // Initialize grid gridTasks.ZeroRowsText = GetString("Tasks.NoTasks"); gridTasks.OnAction += gridTasks_OnAction; gridTasks.OnDataReload += gridTasks_OnDataReload; gridTasks.OnExternalDataBound += gridTasks_OnExternalDataBound; gridTasks.ShowActionsMenu = true; gridTasks.Columns = "TaskID, TaskSiteID, TaskDocumentID, TaskNodeAliasPath, TaskTitle, TaskTime, TaskType, TaskObjectType, TaskObjectID, TaskRunning, (SELECT COUNT(*) FROM Staging_Synchronization WHERE SynchronizationTaskID = TaskID AND SynchronizationErrorMessage IS NOT NULL AND (SynchronizationServerID = @ServerID OR (@ServerID = 0 AND (@TaskSiteID = 0 OR SynchronizationServerID IN (SELECT ServerID FROM Staging_Server WHERE ServerSiteID = @TaskSiteID AND ServerEnabled=1))))) AS FailedCount"; StagingTaskInfo ti = new StagingTaskInfo(); gridTasks.AllColumns = SqlHelper.MergeColumns(ti.ColumnNames); pnlLog.Visible = false; } } ctlAsync.OnFinished += ctlAsync_OnFinished; ctlAsync.OnError += ctlAsync_OnError; ctlAsync.OnRequestLog += ctlAsync_OnRequestLog; ctlAsync.OnCancel += ctlAsync_OnCancel; }
protected void Page_Load(object sender, EventArgs e) { // Register script for pendingCallbacks repair ScriptHelper.FixPendingCallbacks(Page); // Initialize current user for the async actions currentUser = CMSContext.CurrentUser; if (!RequestHelper.IsCallback()) { // Check 'Manage object tasks' permission if (!currentUser.IsAuthorizedPerResource("cms.staging", "ManageObjectsTasks")) { RedirectToAccessDenied("cms.staging", "ManageObjectsTasks"); } siteId = QueryHelper.GetInteger("siteid", 0); currentSiteId = CMSContext.CurrentSiteID; currentSiteName = CMSContext.CurrentSiteName; // Check logging if (siteId > 0) { if (!ValidationHelper.GetBoolean(SettingsKeyProvider.GetBoolValue(currentSiteName + ".CMSStagingLogObjectChanges"), false)) { plcTasks.Visible = false; pnlNotLogged.Visible = true; lblNotLogged.Text = GetString("ObjectStaging.SiteNotLogged"); return; } } else if (siteId == 0) { if (!ValidationHelper.GetBoolean(SettingsKeyProvider.GetBoolValue("CMSStagingLogObjectChanges"), false)) { plcTasks.Visible = false; pnlNotLogged.Visible = true; lblNotLogged.Text = GetString("ObjectStaging.GlobalNotLogged"); return; } } serverId = QueryHelper.GetInteger("serverid", 0); // Get object type objectType = QueryHelper.GetString("objecttype", string.Empty); if ((objectType == string.Empty) || (objectType == PredefinedObjectType.MEDIAFOLDER)) { pnlMenu.Visible = false; } // Setup title titleElem.TitleText = GetString("Synchronization.Title"); titleElem.TitleImage = GetImageUrl("/CMSModules/CMS_Staging/synchronization.png"); // Get the selected types ObjectTypeTreeNode selectedNode = TaskInfoProvider.ObjectTree.FindNode(objectType, (siteId > 0)); objectType = (selectedNode != null) ? selectedNode.GetObjectTypes(true) : string.Empty; if (!RequestHelper.CausedPostback(btnCurrent, btnSyncSelected, btnSyncAll)) { // Register the dialog script ScriptHelper.RegisterDialogScript(this); // Initialize images viewImage = GetImageUrl("Design/Controls/UniGrid/Actions/View.png"); deleteImage = GetImageUrl("Design/Controls/UniGrid/Actions/Delete.png"); syncImage = GetImageUrl("Design/Controls/UniGrid/Actions/Synchronize.png"); imgCurrent.ImageUrl = GetImageUrl("CMSModules/CMS_Staging/syncsubtree.png"); // Initialize tooltips syncTooltip = GetString("general.synchronize"); deleteTooltip = GetString("general.delete"); viewTooltip = GetString("general.view"); syncCurrent = GetString("ObjectTasks.SyncCurrent"); plcContent.Visible = true; // Initialize buttons btnCancel.Attributes.Add("onclick", ctlAsync.GetCancelScript(true) + "return false;"); btnCancel.Text = GetString("General.Cancel"); btnDeleteAll.OnClientClick = "return confirm(" + ScriptHelper.GetString(GetString("Tasks.ConfirmDeleteAll")) + ");"; btnDeleteSelected.OnClientClick = "return confirm(" + ScriptHelper.GetString(GetString("general.confirmdelete")) + ");"; btnSyncSelected.OnClientClick = "return !" + gridTasks.GetCheckSelectionScript(); // Initialize grid gridTasks.ZeroRowsText = GetString("Tasks.NoTasks"); gridTasks.OnAction += gridTasks_OnAction; gridTasks.OnDataReload += gridTasks_OnDataReload; gridTasks.OnExternalDataBound += gridTasks_OnExternalDataBound; gridTasks.ShowActionsMenu = true; gridTasks.Columns = "TaskID, TaskSiteID, TaskDocumentID, TaskNodeAliasPath, TaskTitle, TaskTime, TaskType, TaskObjectType, TaskObjectID, TaskRunning, (SELECT COUNT(*) FROM Staging_Synchronization WHERE SynchronizationTaskID = TaskID AND SynchronizationErrorMessage IS NOT NULL AND (SynchronizationServerID = @ServerID OR (@ServerID = 0 AND (@TaskSiteID = 0 OR SynchronizationServerID IN (SELECT ServerID FROM Staging_Server WHERE ServerSiteID = @TaskSiteID AND ServerEnabled=1))))) AS FailedCount"; TaskInfo ti = new TaskInfo(); gridTasks.AllColumns = SqlHelperClass.MergeColumns(ti.ColumnNames.ToArray()); pnlLog.Visible = false; } } ctlAsync.OnFinished += ctlAsync_OnFinished; ctlAsync.OnError += ctlAsync_OnError; ctlAsync.OnRequestLog += ctlAsync_OnRequestLog; ctlAsync.OnCancel += ctlAsync_OnCancel; }