예제 #1
0
        public IList <KeyValuePair <Guid, String> > GetCollections()
        {
            //ApplicationLogger.Log("Entered into GetCollections() : ");
            var collectionList = new List <KeyValuePair <Guid, String> >();

            try
            {
                _TfsConfigurationServer.Authenticate();

                ReadOnlyCollection <CatalogNode> collectionNodes = _TfsConfigurationServer.CatalogNode.QueryChildren(
                    new[] { CatalogResourceTypes.ProjectCollection },
                    false,
                    CatalogQueryOptions.None);
                foreach (CatalogNode collectionNode in collectionNodes)
                {
                    var collectionId = new Guid(collectionNode.Resource.Properties["InstanceId"]);
                    TfsTeamProjectCollection teamProjectCollection =
                        _TfsConfigurationServer.GetTeamProjectCollection(collectionId);

                    if (teamProjectCollection == null)
                    {
                        continue;
                    }

                    collectionList.Add(new KeyValuePair <Guid, String>(collectionId, teamProjectCollection.Name));
                }
            }
            catch (Exception e)
            {
                //ApplicationLogger.Log(e);
            }

            return(collectionList);
        }
예제 #2
0
        /// <summary>
        /// Connects to the TFS server.
        /// </summary>
        public void Connect()
        {
            configurationServer = new TfsConfigurationServer(ServerUri, System.Net.CredentialCache.DefaultCredentials);

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

            // 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);

                // Find the requested team project collection
                if (teamProjectCollection.Name.ToUpper(CultureInfo.InvariantCulture).EndsWith(this.TeamProjectCollectionName.ToUpper(CultureInfo.InvariantCulture), StringComparison.Ordinal))
                {
                    SourceControl = (VersionControlServer)teamProjectCollection.GetService(typeof(VersionControlServer));

                    this.TeamProjects = new ReadOnlyCollection <TeamProject>(SourceControl.GetAllTeamProjects(false));

                    break; // We got what we want, now exit the loop
                }
            }
        }
예제 #3
0
        public static void Main(string[] args)
        {
            LogArguments(args);

            Uri    projectCollectionUri = new Uri(args.ElementAt(0));
            Guid   projectCollectionId  = Guid.Parse(args.ElementAt(1));
            Guid   requestedByUserId    = Guid.Parse(args.ElementAt(2));
            string artifactsFolder      = Path.GetFullPath(args.ElementAt(3));
            string emailSubject         = args.ElementAt(4);
            string emailBody            = args.ElementAt(5);

            Console.WriteLine("Project collection URI: " + projectCollectionUri);
            Console.WriteLine("Project collection id:  " + projectCollectionId);
            Console.WriteLine("User identifier:        " + requestedByUserId);
            Console.WriteLine("Artifacts folder:       " + artifactsFolder);
            Console.WriteLine("Email subject:          " + emailSubject);
            Console.WriteLine("Email body:             " + emailBody);

            string tfsUriFromCollectionUri             = projectCollectionUri.AbsoluteUri.Replace(projectCollectionUri.Segments.Last(), string.Empty);
            TfsConfigurationServer configurationServer = TfsConfigurationServerFactory.GetConfigurationServer(new Uri(tfsUriFromCollectionUri));

            TfsTeamProjectCollection teamProjectCollection = configurationServer.GetTeamProjectCollection(projectCollectionId);

            IIdentityManagementService identityServiceManager = teamProjectCollection.GetService <IIdentityManagementService>();

            TeamFoundationIdentity[] tfsIdentities = identityServiceManager.ReadIdentities(new Guid[1] {
                requestedByUserId
            }, MembershipQuery.Direct);

            SendArtifacs(tfsIdentities, emailSubject, emailBody, artifactsFolder);
        }
예제 #4
0
        public static BuildDefinitionDtoCollection GetBuildDefinitions(this TfsConfigurationServer tfsConfigurationServer, Guid teamProjectCollectionId, string teamProjectName)
        {
            if (tfsConfigurationServer == null)
            {
                throw new ArgumentNullException("tfsConfigurationServer");
            }

            TfsTeamProjectCollection tfsTeamProjectCollection = tfsConfigurationServer.GetTeamProjectCollection(teamProjectCollectionId);
            IBuildServer             buildServer = tfsTeamProjectCollection.GetService <IBuildServer>();

            IBuildDefinition[]           buildDefinitions             = buildServer.QueryBuildDefinitions(teamProjectName);
            BuildDefinitionDtoCollection buildDefinitionDtoCollection = new BuildDefinitionDtoCollection();

            foreach (IBuildDefinition buildDefinition in buildDefinitions)
            {
                BuildDefinitionDto buildDefinitionDto = new BuildDefinitionDto();
                buildDefinitionDto.TeamProjectName = buildDefinition.TeamProject;
                buildDefinitionDto.Name            = buildDefinition.Name;
                buildDefinitionDto.Id  = buildDefinition.Id;
                buildDefinitionDto.Uri = buildDefinition.Uri;
                buildDefinitionDtoCollection.Add(buildDefinitionDto);
            }

            return(buildDefinitionDtoCollection);
        }
예제 #5
0
        /// <summary>
        /// Lists all TFS collection from server, each collection can have project
        /// </summary>
        public void ListAllCollections()
        {
            try
            {
                TfsConfigurationServer server = TfsConfigurationServerFactory.GetConfigurationServer(new Uri(_tfsAddress));

                ReadOnlyCollection <CatalogNode> collectionNodes = server.CatalogNode.QueryChildren(new[] { CatalogResourceTypes.ProjectCollection }, false, CatalogQueryOptions.None);

                foreach (CatalogNode node in collectionNodes)
                {
                    Guid collectionId = new Guid(node.Resource.Properties["InstanceId"]);
                    TfsTeamProjectCollection teamProjectCollection = server.GetTeamProjectCollection(collectionId);
                    Console.WriteLine("Collection: " + teamProjectCollection.Name);

                    // TODO - temporary list all projects also here
                    ReadOnlyCollection <CatalogNode> projectNodes = node.QueryChildren(new[] { CatalogResourceTypes.TeamProject }, false, CatalogQueryOptions.None);
                    foreach (CatalogNode elem in projectNodes)
                    {
                        Console.WriteLine("Team project name is: " + elem.Resource.DisplayName);
                    }
                }
            }
            catch (Exception ex)
            {
                // custom exception handling - TODO throw custom exception
                _logger.Error("Tfs conection error: " + ex.Message);
                throw;
            }
        }
