Пример #1
0
 public void GetBuildDefinitions(TeamCityProject project, string userName, string password, GetBuildDefinitionsCompleteDelegate complete)
 {
     WebClient webClient = new WebClient
     {
         Credentials = new NetworkCredential(userName, password)
     };
     var projectDetailsUrl = new Uri(project.RootUrl + project.Href);
     webClient.DownloadStringCompleted += (s, e) =>
     {
         XDocument doc = XDocument.Parse(e.Result);
         if (doc.Root == null)
         {
             throw new Exception("Could not get project build definitions");
         }
         XElement buildTypes = doc.Root.Element("buildTypes");
         if (buildTypes == null)
         {
             throw new Exception("Could not get project build definitions");
         }
         TeamCityBuildDefinition[] projects = buildTypes
             .Elements("buildType")
             .Select(buildTypeXml => new TeamCityBuildDefinition(project.RootUrl, buildTypeXml))
             .ToArray();
         complete(projects);
     };
     webClient.DownloadStringAsync(projectDetailsUrl);
 }
Пример #2
0
        public void GetBuildDefinitions(TeamCityProject project, string userName, string password, GetBuildDefinitionsCompleteDelegate complete)
        {
            WebClient webClient = new WebClient
            {
                Credentials = new NetworkCredential(userName, password)
            };
            var projectDetailsUrl = new Uri(project.RootUrl + project.Href);

            webClient.DownloadStringCompleted += (s, e) =>
            {
                XDocument doc = XDocument.Parse(e.Result);
                if (doc.Root == null)
                {
                    throw new Exception("Could not get project build definitions");
                }
                XElement buildTypes = doc.Root.Element("buildTypes");
                if (buildTypes == null)
                {
                    throw new Exception("Could not get project build definitions");
                }
                TeamCityBuildDefinition[] projects = buildTypes
                                                     .Elements("buildType")
                                                     .Select(buildTypeXml => new TeamCityBuildDefinition(project.RootUrl, buildTypeXml))
                                                     .ToArray();
                complete(projects);
            };
            webClient.DownloadStringAsync(projectDetailsUrl);
        }
Пример #3
0
        private static async Task LoadProjectInfoFromApi(TeamCityProject project, WebClient webClient)
        {
            try
            {
                var projectDetailsUrl = new Uri(project.RootUrl + project.Href);
                _log.Debug("Retrieving project info for " + project.Name + " at " + projectDetailsUrl);
                var projectDetailsStr = await webClient.DownloadStringTaskAsync(projectDetailsUrl);
                XDocument projectDoc = XDocument.Parse(projectDetailsStr);
                if (projectDoc.Root == null)
                {
                    throw new Exception("Could not get project build definitions");
                }

                var parentProjectElement = projectDoc.Root.Element("parentProject");
                if (parentProjectElement != null)
                {
                    project.ParentProjectId = parentProjectElement.Attribute("id").Value;
                }

                XElement buildTypes = projectDoc.Root.Element("buildTypes");
                if (buildTypes == null)
                    throw new ArgumentException(string.Format("buildTypes was null for {0}, this shouldn't happen", project.Name));
                project.BuildDefinitions = buildTypes
                    .Elements("buildType")
                    .Select(buildTypeXml => new TeamCityBuildDefinition(project.RootUrl, buildTypeXml))
                    .ToList();
            }
            catch (Exception ex)
            {
                _log.Error(string.Format("Error parsing project info for project {0} ({1})", project.Name, project.Id), ex);
                throw;
            }
        }
Пример #4
0
 private void RecreateTreeOfProjects(TeamCityProject project, TeamCityProject[] allProjects)
 {
     project.SubProjects = allProjects.Where(i => i.ParentProjectId == project.Id).ToList();
     foreach (var subProject in project.SubProjects)
     {
         RecreateTreeOfProjects(subProject, allProjects);
     }
 }
Пример #5
0
 private void RecreateTreeOfProjects(TeamCityProject project, TeamCityProject[] allProjects)
 {
     project.SubProjects = allProjects.Where(i => i.ParentProjectId == project.Id).ToList();
     foreach (var subProject in project.SubProjects)
     {
         RecreateTreeOfProjects(subProject, allProjects);
     }
 }
Пример #6
0
 private TeamCityProject[] RecreateTreeOfProjects(TeamCityProject[] allProjects)
 {
     var roots = allProjects.Where(i => i.ParentProjectId == null).ToArray();
     foreach (var project in roots)
     {
         RecreateTreeOfProjects(project, allProjects);
     }
     return roots;
 }
Пример #7
0
        private static async Task LoadProjectInfoFromApi(TeamCityProject project, WebClient webClient)
        {
            try
            {
                var projectDetailsUrl = new Uri(project.RootUrl + project.Href);
                _log.Debug("Retrieving project info for " + project.Name + " at " + projectDetailsUrl);
                var projectDetailsStr = await webClient.DownloadStringTaskAsync(projectDetailsUrl);

                XDocument projectDoc = XDocument.Parse(projectDetailsStr);
                if (projectDoc.Root == null)
                {
                    throw new Exception("Could not get project build definitions");
                }

                var parentProjectElement = projectDoc.Root.Element("parentProject");
                if (parentProjectElement != null)
                {
                    project.ParentProjectId = parentProjectElement.Attribute("id").Value;
                }

                XElement buildTypes = projectDoc.Root.Element("buildTypes");
                if (buildTypes == null)
                {
                    throw new ArgumentException(string.Format("buildTypes was null for {0}, this shouldn't happen", project.Name));
                }
                project.BuildDefinitions = buildTypes
                                           .Elements("buildType")
                                           .Select(buildTypeXml => new TeamCityBuildDefinition(project.RootUrl, buildTypeXml))
                                           .ToList();
            }
            catch (Exception ex)
            {
                _log.Error(string.Format("Error parsing project info for project {0} ({1})", project.Name, project.Id), ex);
                throw;
            }
        }