示例#1
0
    protected DataSet gridTasks_OnDataReload(string completeWhere, string currentOrder, int currentTopN, string columns, int currentOffset, int currentPageSize, ref int totalRecords)
    {
        // Get the tasks
        bool classesFound;

        string where = GetAllTasksWhere(out classesFound);

        WhereCondition mergedWhere = new WhereCondition(completeWhere).And().Where(where);

        DataSet ds = null;

        // There are some custom tables assigned to the site, get the data
        if (classesFound || !string.IsNullOrEmpty(objectType))
        {
            var tasksQuery = StagingTaskInfoProvider.SelectObjectTaskList(CurrentSiteID, SelectedServerID, objectType, mergedWhere.ToString(true), currentOrder, currentTopN, columns, currentOffset, currentPageSize);
            ds           = tasksQuery.Result;
            totalRecords = tasksQuery.TotalRecords;
        }
        else
        {
            totalRecords = -1;
        }

        return(ds);
    }
示例#2
0
    /// <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);
    }
示例#3
0
        /// <inheritdoc/>
        public string SynchronizeStagingTask(IServer server)
        {
            string res = string.Empty;

            // Gets a staging server
            ServerInfo stagingServer = this.GetServer(server.ServerName, server.ServerSiteID).UndoActLike();

            if (stagingServer != null)
            {
                // Gets all staging tasks that target the given server
                var tasks = StagingTaskInfoProvider.SelectTaskList(stagingServer.ServerSiteID, stagingServer.ServerID, null, null);

                if (tasks.Count == 0)
                {
                    return("There is no task that target the given server.");
                }

                // Loops through individual staging tasks
                foreach (StagingTaskInfo task in tasks)
                {
                    // Synchronizes the staging task
                    string result = new StagingTaskRunner(stagingServer.ServerID).RunSynchronization(task.TaskID);

                    // The task synchronization failed
                    // The 'result' string returned by the RunSynchronization method contains the error message for the given task
                    if (!string.IsNullOrEmpty(result))
                    {
                        res += result + "\n";
                    }
                }
            }

            return(res);
        }
示例#4
0
    /// <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);
    }
示例#5
0
 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);
 }
示例#6
0
    private string SynchronizeCurrentInternal()
    {
        int sid = SelectedServerID;

        if (sid <= 0)
        {
            sid = SynchronizationInfoProvider.ENABLED_SERVERS;
        }

        string result = null;

        // Process all types
        string[] syncTypes = objectType.Split(';');
        foreach (string syncType in syncTypes)
        {
            if (syncType != string.Empty)
            {
                AddLog(String.Format(GetString("Synchronization.LoggingTasks"), syncType));

                // Create update tasks
                SynchronizationHelper.LogObjectChange(syncType, synchronizedSiteId, DateTimeHelper.ZERO_TIME, TaskTypeEnum.UpdateObject, true, false, false, false, false, CurrentSiteID, sid);

                AddLog(GetString("Synchronization.RunningTasks"));

                // Get the tasks
                string where = GetSiteWhere();
                DataSet ds = StagingTaskInfoProvider.SelectObjectTaskList(CurrentSiteID, SelectedServerID, syncType, @where, "TaskID", -1, "TaskID");

                // Run the synchronization
                result += StagingTaskRunner.RunSynchronization(ds);
            }
        }

        return(result);
    }
示例#7
0
    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();
        }
    }
示例#8
0
    /// <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();
        }
    }
示例#9
0
    /// <summary>
    /// Deletes tasks based on the given where condition
    /// </summary>
    /// <param name="where">Where condition</param>
    protected void DeleteTasks(string where)
    {
        // Get the tasks
        DataSet ds = StagingTaskInfoProvider.SelectObjectTaskList(CurrentSiteID, SelectedServerID, objectType, where, "TaskID", 0, "TaskID, TaskTitle");

        DeleteTasks(ds);
    }
示例#10
0
    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);
    }
