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()); }
public ReportEngine(EngineFactory factory) { ProjectEngine = factory.ProjectEngine; TaskEngine = factory.TaskEngine; MilestoneEngine = factory.MilestoneEngine; MessageEngine = factory.MessageEngine; }
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); }
public static bool CanGoToFeed(Message discussion, Guid userId) { if (discussion == null || !IsProjectsEnabled(userId)) { return(false); } if (discussion.CreateBy == userId) { return(true); } if (!IsInTeam(discussion.Project, userId, false) && !IsFollow(discussion.Project, userId)) { return(false); } var isSubscriber = new MessageEngine(GetFactory(), null).GetSubscribers(discussion).Any(r => new Guid(r.ID).Equals(userId)); return(isSubscriber && GetTeamSecurityForParticipants(discussion.Project, userId, ProjectTeamSecurity.Messages)); }
public static bool CanGoToFeed(Message discussion, Guid userId) { if (discussion == null) { return(false); } if (discussion.CreateBy == userId) { return(true); } if (!CanGoToFeed(discussion.Project, userId)) { return(false); } var participiants = new MessageEngine(GetFactory(), null).GetSubscribers(discussion); return(participiants.Any(r => new Guid(r.ID).Equals(userId)) && GetTeamSecurityForParticipants(discussion.Project, userId, ProjectTeamSecurity.Messages)); }
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); }
public CommentEngine(bool disableNotifications, EngineFactory factory) { DisableNotifications = disableNotifications; TaskEngine = factory.TaskEngine; MessageEngine = factory.MessageEngine; }
public static bool CanGoToFeed(Message discussion, Guid userId) { if (discussion == null || !IsProjectsEnabled(userId)) { return false; } if (discussion.CreateBy == userId) { return true; } if (!IsInTeam(discussion.Project, userId, false) && !IsFollow(discussion.Project, userId)) { return false; } var isSubscriber = new MessageEngine(GetFactory(), null).GetSubscribers(discussion).Any(r => new Guid(r.ID).Equals(userId)); return isSubscriber && GetTeamSecurityForParticipants(discussion.Project, userId, ProjectTeamSecurity.Messages); }
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); }
public static bool CanGoToFeed(Message discussion, Guid userId) { if (discussion == null) return false; if (discussion.CreateBy == userId) return true; if (!CanGoToFeed(discussion.Project, userId)) return false; var participiants = new MessageEngine(GetFactory(), null).GetSubscribers(discussion); return participiants.Any(r => new Guid(r.ID).Equals(userId)) && GetTeamSecurityForParticipants(discussion.Project, userId, ProjectTeamSecurity.Messages); }