Ejemplo n.º 1
0
        /// <summary>
        /// Retrieves a collection of open tasks assigned to the user
        /// </summary>
        /// <param name="User">The User who have the tasks assigned</param>
        /// <param name="IncludeClosed">If true both open and closed tasks will be returned</param>
        /// <returns>A collections of tasks</returns>
        public static Tasks GetOwnedTasks(User User, bool IncludeClosed)
        {
            string sql = "select id, taskTypeId, nodeId, parentUserId, userId, DateTime, comment, closed from cmsTask where parentUserId = @userId";

            if (!IncludeClosed)
            {
                sql += " and closed = 0";
            }
            sql += " order by DateTime desc";

            Tasks tasks = new Tasks();

            using (IRecordsReader dr = SqlHelper.ExecuteReader(
                       sql,
                       SqlHelper.CreateParameter("@userId", User.Id))) {
                while (dr.Read())
                {
                    var t = new Task();
                    t.PopulateTaskFromReader(dr);
                    tasks.Add(t);
                }
            }

            return(tasks);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Retrieves a collection of open tasks assigned to the user
        /// </summary>
        /// <param name="User">The User who have the tasks assigned</param>
        /// <param name="IncludeClosed">If true both open and closed tasks will be returned</param>
        /// <returns>A collections of tasks</returns>
        public static Tasks GetOwnedTasks(User User, bool IncludeClosed)
        {
            var result = new Tasks();
            var tasks  = ApplicationContext.Current.Services.TaskService.GetTasks(ownerUser: User.Id, includeClosed: IncludeClosed);

            foreach (var task in tasks)
            {
                result.Add(new Task(task));
            }
            return(result);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Get all tasks assigned to a node
        /// </summary>
        /// <param name="nodeId"></param>
        /// <returns></returns>
        public static Tasks GetTasks(int nodeId)
        {
            var result = new Tasks();
            var tasks  = ApplicationContext.Current.Services.TaskService.GetTasks(itemId: nodeId);

            foreach (var task in tasks)
            {
                result.Add(new Task(task));
            }

            return(result);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Get all tasks assigned to a node
        /// </summary>
        /// <param name="nodeId"></param>
        /// <returns></returns>
        public static Tasks GetTasks(int nodeId)
        {
            var   sql   = "select id, taskTypeId, nodeId, parentUserId, userId, DateTime, comment, closed from cmsTask where nodeId = @nodeId";
            Tasks tasks = new Tasks();

            using (IRecordsReader dr = SqlHelper.ExecuteReader(sql, SqlHelper.CreateParameter("@nodeId", nodeId)))
            {
                while (dr.Read())
                {
                    var t = new Task();
                    t.PopulateTaskFromReader(dr);
                    tasks.Add(t);
                }
            }

            return(tasks);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Returns all tasks by type
        /// </summary>
        /// <param name="taskType"></param>
        /// <returns></returns>
        public static Tasks GetTasksByType(int taskType)
        {
            var foundTaskType = ApplicationContext.Current.Services.TaskService.GetTaskTypeById(taskType);

            if (foundTaskType == null)
            {
                return(null);
            }

            var result = new Tasks();
            var tasks  = ApplicationContext.Current.Services.TaskService.GetTasks(taskTypeAlias: foundTaskType.Alias);

            foreach (var task in tasks)
            {
                result.Add(new Task(task));
            }

            return(result);
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Retrieves a collection of open tasks assigned to the user
        /// </summary>
        /// <param name="User">The User who have the tasks assigned</param>
        /// <param name="IncludeClosed">If true both open and closed tasks will be returned</param>
        /// <returns>A collections of tasks</returns>
        public static Tasks GetOwnedTasks(User User, bool IncludeClosed) {
            string sql = "select id, taskTypeId, nodeId, parentUserId, userId, DateTime, comment, closed from cmsTask where parentUserId = @userId";
            if (!IncludeClosed)
                sql += " and closed = 0";
            sql += " order by DateTime desc";

            Tasks tasks = new Tasks();
            using (IRecordsReader dr = SqlHelper.ExecuteReader(
                sql,
                SqlHelper.CreateParameter("@userId", User.Id))) {
                    while (dr.Read())
                    {
                        var t = new Task();
                        t.PopulateTaskFromReader(dr);
                        tasks.Add(t);
                    }   
            }

            return tasks;
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Get all tasks assigned to a node
        /// </summary>
        /// <param name="nodeId"></param>
        /// <returns></returns>
        public static Tasks GetTasks(int nodeId)
        {
            var sql = "select id, taskTypeId, nodeId, parentUserId, userId, DateTime, comment, closed from cmsTask where nodeId = @nodeId";
            Tasks tasks = new Tasks();
            using (IRecordsReader dr = SqlHelper.ExecuteReader(sql, SqlHelper.CreateParameter("@nodeId", nodeId)))
            {
                while (dr.Read())
                {
                    var t = new Task();
                    t.PopulateTaskFromReader(dr);
                    tasks.Add(t);
                }                    
            }

            return tasks;
        }