Ejemplo n.º 1
0
        /// <summary>
        /// Check to see if two sets of configuration are the same.
        /// </summary>
        /// <param name="obj">The other configuration set to check.</param>
        /// <returns>True if they are both the same, false otherwise.</returns>
        /// <remarks>
        /// This is part of the fix for CCNET-1179.
        /// </remarks>
        public override bool Equals(object obj)
        {
            CCTrayProject objToCompare = obj as CCTrayProject;

            if (objToCompare != null)
            {
                bool isSame = string.Equals(projectName, objToCompare.projectName);

                if (isSame)
                {
                    if ((buildServer != null) && (objToCompare.buildServer != null))
                    {
                        // If both instances have a build server then compare the build server settings
                        isSame = string.Equals(buildServer.Url, objToCompare.buildServer.Url);
                    }
                    else if ((buildServer != null) && (objToCompare.buildServer != null))
                    {
                        // If neither instance has a build server then they are the same
                        isSame = true;
                    }
                    else
                    {
                        // Otherwise we know we have a difference
                        isSame = false;
                    }
                }
                return(isSame);
            }
            else
            {
                return(false);
            }
        }
		public ProjectConfigurationListViewItemAdaptor(CCTrayProject project)
		{
			this.project = project;
			item = new ListViewItem(new string[] {project.BuildServer.DisplayName, project.BuildServer.Transport.ToString(), project.ProjectName});
			item.Checked = project.ShowProject;
			item.Tag = this;
		}
 private static ISingleServerMonitor GetServerMonitorForProject(CCTrayProject project, IEnumerable <ISingleServerMonitor> serverMonitors)
 {
     foreach (ISingleServerMonitor serverMonitor in serverMonitors)
     {
         if (serverMonitor.ServerUrl == project.ServerUrl)
         {
             return(serverMonitor);
         }
     }
     throw new ApplicationException("Server monitor not found for project: " + project.ProjectName);
 }
 private static ISingleServerMonitor GetServerMonitorForProject(CCTrayProject project, IEnumerable<ISingleServerMonitor> serverMonitors)
 {
     foreach (ISingleServerMonitor serverMonitor in serverMonitors)
     {
         if (serverMonitor.ServerUrl == project.ServerUrl)
         {
             return serverMonitor;
         }
     }
     throw new ApplicationException("Server monitor not found for project: " + project.ProjectName);
 }
        /// <summary>
        /// Gets the list of projects.
        /// </summary>
        /// <returns>The available projects on the server.</returns>
        public CCTrayProject[] GetProjectList()
        {
            ProjectStatus[] statuses = manager.GetProjectStatus();
            CCTrayProject[] projects = new CCTrayProject[statuses.Length];

            for (int i = 0; i < statuses.Length; i++)
            {
                ProjectStatus status = statuses[i];
                projects[i] = new CCTrayProject(this.configuration, status.Name);
            }

            return projects;
        }
		public AddProjects(ICruiseProjectManagerFactory cruiseProjectManagerFactory,
            ICruiseServerManagerFactory cruiseServerManagerFactory,
            CCTrayProject[] currentProjectList)
		{
			this.cruiseProjectManagerFactory = cruiseProjectManagerFactory;
            this.cruiseServerManagerFactory = cruiseServerManagerFactory;
			this.currentProjectList = currentProjectList;

			InitializeComponent();

            List<BuildServer> serverList = new List<BuildServer>();
			foreach (CCTrayProject project in currentProjectList)
			{
                if (!serverList.Contains(project.BuildServer)) serverList.Add(project.BuildServer);
		}

            foreach (BuildServer server in serverList)
		{
                AddServer(server);
			}
		}
 public ICruiseProjectManager Create(CCTrayProject project, IDictionary<BuildServer, ICruiseServerManager> serverManagers)
 {
     BuildServer server = project.BuildServer;
     switch (server.Transport)
     {
         case BuildServerTransport.Remoting:
             {
                 var client = GenerateRemotingClient(server);
                 return new RemotingCruiseProjectManager(client, project.ProjectName);
             }
         case BuildServerTransport.Extension:
             ITransportExtension extensionInstance = ExtensionHelpers.RetrieveExtension(server.ExtensionName);
             extensionInstance.Settings = server.ExtensionSettings;
             extensionInstance.Configuration = server;
             return extensionInstance.RetrieveProjectManager(project.ProjectName);
         default:
             {
                 var client = GenerateHttpClient(server);
                 return new HttpCruiseProjectManager(client, project.ProjectName, serverManagers[server]);
             }
     }
 }
        /// <summary>
        /// Update the projects configuration.
        /// </summary>
        public void UpdateProjectList()
        {
            mainForm.ReloadConfiguration(() =>
            {
                var form = new DisplayChangedProjects(changeList);
                form.UpdateConfiguration += (servers) =>
                {
                    // Update each server
                    var projects = new List<CCTrayProject>(configuration.Projects);
                    foreach (var server in servers)
                    {
                        // Generate each project and add it to the configuration
                        foreach (var newProject in server.AddedProjects)
                        {
                            var projectConfig = new CCTrayProject
                            {
                                BuildServer = server.Configuration,
                                ProjectName = newProject,
                                ShowProject = true

                            };
                            projects.Add(projectConfig);
                        }

                        // Remove the old projects
                        foreach (var oldProject in server.DeletedProjects)
                        {
                            // Try to find the project
                            CCTrayProject actualProject = null;
                            foreach (var project in projects)
                            {
                                if (project.BuildServer.Equals(server.Configuration) &&
                                    project.ProjectName.Equals(oldProject))
                                {
                                    actualProject = project;
                                    break;
                                }
                            }

                            // If the project is found, it can be removed
                            if (actualProject != null) projects.Remove(actualProject);
                        }
                    }
                    var newConfig = configuration.Clone();
                    newConfig.Projects = projects.ToArray();

                    // Save the configuration and reload
                    newConfig.Persist();
                    mainForm.CloseUpdatePanel();
                };

                var result = form.ShowDialog(mainForm);
                return (result == DialogResult.OK);
            });
        }
 public void SetExtensionNameBlank()
 {
     CCTrayProject newValue = new CCTrayProject();
     newValue.ExtensionName = string.Empty;
     Assert.AreEqual(string.Empty, newValue.ExtensionName);
     Assert.AreEqual(BuildServerTransport.HTTP, newValue.BuildServer.Transport);
 }
 public void SetExtensionNameNonBlank()
 {
     CCTrayProject newValue = new CCTrayProject();
     newValue.ExtensionName = "An extension";
     Assert.AreEqual("An extension", newValue.ExtensionName);
     Assert.AreEqual(BuildServerTransport.Extension, newValue.BuildServer.Transport);
 }
 public void SetExtensionSettings()
 {
     CCTrayProject newValue = new CCTrayProject();
     newValue.ExtensionSettings = "Some settings";
     Assert.AreEqual("Some settings", newValue.ExtensionSettings);
 }
		private CCTrayProject[] BuildProjectListFromListView()
		{
			CCTrayProject[] newProjectList = new CCTrayProject[lvProjects.Items.Count];

			for (int i = 0; i < lvProjects.Items.Count; i++)
			{
				ProjectConfigurationListViewItemAdaptor adaptor = (ProjectConfigurationListViewItemAdaptor)lvProjects.Items[i].Tag;
				newProjectList[i] = adaptor.Project;
			}
			return newProjectList;
		}
        public CCTrayProject[] GetProjectList()
        {
            IBuildDefinitionSpec defSpec = TfsBuildServer.CreateBuildDefinitionSpec(Settings.TeamProject);
            IBuildDefinitionQueryResult query = TfsBuildServer.QueryBuildDefinitions(defSpec);

            if (query != null)
            {
                CCTrayProject[] projects = new CCTrayProject[query.Definitions.Length];

                for (int i = 0; i < query.Definitions.Length; i++)
                {
                    projects[i] = new CCTrayProject()
                    {
                        BuildServer = Configuration,
                        ExtensionName = Configuration.ExtensionName,
                        ExtensionSettings = Configuration.ExtensionSettings,
                        ProjectName = query.Definitions[i].Name,
                        SecuritySettings = Configuration.SecuritySettings,
                        SecurityType = Configuration.SecurityType,
                        ServerUrl = Configuration.Url,
                        ShowProject = query.Definitions[i].Enabled
                    };
                }

                return projects;
            }

            return null;
        }
		private bool IsProjectAlreadyAdded(CCTrayProject project)
		{
			foreach (CCTrayProject currentProject in currentProjectList)
			{
				if (project.ServerUrl == currentProject.ServerUrl && project.ProjectName == currentProject.ProjectName)
					return true;
			}
			return false;
		}