protected void Page_Load(object sender, EventArgs e) { StagingTaskInfo ti = StagingTaskInfoProvider.GetTaskInfo(TaskId); // Set edited object EditedObject = ti; if (ti == null) { return; } ((CMSDeskPage)Page).PageTitle.TitleText += " (" + HTMLHelper.HTMLEncode(ti.TaskTitle) + ")"; // Get users and task groups var usersWhoModifiedObject = GetUsersFromStagingTask(ti); var taskInGroups = GetTaskGroupsFromStagingTask(ti); string objectType = ti.TaskObjectType; if (ti.TaskNodeID > 0) { objectType = TreeNode.OBJECT_TYPE; } viewDataSet.ObjectType = objectType; viewDataSet.DataSet = GetDataSet(ti.TaskData, ti.TaskType, ti.TaskObjectType); viewDataSet.AdditionalContent = GetTaskHeader(ti, usersWhoModifiedObject, taskInGroups); }
protected void Page_Load(object sender, EventArgs e) { StagingTaskInfo ti = StagingTaskInfoProvider.GetTaskInfo(TaskId); // Set edited object EditedObject = ti; if (ti != null) { ((CMSDeskPage)Page).PageTitle.TitleText += " (" + HTMLHelper.HTMLEncode(ti.TaskTitle) + ")"; // Prepare task description StringBuilder sbTaskInfo = new StringBuilder(); sbTaskInfo.Append("<table>"); sbTaskInfo.Append("<tr><td class=\"Title Grid\" style=\"width:135px\">" + GetString("staging.tasktype") + "</td><td>" + ti.TaskType.ToString() + "</td></tr>"); sbTaskInfo.Append("<tr><td class=\"Title Grid\">" + GetString("staging.tasktime") + "</td><td>" + ti.TaskTime.ToString() + "</td></tr>"); sbTaskInfo.Append("<tr><td class=\"Title Grid\">" + GetString("staging.taskprocessedby") + "</td><td>" + DataHelper.GetNotEmpty(ti.TaskServers.Trim(';').Replace(";", ", "), "-") + "</td></tr>"); sbTaskInfo.Append("</table>"); string objectType = ti.TaskObjectType; if (ti.TaskNodeID > 0) { objectType = TreeNode.OBJECT_TYPE; } viewDataSet.ObjectType = objectType; viewDataSet.DataSet = GetDataSet(ti.TaskData, ti.TaskType, ti.TaskObjectType); viewDataSet.AdditionalContent = sbTaskInfo.ToString(); } }
/// <summary> /// Deletes selected tasks. /// </summary> protected void DeleteSelected(object parameter) { List <String> list = parameter as List <String>; if (list == null) { return; } eventCode = "DELETESELECTEDOBJECTS"; CanceledString = GetString("Tasks.DeletionCanceled"); try { AddLog(GetString("Synchronization.DeletingTasks")); foreach (string taskIdString in list) { int taskId = ValidationHelper.GetInteger(taskIdString, 0); if (taskId > 0) { StagingTaskInfo task = StagingTaskInfoProvider.GetTaskInfo(taskId); if (task != null) { AddLog(string.Format(ResHelper.GetAPIString("deletion.running", "Deleting '{0}' task"), HTMLHelper.HTMLEncode(task.TaskTitle))); // Delete synchronization SynchronizationInfoProvider.DeleteSynchronizationInfo(task.TaskID, serverId, currentSiteId); } } } CurrentInfo = GetString("Tasks.DeleteOK"); AddLog(CurrentInfo); } catch (ThreadAbortException ex) { string state = ValidationHelper.GetString(ex.ExceptionState, string.Empty); if (state == CMSThread.ABORT_REASON_STOP) { // Canceled by user CurrentInfo = CanceledString; AddLog(CurrentInfo); } else { CurrentError = GetString("Tasks.DeletionFailed"); AddErrorLog(CurrentError); } } catch (Exception ex) { CurrentError = GetString("Tasks.DeletionFailed") + ": " + ex.Message; AddErrorLog(CurrentError); } finally { // Finalizes log context FinalizeContext(); } }
protected override void OnPreRender(EventArgs e) { // Get task data if (taskId > 0) { StagingTaskInfo ti = StagingTaskInfoProvider.GetTaskInfo(taskId); if (ti != null) { lblInfo.Text += String.Format(GetString("Task.LogTaskInfo"), HTMLHelper.HTMLEncode(ti.TaskTitle)); } } // Get server data if (serverId > 0) { ServerInfo si = ServerInfoProvider.GetServerInfo(serverId); if (si != null) { if (lblInfo.Text != "") { lblInfo.Text += "<br /><br />"; } lblInfo.Text += String.Format(GetString("Task.LogServerInfo"), si.ServerDisplayName); } } lblInfo.Visible = (lblInfo.Text != ""); base.OnPreRender(e); }
/// <summary> /// Synchronizes all tasks. Called when the "Get and synchronize tasks" button is pressed. /// Expects the CreateStagingServer method to be run first and that there are tasks logged /// for the server. /// </summary> private bool GetAndSynchronizeTasks() { // Get server ServerInfo server = ServerInfoProvider.GetServerInfo("MyNewServer", SiteContext.CurrentSiteID); if (server != null) { // Get tasks for the server DataSet tasks = StagingTaskInfoProvider.SelectTaskList(SiteContext.CurrentSiteID, server.ServerID, null, null); if (!DataHelper.DataSourceIsEmpty(tasks)) { foreach (DataRow taskDr in tasks.Tables[0].Rows) { // Create task info object from data row StagingTaskInfo task = new StagingTaskInfo(taskDr); // Synchronize the task if (!string.IsNullOrEmpty(StagingHelper.RunSynchronization(task.TaskID, server.ServerID))) { apiGetAndSynchronizeTasks.ErrorMessage = "Synchronization failed."; return(false); } } return(true); } apiGetAndSynchronizeTasks.ErrorMessage = "No tasks found."; } return(false); }
/// <summary> /// Deletes staging tasks. Called when the "Delete tasks" button is pressed. /// Expects the CreateStagingServer method to be run first. /// </summary> private bool DeleteTasks() { // Get server ServerInfo server = ServerInfoProvider.GetServerInfo("MyNewServer", SiteContext.CurrentSiteID); if (server != null) { // Get tasks for the server DataSet tasks = StagingTaskInfoProvider.SelectTaskList(SiteContext.CurrentSiteID, server.ServerID, null, null); if (!DataHelper.DataSourceIsEmpty(tasks)) { foreach (DataRow taskDr in tasks.Tables[0].Rows) { // Create task info object from data row StagingTaskInfo deleteTask = new StagingTaskInfo(taskDr); // Delete the task StagingTaskInfoProvider.DeleteTaskInfo(deleteTask); } return(true); } apiDeleteTasks.ErrorMessage = "No tasks found."; } return(false); }
/// <summary> /// Gets the task groups, in which the staging task is. /// </summary> /// <param name="ti">Staging task</param> /// <returns>Returns display names of task groups, in which the task exists</returns> private static IEnumerable <string> GetTaskGroupsFromStagingTask(StagingTaskInfo ti) { List <string> taskGroups = new List <string>(); TaskGroupInfoProvider.GetTaskGroups() .Columns("TaskGroupID", "TaskGroupCodeName") .WhereIn("TaskGroupID", TaskGroupTaskInfoProvider.GetTaskGroupTasks().WhereEquals("TaskID", ti.TaskID).Column("TaskGroupID")) .ForEachObject(t => taskGroups.Add(t.TaskGroupCodeName)); return(taskGroups); }
/// <summary> /// Gets the usernames of users, who modified object for which the given staging task was created. /// </summary> /// <param name="ti">Staging task</param> /// <returns>Returns usernames of users, who modified object for which the given staging task was created</returns> private static IEnumerable <string> GetUsersFromStagingTask(StagingTaskInfo ti) { List <string> usersWhoModifiedObject = new List <string>(); UserInfoProvider.GetUsers() .Columns("UserID", "UserName") .WhereIn("UserID", StagingTaskUserInfoProvider.GetTaskUsers().Column("UserID").WhereEquals("TaskID", ti.TaskID)) .ForEachObject(u => usersWhoModifiedObject.Add(u.UserName)); return(usersWhoModifiedObject); }
/// <summary> /// Inits unigrid events and data. /// </summary> private void InitUniGrid() { // 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"; gridTasks.WhereCondition = new WhereCondition().WhereIn("TaskID", TaskGroupInfoProvider.GetTaskGroups().WhereEquals("TaskGroupID", CurrentTaskGroup.TaskGroupID).Column("TaskID")).ToString(true); StagingTaskInfo ti = new StagingTaskInfo(); gridTasks.AllColumns = SqlHelper.MergeColumns(ti.ColumnNames); }
protected void gridTasks_OnAction(string actionName, object actionArgument) { // Parse action argument int taskId = ValidationHelper.GetInteger(actionArgument, 0); eventType = EventType.INFORMATION; if (taskId > 0) { StagingTaskInfo task = StagingTaskInfoProvider.GetTaskInfo(taskId); if (task != null) { switch (actionName.ToLowerCSafe()) { case "delete": // Delete task eventCode = "DELETESELECTEDOBJECT"; AddEventLog(string.Format(ResHelper.GetAPIString("deletion.running", "Deleting '{0}' task"), HTMLHelper.HTMLEncode(task.TaskTitle))); SynchronizationInfoProvider.DeleteSynchronizationInfo(taskId, serverId, currentSiteId); break; case "synchronize": string result = null; try { // Run task synchronization eventCode = "SYNCSELECTEDOBJECT"; result = StagingHelper.RunSynchronization(taskId, serverId, true, currentSiteId); if (string.IsNullOrEmpty(result)) { ShowConfirmation(GetString("Tasks.SynchronizationOK")); } else { ShowError(GetString("Tasks.SynchronizationFailed")); eventType = EventType.ERROR; } } catch (Exception ex) { result = ex.Message; ShowError(GetString("Tasks.SynchronizationFailed")); eventType = EventType.ERROR; } // Log message AddEventLog(result + string.Format(ResHelper.GetAPIString("synchronization.running", "Processing '{0}' task"), HTMLHelper.HTMLEncode(task.TaskTitle))); break; } } } }
/// <summary> /// Creates the Staging Task manually /// </summary> /// <param name="RelationshipObj"></param> /// <param name="TaskType"></param> private void RelationshipName_CreateStagingTask(RelationshipNameInfo RelationshipObj, TaskTypeEnum TaskType) { List <ServerInfo> ActiveServers = ServerInfo.Provider.Get().WhereEquals("ServerSiteID", SiteContext.CurrentSiteID).WhereEquals("ServerEnabled", true).ToList(); if (IsCustomAdhocRelationshipName(RelationshipObj) && ActiveServers.Count > 0) { string Data = "<NewDataSet>" + RelationshipObj.ToXML("CMS_RelationshipName", false) + "</NewDataSet>"; string TaskTitle = ""; switch (TaskType) { case TaskTypeEnum.CreateObject: TaskTitle = "Create"; break; case TaskTypeEnum.UpdateObject: TaskTitle = "Update"; break; case TaskTypeEnum.DeleteObject: TaskTitle = "Delete"; break; } StagingTaskInfo Task = new StagingTaskInfo() { TaskTitle = string.Format("{0} Relationship name '{1}'", TaskTitle, RelationshipObj.RelationshipDisplayName), TaskType = TaskType, TaskObjectType = RelationshipNameInfo.OBJECT_TYPE, TaskObjectID = RelationshipObj.RelationshipNameId, TaskData = Data, TaskTime = DateTime.Now }; StagingTaskInfo.Provider.Set(Task); foreach (ServerInfo ServerObj in ActiveServers) { // Create synchronization SynchronizationInfo SyncInfo = new SynchronizationInfo() { SynchronizationTaskID = Task.TaskID, SynchronizationServerID = ServerObj.ServerID }; SynchronizationInfo.Provider.Set(SyncInfo); } TaskGroupInfo TaskGroup = TaskGroupInfoProvider.GetUserTaskGroupInfo(MembershipContext.AuthenticatedUser.UserID); if (TaskGroup != null) { TaskGroupTaskInfo.Provider.Add(TaskGroup.TaskGroupID, Task.TaskID); } } }
/// <summary> /// Returns task header table in HTML code /// </summary> private string GetTaskHeader(StagingTaskInfo ti, IEnumerable <string> usersWhoModifiedObject, IEnumerable <string> taskInGroups) { const string FORMATTED_TABLE_ROW = "<tr><td class=\"Title Grid\">{0}</td><td>{1}</td></tr>"; var taskHeaderInHtml = "<table class=\"table table-hover\">"; taskHeaderInHtml += String.Format(FORMATTED_TABLE_ROW, GetString("staging.detailtasktype"), GetEncodedTaskType(ti)); taskHeaderInHtml += String.Format(FORMATTED_TABLE_ROW, GetString("staging.detailtasktime"), ti.TaskTime); taskHeaderInHtml += String.Format(FORMATTED_TABLE_ROW, GetString("staging.taskprocessedby"), GetEncodedTaskProccessedBy(ti)); taskHeaderInHtml += String.Format(FORMATTED_TABLE_ROW, GetString("taskUser.taskModifiedBy"), GetEncodedEnumeration(usersWhoModifiedObject)); taskHeaderInHtml += String.Format(FORMATTED_TABLE_ROW, GetString("stagingTaskGroup.taskGroupedIn"), GetEncodedEnumeration(taskInGroups)); taskHeaderInHtml += "</table>"; return(taskHeaderInHtml); }
protected override void OnLoad(EventArgs e) { base.OnLoad(e); // Check 'Manage servers' permission if (!CurrentUser.IsAuthorizedPerResource("cms.staging", "ManageDocumentsTasks")) { RedirectToAccessDenied("cms.staging", "ManageDocumentsTasks"); } 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; } // 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 + ";"); // Register script for pendingCallbacks repair ScriptHelper.FixPendingCallbacks(Page); HeaderActions.ActionPerformed += HeaderActions_ActionPerformed; if (!isCallback) { int nodeId = QueryHelper.GetInteger("stagingnodeid", 0); aliasPath = "/"; // Get the document node if (nodeId > 0) { TreeProvider tree = new TreeProvider(CurrentUser); TreeNode node = tree.SelectSingleNode(nodeId, TreeProvider.ALL_CULTURES); if (node != null) { aliasPath = node.NodeAliasPath; } } // Setup title ucDisabledModule.TestSettingKeys = "CMSStagingLogChanges"; ucDisabledModule.InfoText = GetString("ContentStaging.TaskSeparator"); ucDisabledModule.ParentPanel = pnlNotLogged; // Check logging if (!ucDisabledModule.Check()) { CurrentMaster.PanelHeader.Visible = false; plcContent.Visible = false; pnlFooter.Visible = false; return; } // Create header actions HeaderActions.AddAction(new HeaderAction { Text = GetString("Tasks.SyncCurrent"), EventName = SYNCHRONIZE_CURRENT }); HeaderActions.AddAction(new HeaderAction { Text = GetString("Tasks.SyncSubtree"), EventName = SYNCHRONIZE_SUBTREE, ButtonStyle = ButtonStyle.Default }); // Create header action HeaderActions.AddAction(new HeaderAction { Text = GetString("Tasks.CompleteSync"), EventName = SYNCHRONIZE_COMPLETE, ButtonStyle = ButtonStyle.Default }); // Add CSS class to panels wrapper in order it could be stacked CurrentMaster.PanelHeader.AddCssClass("header-container-multiple-panels"); if (!ControlsHelper.CausedPostBack(HeaderActions, btnSyncSelected, btnSyncAll)) { // Check 'Manage servers' permission if (!CurrentUser.IsAuthorizedPerResource("cms.staging", "ManageDocumentsTasks")) { RedirectToAccessDenied("cms.staging", "ManageDocumentsTasks"); } // Register the dialog script ScriptHelper.RegisterDialogScript(this); ltlScript.Text += ScriptHelper.GetScript("function ConfirmDeleteTask(taskId) { return confirm(" + ScriptHelper.GetString(GetString("Tasks.ConfirmDelete")) + "); }"); ltlScript.Text += ScriptHelper.GetScript("function CompleteSync(){" + Page.ClientScript.GetPostBackEventReference(btnSyncComplete, "") + "}"); // Initialize grid tasksUniGrid.OnDataReload += tasksUniGrid_OnDataReload; tasksUniGrid.ShowActionsMenu = true; tasksUniGrid.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(); tasksUniGrid.AllColumns = SqlHelper.MergeColumns(ti.ColumnNames); plcContent.Visible = true; // Initialize buttons btnSyncSelected.OnClientClick = "return !" + tasksUniGrid.GetCheckSelectionScript(); btnDeleteAll.OnClientClick = "return confirm(" + ScriptHelper.GetString(GetString("Tasks.ConfirmDeleteAll")) + ");"; btnDeleteSelected.OnClientClick = "return confirm(" + ScriptHelper.GetString(GetString("general.confirmdelete")) + ");"; pnlLog.Visible = false; TaskTypeCategories = TaskHelper.TASK_TYPE_CATEGORY_CONTENT + ";" + TaskHelper.TASK_TYPE_CATEGORY_GENERAL; } } var script = @"var currentNodeId = 0, selectDocuments = false; function ChangeServer(value) { currentServerId = value; } function SelectNode(serverId, nodeId) { currentServerId = serverId; currentNodeId = nodeId; document.location = 'Tasks.aspx?serverId=' + currentServerId + '&stagingnodeid=' + nodeId; } function SelectDocNode(serverId, nodeId) { currentNodeId = nodeId; document.location = 'DocumentsList.aspx?serverId=' + currentServerId + '&stagingnodeid=' + nodeId; }"; ScriptHelper.RegisterClientScriptBlock(Page, typeof(string), ClientID + "HandlingTasks", ScriptHelper.GetScript(script)); }
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; currentSiteId = SiteContext.CurrentSiteID; serverId = QueryHelper.GetInteger("serverid", 0); HeaderActions.ActionPerformed += HeaderActions_ActionPerformed; if (ControlsHelper.CausedPostBack(btnSyncComplete)) { SyncComplete(); } else { if (!RequestHelper.IsCallback()) { // Check 'Manage object tasks' permission if (!currentUser.IsAuthorizedPerResource("cms.staging", "ManageDataTasks")) { RedirectToAccessDenied("cms.staging", "ManageDataTasks"); } ucDisabledModule.SettingsKeys = "CMSStagingLogDataChanges"; ucDisabledModule.InfoTexts.Add(GetString("DataStaging.TaskSeparator") + "<br />"); ucDisabledModule.InfoTexts.Add(GetString("stagingchanges.notlogged")); ucDisabledModule.ParentPanel = pnlNotLogged; // Check logging if (!ucDisabledModule.Check()) { pnlFooter.Visible = false; plcContent.Visible = false; return; } // Register the dialog script ScriptHelper.RegisterDialogScript(this); // Get object type objectType = QueryHelper.GetString("objecttype", string.Empty); if (!String.IsNullOrEmpty(objectType)) { // Create header action HeaderActions.AddAction(new HeaderAction { Text = GetString("ObjectTasks.SyncCurrent"), EventName = SYNCHRONIZE_CURRENT }); } // Setup title titleElem.TitleText = GetString("Synchronization.Title"); if (!ControlsHelper.CausedPostBack(HeaderActions, btnSyncSelected, btnSyncAll)) { 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(); ltlScript.Text += ScriptHelper.GetScript("function CompleteSync(){" + Page.ClientScript.GetPostBackEventReference(btnSyncComplete, null) + "}"); // Initialize grid gridTasks.OrderBy = "TaskTime"; 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) { // Initialize current user for the async actions currentUser = MembershipContext.AuthenticatedUser; // Check 'Manage data tasks' permission if (!currentUser.IsAuthorizedPerResource("cms.staging", "ManageDataTasks")) { RedirectToAccessDenied("cms.staging", "ManageDataTasks"); } // Check enabled servers if (!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); // Initialize current site ID currentSiteId = SiteContext.CurrentSiteID; // Setup server dropdown selectorElem.DropDownList.AutoPostBack = true; selectorElem.UniSelector.OnSelectionChanged += UniSelector_OnSelectionChanged; // Set server ID serverId = ValidationHelper.GetInteger(selectorElem.Value, QueryHelper.GetInteger("serverId", 0)); // All servers if (serverId == UniSelector.US_ALL_RECORDS) { serverId = 0; selectorElem.Value = UniSelector.US_ALL_RECORDS; } else { selectorElem.Value = serverId.ToString(); } ltlScript.Text += ScriptHelper.GetScript("var currentServerId = " + serverId + ";"); HeaderActions.ActionPerformed += HeaderActions_ActionPerformed; if (ControlsHelper.CausedPostBack(btnSyncComplete)) { SyncComplete(); } else { if (!RequestHelper.IsCallback()) { // Check 'Manage object tasks' permission if (!currentUser.IsAuthorizedPerResource("cms.staging", "ManageDataTasks")) { RedirectToAccessDenied("cms.staging", "ManageDataTasks"); } ucDisabledModule.SettingsKeys = "CMSStagingLogDataChanges"; ucDisabledModule.InfoTexts.Add(GetString("DataStaging.TaskSeparator")); ucDisabledModule.ParentPanel = pnlNotLogged; // Check logging if (!ucDisabledModule.Check()) { CurrentMaster.PanelHeader.Visible = false; plcContent.Visible = false; pnlFooter.Visible = false; return; } // Register the dialog script ScriptHelper.RegisterDialogScript(this); // Get object type objectType = QueryHelper.GetString("objecttype", string.Empty); if (!String.IsNullOrEmpty(objectType)) { // Create header action 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"); // Set Complete synchronization button as default btnComplete.ButtonStyle = ButtonStyle.Default; } // Setup title ctlAsyncLog.TitleText = GetString("Synchronization.Title"); if (!ControlsHelper.CausedPostBack(HeaderActions, btnSyncSelected, btnSyncAll)) { 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(); ltlScript.Text += ScriptHelper.GetScript("function CompleteSync(){" + Page.ClientScript.GetPostBackEventReference(btnSyncComplete, null) + "}"); // Initialize grid gridTasks.OrderBy = "TaskTime"; 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; } } } ctlAsyncLog.OnFinished += ctlAsyncLog_OnFinished; ctlAsyncLog.OnError += ctlAsyncLog_OnError; ctlAsyncLog.OnRequestLog += ctlAsyncLog_OnRequestLog; ctlAsyncLog.OnCancel += ctlAsyncLog_OnCancel; }
private static string GetEncodedTaskProccessedBy(StagingTaskInfo ti) { return(DataHelper.GetNotEmpty(ti.TaskServers.Trim(';').Replace(";", ", "), "-")); }
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 = MembershipContext.AuthenticatedUser; if (!RequestHelper.IsCallback()) { // Check 'Manage object tasks' permission if (!currentUser.IsAuthorizedPerResource("cms.staging", "ManageAllTasks")) { RedirectToAccessDenied("cms.staging", "ManageAllTasks"); } currentSiteId = SiteContext.CurrentSiteID; currentSiteName = SiteContext.CurrentSiteName; ucDisabledModule.SettingsKeys = "CMSStagingLogObjectChanges;CMSStagingLogDataChanges;CMSStagingLogChanges"; ucDisabledModule.InfoText = GetString("AllTasks.TaskSeparator"); ucDisabledModule.AtLeastOne = true; ucDisabledModule.ShowButtons = false; ucDisabledModule.SiteOrGlobal = true; ucDisabledModule.ParentPanel = pnlNotLogged; if (!ucDisabledModule.Check()) { pnlFooter.Visible = false; plcContent.Visible = false; return; } // Register the dialog script ScriptHelper.RegisterDialogScript(this); serverId = QueryHelper.GetInteger("serverid", 0); // Setup title if (!ControlsHelper.CausedPostBack(btnSyncSelected, btnSyncAll)) { 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; }
/// <summary> /// Deletes staging tasks. Called when the "Delete tasks" button is pressed. /// Expects the CreateStagingServer method to be run first. /// </summary> private bool DeleteTasks() { // Get server ServerInfo server = ServerInfoProvider.GetServerInfo("MyNewServer", SiteContext.CurrentSiteID); if (server != null) { // Get tasks for the server DataSet tasks = StagingTaskInfoProvider.SelectTaskList(SiteContext.CurrentSiteID, server.ServerID, null, null); if (!DataHelper.DataSourceIsEmpty(tasks)) { foreach (DataRow taskDr in tasks.Tables[0].Rows) { // Create task info object from data row StagingTaskInfo deleteTask = new StagingTaskInfo(taskDr); // Delete the task StagingTaskInfoProvider.DeleteTaskInfo(deleteTask); } return true; } apiDeleteTasks.ErrorMessage = "No tasks found."; } return false; }
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.SettingsKeys = "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.StartsWithCSafe("##") || (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; } } }
/// <summary> /// Synchronizes all tasks. Called when the "Get and synchronize tasks" button is pressed. /// Expects the CreateStagingServer method to be run first and that there are tasks logged /// for the server. /// </summary> private bool GetAndSynchronizeTasks() { // Get server ServerInfo server = ServerInfoProvider.GetServerInfo("MyNewServer", SiteContext.CurrentSiteID); if (server != null) { // Get tasks for the server DataSet tasks = StagingTaskInfoProvider.SelectTaskList(SiteContext.CurrentSiteID, server.ServerID, null, null); if (!DataHelper.DataSourceIsEmpty(tasks)) { foreach (DataRow taskDr in tasks.Tables[0].Rows) { // Create task info object from data row StagingTaskInfo task = new StagingTaskInfo(taskDr); // Synchronize the task if (!string.IsNullOrEmpty(StagingHelper.RunSynchronization(task.TaskID, server.ServerID))) { apiGetAndSynchronizeTasks.ErrorMessage = "Synchronization failed."; return false; } } return true; } apiGetAndSynchronizeTasks.ErrorMessage = "No tasks found."; } return false; }
private static string GetEncodedTaskType(StagingTaskInfo ti) { return(HTMLHelper.HTMLEncode(ti.TaskType.ToLocalizedString(TaskHelper.TASK_TYPE_RESOURCE_STRING_PREFIX))); }
protected override void OnLoad(EventArgs e) { base.OnLoad(e); // Check 'Manage object tasks' permission if (!CurrentUser.IsAuthorizedPerResource("cms.staging", "ManageAllTasks")) { RedirectToAccessDenied("cms.staging", "ManageAllTasks"); } 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; } // Setup server dropdown selectorElem.DropDownList.AutoPostBack = true; selectorElem.UniSelector.OnSelectionChanged += UniSelector_OnSelectionChanged; // Set server ID SelectedServerID = ValidationHelper.GetInteger(selectorElem.Value, 0); // All servers if (SelectedServerID == UniSelector.US_ALL_RECORDS) { SelectedServerID = 0; } // Register script for pendingCallbacks repair ScriptHelper.FixPendingCallbacks(Page); if (!isCallback) { // Check 'Manage object tasks' permission if (!CurrentUser.IsAuthorizedPerResource("cms.staging", "ManageAllTasks")) { RedirectToAccessDenied("cms.staging", "ManageAllTasks"); } ucDisabledModule.TestAnyKey = true; ucDisabledModule.TestSettingKeys = "CMSStagingLogObjectChanges;CMSStagingLogDataChanges;CMSStagingLogChanges"; ucDisabledModule.ParentPanel = pnlNotLogged; ucDisabledModule.InfoText = GetString("staging.disabledModule.allTasks"); if (!ucDisabledModule.Check()) { CurrentMaster.PanelHeader.Visible = false; plcContent.Visible = false; pnlFooter.Visible = false; return; } // Register the dialog script ScriptHelper.RegisterDialogScript(this); // Setup title if (!ControlsHelper.CausedPostBack(btnSyncSelected, btnSyncAll)) { 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; } } }
protected override void OnLoad(EventArgs e) { base.OnLoad(e); // Check 'Manage object tasks' permission if (!CurrentUser.IsAuthorizedPerResource("cms.staging", "ManageAllTasks")) { RedirectToAccessDenied("cms.staging", "ManageAllTasks"); } 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; } // Setup server dropdown selectorElem.DropDownList.AutoPostBack = true; selectorElem.UniSelector.OnSelectionChanged += UniSelector_OnSelectionChanged; // Set server ID SelectedServerID = ValidationHelper.GetInteger(selectorElem.Value, 0); // All servers if (SelectedServerID == UniSelector.US_ALL_RECORDS) { SelectedServerID = 0; } // Register script for pendingCallbacks repair ScriptHelper.FixPendingCallbacks(Page); if (!isCallback) { // Check 'Manage object tasks' permission if (!CurrentUser.IsAuthorizedPerResource("cms.staging", "ManageAllTasks")) { RedirectToAccessDenied("cms.staging", "ManageAllTasks"); } ucDisabledModule.AtLeastOne = true; ucDisabledModule.SettingsKeys = "CMSStagingLogObjectChanges;CMSStagingLogDataChanges;CMSStagingLogChanges"; ucDisabledModule.ParentPanel = pnlNotLogged; ucDisabledModule.InfoText = GetString("staging.disabledModule.allTasks"); if (!ucDisabledModule.Check()) { CurrentMaster.PanelHeader.Visible = false; plcContent.Visible = false; pnlFooter.Visible = false; return; } // Register the dialog script ScriptHelper.RegisterDialogScript(this); // Setup title if (!ControlsHelper.CausedPostBack(btnSyncSelected, btnSyncAll)) { 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; } } }
protected override void OnLoad(EventArgs e) { base.OnLoad(e); // Check 'Manage servers' permission if (!CurrentUser.IsAuthorizedPerResource("cms.staging", "ManageDocumentsTasks")) { RedirectToAccessDenied("cms.staging", "ManageDocumentsTasks"); } 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; } // 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 + ";"); // Register script for pendingCallbacks repair ScriptHelper.FixPendingCallbacks(Page); HeaderActions.ActionPerformed += HeaderActions_ActionPerformed; if (!isCallback) { int nodeId = QueryHelper.GetInteger("stagingnodeid", 0); aliasPath = "/"; // Get the document node if (nodeId > 0) { TreeProvider tree = new TreeProvider(CurrentUser); TreeNode node = tree.SelectSingleNode(nodeId, TreeProvider.ALL_CULTURES); if (node != null) { aliasPath = node.NodeAliasPath; } } // Setup title ucDisabledModule.SettingsKeys = "CMSStagingLogChanges"; ucDisabledModule.InfoText = GetString("ContentStaging.TaskSeparator"); ucDisabledModule.ParentPanel = pnlNotLogged; // Check logging if (!ucDisabledModule.Check()) { CurrentMaster.PanelHeader.Visible = false; plcContent.Visible = false; pnlFooter.Visible = false; return; } // Create header actions HeaderActions.AddAction(new HeaderAction { Text = GetString("Tasks.SyncCurrent"), EventName = SYNCHRONIZE_CURRENT }); HeaderActions.AddAction(new HeaderAction { Text = GetString("Tasks.SyncSubtree"), EventName = SYNCHRONIZE_SUBTREE, ButtonStyle = ButtonStyle.Default }); // Create header action HeaderActions.AddAction(new HeaderAction { Text = GetString("Tasks.CompleteSync"), EventName = SYNCHRONIZE_COMPLETE, ButtonStyle = ButtonStyle.Default }); // Add CSS class to panels wrapper in order it could be stacked CurrentMaster.PanelHeader.AddCssClass("header-container-multiple-panels"); if (!ControlsHelper.CausedPostBack(HeaderActions, btnSyncSelected, btnSyncAll)) { // Check 'Manage servers' permission if (!CurrentUser.IsAuthorizedPerResource("cms.staging", "ManageDocumentsTasks")) { RedirectToAccessDenied("cms.staging", "ManageDocumentsTasks"); } // Register the dialog script ScriptHelper.RegisterDialogScript(this); ltlScript.Text += ScriptHelper.GetScript("function ConfirmDeleteTask(taskId) { return confirm(" + ScriptHelper.GetString(GetString("Tasks.ConfirmDelete")) + "); }"); ltlScript.Text += ScriptHelper.GetScript("function CompleteSync(){" + Page.ClientScript.GetPostBackEventReference(btnSyncComplete, "") + "}"); // Initialize grid tasksUniGrid.OnDataReload += tasksUniGrid_OnDataReload; tasksUniGrid.ShowActionsMenu = true; tasksUniGrid.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(); tasksUniGrid.AllColumns = SqlHelper.MergeColumns(ti.ColumnNames); plcContent.Visible = true; // Initialize buttons btnSyncSelected.OnClientClick = "return !" + tasksUniGrid.GetCheckSelectionScript(); btnDeleteAll.OnClientClick = "return confirm(" + ScriptHelper.GetString(GetString("Tasks.ConfirmDeleteAll")) + ");"; btnDeleteSelected.OnClientClick = "return confirm(" + ScriptHelper.GetString(GetString("general.confirmdelete")) + ");"; pnlLog.Visible = false; TaskTypeCategories = TaskHelper.TASK_TYPE_CATEGORY_CONTENT + ";" + TaskHelper.TASK_TYPE_CATEGORY_GENERAL; } } var script = @"var currentNodeId = 0, selectDocuments = false; function ChangeServer(value) { currentServerId = value; } function SelectNode(serverId, nodeId) { currentServerId = serverId; currentNodeId = nodeId; document.location = 'Tasks.aspx?serverId=' + currentServerId + '&stagingnodeid=' + nodeId; } function SelectDocNode(serverId, nodeId) { currentNodeId = nodeId; document.location = 'DocumentsList.aspx?serverId=' + currentServerId + '&stagingnodeid=' + nodeId; }"; ScriptHelper.RegisterClientScriptBlock(Page, typeof(string), ClientID + "HandlingTasks", ScriptHelper.GetScript(script)); }
protected void Page_Load(object sender, EventArgs e) { // Register script for pendingCallbacks repair ScriptHelper.FixPendingCallbacks(Page); // Get site info currentSiteId = SiteContext.CurrentSiteID; currentSiteName = SiteContext.CurrentSiteName; // Initialize current user for the async actions currentUser = MembershipContext.AuthenticatedUser; serverId = QueryHelper.GetInteger("serverid", 0); HeaderActions.ActionPerformed += HeaderActions_ActionPerformed; if (ControlsHelper.CausedPostBack(btnSyncComplete)) { SyncComplete(); } else { if (!RequestHelper.IsCallback()) { int nodeId = QueryHelper.GetInteger("nodeid", 0); aliasPath = "/"; // Get the document node if (nodeId > 0) { TreeProvider tree = new TreeProvider(currentUser); TreeNode node = tree.SelectSingleNode(nodeId, TreeProvider.ALL_CULTURES); if (node != null) { aliasPath = node.NodeAliasPath; } } // Setup title titleElem.TitleText = GetString("Synchronization.Title"); ucDisabledModule.SettingsKeys = "CMSStagingLogChanges"; ucDisabledModule.InfoTexts.Add(GetString("ContentStaging.TaskSeparator") + "<br/>"); ucDisabledModule.InfoTexts.Add(GetString("StagingChanges.NotLogged")); ucDisabledModule.ParentPanel = pnlNotLogged; // Check logging if (!ucDisabledModule.Check()) { plcContent.Visible = false; pnlFooter.Visible = false; return; } // Create header actions HeaderActions.AddAction(new HeaderAction() { Text = GetString("Tasks.SyncCurrent"), EventName = SYNCHRONIZE_CURRENT }); HeaderActions.AddAction(new HeaderAction() { Text = GetString("Tasks.SyncSubtree"), EventName = SYNCHRONIZE_SUBTREE }); if (!ControlsHelper.CausedPostBack(HeaderActions, btnSyncSelected, btnSyncAll)) { // Check 'Manage servers' permission if (!currentUser.IsAuthorizedPerResource("cms.staging", "ManageDocumentsTasks")) { RedirectToAccessDenied("cms.staging", "ManageDocumentsTasks"); } // Register the dialog script ScriptHelper.RegisterDialogScript(this); ltlScript.Text += ScriptHelper.GetScript("function ConfirmDeleteTask(taskId) { return confirm(" + ScriptHelper.GetString(GetString("Tasks.ConfirmDelete")) + "); }"); ltlScript.Text += ScriptHelper.GetScript("function CompleteSync(){" + Page.ClientScript.GetPostBackEventReference(btnSyncComplete, null) + "}"); // Initialize grid tasksUniGrid.OnExternalDataBound += tasksUniGrid_OnExternalDataBound; tasksUniGrid.OnAction += tasksUniGrid_OnAction; tasksUniGrid.OnDataReload += tasksUniGrid_OnDataReload; tasksUniGrid.ShowActionsMenu = true; tasksUniGrid.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(); tasksUniGrid.AllColumns = SqlHelper.MergeColumns(ti.ColumnNames); plcContent.Visible = true; // Initialize buttons btnCancel.Attributes.Add("onclick", ctlAsync.GetCancelScript(true) + "return false;"); btnCancel.Text = GetString("General.Cancel"); btnDeleteAll.Text = GetString("Tasks.DeleteAll"); btnDeleteSelected.Text = GetString("Tasks.DeleteSelected"); btnSyncAll.Text = GetString("Tasks.SyncAll"); btnSyncSelected.Text = GetString("Tasks.SyncSelected"); btnSyncSelected.OnClientClick = "return !" + tasksUniGrid.GetCheckSelectionScript(); btnDeleteAll.OnClientClick = "return confirm(" + ScriptHelper.GetString(GetString("Tasks.ConfirmDeleteAll")) + ");"; btnDeleteSelected.OnClientClick = "return confirm(" + ScriptHelper.GetString(GetString("general.confirmdelete")) + ");"; pnlLog.Visible = false; } } } ctlAsync.OnFinished += ctlAsync_OnFinished; ctlAsync.OnError += ctlAsync_OnError; ctlAsync.OnRequestLog += ctlAsync_OnRequestLog; ctlAsync.OnCancel += ctlAsync_OnCancel; }