示例#11
0
    protected DataSet gridTasks_OnDataReload(string completeWhere, string currentOrder, int currentTopN, string columns, int currentOffset, int currentPageSize, ref int totalRecords)
    {
        // Get the tasks
        DataSet ds = StagingTaskInfoProvider.SelectTaskList(CurrentSiteID, SelectedServerID, completeWhere, currentOrder, currentTopN, columns, currentOffset, currentPageSize, ref totalRecords);

        pnlFooter.Visible = (totalRecords > 0);
        return(ds);
    }
        /// <summary>
        /// Custom Staging Task generation
        /// </summary>
        /// <param name="RelationshipSiteObj"></param>
        /// <param name="TaskType"></param>
        private void RelationshipNameSite_CreateStagingTask(RelationshipNameSiteInfo RelationshipSiteObj, TaskTypeEnum TaskType)
        {
            List <ServerInfo>    ActiveServers   = ServerInfoProvider.GetServers().WhereEquals("ServerSiteID", SiteContext.CurrentSiteID).WhereEquals("ServerEnabled", true).ToList();
            RelationshipNameInfo RelationshipObj = RelationshipNameInfoProvider.GetRelationshipNameInfo(RelationshipSiteObj.RelationshipNameID);

            // If relationship obj is already gone, then the Site deletion thing is already handled with the deletion of the relationship name.
            if (RelationshipObj == null)
            {
                return;
            }

            if (IsCustomAdhocRelationshipName(RelationshipObj) && ActiveServers.Count > 0)
            {
                string Data         = "<NewDataSet>" + RelationshipObj.ToXML("CMS_RelationshipName", false) + "</NewDataSet>";
                string TaskTitle    = "";
                string TaskTitleEnd = "";
                switch (TaskType)
                {
                case TaskTypeEnum.AddToSite:
                    TaskTitle    = "Add";
                    TaskTitleEnd = "to";
                    break;

                case TaskTypeEnum.RemoveFromSite:
                    TaskTitle    = "Remove";
                    TaskTitleEnd = "from";
                    break;
                }
                StagingTaskInfo SiteTask = new CMS.Synchronization.StagingTaskInfo()
                {
                    TaskTitle      = string.Format("{0} Relationship name '{1}' {2} site", TaskTitle, RelationshipObj.RelationshipDisplayName, TaskTitleEnd),
                    TaskType       = TaskType,
                    TaskObjectType = RelationshipNameInfo.OBJECT_TYPE,
                    TaskObjectID   = RelationshipObj.RelationshipNameId,
                    TaskData       = Data,
                    TaskTime       = DateTime.Now,
                    TaskSiteID     = SiteContext.CurrentSiteID
                };
                StagingTaskInfoProvider.SetTaskInfo(SiteTask);

                foreach (ServerInfo ServerObj in ActiveServers)
                {
                    // Create synchronization
                    SynchronizationInfo SyncSiteInfo = new SynchronizationInfo()
                    {
                        SynchronizationTaskID   = SiteTask.TaskID,
                        SynchronizationServerID = ServerObj.ServerID
                    };
                    SynchronizationInfoProvider.SetSynchronizationInfo(SyncSiteInfo);
                }

                TaskGroupInfo TaskGroup = TaskGroupInfoProvider.GetUserTaskGroupInfo(MembershipContext.AuthenticatedUser.UserID);
                if (TaskGroup != null)
                {
                    TaskGroupTaskInfoProvider.AddTaskGroupToTask(TaskGroup.TaskGroupID, SiteTask.TaskID);
                }
            }
        }
示例#13
0
    protected DataSet gridTasks_OnDataReload(string completeWhere, string currentOrder, int currentTopN, string columns, int currentOffset, int currentPageSize, ref int totalRecords)
    {
        // Get the tasks
        string where = GetWhere();
        DataSet ds = StagingTaskInfoProvider.SelectObjectTaskList(currentSiteId, serverId, objectType, where, currentOrder, 0, columns, currentOffset, currentPageSize, ref totalRecords);

        pnlFooter.Visible = (totalRecords > 0);
        return(ds);
    }