예제 #6
0
        private static void ListProjects()
        {
            // URI of the team project collection
            string _myUri = @"https://bupa-international.visualstudio.com";

            TfsConfigurationServer configurationServer =
                TfsConfigurationServerFactory.GetConfigurationServer(new Uri(_myUri));

            CatalogNode catalogNode = configurationServer.CatalogNode;

            ReadOnlyCollection <CatalogNode> tpcNodes = catalogNode.QueryChildren(
                new Guid[] { CatalogResourceTypes.ProjectCollection },
                false, CatalogQueryOptions.None);

            // tpc = Team Project Collection
            foreach (CatalogNode tpcNode in tpcNodes)
            {
                Guid tpcId = new Guid(tpcNode.Resource.Properties["InstanceId"]);
                TfsTeamProjectCollection tpc = configurationServer.GetTeamProjectCollection(tpcId);

                // Get catalog of tp = 'Team Projects' for the tpc = 'Team Project Collection'
                var tpNodes = tpcNode.QueryChildren(
                    new Guid[] { CatalogResourceTypes.TeamProject },
                    false, CatalogQueryOptions.None);

                foreach (var p in tpNodes)
                {
                    Debug.Write(Environment.NewLine + " Team Project : " + p.Resource.DisplayName + " - " + p.Resource.Description + Environment.NewLine);
                }
            }
        }
예제 #7
0
        public static TeamBuildDtoCollection GetTeamBuilds(this TfsConfigurationServer tfsConfigurationServer, Guid teamProjectCollectionId, string teamProjectName, IEnumerable <string> teamBuildDefinitionNames)
        {
            if (tfsConfigurationServer == null)
            {
                throw new ArgumentNullException("tfsConfigurationServer");
            }

            if (teamBuildDefinitionNames == null)
            {
                throw new ArgumentNullException("teamBuildDefinitionNames");
            }

            TfsTeamProjectCollection tfsTeamProjectCollection = tfsConfigurationServer.GetTeamProjectCollection(teamProjectCollectionId);
            IBuildServer             buildServer            = tfsTeamProjectCollection.GetService <IBuildServer>();
            TeamBuildDtoCollection   teamBuildDtoCollection = new TeamBuildDtoCollection();

            foreach (string teamBuildDefinitionName in teamBuildDefinitionNames)
            {
                IBuildDetailSpec buildDetailSpec = buildServer.CreateBuildDetailSpec(teamProjectName, teamBuildDefinitionName);
                buildDetailSpec.Reason             = BuildReason.All;
                buildDetailSpec.QueryOrder         = BuildQueryOrder.FinishTimeDescending;
                buildDetailSpec.QueryDeletedOption = QueryDeletedOption.ExcludeDeleted;
                IBuildQueryResult buildQueryResult = buildServer.QueryBuilds(buildDetailSpec);
                foreach (IBuildDetail buildDetail in buildQueryResult.Builds)
                {
                    TeamBuildDto teamBuildDto = new TeamBuildDto();
                    teamBuildDto.BuildNumber    = buildDetail.BuildNumber;
                    teamBuildDto.Uri            = buildDetail.Uri;
                    teamBuildDto.DefinitionName = teamBuildDefinitionName;
                    teamBuildDtoCollection.Add(teamBuildDto);
                }
            }

            return(teamBuildDtoCollection);
        }
예제 #8
0
    static void Main()
    {
        var tfsUri = new Uri("http://xx.xx.xx.xx:8080/tfs");
        TfsConfigurationServer configurationServer =
            TfsConfigurationServerFactory.GetConfigurationServer(tfsUri);
        // Get the catalog of team project collections
        ReadOnlyCollection <CatalogNode> collectionNodes = configurationServer.CatalogNode.QueryChildren(
            new[] { CatalogResourceTypes.ProjectCollection },
            false, CatalogQueryOptions.None);

        // 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);
            // Print the name of the team project collection
            Console.WriteLine("Collection: " + teamProjectCollection.Name);
            // Get a catalog of team projects for the collection
            ReadOnlyCollection <CatalogNode> projectNodes = collectionNode.QueryChildren(
                new[] { CatalogResourceTypes.TeamProject },
                false, CatalogQueryOptions.None);
            // List the team projects in the collection
            foreach (CatalogNode projectNode in projectNodes)
            {
                Console.WriteLine(" Team Project: " + projectNode.Resource.DisplayName);
            }
        }
    }
예제 #9
0
파일: Form1.cs 프로젝트: shashik5/myRepo
        public void ConnectToTFSServer(string ServerURL)
        {
            // Connect to Team Foundation Server
            //     Server is the name of the server that is running the application tier for Team Foundation.
            //     Port is the port that Team Foundation uses. The default port is 8080.
            //     VDir is the virtual path to the Team Foundation application. The default path is tfs.
            Uri tfsUri = new Uri(ServerURL);
            TfsConfigurationServer configurationServer =
                TfsConfigurationServerFactory.GetConfigurationServer(tfsUri);

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

            // 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);

                // Print the name of the team project collection
                Console.WriteLine("Collection: " + teamProjectCollection.Name);

                // Get a catalog of team projects for the collection
                ReadOnlyCollection <CatalogNode> projectNodes = collectionNode.QueryChildren(
                    new[] { CatalogResourceTypes.TeamProject },
                    false, CatalogQueryOptions.None);
            }
        }
예제 #10
0
        public static TfsTeamProjectCollection Get_TeamProjectCollection(
            TfsConfigurationServer configurationServer,
            CatalogNode teamProjectCollectionNode)
        {
            Int64 startTicks = Log.DOMAINSERVICES("Enter", Common.LOG_APPNAME);

            Guid collectionId = new Guid(teamProjectCollectionNode.Resource.Properties["InstanceId"]);

            TfsTeamProjectCollection teamProjectCollection;

            try
            {
                teamProjectCollection = configurationServer.GetTeamProjectCollection(collectionId);
            }
            catch (TimeoutException)
            {
                throw;
            }
            catch
            {
                throw;
            }

            Log.DOMAINSERVICES("Exit", Common.LOG_APPNAME, startTicks);

            return(teamProjectCollection);
        }
