예제 #1
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);
    }
예제 #2
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);
    }
예제 #3
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);
    }
예제 #4
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);
    }
예제 #5
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
        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);
    }
예제 #7
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);
    }
예제 #8
0
    private string SynchronizeAllInternal()
    {
        AddLog(GetString("Synchronization.RunningTasks"));

        // Get the tasks
        string where = new WhereCondition()
                       .Where(GetSiteWhere())
                       .And()
                       .Where(gridTasks.CustomFilter.WhereCondition)
                       .ToString(true);

        DataSet ds = StagingTaskInfoProvider.SelectObjectTaskList(CurrentSiteID, SelectedServerID, objectType, @where, "TaskID", -1, "TaskID");

        // Run the synchronization
        return(StagingTaskRunner.RunSynchronization(ds));
    }
예제 #9
0
    private string DeleteAllInternal()
    {
        AddLog(GetString("Synchronization.DeletingTasks"));

        // Process all records
        var where = new WhereCondition()
                    .Where(GetSiteWhere())
                    .And()
                    .Where(gridTasks.CustomFilter.WhereCondition)
                    .ToString(true);

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

        DeleteTasks(ds);

        return(null);
    }
예제 #10
0
    private string SynchronizeAllInternal()
    {
        string where = new WhereCondition()
                       .Where(GetAllTasksWhere())
                       .And()
                       .Where(gridTasks.CustomFilter.WhereCondition)
                       .ToString(true);

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

        // Get the tasks
        DataSet ds = StagingTaskInfoProvider.SelectObjectTaskList(CurrentSiteID, SelectedServerID, objectType, where, "TaskID", -1, "TaskID,TaskTitle");

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

        return(result);
    }
예제 #11
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));

                // Scheduled tasks have disabled staging, they have to be dealt in extra manner
                if (syncType.Equals(TaskInfo.OBJECT_TYPE, StringComparison.InvariantCultureIgnoreCase))
                {
                    CreateStagingTasksForScheduledTasks(synchronizedSiteId, CurrentSiteID);
                }
                else
                {
                    // 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);
    }
예제 #12
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 = "TaskSiteID IS NULL";
        string classWhere = string.Empty;

        // Ensure only data task selection
        if (string.IsNullOrEmpty(objectType))
        {
            DataSet dsTables = CustomTableHelper.GetCustomTableClasses(currentSiteId).Column("ClassName");
            if (!DataHelper.DataSourceIsEmpty(dsTables))
            {
                foreach (DataRow dr in dsTables.Tables[0].Rows)
                {
                    classWhere += "N'" + SqlHelper.EscapeQuotes(CustomTableItemProvider.GetObjectType(dr["ClassName"].ToString())) + "',";
                }
                classWhere = classWhere.TrimEnd(new [] { ',' });
            }
            where = SqlHelper.AddWhereCondition(where, "TaskObjectType IN (" + classWhere + ")");
        }

        DataSet ds = null;

        // There are some custom tables assigned to the site, get the data
        if (!string.IsNullOrEmpty(classWhere) || !string.IsNullOrEmpty(objectType))
        {
            ds = StagingTaskInfoProvider.SelectObjectTaskList(currentSiteId, serverId, objectType, where, currentOrder, 0, columns, currentOffset, currentPageSize, ref totalRecords);
        }
        else
        {
            totalRecords = -1;
        }

        pnlFooter.Visible = (totalRecords > 0);
        return(ds);
    }
예제 #13
0
    /// <summary>
    /// Deletes all tasks.
    /// </summary>
    protected void DeleteAll(object parameter)
    {
        eventCode      = "DELETEALLOBJECTS";
        CanceledString = GetString("Tasks.DeletionCanceled");
        try
        {
            AddLog(GetString("Synchronization.DeletingTasks"));

            // Process all records
            string where = null;
            if (siteId > 0)
            {
                where = "TaskSiteID = " + siteId;
            }
            else if (siteId == 0)
            {
                where = "TaskSiteID IS NULL OR TaskType IN (N'" + TaskTypeEnum.AddToSite + "', N'" + TaskTypeEnum.RemoveFromSite + "')";
            }

            // Get the tasks
            DataSet ds = StagingTaskInfoProvider.SelectObjectTaskList(currentSiteId, serverId, objectType, where, "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();
        }
    }
예제 #14
0
 private DataSet GetStagingDataTasks()
 {
     return(StagingTaskInfoProvider.SelectObjectTaskList(CurrentSiteID, SelectedServerID, objectType, BASE_TASK_WHERE, "TaskID", -1, "TaskID"));
 }
예제 #15
0
    /// <summary>
    /// Deletes all tasks.
    /// </summary>
    protected void DeleteAll(object parameter)
    {
        eventCode      = "DELETEALLDATA";
        CanceledString = GetString("Tasks.DeletionCanceled");
        try
        {
            AddLog(GetString("Synchronization.DeletingTasks"));

            string where = "TaskSiteID IS NULL";
            string classWhere = string.Empty;

            // Ensure only data task selection
            if (string.IsNullOrEmpty(objectType))
            {
                DataSet dsTables = CustomTableHelper.GetCustomTableClasses(currentSiteId).Column("ClassName");
                if (!DataHelper.DataSourceIsEmpty(dsTables))
                {
                    foreach (DataRow dr in dsTables.Tables[0].Rows)
                    {
                        classWhere += "N'" + SqlHelper.EscapeQuotes(CustomTableItemProvider.GetObjectType(dr["ClassName"].ToString())) + "',";
                    }
                    classWhere = classWhere.TrimEnd(new char[] { ',' });
                }
                where = SqlHelper.AddWhereCondition(where, "TaskObjectType IN (" + classWhere + ")");
            }

            // Get the tasks
            DataSet ds = StagingTaskInfoProvider.SelectObjectTaskList(currentSiteId, serverId, objectType, where, "TaskID", 0, "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();
        }
    }
예제 #16
0
    /// <summary>
    /// All items synchronization.
    /// </summary>
    protected void SynchronizeAll(object parameter)
    {
        string result = string.Empty;

        eventCode      = "SYNCALLDATA";
        CanceledString = GetString("Tasks.SynchronizationCanceled");
        try
        {
            string where = "TaskSiteID IS NULL";
            string classWhere = string.Empty;

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

            // Ensure only data task selection
            if (string.IsNullOrEmpty(objectType))
            {
                DataSet dsTables = CustomTableHelper.GetCustomTableClasses(currentSiteId).Column("ClassName");
                if (!DataHelper.DataSourceIsEmpty(dsTables))
                {
                    foreach (DataRow dr in dsTables.Tables[0].Rows)
                    {
                        classWhere += "N'" + SqlHelper.EscapeQuotes(CustomTableItemProvider.GetObjectType(dr["ClassName"].ToString())) + "',";
                    }
                    classWhere = classWhere.TrimEnd(new [] { ',' });
                }
                where = SqlHelper.AddWhereCondition(where, "TaskObjectType IN (" + classWhere + ")");
            }

            // Get the tasks
            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 error
            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();
        }
    }