private void RefreshDisabledParentProjects() { disabledParentProjects = new HashSet <Project>(); foreach (var pid in projects .Where(x => x.ParentProjectId.HasValue) .SelectMany(x => projectAncestors[x.Id]).Distinct() .Where(x => !projects.Select(y => y.Id).Contains(x))) { var p = new Project(); p.Id = pid; p.ParentProjectId = projectAncestors[pid].FirstOrDefault(); p.Name = projectNames[pid]; disabledParentProjects.Add(p); } }
private void RefreshDisabledParentResources() { disabledParentResources = new HashSet <Resource>(); foreach (var rid in resources .Where(x => x.ParentResourceId.HasValue) .SelectMany(x => resourceAncestors[x.Id]).Distinct() .Where(x => !resources.Select(y => y.Id).Contains(x))) { var r = new SlaveGroup(); r.Id = rid; r.ParentResourceId = resourceAncestors[rid].FirstOrDefault(); r.Name = resourceNames[rid]; disabledParentResources.Add(r); } }
public void Refresh() { OnRefreshing(); try { resources = new ItemList <Resource>(); projects = new ItemList <Project>(); projectResourceAssignments = new ItemList <AssignedProjectResource>(); jobs = new Dictionary <Guid, HiveItemCollection <RefreshableJob> >(); tasks = new Dictionary <Guid, List <LightweightTask> >(); projectNames = new Dictionary <Guid, string>(); resourceNames = new Dictionary <Guid, string>(); projectAncestors = new Dictionary <Guid, HashSet <Guid> >(); projectDescendants = new Dictionary <Guid, HashSet <Guid> >(); resourceAncestors = new Dictionary <Guid, HashSet <Guid> >(); resourceDescendants = new Dictionary <Guid, HashSet <Guid> >(); HiveServiceLocator.Instance.CallHiveService(service => { service.GetSlaveGroupsForAdministration().ForEach(g => resources.Add(g)); service.GetSlavesForAdministration().ForEach(s => resources.Add(s)); service.GetProjectsForAdministration().ForEach(p => projects.Add(p)); var projectIds = projects.Select(p => p.Id).ToList(); if (projectIds.Any()) { service.GetAssignedResourcesForProjectsAdministration(projectIds) .ForEach(a => projectResourceAssignments.Add(a)); var unsortedJobs = service.GetJobsByProjectIds(projectIds) .OrderBy(x => x.DateCreated).ToList(); projectNames = service.GetProjectNames(); resourceNames = service.GetResourceNames(); } }); UpdateResourceGenealogy(); UpdateProjectGenealogy(); RefreshDisabledParentProjects(); RefreshDisabledParentResources(); } catch { throw; } finally { OnRefreshed(); } }