예제 #11
0
        public static IEnumerable <WorkItemDto> GetWorkItemsFromTeamBuilds(this TfsConfigurationServer tfsConfigurationServer, Guid teamProjectCollectionId, IEnumerable <WorkItemSummaryDto> workItems)
        {
            if (tfsConfigurationServer == null)
            {
                throw new ArgumentNullException("tfsConfigurationServer");
            }

            if (workItems == null)
            {
                throw new ArgumentNullException("workItems");
            }

            TfsTeamProjectCollection tfsTeamProjectCollection = tfsConfigurationServer.GetTeamProjectCollection(teamProjectCollectionId);
            WorkItemStore            workItemStore            = tfsTeamProjectCollection.GetService <WorkItemStore>();
            WorkItemDtoCollection    workItemDtoCollection    = new WorkItemDtoCollection();

            foreach (WorkItemSummaryDto workItemSummaryDto in workItems)
            {
                WorkItem    workItem    = workItemStore.GetWorkItem(workItemSummaryDto.Id);
                WorkItemDto workItemDto = WorkItemDto.CreateFromWorkItem(workItem, workItemSummaryDto.AssociatedBuildNumber);
                workItemDtoCollection.Add(workItemDto);
            }

            return(workItemDtoCollection);
        }
예제 #12
0
        public static TeamProjectDtoCollection GetAllTeamProjectsInAllTeamProjectCollections(this TfsConfigurationServer tfsConfigurationServer)
        {
            if (tfsConfigurationServer == null)
            {
                throw new ArgumentNullException("tfsConfigurationServer");
            }

            TeamProjectDtoCollection         teamProjectDtoCollection   = new TeamProjectDtoCollection();
            ReadOnlyCollection <CatalogNode> teamProjectCollectionNodes = tfsConfigurationServer.CatalogNode.QueryChildren(new[] { CatalogResourceTypes.ProjectCollection }, false, CatalogQueryOptions.None);

            foreach (CatalogNode teamProjectCollectionNode in teamProjectCollectionNodes)
            {
                Guid collectionId = new Guid(teamProjectCollectionNode.Resource.Properties[TeamProjectCollectionResourcePropertyName.InstanceId]);
                TfsTeamProjectCollection         teamProjectCollection = tfsConfigurationServer.GetTeamProjectCollection(collectionId);
                ReadOnlyCollection <CatalogNode> projectNodes          = teamProjectCollectionNode.QueryChildren(new[] { CatalogResourceTypes.TeamProject }, false, CatalogQueryOptions.None);
                foreach (CatalogNode teamProjectNode in projectNodes)
                {
                    TeamProjectDto teamProjectDto = new TeamProjectDto();
                    teamProjectDto.CollectionId   = teamProjectCollection.InstanceId;
                    teamProjectDto.CollectionName = teamProjectCollection.Name;
                    teamProjectDto.DisplayName    = teamProjectNode.Resource.DisplayName;
                    teamProjectDto.Uri            = new Uri(teamProjectNode.Resource.Properties[TeamProjectResourcePropertyName.ProjectUri]);
                    teamProjectDto.Id             = Guid.Parse(teamProjectNode.Resource.Properties[TeamProjectResourcePropertyName.ProjectId]);
                    teamProjectDtoCollection.Add(teamProjectDto);
                }
            }

            return(teamProjectDtoCollection);
        }
예제 #13
0
        public static WorkItemStore GetWorkItemStore(TfsConfigurationServer tfs, CatalogNode teamProjectColCatalog)
        {
            Guid teamProjectCatalogId = new Guid(teamProjectColCatalog.Resource.Properties["InstanceId"]);
            TfsTeamProjectCollection teamProjectCollection = tfs.GetTeamProjectCollection(teamProjectCatalogId);

            return(new WorkItemStore(teamProjectCollection));
        }
예제 #14
0
        static void Main(string[] args)
        {
            // Connect to Team Foundation Server
            //     Server is the name of the server that is running the application tier for Team Foundation.
            //     Port is the port that Team Foundation uses. The default port is 8080.
            //     VDir is the virtual path to the Team Foundation application. The default path is tfs.
            Uri tfsUri = (args.Length < 1) ?
                         new Uri("http://pro-pggm-manoj:8080/tfs") : new Uri(args[0]);

            TfsConfigurationServer configurationServer =
                TfsConfigurationServerFactory.GetConfigurationServer(tfsUri);

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

            // Use the InstanceId property to get the team project collection
            Guid collectionId = new Guid(collectionNodes[0].Resource.Properties["InstanceId"]);
            TfsTeamProjectCollection teamProjectCollection = configurationServer.GetTeamProjectCollection(collectionId);

            ClientObjectModel.UpdateChangeSetComments(teamProjectCollection, "Updated Thru Code");

            ClientObjectModel.DisplayWorkItemsInConsole(teamProjectCollection);
        }
예제 #15
0
        public TfsTeamProjectCollection GetTfsTeamProjectCollection(Guid collectionId, Uri tfsServer)
        {
            TfsConfigurationServer configurationServer =
                TfsConfigurationServerFactory.GetConfigurationServer(tfsServer);
            var collection = configurationServer.GetTeamProjectCollection(collectionId);

            return(collection);
        }
예제 #16
0
파일: RemoteTfs.cs 프로젝트: elvza/bmx-tfs
        private static TfsTeamProjectCollection FindCollection(TfsConfigurationServer server, Guid?collectionId, string collectionName)
        {
            if (collectionId != null)
            {
                return(server.GetTeamProjectCollection(collectionId.Value));
            }

            var match = server
                        .GetService <ITeamProjectCollectionService>()
                        .GetCollections()
                        .FirstOrDefault(c => string.Equals(c.Name, collectionName, StringComparison.OrdinalIgnoreCase));

            if (match == null)
            {
                return(null);
            }

            return(server.GetTeamProjectCollection(match.Id));
        }
