public IList <object[]> BuildUsersActivity(TaskFilter filter)
        {
            var result     = new List <object[]>();
            var tasks      = TaskEngine.GetByFilterCountForReport(filter);
            var milestones = MilestoneEngine.GetByFilterCountForReport(filter);
            var messages   = MessageEngine.GetByFilterCountForReport(filter);

            if (filter.ViewType == 1)
            {
                var projectIds = GetProjects(tasks, milestones, messages);
                var projects   = ProjectEngine.GetByID(projectIds).ToList();

                foreach (var p in projects)
                {
                    var userIds = GetUsers(p.ID, tasks, milestones, messages);

                    foreach (var userId in userIds)
                    {
                        var userName        = CoreContext.UserManager.GetUsers(userId).DisplayUserName();
                        var tasksCount      = GetCount(tasks, p.ID, userId);
                        var milestonesCount = GetCount(milestones, p.ID, userId);
                        var messagesCount   = GetCount(messages, p.ID, userId);

                        result.Add(new object[]
                        {
                            p.ID, p.Title, userName, tasksCount, milestonesCount, messagesCount,
                            tasksCount + milestonesCount + messagesCount
                        });
                    }
                }
            }
            else
            {
                var userIds = GetUsers(-1, tasks, milestones, messages);

                foreach (var userId in userIds)
                {
                    var group    = CoreContext.UserManager.GetUserGroups(userId).FirstOrDefault();
                    var userName = CoreContext.UserManager.GetUsers(userId).DisplayUserName();

                    var tasksCount      = GetCount(tasks, userId);
                    var milestonesCount = GetCount(milestones, userId);
                    var messagesCount   = GetCount(messages, userId);

                    result.Add(new object[]
                    {
                        group != null ? group.ID : Guid.Empty,
                        group != null ? group.Name : "", userName,
                        tasksCount,
                        milestonesCount,
                        messagesCount,
                        tasksCount + milestonesCount + messagesCount
                    });
                }
            }

            return(result);
        }
示例#2
0
        public IList <object[]> BuildUsersWithoutActiveTasks(TaskFilter filter)
        {
            var result = new List <object[]>();

            var users = new List <Guid>();

            if (filter.UserId != Guid.Empty)
            {
                users.Add(filter.UserId);
            }
            else if (filter.DepartmentId != Guid.Empty)
            {
                users.AddRange(CoreContext.UserManager.GetUsersByGroup(filter.DepartmentId).Select(u => u.ID));
            }
            else if (filter.HasProjectIds)
            {
                users.AddRange(ProjectEngine.GetTeam(filter.ProjectIds).Select(r => r.ID).Distinct());
            }
            else if (!filter.HasProjectIds)
            {
                users.AddRange(ProjectEngine.GetTeam(ProjectEngine.GetAll().Select(r => r.ID).ToList()).Select(r => r.ID).Distinct());
            }

            var data = TaskEngine.GetByFilterCountForStatistic(filter);

            foreach (var row in data)
            {
                users.Remove(row.UserId);
                if (row.TasksOpen == 0)
                {
                    result.Add(new object[]
                    {
                        row.UserId, 0, row.TasksOpen, row.TasksClosed
                    });
                }
            }
            result.AddRange(users.Select(u => new object[] { u, 0, 0, 0 }));

            return(result.Select(x => new[] { DisplayUserSettings.GetFullUserName(CoreContext.UserManager.GetUsers((Guid)x[0]), false), x[2], x[3] }).ToList());
        }
示例#3
0
        public IList <object[]> BuildUsersActivity(TaskFilter filter)
        {
            var result     = new List <object[]>();
            var tasks      = TaskEngine.GetByFilterCountForReport(filter);
            var milestones = MilestoneEngine.GetByFilterCountForReport(filter);
            var messages   = MessageEngine.GetByFilterCountForReport(filter);

            List <Tuple <Guid, int, int> > averageTasks    = null;
            List <Tuple <Guid, int> >      averageProjects = null;

            if (filter.IsShowAverageTime)
            {
                if (filter.TypeOfShowAverageTime == AverageTime.All || filter.TypeOfShowAverageTime == AverageTime.ClosingProjects)
                {
                    averageProjects = ProjectEngine.GetByFilterAverageTime(filter);
                }
                if (filter.TypeOfShowAverageTime == AverageTime.All || filter.TypeOfShowAverageTime == AverageTime.CompletingTasks)
                {
                    averageTasks = TaskEngine.GetByFilterAverageTime(filter);
                }
            }

            if (filter.ViewType == 1)
            {
                var projectIds = GetProjects(tasks, milestones, messages);
                var projects   = ProjectEngine.GetByID(projectIds).ToList();

                foreach (var p in projects)
                {
                    var userIds = GetUsers(p.ID, tasks, milestones, messages, averageTasks);

                    foreach (var userId in userIds)
                    {
                        var userName        = CoreContext.UserManager.GetUsers(userId).DisplayUserName();
                        var tasksCount      = GetCount(tasks, p.ID, userId);
                        var milestonesCount = GetCount(milestones, p.ID, userId);
                        var messagesCount   = GetCount(messages, p.ID, userId);

                        var avgTasks = -1;
                        if (averageTasks != null)
                        {
                            if (averageTasks.Where(r => r.Item2 == p.ID && r.Item1 == userId).Any())
                            {
                                avgTasks = averageTasks.FirstOrDefault(r => r.Item2 == p.ID && r.Item1 == userId).Item3;
                            }
                            else
                            {
                                avgTasks = -2;
                            }
                        }

                        result.Add(new object[]
                        {
                            p.ID,
                            p.Title,
                            userName,
                            tasksCount,
                            milestonesCount,
                            messagesCount,
                            tasksCount + milestonesCount + messagesCount,
                            avgTasks
                        });
                    }
                }
            }
            else
            {
                var userIds = GetUsers(-1, tasks, milestones, messages);
                if (averageProjects != null)
                {
                    userIds.AddRange(averageProjects.Select(r => r.Item1));
                    userIds = userIds.Distinct().ToList();
                }
                foreach (var userId in userIds)
                {
                    var group    = CoreContext.UserManager.GetUserGroups(userId).FirstOrDefault();
                    var userName = CoreContext.UserManager.GetUsers(userId).DisplayUserName();

                    var tasksCount      = GetCount(tasks, userId);
                    var milestonesCount = GetCount(milestones, userId);
                    var messagesCount   = GetCount(messages, userId);

                    var avgTasks   = -1;
                    var avgProject = -1;
                    if (averageTasks != null)
                    {
                        if (averageTasks.Where(r => r.Item1 == userId).Any())
                        {
                            avgTasks = averageTasks.Where(r => r.Item1 == userId).Sum(r => r.Item3) / averageTasks.Where(r => r.Item1 == userId).Count();
                        }
                        else
                        {
                            avgTasks = -2;
                        }
                    }
                    if (averageProjects != null)
                    {
                        if (averageProjects.Where(r => r.Item1 == userId).Any())
                        {
                            avgProject = averageProjects.FirstOrDefault(r => r.Item1 == userId).Item2;
                        }
                        else
                        {
                            avgProject = -2;
                        }
                    }


                    result.Add(new object[]
                    {
                        group != null ? group.ID : Guid.Empty,
                        group != null ? group.Name : "",
                        userName,
                        tasksCount,
                        milestonesCount,
                        messagesCount,
                        tasksCount + milestonesCount + messagesCount,
                        avgProject,
                        avgTasks
                    });
                }
            }

            return(result);
        }