示例#14
0
    /// <summary>
    /// All items synchronization.
    /// </summary>
    protected void SynchronizeAll(object parameter)
    {
        string result = string.Empty;

        eventCode      = "SYNCALLOBJECTS";
        CanceledString = GetString("Tasks.SynchronizationCanceled");
        try
        {
            AddLog(GetString("Synchronization.RunningTasks"));

            // Get the tasks
            string where = GetWhere();

            DataSet ds = StagingTaskInfoProvider.SelectObjectTaskList(currentSiteId, serverId, objectType, where, "TaskID", -1, "TaskID, TaskTitle");

            // Run the synchronization
            result = StagingHelper.RunSynchronization(ds, serverId, true, currentSiteId, AddLog);

            // Log possible errors
            if (result != string.Empty)
            {
                CurrentError = GetString("Tasks.SynchronizationFailed");
                AddErrorLog(CurrentError, null);
            }
            else
            {
                CurrentInfo = GetString("Tasks.SynchronizationOK");
                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.SynchronizationFailed");
                AddErrorLog(CurrentError, result);
            }
        }
        catch (Exception ex)
        {
            CurrentError = GetString("Tasks.SynchronizationFailed") + ": " + ex.Message;
            AddErrorLog(CurrentError);
        }
        finally
        {
            // Finalize log context
            FinalizeContext();
        }
    }
    protected DataSet gridTasks_OnDataReload(string completeWhere, string currentOrder, int currentTopN, string columns, int currentOffset, int currentPageSize, ref int totalRecords)
    {
        // Get the tasks
        var tasksQuery = StagingTaskInfoProvider.SelectTaskList(CurrentSiteID, SelectedServerID, completeWhere, currentOrder, currentTopN, columns, currentOffset, currentPageSize);
        var result     = tasksQuery.Result;

        totalRecords = tasksQuery.TotalRecords;

        return(result);
    }
示例#16
0
    private string SynchronizeAllInternal()
    {
        AddLog(GetString("Synchronization.RunningTasks"));

        // Get the tasks
        DataSet ds = StagingTaskInfoProvider.SelectTaskList(CurrentSiteID, SelectedServerID, GridTasks.CustomFilter.WhereCondition, "TaskID", -1, "TaskID");

        // Run the synchronization
        return(StagingTaskRunner.RunSynchronization(ds));
    }
示例#17
0
    private DataSet gridTasks_OnDataReload(string completeWhere, string currentOrder, int currentTopN, string columns, int currentOffset, int currentPageSize, ref int totalRecords)
    {
        completeWhere = new WhereCondition(completeWhere).And().WhereIn("TaskID", TaskGroupTaskInfoProvider.GetTaskGroupTasks().WhereEquals("TaskGroupID", CurrentTaskGroup.TaskGroupID).Column("TaskID")).ToString(true);

        // Get the tasks
        DataSet ds = StagingTaskInfoProvider.SelectTaskList(CurrentSiteID, SelectedServerID, completeWhere, currentOrder, currentTopN, columns, currentOffset, currentPageSize, ref totalRecords);

        pnlFooter.Visible = (totalRecords > 0);
        return(ds);
    }
    protected DataSet gridTasks_OnDataReload(string completeWhere, string currentOrder, int currentTopN, string columns, int currentOffset, int currentPageSize, ref int totalRecords)
    {
        // Get the tasks
        string where = GetSiteWhere();
        WhereCondition mergedWhere = new WhereCondition(completeWhere).And().Where(where);

        DataSet ds = StagingTaskInfoProvider.SelectObjectTaskList(CurrentSiteID, SelectedServerID, objectType, mergedWhere.ToString(true), currentOrder, currentTopN, columns, currentOffset, currentPageSize, ref totalRecords);

        pnlFooter.Visible = (totalRecords > 0);
        return(ds);
    }
示例#19
0
    /// <summary>
    /// All items synchronization.
    /// </summary>
    public void SynchronizeAll(object parameter)
    {
        string result = string.Empty;

        eventCode      = "SYNCALLDOCS";
        CanceledString = GetString("Tasks.SynchronizationCanceled");
        try
        {
            AddLog(GetString("Synchronization.RunningTasks"));

            // Process all records
            DataSet ds = StagingTaskInfoProvider.SelectDocumentTaskList(currentSiteId, serverId, aliasPath, null, "TaskID", -1, "TaskID, TaskTitle");

            // Run the synchronization
            result = StagingHelper.RunSynchronization(ds, serverId, true, currentSiteId, AddLog);

            // Log possible error
            if (!String.IsNullOrEmpty(result))
            {
                CurrentError = GetString("Tasks.SynchronizationFailed");
                AddErrorLog(CurrentError, null);
            }
            else
            {
                CurrentInfo = GetString("Tasks.SynchronizationOK");
                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.SynchronizationFailed");
                AddErrorLog(CurrentError, result);
            }
        }
        catch (Exception ex)
        {
            CurrentError = GetString("Tasks.SynchronizationFailed") + ": " + ex.Message;
            AddErrorLog(CurrentError);
        }
        finally
        {
            // Finalize log context
            FinalizeContext();
        }
    }