예제 #17
0
        protected void GetServices(out Workspace workspace, out VersionControlServer versionControlServer)
        {
            var workstation = Workstation.Current;

            Log.LogMessage(MessageImportance.Normal, "workstation name: " + workstation.Name);
            var workspaceInfo       = workstation.GetLocalWorkspaceInfo(LocalPath);
            var serverCollectionUrl = workspaceInfo.ServerUri;

            Log.LogMessage(MessageImportance.Normal, "serverCollectionUrl: " + serverCollectionUrl);

            var uri = new Uri(GetVDirUrl(serverCollectionUrl));

            Log.LogMessage(MessageImportance.Normal, "serverUrl: " + uri);

            TfsConfigurationServer configurationServer =
                TfsConfigurationServerFactory.GetConfigurationServer(uri);

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

            workspace            = null;
            versionControlServer = 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"]);
                if (collectionId == workspaceInfo.ServerGuid)
                {
                    TfsTeamProjectCollection teamProjectCollection =
                        configurationServer.GetTeamProjectCollection(collectionId);

                    versionControlServer = teamProjectCollection.GetService <VersionControlServer>();

                    workspace = workspaceInfo.GetWorkspace(teamProjectCollection);
                    Log.LogMessage(MessageImportance.Normal, "found workspace for collectionId: " + collectionId);
                    break;
                }
            }

            if (workspace == null)
            {
                Log.LogError("No workspace found.");
            }

            if (versionControlServer == null)
            {
                Log.LogError("No VersionControlServer found.");
            }
        }
예제 #18
0
        public IEnumerable <TfsTeamProjectCollection> GetTeamProjectCollections()
        {
            var topNode  = _configServer.CatalogNode;
            var tpcNodes = topNode.QueryChildren(new[] { CatalogResourceTypes.ProjectCollection }, false, CatalogQueryOptions.None);

            foreach (var node in tpcNodes)
            {
                var instanceIdGuid = new Guid(node.Resource.Properties["InstanceId"]);
                var projCollection = _configServer.GetTeamProjectCollection(instanceIdGuid);
                yield return(projCollection);
            }
        }
예제 #19
0
        /// <summary>
        /// main function
        /// </summary>
        /// <param name="args"></param>
        private static void Main(string[] args)
        {
            //string path1 = "ISH3\\ISH3_KBL\\KBL_RS2\\Test";
            string logPath = Directory.GetCurrentDirectory();
            string logfile = Path.Combine(logPath, "log-file.txt");

            if (File.Exists(logfile))
            {
                File.Delete(logfile);
            }
            ILog log = LogManager.GetLogger("testApp.Logging");

            try
            {
                Uri tfsUri = new Uri(ConfigurationManager.AppSettings["TfsUri"]);
                //Uri tfsUri = new Uri("https://tfs-alm.intel.com:8088/tfs/");
                TfsConfigurationServer configurationServer =
                    TfsConfigurationServerFactory.GetConfigurationServer(tfsUri);
                // Get the catalog of team project collections
                ReadOnlyCollection <CatalogNode> collectionNodes = configurationServer.CatalogNode.QueryChildren(new[] { CatalogResourceTypes.ProjectCollection }, false, CatalogQueryOptions.None);
                var collectionNode = collectionNodes.Single();
                // Use the InstanceId property to get the team project collection
                Guid collectionId = new Guid(collectionNode.Resource.Properties["InstanceId"]);
                teamProjectCollection = configurationServer.GetTeamProjectCollection(collectionId);
                //Console.WriteLine("Collection: " + teamProjectCollection.Name);
                log.InfoFormat("Collecton: {0}", teamProjectCollection.Name);
                //log.Info("---------------------------------");
                log.Info("*********************************");
                workItemStore = teamProjectCollection.GetService <WorkItemStore>();
                //ICommonStructureService css = teamProjectCollection.GetService<ICommonStructureService>();
                //"ISH3\ISH3_KBL\KBL_RS2\Test"
                log.Info("path:" + args[0]);
                string   path   = args[0];
                string[] folder = path.Split('\\');
                for (int i = 0; i < folder.Length; i++)
                {
                    log.Info("folder[" + i + "]:" + folder[i]);
                }
                if (!CreateCycle(folder))
                {
                    return;
                }
                log.Info("Create test cycle:" + args[0] + " successfully!");
            }
            catch (Exception e)
            {
                log.Info(e.Message.ToString());
                return;
            }
        }
예제 #20
0
        /// <summary>
        /// Get TeamProject from TFS
        /// </summary>
        /// <param name="teamProjecName">The teamProjectName object.</param>
        public void GetTeamProject(string teamProjecName)
        {
            ReadOnlyCollection <CatalogNode> collectionNodes
                = configurationServer.CatalogNode.QueryChildren(new[] { CatalogResourceTypes.ProjectCollection }, false, CatalogQueryOptions.None);

            var  collectionNode = collectionNodes.Single();
            Guid collectionId   = new Guid(collectionNode.Resource.Properties["InstanceId"]);

            teamProjectCollection = configurationServer.GetTeamProjectCollection(collectionId);

            ITestManagementService testManagementService = teamProjectCollection.GetService <ITestManagementService>();

            testProject = testManagementService.GetTeamProject(teamProjecName);
        }
예제 #21
0
        private TfsTeamProjectCollection GetTeamProjectCollection(CatalogNode node)
        {
            foreach (TfsTeamProjectCollection projectCollection in _TeamProjectCollections.Where(x => x.CatalogNode.Resource.DisplayName == node.Resource.DisplayName))
            {
                return(projectCollection);
            }

            Guid collectionId = GetCollectionGuid(node);
            var  collection   = _Server.GetTeamProjectCollection(collectionId);

            _TeamProjectCollections.Add(collection);

            return(collection);
        }
예제 #22
0
        public Tfs(Uri tfsUri)
        {
            TfsConfigurationServer configurationServer = TfsConfigurationServerFactory.GetConfigurationServer(tfsUri);
            // Get the catalog of team project collections
            ReadOnlyCollection <CatalogNode> collectionNodes = configurationServer.CatalogNode.QueryChildren(new[] { CatalogResourceTypes.ProjectCollection }, false, CatalogQueryOptions.None);

            // 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 tfs = configurationServer.GetTeamProjectCollection(collectionId);
                store = (WorkItemStore)tfs.GetService(typeof(WorkItemStore));
            }
        }
