Beispiel #1
0
    /// <summary>
    /// Adds  specific conditions to the list where condition.
    /// </summary>
    string ucTaskList_BuildCondition(object sender, string whereCondition)
    {
        CurrentUserInfo currentUser = CMSContext.CurrentUser;

        // Display onlyt task assigned to me
        whereCondition = SqlHelperClass.AddWhereCondition(whereCondition, "ProjectTaskAssignedToUserID = " + currentUser.UserID);

        // Add security condition - display only tasks which are assigned or owned by the current user or which are a part of a project where the current user is authorised to Read from
        whereCondition = SqlHelperClass.AddWhereCondition(whereCondition, ProjectTaskInfoProvider.CombineSecurityWhereCondition(whereCondition, currentUser, null));

        return(whereCondition);
    }
Beispiel #2
0
    /// <summary>
    /// Adds  specific conditions to the list where condition.
    /// </summary>
    private string ucTaskList_BuildCondition(object sender, string whereCondition)
    {
        var currentUser = MembershipContext.AuthenticatedUser;

        // Display onlyt task assigned to me
        whereCondition = SqlHelper.AddWhereCondition(whereCondition, "ProjectTaskOwnerID = " + currentUser.UserID);

        // Add security condition - display only tasks which are assigned or owned by the current user or which are a part of a project where the current user is authorised to Read from
        whereCondition = SqlHelper.AddWhereCondition(whereCondition, ProjectTaskInfoProvider.CombineSecurityWhereCondition(whereCondition, currentUser, null));

        return(whereCondition);
    }
Beispiel #3
0
    /// <summary>
    /// Build list where condition.
    /// </summary>
    string ucTaskList_BuildCondition(object sender, string whereCondition)
    {
        // Keep current user
        CurrentUserInfo currentUser = CMSContext.CurrentUser;

        // Switch by display type
        switch (this.TasksDisplayType)
        {
        // Tasks owned by me
        case TasksDisplayTypeEnum.TasksOwnedByMe:
            whereCondition = SqlHelperClass.AddWhereCondition(whereCondition, "ProjectTaskOwnerID = " + currentUser.UserID);
            break;

        // Tasks assigned to me
        case TasksDisplayTypeEnum.TasksAssignedToMe:
            whereCondition = SqlHelperClass.AddWhereCondition(whereCondition, "ProjectTaskAssignedToUserID = " + currentUser.UserID);
            break;

        // Project tasks
        case TasksDisplayTypeEnum.ProjectTasks:
            // Check whether project names are defined
            if (!String.IsNullOrEmpty(ProjectNames))
            {
                string condition = SqlHelperClass.GetSafeQueryString(ProjectNames, false);
                condition = "N'" + condition.Replace(";", "',N'") + "'";
                // Add condition for specified projects
                condition = "ProjectTaskProjectID IN (SELECT ProjectID FROM PM_Project WHERE ProjectName IN (" + condition + "))";

                // Add condition for private task, only if current user isn't project management admin
                if (!currentUser.IsAuthorizedPerResource("CMS.ProjectManagement", CMSAdminControl.PERMISSION_MANAGE))
                {
                    condition = SqlHelperClass.AddWhereCondition(condition, "(ProjectTaskIsPrivate = 0 OR ProjectTaskIsPrivate IS NULL) OR (ProjectTaskOwnerID = " + currentUser.UserID + " OR ProjectTaskAssignedToUserID = " + currentUser.UserID + " OR ProjectOwner = " + currentUser.UserID + ")");
                }

                // Complete where condition
                whereCondition = SqlHelperClass.AddWhereCondition(whereCondition, condition);
            }
            // If project names aren't defined do nothing
            else
            {
                whereCondition = "(1=2)";
            }
            break;
        }

        // Do not dsiplay finished tasks
        if (!ShowFinishedTasks)
        {
            whereCondition = SqlHelperClass.AddWhereCondition(whereCondition, "TaskStatusIsFinished = 0");
        }

        // Do not display on time tasks
        if (!ShowOnTimeTasks)
        {
            whereCondition = SqlHelperClass.AddWhereCondition(whereCondition, "((ProjectTaskDeadline < @Now) OR (ProjectTaskDeadline IS NULL))");
        }

        // Do not display overdue tasks
        if (!ShowOverdueTasks)
        {
            whereCondition = SqlHelperClass.AddWhereCondition(whereCondition, "((ProjectTaskDeadline > @Now) OR (ProjectTaskDeadline IS NULL))");
        }

        // Do not display private tasks
        if (!ShowPrivateTasks)
        {
            whereCondition = SqlHelperClass.AddWhereCondition(whereCondition, "ProjectTaskIsPrivate = 0");
        }

        // Task assigned to me, Task owned by me webparts
        object[,] projectParameters = null;
        if ((!ShowOnTimeTasks) || (!ShowOverdueTasks))
        {
            projectParameters       = new object[1, 3];
            projectParameters[0, 0] = "@Now";
            projectParameters[0, 1] = DateTime.Now;

            this.ucTaskList.Grid.QueryParameters = QueryDataParameters.FromArray(projectParameters);
        }

        // Add security condition - display only tasks which are assigned or owned by the current user or which are a part of a project where the current user is authorised to Read from
        whereCondition = SqlHelperClass.AddWhereCondition(whereCondition, ProjectTaskInfoProvider.CombineSecurityWhereCondition(whereCondition, currentUser, SiteName));

        return(whereCondition);
    }