示例#20
0
    private string DeleteAllInternal()
    {
        AddLog(GetString("Synchronization.DeletingTasks"));

        // Get the tasks
        DataSet ds = StagingTaskInfoProvider.SelectTaskList(CurrentSiteID, SelectedServerID, gridTasks.CustomFilter.WhereCondition, "TaskID", -1, "TaskID, TaskTitle");

        DeleteTasks(ds);

        return(null);
    }
示例#21
0
    /// <summary>
    /// Deletes all tasks.
    /// </summary>
    private string DeleteAllInternal()
    {
        AddLog(GetString("Synchronization.DeletingTasks"));

        // Get the tasks
        DataSet ds = StagingTaskInfoProvider.SelectTaskList(CurrentSiteID, SelectedServerID, GridTasks.CustomFilter.WhereCondition, "TaskID", -1, "TaskID, TaskTitle")
                     .WhereIn("TaskID", TaskGroupTaskInfo.Provider.Get().WhereEquals("TaskGroupID", CurrentTaskGroup.TaskGroupID).Column("TaskID"));

        DeleteTasks(ds);

        return(null);
    }
示例#22
0
    private string SynchronizeAllInternal()
    {
        AddLog(GetString("Synchronization.RunningTasks"));

        // Get the tasks
        DataSet ds = StagingTaskInfoProvider.SelectTaskList(CurrentSiteID, SelectedServerID, GridTasks.CustomFilter.WhereCondition, "TaskID", -1, "TaskID, TaskTitle");

        // Run the synchronization
        string result = StagingHelper.RunSynchronization(ds, SelectedServerID, true, CurrentSiteID, AddLog);

        return(result);
    }