예제 #23
0
        public void IntegrationTestUpdateRetentionPolicies()
        {
            TfsConfigurationServer tfsConfigurationServer = TfsConfigurationServerFactory.GetConfigurationServer(new Uri("myTfsUrl"));

            tfsConfigurationServer.Authenticate();
            TeamProjectDtoCollection allTeamProjectCollections = tfsConfigurationServer.GetAllTeamProjectsInAllTeamProjectCollections();

            foreach (TeamProjectDto teamProjectDto in allTeamProjectCollections)
            {
                TfsTeamProjectCollection teamProjectCollection = tfsConfigurationServer.GetTeamProjectCollection(teamProjectDto.CollectionId);
                IBuildServer             buildServer           = teamProjectCollection.GetService <IBuildServer>();
                BuildServerFacade        buildServerFacade     = new BuildServerFacade(buildServer);
                buildServerFacade.UpdateRetentionPolicies(teamProjectDto.DisplayName, 1, 5, 5, 10, "All");
            }
        }
예제 #24
0
        private void AddProjectCollectionNodes(List <IPathNode> nodes)
        {
            var catalogNode  = Server.CatalogNode;
            var catalogNodes = catalogNode.QueryChildren(new Guid[] { CatalogResourceTypes.ProjectCollection }, false,
                                                         CatalogQueryOptions.None);


            nodes.AddRange(catalogNodes.ToList().ConvertAll(c =>
            {
                var n =
                    Server.GetTeamProjectCollection(
                        new Guid(c.Resource.Properties["InstanceId"]));
                return(new TeamProjectCollectionPathNode(n, c));
            }));
        }
예제 #25
0
        public ConnectionState ConnectToServer(Uri serverUri, out List <TeamProjectCollectionData> teamProjectCollections)
        {
            IsConnected            = false;
            teamProjectCollections = new List <TeamProjectCollectionData>();
            try
            {
                _configurationServer = TfsConfigurationServerFactory.GetConfigurationServer(serverUri);

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

                // 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);

                    // Get a catalog of team projects for the collection
                    ReadOnlyCollection <CatalogNode> projectNodes = collectionNode.QueryChildren(
                        new[] { CatalogResourceTypes.TeamProject },
                        false, CatalogQueryOptions.None);

                    // List the team projects in the collection
                    string[] teamProjectNames = projectNodes.Select(it => it.Resource.DisplayName).ToArray();

                    teamProjectCollections.Add(new TeamProjectCollectionData()
                    {
                        Name             = teamProjectCollection.Name,
                        Uri              = teamProjectCollection.Uri,
                        TeamProjectNames = teamProjectNames
                    });
                }
            }
            catch (UnauthorizedAccessException)
            {
                return(ConnectionState.AuthorizationError);
            }
            catch (Exception ex)
            {
                //throw new MyTFSConnectionException(" exception on connect:\n" + ex.ToString());
                Popups.ShowMessage("Exception on connect: " + ex.ToString(), MessageBoxImage.Error);
                return(ConnectionState.UnknownError);
            }
            IsConnected = true;
            return(ConnectionState.Connected);
        }
예제 #26
0
        private List <String> GetTFSListOfCollections(TfsConfigurationServer configServer, ReadOnlyCollection <CatalogNode> collectionNodes)
        {
            List <String> CollectionNodes = new List <string>();

            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 = configServer.GetTeamProjectCollection(collectionId);

                // Print the name of the team project collection
                CollectionNodes.Add(teamProjectCollection.Name);
            }

            return(CollectionNodes);
        }
예제 #27
0
        }     // End Sub TfsItemList

        public static void TfsMain()
        {
            // Connect to Team Foundation Server
            //     Server is the name of the server that is running the application tier for Team Foundation.
            //     Port is the port that Team Foundation uses. The default port is 8080.
            //     VDir is the virtual path to the Team Foundation application. The default path is tfs.
            //Uri tfsUri = (args.Length < 1) ? new Uri("http://corfoundation:8080/tfs") : new Uri(args[0]);
            //Uri tfsUri = (args.Length < 1) ? new Uri("http://Server:Port/VDir") : new Uri(args[0]);

            Uri tfsUri = new Uri("http://corfoundation:8080/tfs");


            TfsConfigurationServer configurationServer =
                TfsConfigurationServerFactory.GetConfigurationServer(tfsUri);

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

            // 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);

                // Print the name of the team project collection
                Console.WriteLine("Collection: " + teamProjectCollection.Name);

                // Get a catalog of team projects for the collection
                ReadOnlyCollection <CatalogNode> projectNodes = collectionNode.QueryChildren(
                    new[] { CatalogResourceTypes.TeamProject }
                    , false
                    , CatalogQueryOptions.None
                    );

                // List the team projects in the collection
                foreach (CatalogNode projectNode in projectNodes)
                {
                    Console.WriteLine(" Team Project: " + projectNode.Resource.DisplayName);
                } // Next projectNode
            }     // Next collectionNode
        }         // End Sub TfsMain
예제 #28
0
        protected void Page_Load(object sender, EventArgs e)
        {
            //Move to config
            var tfsUri  = new Uri(ConfigurationManager.AppSettings[TFS_URI]);
            var tfsCred = new NetworkCredential(
                ConfigurationManager.AppSettings[TFS_USER],
                ConfigurationManager.AppSettings[TFS_PASS],
                ConfigurationManager.AppSettings[TFS_DOMAIN]
                );

            var configurationServer = new TfsConfigurationServer(tfsUri, tfsCred);

            ReadOnlyCollection <CatalogNode> collectionNodes = configurationServer.CatalogNode.QueryChildren(
                new[] { CatalogResourceTypes.ProjectCollection },
                false, CatalogQueryOptions.None);

            var players = new List <Player>();

            // List the team project collections
            foreach (CatalogNode collectionNode in collectionNodes)
            {
                Guid tpcId = new Guid(collectionNode.Resource.Properties["InstanceId"]);
                TfsTeamProjectCollection tpc = configurationServer.GetTeamProjectCollection(tpcId);
                var vcs     = tpc.GetService <VersionControlServer>();
                var srcRoot = vcs.GetItem("$/");

                IEnumerable <PendingSet> pendings = vcs.QueryPendingSets(new[] { srcRoot.ServerItem }, RecursionType.Full, null, null).AsEnumerable();

                foreach (var pending in pendings)
                {
                    Player player;
                    if (players.Exists(x => x.Name == pending.OwnerDisplayName))
                    {
                        player = players.Find(x => x.Name == pending.OwnerDisplayName);
                    }
                    else
                    {
                        player = new Player(pending.OwnerDisplayName);
                        players.Add(player);
                    }
                    player.Score += pending.PendingChanges.Count();
                }
            }

            NamesList.Text = GetNamesHtml(players);
        }
