public static ObservableCollection <TfsQueryItem> CreateTreeView(TfsProject project)
        {
            var childItems = new ObservableCollection <TfsQueryItem>();

            AppendChildItems(project.Project.QueryHierarchy, childItems);
            return(childItems);
        }
Exemple #2
0
        public void SetProjectByName(string projectName)
        {
            var project = Projects.SingleOrDefault(p => p.Name == projectName);

            if (project != null)
            {
                SelectedProject = project;
            }
        }
Exemple #3
0
        public TfsApi()
        {
            Server = new Uri("http://vstfdevdiv:8080");

            var configurationServer = TfsConfigurationServerFactory.GetConfigurationServer(Server);

            // Get the catalog of team project collections
            ReadOnlyCollection <CatalogNode> collectionNodes = configurationServer.CatalogNode.QueryChildren(
                new[] { CatalogResourceTypes.ProjectCollection },
                false, CatalogQueryOptions.None);

            TfsTeamProjectCollection tpc = null;

            // List the team project collections
            foreach (CatalogNode collectionNode in collectionNodes)
            {
                // Use the InstanceId property to get the team project collection
                Guid collectionId = new Guid(collectionNode.Resource.Properties["InstanceId"]);
                TfsTeamProjectCollection teamProjectCollection = configurationServer.GetTeamProjectCollection(collectionId);
                if (teamProjectCollection.Name.ToLower().EndsWith("devdiv2"))
                {
                    tpc = teamProjectCollection;
                    break;
                }
            }

            if (tpc == null)
            {
                return;
            }

            _workItemStore = tpc.GetService <WorkItemStore>();

            Projects = new BindingList <TfsProject>();
            foreach (Project project in _workItemStore.Projects)
            {
                var tfsProject = new TfsProject(project);
                if (project.Name.Equals("DevDiv"))
                {
                    Projects.Insert(0, tfsProject);
                }
                else
                {
                    Projects.Add(tfsProject);
                }
            }

            _selectedProject = Projects[0];
            _queryItems      = TfsQueryItem.CreateTreeView(_selectedProject);
            _state           = null;
        }