Exemple #1
0
        public List <Message> GetByFilter(TaskFilter filter)
        {
            var isAdmin = ProjectSecurity.IsAdministrator(SecurityContext.CurrentAccount.ID);

            var messages = messageDao.GetByFilter(filter, isAdmin);

            var commentsCount = commentDao.GetCommentsCount(messages.Select(r => (ProjectEntity)r).ToList());

            return(messages.Select((message, index) =>
            {
                message.CommentsCount = commentsCount[index];
                return message;
            }).ToList());
        }
        public List <Milestone> GetByFilter(TaskFilter filter)
        {
            var listMilestones = new List <Milestone>();

            var isAdmin = ProjectSecurity.IsAdministrator(SecurityContext.CurrentAccount.ID);

            while (true)
            {
                var milestones = _milestoneDao.GetByFilter(filter, isAdmin);

                if (filter.LastId != 0)
                {
                    var lastMilestoneIndex = milestones.FindIndex(r => r.ID == filter.LastId);

                    if (lastMilestoneIndex >= 0)
                    {
                        milestones = milestones.SkipWhile((r, index) => index <= lastMilestoneIndex).ToList();
                    }
                }

                listMilestones.AddRange(milestones);

                if (filter.Max <= 0 || filter.Max > 150000)
                {
                    break;
                }

                listMilestones = listMilestones.Take((int)filter.Max).ToList();

                if (listMilestones.Count == filter.Max || milestones.Count == 0)
                {
                    break;
                }

                if (listMilestones.Count != 0)
                {
                    filter.LastId = listMilestones.Last().ID;
                }

                filter.Offset += filter.Max;
            }

            return(listMilestones);
        }
        public TaskFilterOperationResult GetByFilter(TaskFilter filter)
        {
            if (filter.Offset < 0 || filter.Max < 0)
            {
                return(null);
            }

            var isAdmin = ProjectSecurity.IsAdministrator(SecurityContext.CurrentAccount.ID);
            var anyOne  = ProjectSecurity.IsPrivateDisabled;
            var count   = taskDao.GetByFilterCount(filter, isAdmin, anyOne);

            var filterLimit  = filter.Max;
            var filterOffset = filter.Offset;

            if (filterOffset > count.TasksTotal)
            {
                return(new TaskFilterOperationResult(count)); //there are some records but we cant see them due to offset
            }
            var taskList = new List <Task>();

            if (filter.HasTaskStatuses)
            {
                taskList = taskDao.GetByFilter(filter, isAdmin, anyOne);
            }
            else if (filterOffset > count.TasksOpen && count.TasksClosed != 0)
            {
                filter.TaskStatuses.Add(TaskStatus.Closed);
                filter.Offset = filterOffset - count.TasksOpen;
                taskList      = taskDao.GetByFilter(filter, isAdmin, anyOne);
            }
            else
            {
                //TODO: to one sql query using UNION ALL
                if (count.TasksOpen != 0)
                {
                    filter.TaskStatuses.Add(TaskStatus.Open);
                    taskList = taskDao.GetByFilter(filter, isAdmin, anyOne);
                }

                if (taskList.Count < filterLimit && count.TasksClosed != 0)
                {
                    filter.TaskStatuses.Clear();
                    filter.TaskStatuses.Add(TaskStatus.Closed);
                    filter.Offset = 0;
                    filter.Max    = filterLimit - taskList.Count;
                    taskList.AddRange(taskDao.GetByFilter(filter, isAdmin, anyOne));
                }
            }

            filter.Offset = filterOffset;
            filter.Max    = filterLimit;
            filter.TaskStatuses.Clear();

            subtaskDao.GetSubtasks(ref taskList);

            var taskLinks = taskDao.GetLinks(taskList).ToList();

            taskList = taskList.GroupJoin(taskLinks, task => task.ID, link => link.DependenceTaskId, (task, linksCol) =>
            {
                task.Links.AddRange(linksCol);
                return(task);
            }).ToList();

            taskList = taskList.GroupJoin(taskLinks, task => task.ID, link => link.ParentTaskId, (task, linksCol) =>
            {
                task.Links.AddRange(linksCol);
                return(task);
            }).ToList();

            return(new TaskFilterOperationResult(taskList, count));
        }
        public int GetByFilterCount(TaskFilter filter)
        {
            var isAdmin = ProjectSecurity.IsAdministrator(SecurityContext.CurrentAccount.ID);

            return(_milestoneDao.GetByFilterCount(filter, isAdmin));
        }
Exemple #5
0
        public int GetByFilterCount(TaskFilter filter)
        {
            var isAdmin = ProjectSecurity.IsAdministrator(SecurityContext.CurrentAccount.ID);

            return(taskDao.GetByFilterCount(filter, isAdmin).TasksTotal);
        }
Exemple #6
0
        public virtual List <Project> GetByFilter(TaskFilter filter)
        {
            var isAdmin = ProjectSecurity.IsAdministrator(SecurityContext.CurrentAccount.ID);

            return(projectDao.GetByFilter(filter, isAdmin));
        }
Exemple #7
0
        public virtual List <int> GetTaskCount(List <int> projectId, TaskStatus?taskStatus)
        {
            var isAdmin = ProjectSecurity.IsAdministrator(SecurityContext.CurrentAccount.ID);

            return(projectDao.GetTaskCount(projectId, taskStatus, isAdmin));
        }