예제 #29
0
        private static List <User> GetAllTfsValidUsers(string tfsServerUrl)
        {
            List <User> tfsUsers = new List <User>();

            TfsConfigurationServer configServer = Connect(tfsServerUrl);

            // Get all Team Project Collections
            ITeamProjectCollectionService tpcService = configServer.GetService <ITeamProjectCollectionService>();

            foreach (TeamProjectCollection tpc in tpcService.GetCollections())
            {
                TfsTeamProjectCollection teamProjectCollection = configServer.GetTeamProjectCollection(tpc.Id);
                teamProjectCollection.EnsureAuthenticated();

                var identityManagementService = teamProjectCollection.GetService <IIdentityManagementService>();
                // Get members of Project Collection Valid Users group
                var collectionWideValidUsers = identityManagementService.ReadIdentity(IdentitySearchFactor.DisplayName,
                                                                                      "Project Collection Valid Users",
                                                                                      MembershipQuery.Expanded,
                                                                                      ReadIdentityOptions.None);
                var validMembers = identityManagementService.ReadIdentities(collectionWideValidUsers.Members,
                                                                            MembershipQuery.Expanded,
                                                                            ReadIdentityOptions.ExtendedProperties);
                var members = validMembers
                              .Where(m => !m.IsContainer &&
                                     m.Descriptor.IdentityType != "Microsoft.TeamFoundation.UnauthenticatedIdentity" &&
                                     m.Descriptor.IdentityType != "Microsoft.TeamFoundation.ServiceIdentity")
                              .Select(m => new User {
                    DisplayName = m.DisplayName, AccountName = m.UniqueName
                })
                              .ToList();

                // Collect members
                foreach (var m in members)
                {
                    if (!tfsUsers.Any(t => t.AccountName == m.AccountName))
                    {
                        tfsUsers.Add(m);
                    }
                }
            }

            tfsUsers = tfsUsers.OrderBy(m => m.DisplayName).ToList();

            return(tfsUsers);
        }
예제 #30
0
        static void Main(string[] args)
        {
            LogArguments(args);

            Uri    projectCollectionUri = new Uri(args.ElementAt(0));
            Guid   projectCollectionId  = Guid.Parse(args.ElementAt(1));
            Uri    buildUri             = new Uri(args.ElementAt(2));
            string logPath = Path.GetFullPath(args.ElementAt(3));

            Console.WriteLine("Project collection URI: " + projectCollectionUri);
            Console.WriteLine("Project collection id:  " + projectCollectionId);
            Console.WriteLine("Build URI:              " + buildUri);
            Console.WriteLine("Log path:               " + logPath);

            string tfsUriFromCollectionUri             = projectCollectionUri.AbsoluteUri.Replace(projectCollectionUri.Segments.Last(), string.Empty);
            TfsConfigurationServer configurationServer = TfsConfigurationServerFactory.GetConfigurationServer(new Uri(tfsUriFromCollectionUri));

            TfsTeamProjectCollection teamProjectCollection = configurationServer.GetTeamProjectCollection(projectCollectionId);

            IBuildServer buildServer = (IBuildServer)teamProjectCollection.GetService(typeof(IBuildServer));

            IBuildDetail buildDetails = buildServer.GetBuild(buildUri);

            Console.WriteLine("Build details have been retrieved");

            using (WebClient webClient = new WebClient())
            {
                // see http://stackoverflow.com/questions/11414266/obtain-network-credentials-from-current-user-in-windows-authentication-applicati
                webClient.Credentials = CredentialCache.DefaultNetworkCredentials;

                string buildLogJson = webClient.DownloadString(buildDetails.LogLocation);

                BuildLogDetail buildInfo = JsonConvert.DeserializeObject <BuildLogDetail>(buildLogJson);
                Console.WriteLine("Build log has been retrieved");

                using (StreamWriter logWriter = new StreamWriter(logPath))
                {
                    foreach (BuildStep buildStep in buildInfo.value)
                    {
                        LogBuildStep(buildStep, logWriter);
                    }
                    Console.WriteLine("Build log has been generated");
                }
            }
        }
예제 #31
0
        private static TfsTeamProjectCollection GetProjectCollection(TfsConfigurationServer configurationServer)
        {
            // Get the catalog of team project collections
            ReadOnlyCollection<CatalogNode> collectionNodes = configurationServer.CatalogNode.QueryChildren(
                new[] { CatalogResourceTypes.ProjectCollection },
                false, CatalogQueryOptions.None);

            foreach (CatalogNode collectionNode in collectionNodes)
            {
                if (collectionNode.Resource.DisplayName == projectCollectionName)
                {
                    Guid collectionId = new Guid(collectionNode.Resource.Properties["InstanceId"]);
                    return configurationServer.GetTeamProjectCollection(collectionId);
                }
            }

            return null;
        }
예제 #32
0
        void DoStuffForSpecificCatalog(TfsConfigurationServer configurationServer,CatalogNode collectionNode)
        {
            // Use the InstanceId property to get the team project collection
            Guid collectionId = new Guid(collectionNode.Resource.Properties["InstanceId"]);
            TfsTeamProjectCollection teamProjectCollection = configurationServer.GetTeamProjectCollection(collectionId);
            GetChangesets(teamProjectCollection);
            // Print the name of the team project collection
            Console.WriteLine("Collection: " + teamProjectCollection.Name);

            // Get a catalog of team projects for the collection
            ReadOnlyCollection<CatalogNode> projectNodes = collectionNode.QueryChildren(
                new[] { CatalogResourceTypes.TeamProject },
                false, CatalogQueryOptions.None);

            // List the team projects in the collection
            foreach (CatalogNode projectNode in projectNodes)
            {
                Console.WriteLine(" Team Project: " + projectNode.Resource.DisplayName);
            }
        }
