示例#1
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);
    }
示例#2
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);
    }
示例#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
    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);
    }
示例#5
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));
    }
    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);
    }
示例#7
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);
    }
示例#8
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);
    }
示例#9
0
    /// <summary>
    /// All items synchronization.
    /// </summary>
    protected void SynchronizeAll(object parameter)
    {
        string result = string.Empty;

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

            // Get the tasks
            DataSet ds = StagingTaskInfoProvider.SelectTaskList(currentSiteId, serverId, null, "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);
            }
            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();
        }
    }
示例#10
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);
    }
示例#11
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();
        }
    }
示例#12
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);
    }
示例#13
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);
    }
示例#14
0
        /// <inheritdoc/>
        public void DeleteStagingTask(IServer server)
        {
            // Gets the 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);

                // Loops through individual staging tasks
                foreach (StagingTaskInfo task in tasks)
                {
                    // Deletes the staging task
                    StagingTaskInfoProvider.DeleteTaskInfo(task);
                }
            }
        }