Пример #1
0
        public void Execute(Bot bot)
        {
            if (string.IsNullOrWhiteSpace(IpAddressOrHostNameOfCCServer) || !Projects.Any()) return;

            _client = new TeamCityClient(IpAddressOrHostNameOfCCServer);
            _client.Connect("teamcitysharpuser", "qwerty");

            var allProjects = _client.AllProjects();
            var allBuildConfigs = _client.AllBuildConfigs();

            foreach (var proj in allProjects)
            {
                Project currentProject = proj;
                var buildConfigs = allBuildConfigs.Where(buildConfig => currentProject.Id == buildConfig.Project.Id);

                foreach (var currentBuildConfig in buildConfigs)
                {
                    var build = _client.LastBuildByBuildConfigId(currentBuildConfig.Id);

                    var project = new ProjectModel(currentProject.Name, currentProject.Id, currentBuildConfig.Name, build.StartDate,
                                                     build.Status, build.StatusText);
                    Update(bot, project);
                }
            }
        }
Пример #2
0
 private void NotifyRooms(Bot bot, ProjectModel project)
 {
     foreach (var room in bot.Rooms)
     {
         bot.Say(
             string.Format("TeamCity Build Server: {0} / {1} - {2} ({3}) ",
                           project.BuildConfigName,
                           project.ProjectName,
                           project.LastBuildTime,
                           project.LastBuildStatus), room);
     }
 }
Пример #3
0
 private void Update(Bot bot, ProjectModel project)
 {
     if (Projects.Contains(project.ProjectName))
     {
         if (MappedProjects.All(x => x.ProjectName != project.ProjectName))
         {
             MappedProjects.Add(project);
             NotifyRooms(bot, project);
         }
         else
         {
             var mappedProject = MappedProjects.FirstOrDefault(x => x.ProjectName == project.ProjectName);
             if (mappedProject != null)
             {
                 if (project.LastBuildTime != mappedProject.LastBuildTime)
                 {
                     MappedProjects.Remove(mappedProject);
                     MappedProjects.Add(project);
                     NotifyRooms(bot, project);
                 }
             }
         }
     }
 }