예제 #33
0
        public IEnumerable<Node> GetTfsProjects(TfsConnection conn)
        {
            var cols = new List<Node>();
            var configServer = new TfsConfigurationServer(
                new Uri(conn.TfsUrl),
                new NetworkCredential(conn.Username, conn.Password, conn.Domain));
            configServer.Authenticate();

            var catalog = configServer.CatalogNode;
            var tpcNodes = catalog.QueryChildren(
                new Guid[] { CatalogResourceTypes.ProjectCollection },
                false, CatalogQueryOptions.None);

            foreach (var tpcNode in tpcNodes)
            {
                Node nd = new Node();

                Guid tpcId = new Guid(tpcNode.Resource.Properties["InstanceId"]);
                nd.Properties.Add(new Item("guid", tpcId.ToString()));
                nd.Name = tpcNode.Resource.DisplayName;
                cols.Add(nd);
                var tpc = configServer.GetTeamProjectCollection(tpcId);

                // Get catalog of tp = 'Team Projects' for the tpc = 'Team Project Collection'
                var tpNodes = tpcNode.QueryChildren(
                          new Guid[] { CatalogResourceTypes.TeamProject },
                          false, CatalogQueryOptions.None);

                foreach (var p in tpNodes)
                {
                    var ndProj = new Node();
                    ndProj.Name = p.Resource.DisplayName;
                    nd.Children.Add(ndProj);
                }
            }

            return cols;

            /*
            WorkItemStore workItemStore = (WorkItemStore)collection.GetService(typeof(WorkItemStore));
            string qry = "SELECT [Title] From WorkItems Where [Work Item Type] = 'Bug' " +
                " AND [Iteration Path] = 'AML_Module\\Release 3\\Sprint 4' AND [Team Project]='AML_Module'";

            var res = workItemStore.Query(qry);
            foreach (var wi in res)
            {
                string s = wi.ToString();
            }*/
        }
예제 #34
0
        private void Test()
        {
            TfsConfigurationServer configServer = new TfsConfigurationServer(
                new Uri("https://cmr.wkglobal.com:8088/tfs"),
                new NetworkCredential("Shafqat.Ahmed", "Hello123", "NA"));
            configServer.Authenticate();

            var catalog = configServer.CatalogNode;
            var tpcNodes = catalog.QueryChildren(
                new Guid[] { CatalogResourceTypes.ProjectCollection },
                false, CatalogQueryOptions.None);

            TfsTeamProjectCollection collection = null;
            foreach (var tpcNode in tpcNodes)
            {
                Guid tpcId = new Guid(tpcNode.Resource.Properties["InstanceId"]);
                var tpc = configServer.GetTeamProjectCollection(tpcId);

                // Get catalog of tp = 'Team Projects' for the tpc = 'Team Project Collection'
                var tpNodes = tpcNode.QueryChildren(
                          new Guid[] { CatalogResourceTypes.TeamProject },
                          false, CatalogQueryOptions.None);

                foreach (var p in tpNodes)
                {
                    if (p.Resource.DisplayName == "AML_Module")
                    {
                        collection = tpc;
                    }
                }
            }

            WorkItemStore workItemStore = (WorkItemStore) collection.GetService(typeof(WorkItemStore));
            string qry = "SELECT [Title] From WorkItems Where [Work Item Type] = 'Bug' "  +
                " AND [Iteration Path] = 'AML_Module\\Release 3\\Sprint 4' AND [Team Project]='AML_Module'";

            var res = workItemStore.Query (qry);
            foreach ( var wi in res)
            {
                string s = wi.ToString();
            }
        }
 public static WorkItemStore GetWorkItemStore(TfsConfigurationServer tfs, CatalogNode teamProjectColCatalog)
 {
     Guid teamProjectCatalogId = new Guid(teamProjectColCatalog.Resource.Properties["InstanceId"]);
     TfsTeamProjectCollection teamProjectCollection = tfs.GetTeamProjectCollection(teamProjectCatalogId);
     return new WorkItemStore(teamProjectCollection);
 }
예제 #36
0
        private async Task<List<BuildInfoDto>>  GetBuildInfoDtosPerTeamProject(CatalogNode teamProjectCollectionNode,
            TfsConfigurationServer tfsServer, DateTime filterDate)
        {
            var buildInfoDtos = new List<BuildInfoDto>();
            try
            {
                // Use the InstanceId property to get the team project collection
                var collectionId = new Guid(teamProjectCollectionNode.Resource.Properties["InstanceId"]);
                var teamProjectCollection = tfsServer.GetTeamProjectCollection(collectionId);

                var buildServer = (IBuildServer)teamProjectCollection.GetService(typeof(IBuildServer));
                var testService = teamProjectCollection.GetService<ITestManagementService>();



                // Get a catalog of team projects for the collection


                if (tfsServer.ServerDataProvider.ServerVersion == null)
                {


                    var teamProjectNodes = teamProjectCollectionNode.QueryChildren(new[] {CatalogResourceTypes.TeamProject}, false, CatalogQueryOptions.None);

                    // List the team projects in the collection
                    Parallel.ForEach(teamProjectNodes, teamProjectNode =>
                    {
                        var buildDefinitionList = buildServer.QueryBuildDefinitions(teamProjectNode.Resource.DisplayName).ToList();

                        lock (buildInfoDtos)
                        {
                            buildInfoDtos.AddRange(GetBuildInfoDtosPerBuildDefinition(buildDefinitionList, buildServer, teamProjectNode, teamProjectCollection, testService, filterDate));
                        }
                    });
                }
                else
                {
                    var commonStructureService = teamProjectCollection.GetService<ICommonStructureService>();
                    var httpClient = teamProjectCollection.GetClient<BuildHttpClient>();
                    var listAllProjects = commonStructureService.ListAllProjects().ToList();
                    foreach (var project in listAllProjects)
                    {
                        var definitionReferences = await httpClient.GetDefinitionsAsync(project: project.Name).ConfigureAwait(false);
                        
                        var buildInfos = await GetBuildInfoDtosPerBuildDefinitionRest(teamProjectCollection, definitionReferences, httpClient);
                        lock (buildInfoDtos)
                        {
                            buildInfoDtos.AddRange(buildInfos);
                        }
                    }
                }
            }
            catch (Exception e)
            {
                LogService.WriteError(e);
                throw;
            }


            return await Task.FromResult(buildInfoDtos);
        }