示例#23
0
    /// <summary>
    /// Deletes all tasks.
    /// </summary>
    protected void DeleteAll(object parameter)
    {
        eventCode      = "DELETEALLTASKS";
        CanceledString = GetString("Tasks.DeletionCanceled");
        try
        {
            AddLog(GetString("Synchronization.DeletingTasks"));
            // Get the tasks
            DataSet ds = StagingTaskInfoProvider.SelectTaskList(currentSiteId, serverId, null, "TaskID", -1, "TaskID, TaskTitle");
            if (!DataHelper.DataSourceIsEmpty(ds))
            {
                foreach (DataRow row in ds.Tables[0].Rows)
                {
                    int taskId = ValidationHelper.GetInteger(row["TaskID"], 0);
                    if (taskId > 0)
                    {
                        string taskTitle = ValidationHelper.GetString(row["TaskTitle"], null);
                        AddLog(string.Format(ResHelper.GetAPIString("deletion.running", "Deleting '{0}' task"), HTMLHelper.HTMLEncode(taskTitle)));
                        // Delete synchronization
                        SynchronizationInfoProvider.DeleteSynchronizationInfo(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
        {
            // Finalize log context
            FinalizeContext();
        }
    }
示例#24
0
    private DataSet gridTasks_OnDataReload(string completeWhere, string currentOrder, int currentTopN, string columns, int currentOffset, int currentPageSize, ref int totalRecords)
    {
        completeWhere = new WhereCondition(completeWhere).And().WhereIn("TaskID", TaskGroupTaskInfoProvider.GetTaskGroupTasks().WhereEquals("TaskGroupID", CurrentTaskGroup.TaskGroupID).Column("TaskID")).ToString(true);

        // Get the tasks
        var tasksQuery = StagingTaskInfoProvider.SelectTaskList(CurrentSiteID, SelectedServerID, completeWhere, currentOrder, currentTopN, columns, currentOffset, currentPageSize);
        var result     = tasksQuery.Result;

        totalRecords = tasksQuery.TotalRecords;

        return(result);
    }
    private string SynchronizeAllInternal()
    {
        EventCode = "SYNCALLDOCS";

        AddLog(GetString("Synchronization.RunningTasks"));

        // Process all records
        DataSet ds = StagingTaskInfoProvider.SelectDocumentTaskList(CurrentSiteID, SelectedServerID, aliasPath, tasksUniGrid.CustomFilter.WhereCondition, "TaskID", -1, "TaskID");

        // Run the synchronization
        return(StagingTaskRunner.RunSynchronization(ds));
    }
示例#26
0
    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;
                }
            }
        }
    }
    private string CreateUpdateTasksAndRunTasksInternal(string action)
    {
        string result;
        int    sid = SelectedServerID;

        if (sid <= 0)
        {
            sid = SynchronizationInfoProvider.ENABLED_SERVERS;
        }

        EventCode = "SYNCHRONIZE";

        AddLog(String.Format(GetString("Synchronization.LoggingTasks"), PredefinedObjectType.DOCUMENT));

        // Prepare settings for current node
        var settings = new LogMultipleDocumentChangeSettings
        {
            EnsurePublishTask = true,
            NodeAliasPath     = aliasPath,
            TaskType          = TaskTypeEnum.UpdateDocument,
            ServerID          = sid,
            KeepTaskData      = false,
            RunAsynchronously = false,
            SiteName          = CurrentSiteName
        };

        // Create update task for current node
        var currentNodeUpdateTask = DocumentSynchronizationHelper.LogDocumentChange(settings);

        // Create update tasks for subtree or for the whole tree, depends on sync action
        if (action != SYNCHRONIZE_CURRENT)
        {
            settings.NodeAliasPath = action == SYNCHRONIZE_COMPLETE ? "/%" : aliasPath.TrimEnd('/') + "/%";
            DocumentSynchronizationHelper.LogDocumentChange(settings);
        }

        AddLog(GetString("Synchronization.RunningTasks"));

        if (action == SYNCHRONIZE_CURRENT)
        {
            // Run sync for the current node only
            result = StagingTaskRunner.RunSynchronization(currentNodeUpdateTask.Select(t => t.TaskID));
        }
        else
        {
            // Get all tasks for given path, depends on the sync action and run them
            string  path = action == SYNCHRONIZE_COMPLETE ? "/" : aliasPath;
            DataSet ds   = StagingTaskInfoProvider.SelectDocumentTaskList(CurrentSiteID, SelectedServerID, path, null, "TaskID", -1, "TaskID");
            result = StagingTaskRunner.RunSynchronization(ds);
        }
        return(result);
    }
示例#28
0
 /// <summary>
 /// Ensures that StagingTaskGroupMenu control is inserted correctly into the header.
 /// </summary>
 private void EnsureStagingTaskGroupMenu()
 {
     if (StagingTaskInfoProvider.LoggingOfStagingTasksEnabled(SiteContext.CurrentSiteName))
     {
         CMSUserControl stagingTaskGroupMenu = Page.LoadUserControl("~/CMSAdminControls/UI/StagingTaskGroupMenu.ascx") as CMSUserControl;
         if (stagingTaskGroupMenu != null)
         {
             plcStagingTaskGroupContainer.Visible = true;
             plcStagingTaskGroup.Controls.Add(stagingTaskGroupMenu);
             plcStagingTaskGroup.Visible = true;
         }
     }
 }
示例#29
0
    protected DataSet gridTasks_OnDataReload(string completeWhere, string currentOrder, int currentTopN, string columns, int currentOffset, int currentPageSize, ref int totalRecords)
    {
        // Get the tasks
        string where = GetSiteWhere();
        WhereCondition mergedWhere = new WhereCondition(completeWhere).And().Where(where);

        var tasksQuery = StagingTaskInfoProvider.SelectObjectTaskList(CurrentSiteID, SelectedServerID, objectType, mergedWhere.ToString(true), currentOrder, currentTopN, columns, currentOffset, currentPageSize);
        var result     = tasksQuery.Result;

        totalRecords = tasksQuery.TotalRecords;

        return(result);
    }
        /// <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 = ServerInfoProvider.GetServers().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
                };
                StagingTaskInfoProvider.SetTaskInfo(Task);

                foreach (ServerInfo ServerObj in ActiveServers)
                {
                    // Create synchronization
                    SynchronizationInfo SyncInfo = new SynchronizationInfo()
                    {
                        SynchronizationTaskID   = Task.TaskID,
                        SynchronizationServerID = ServerObj.ServerID
                    };
                    SynchronizationInfoProvider.SetSynchronizationInfo(SyncInfo);
                }

                TaskGroupInfo TaskGroup = TaskGroupInfoProvider.GetUserTaskGroupInfo(MembershipContext.AuthenticatedUser.UserID);
                if (TaskGroup != null)
                {
                    TaskGroupTaskInfoProvider.AddTaskGroupToTask(TaskGroup.TaskGroupID, Task.TaskID);
                }
            }
        }