Esempio n. 1
0
 public IList <object[]> BuildUsersWorkload(TaskFilter filter)
 {
     return(TaskEngine.GetByFilterCountForStatistic(filter).Select(r => new object[]
     {
         r.UserId, 0, r.TasksOpen, r.TasksClosed
     }).ToList());
 }
Esempio n. 2
0
        public virtual void Delete(int projectId)
        {
            var project = GetByID(projectId);

            if (project == null)
            {
                return;
            }

            ProjectSecurity.DemandEdit(project);

            FileEngine.RemoveRoot(projectId);

            List <int> messages, tasks;

            DaoFactory.ProjectDao.Delete(projectId, out messages, out tasks);

            NotifyClient.Instance.SendAboutProjectDeleting(new HashSet <Guid> {
                project.Responsible
            }, project);

            MessageEngine.UnSubscribeAll(messages.Select(r => new Message {
                Project = project, ID = r
            }).ToList());
            TaskEngine.UnSubscribeAll(tasks.Select(r => new Task {
                Project = project, ID = r
            }).ToList());
        }
Esempio n. 3
0
 public SubtaskEngine(IDaoFactory daoFactory, EngineFactory factory)
     : base(NotifyConstants.Event_NewCommentForTask, factory)
 {
     this.factory = factory;
     subtaskDao   = daoFactory.GetSubtaskDao();
     taskDao      = daoFactory.GetTaskDao();
     taskEngine   = factory.TaskEngine;
 }
Esempio n. 4
0
 public SubtaskEngine(IDaoFactory daoFactory, EngineFactory factory)
     : base(NotifyConstants.Event_NewCommentForTask, factory)
 {
     this.factory = factory;
     subtaskDao = daoFactory.GetSubtaskDao();
     taskDao = daoFactory.GetTaskDao();
     taskEngine = factory.GetTaskEngine();
 }
        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);
        }
Esempio n. 6
0
        public IList <object[]> BuildUsersWorkload(TaskFilter filter)
        {
            if (filter.ViewType == 0)
            {
                return(TaskEngine.GetByFilterCountForStatistic(filter).Select(r => new object[]
                {
                    DisplayUserSettings.GetFullUserName(CoreContext.UserManager.GetUsers(r.UserId), false), r.TasksOpen, r.TasksClosed, r.TasksTotal,
                    CoreContext.UserManager.GetUserGroups(r.UserId).Select(x => x.Name)
                }).ToList());
            }

            var tasks    = TaskEngine.GetByFilter(filter).FilterResult;
            var projects = tasks.Select(r => r.Project).Distinct();

            var result = new List <object[]>();

            foreach (var pr in projects)
            {
                var prTasks = tasks.Where(r => r.Project.ID == pr.ID && r.Responsibles.Count > 0).ToList();
                if (!prTasks.Any())
                {
                    continue;
                }

                var users = filter.ParticipantId.HasValue ? new List <Guid> {
                    filter.ParticipantId.Value
                } : prTasks.SelectMany(r => r.Responsibles).Distinct();

                var usersResult = new List <object[]>();
                foreach (var user in users)
                {
                    var tasksOpened = prTasks.Count(r => r.Responsibles.Contains(user) && r.Status == TaskStatus.Open);
                    var tasksClosed = prTasks.Count(r => r.Responsibles.Contains(user) && r.Status == TaskStatus.Closed);

                    usersResult.Add(new object[] {
                        DisplayUserSettings.GetFullUserName(CoreContext.UserManager.GetUsers(user), false),
                        tasksOpened,
                        tasksClosed,
                        tasksOpened + tasksClosed
                    });
                }

                result.Add(new object[] { pr.Title, usersResult });
            }

            return(result);
        }
Esempio n. 7
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());
        }
Esempio n. 8
0
        public IList <object[]> BuildUsersActivityReport(TaskFilter filter)
        {
            var result     = new List <object[]>();
            var tasks      = TaskEngine.GetByFilterCountForReport(filter);
            var milestones = MilestoneEngine.GetByFilterCountForReport(filter);
            var messages   = MessageEngine.GetByFilterCountForReport(filter);

            var userIds = tasks.Select(r => r.Key).ToList();

            userIds.AddRange(milestones.Select(r => r.Key).ToList());
            userIds.AddRange(messages.Select(r => r.Key).ToList());

            userIds = userIds.Distinct().ToList();

            foreach (var userId in userIds)
            {
                int tasksCount;
                if (!tasks.TryGetValue(userId, out tasksCount))
                {
                    tasksCount = 0;
                }

                int milestonesCount;
                if (!milestones.TryGetValue(userId, out milestonesCount))
                {
                    milestonesCount = 0;
                }

                int messagesCount;
                if (!messages.TryGetValue(userId, out messagesCount))
                {
                    messagesCount = 0;
                }

                result.Add(new object[] { userId, tasksCount, milestonesCount, messagesCount, 0, tasksCount + milestonesCount + messagesCount });
            }

            return(result);
        }
Esempio n. 9
0
        public Project GetFullProjectByID(int projectID)
        {
            var project = DaoFactory.ProjectDao.GetById(projectID);

            if (!CanRead(project))
            {
                return(null);
            }

            var filter = new TaskFilter
            {
                ProjectIds = new List <int> {
                    projectID
                },
                MilestoneStatuses = new List <MilestoneStatus> {
                    MilestoneStatus.Open
                }
            };
            var taskCount = TaskEngine.GetByFilterCount(filter);

            project.MilestoneCount  = MilestoneEngine.GetByFilterCount(filter);
            project.TaskCount       = taskCount.TasksOpen;
            project.TaskCountTotal  = taskCount.TasksTotal;
            project.DiscussionCount = MessageEngine.GetByFilterCount(filter);

            using (var folderDao = FilesIntegration.GetFolderDao())
            {
                var folderId = FileEngine.GetRoot(projectID);
                project.DocumentsCount = folderDao.GetItemsCount(folderId);
            }

            project.TimeTrackingTotal = TimeTrackingEngine.GetTotalByProject(projectID);
            project.ParticipantCount  = GetTeam(projectID).Count();


            return(project);
        }
Esempio n. 10
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);
        }
Esempio n. 11
0
 public SearchEngine(EngineFactory factory)
 {
     searchItems   = new List <SearchItem>();
     CommentEngine = factory.CommentEngine;
     TaskEngine    = factory.TaskEngine;
 }