예제 #37
0
        private IEnumerable<BuildInfoDto> GetBuildInfoDtosPerTeamProject(CatalogNode teamProjectCollectionNode,
            TfsConfigurationServer tfsServer, DateTime filterDate)
        {
            var buildInfoDtos = new List<BuildInfoDto>();
            try
            {
                // Use the InstanceId property to get the team project collection
                var collectionId = new Guid(teamProjectCollectionNode.Resource.Properties["InstanceId"]);
                var teamProjectCollection = tfsServer.GetTeamProjectCollection(collectionId);

                var buildServer = (IBuildServer)teamProjectCollection.GetService(typeof(IBuildServer));
                var testService = teamProjectCollection.GetService<ITestManagementService>();

                // Get a catalog of team projects for the collection
                var teamProjectNodes = teamProjectCollectionNode.QueryChildren(
                    new[] { CatalogResourceTypes.TeamProject },
                    false, CatalogQueryOptions.None);

                // List the team projects in the collection
                Parallel.ForEach(teamProjectNodes, teamProjectNode =>
                {
                    var buildDefinitionList =
                        new List<IBuildDefinition>(buildServer.QueryBuildDefinitions(teamProjectNode.Resource.DisplayName));
                    lock (buildInfoDtos)
                    {
                        buildInfoDtos.AddRange(GetBuildInfoDtosPerBuildDefinition(buildDefinitionList, buildServer,
                            teamProjectNode,
                            teamProjectCollection, testService, filterDate));
                    }
                });
            }
            catch (Exception e)
            {
                LogService.WriteError(e);
                throw;
            }


            return buildInfoDtos;
        }
 public ITeamProjectsLocator New(TfsConfigurationServer tfsServer, Guid collectionId)
 {
     var collection = tfsServer.GetTeamProjectCollection(collectionId);
     var serviceLocator = m_serviceLocatorFactory.New(collection);
     return New(serviceLocator);
 }
예제 #39
0
파일: RemoteTfs.cs 프로젝트: mwpnl/bmx-tfs
        private static TfsTeamProjectCollection FindCollection(TfsConfigurationServer server, Guid? collectionId, string collectionName)
        {
            if (collectionId != null)
                return server.GetTeamProjectCollection(collectionId.Value);

            var match = server
                .GetService<ITeamProjectCollectionService>()
                .GetCollections()
                .FirstOrDefault(c => string.Equals(c.Name, collectionName, StringComparison.OrdinalIgnoreCase));

            if (match == null)
                return null;

            return server.GetTeamProjectCollection(match.Id);
        }
        public void Connect(Uri tfsUri)
        {
            var projectCollectionName = tfsUri.Segments[tfsUri.Segments.Length - 1];
            var tfsConnection = tfsUri.AbsoluteUri.Substring(0, tfsUri.AbsoluteUri.Length - projectCollectionName.Length);

            m_configurationServer = TfsConfigurationServerFactory.GetConfigurationServer(new Uri(tfsConnection));
            //m_configurationServer.Connect(ConnectOptions.IncludeServices);

            CatalogNode configurationServerNode = m_configurationServer.CatalogNode;

            // Query the children of the configuration server node for all of the team project collection nodes
            ReadOnlyCollection<CatalogNode> tpcNodes = configurationServerNode.QueryChildren(
                    new Guid[] { CatalogResourceTypes.ProjectCollection },
                    false,
                    CatalogQueryOptions.None);

            foreach (CatalogNode tpcNode in tpcNodes)
            {
                if (tpcNode.Resource.DisplayName.ToUpper() == GetWithoutTralingSlash(projectCollectionName).ToUpper())
                {
                    Guid tpcId = new Guid(tpcNode.Resource.Properties["InstanceId"]);
                    TfsTeamProjectCollection tpc = m_configurationServer.GetTeamProjectCollection(tpcId);                
                    m_versionControlServer = tpc.GetService<VersionControlServer>();   
                    break;
                }
            }
            if (m_versionControlServer == null)
            {
                throw new Exception(string.Format("Project collection name '{0}' not found",projectCollectionName));
            }
        }
        private IDictionary<TfsTeamProjectCollection, ReadOnlyCollection<CatalogNode>> GetTeamProjectCollectionsWithTeamProjectCatalogNodes(TfsConfigurationServer tfs)
        {
            CatalogNode catalogNode = tfs.CatalogNode;

            // Note: this requires a dependency to Microsoft.TeamFoundation.Common. Really needed?
            ReadOnlyCollection<CatalogNode> tpcNodes =
                catalogNode.QueryChildren(new[] { CatalogResourceTypes.ProjectCollection }, false, CatalogQueryOptions.None);

            var tpcDictionary = new Dictionary<TfsTeamProjectCollection, ReadOnlyCollection<CatalogNode>>();
            foreach (CatalogNode tpcNode in tpcNodes)
            {
                Guid instanceId = new Guid(tpcNode.Resource.Properties["InstanceId"]);
                TfsTeamProjectCollection tpc = tfs.GetTeamProjectCollection(instanceId);

                // Get catalog of tp = 'Team Projects' for the tpc = 'Team Project Collection'
                ReadOnlyCollection<CatalogNode> tpNodes =
                    tpcNode.QueryChildren(new[] { CatalogResourceTypes.TeamProject }, false, CatalogQueryOptions.None);

                tpcDictionary.Add(tpc, new ReadOnlyCollection<CatalogNode>(tpNodes));
            }

            return tpcDictionary;
        }
 public TfsTeamProjectCollection tfsTeamProjectCollectionConfigServer(TfsConfigurationServer configurationServer, Guid collectionId)
 {
     TfsTeamProjectCollection teamProjectCollection = configurationServer.GetTeamProjectCollection(collectionId);
     return teamProjectCollection;
 }