public MyTfsProjectCollection(MyTfsServer myTfsServer, CatalogNode teamProjectCollectionNode)
 {
     try
     {
         _myTfsServer = myTfsServer;
         Name         = teamProjectCollectionNode.Resource.DisplayName;
         ServiceDefinition tpcServiceDefinition = teamProjectCollectionNode.Resource.ServiceReferences["Location"];
         var configLocationService = myTfsServer.GetConfigLocationService();
         var tpcUri = new Uri(configLocationService.LocationForCurrentConnection(tpcServiceDefinition));
         _tfsTeamProjectCollection = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(tpcUri);
         _commonStructureService   = _tfsTeamProjectCollection.GetService <ICommonStructureService>();
         _buildServer = _tfsTeamProjectCollection.GetService <IBuildServer>();
         _tswaClientHyperlinkService = _tfsTeamProjectCollection.GetService <TswaClientHyperlinkService>();
         CurrentUserHasAccess        = true;
     }
     catch (TeamFoundationServiceUnavailableException ex)
     {
         _log.Debug("Can't access " + Name + ". This could be because the project collection is currently offline.", ex);
         CurrentUserHasAccess = false;
     }
     catch (TeamFoundationServerUnauthorizedException ex)
     {
         _log.Debug("Unauthorized access to " + teamProjectCollectionNode, ex);
         CurrentUserHasAccess = false;
     }
 }
        private void SetNetworkCredentials(WebClient webClient)
        {
            var networkCredentials = MyTfsServer.GetCredentialsForTfsServer();

            webClient.UseDefaultCredentials = networkCredentials == null;
            if (networkCredentials != null)
            {
                webClient.Credentials = networkCredentials;
            }
        }
예제 #3
0
        protected override IList<BuildStatus> GetBuildStatus()
        {
            try {
                if (_myTfsServer == null) _myTfsServer = new MyTfsServer(CiEntryPointSetting);
                if (_watchedBuildDefinitions == null)
                {
                    _watchedBuildDefinitions = GetAllWatchedBuildDefinitions().ToArray();
                }

                var buildDefinitionsByServer = _watchedBuildDefinitions.GroupBy(bd => bd.BuildServer);
                return buildDefinitionsByServer.SelectMany(
                    g => g.Key.GetBuildStatuses(
                        g, CiEntryPointSetting.ApplyBuildQuality)).ToList();
            }
            catch (DatabaseOperationTimeoutException ex)
            {
                Log.Warn(ex);
                throw new ServerUnavailableException(ex.Message, ex);
            }
            catch (DatabaseConnectionException ex)
            {
                throw new ServerUnavailableException(ex.Message, ex);
            }
            catch (TeamFoundationServiceUnavailableException ex)
            {
                throw new ServerUnavailableException(ex.Message, ex);
            }
            catch (BuildServerException ex)
            {
                Log.Error("Logging a BuildServerException as Server Unavailable Exception so SoS will continue to try to find the server", ex);
                throw new ServerUnavailableException(ex.Message, ex);
            }
            catch (WebException ex)
            {
                throw new ServerUnavailableException(ex.Message, ex);
            }
            catch (VersionControlException ex)
            {
                throw new ServerUnavailableException(ex.Message, ex);
            }
            catch (ThreadAbortException)
            {
                throw;
            }
            catch (ServerUnavailableException)
            {
                throw;
            }
            catch (Exception ex)
            {
                Log.Error("Error getting build status", ex);
                throw new ServerUnavailableException(ex.Message, ex);
            }
        }
예제 #4
0
        private void GoClick(object sender, EventArgs e)
        {
            if (MyTfsServer.CheckIfIsHostedTfs(_url.Text) && windowsCredentials.Checked)
            {
                MessageBox.Show("You will need to 'Be Someone Else' when connecting to hosted TFS");
                someoneElse.Checked = true;
                return;
            }

            _ciEntryPointSetting.Url      = _url.Text;
            _ciEntryPointSetting.UserName = windowsCredentials.Checked ? null : username.Text;
            if (someoneElse.Checked)
            {
                _ciEntryPointSetting.SetPassword(password.Text);
            }
            Settings.Save();
            DataBindAsync();
        }
예제 #5
0
 private void DataBind()
 {
     try
     {
         using (var tfs = new MyTfsServer(_ciEntryPointSetting))
         {
             _projectCollections = tfs.ProjectCollections.OrderBy(i => i.Name).ToList();
             Invoke(ApplyFilter);
         }
         Settings.Save();
     }
     catch (Exception ex)
     {
         Invoke(() => _buildConfigurations.Nodes.Clear());
         _log.Error("Failed to connect to server", ex);
         MessageBox.Show(ex.Message);
     }
 }
예제 #6
0
        private void DataBind()
        {
            try
            {
                using (var tfs = new MyTfsServer(_ciEntryPointSetting))
                {
                    IList<TreeNode> projectCollectionNodes = new List<TreeNode>();

                    var myTfsProjectCollections = tfs.ProjectCollections.OrderBy(i => i.Name);
                    foreach (var teamProjectCollection in myTfsProjectCollections)
                    {
                        TreeNode projectCollectionNode = new TreeNode(teamProjectCollection.Name);
                        var myTfsProjects = teamProjectCollection.Projects.OrderBy(i => i.Name);
                        foreach (var project in myTfsProjects)
                        {
                            var projectNode = projectCollectionNode.Nodes.Add(project.Name);
                            var myTfsBuildDefinitions = project.BuildDefinitions.OrderBy(i => i.Name);
                            foreach (var buildDefinition in myTfsBuildDefinitions)
                            {
                                var buildDefinitionSetting = _ciEntryPointSetting.FindAddBuildDefinition(buildDefinition, _tfsCiEntryPoint.Name);
                                projectNode.Nodes.Add(buildDefinition.GetAsNode(buildDefinitionSetting.Active));
                            }
                        }
                        projectCollectionNodes.Add(projectCollectionNode);
                    }

                    Invoke(() => _buildConfigurations.Nodes.Clear());
                    Invoke(() => _buildConfigurations.Nodes.AddRange(projectCollectionNodes.ToArray()));

                }
                Settings.Save();
            }
            catch (Exception ex)
            {
                Invoke(() => _buildConfigurations.Nodes.Clear());
                _log.Error("Failed to connect to server", ex);
                MessageBox.Show(ex.Message);
            }
        }
예제 #7
0
        private void DataBind()
        {
            try
            {
                using (var tfs = new MyTfsServer(_ciEntryPointSetting))
                {
                    IList <TreeNode> projectCollectionNodes = new List <TreeNode>();

                    var myTfsProjectCollections = tfs.ProjectCollections.OrderBy(i => i.Name);
                    foreach (var teamProjectCollection in myTfsProjectCollections)
                    {
                        TreeNode projectCollectionNode = new TreeNode(teamProjectCollection.Name);
                        var      myTfsProjects         = teamProjectCollection.Projects.OrderBy(i => i.Name);
                        foreach (var project in myTfsProjects)
                        {
                            var projectNode           = projectCollectionNode.Nodes.Add(project.Name);
                            var myTfsBuildDefinitions = project.BuildDefinitions.OrderBy(i => i.Name);
                            foreach (var buildDefinition in myTfsBuildDefinitions)
                            {
                                var buildDefinitionSetting = _ciEntryPointSetting.FindAddBuildDefinition(buildDefinition, _tfsCiEntryPoint.Name);
                                projectNode.Nodes.Add(buildDefinition.GetAsNode(buildDefinitionSetting.Active));
                            }
                        }
                        projectCollectionNodes.Add(projectCollectionNode);
                    }

                    Invoke(() => _buildConfigurations.Nodes.Clear());
                    Invoke(() => _buildConfigurations.Nodes.AddRange(projectCollectionNodes.ToArray()));
                }
                Settings.Save();
            }
            catch (Exception ex)
            {
                Invoke(() => _buildConfigurations.Nodes.Clear());
                _log.Error("Failed to connect to server", ex);
                MessageBox.Show(ex.Message);
            }
        }
        /// <summary>
        /// Using basic auth via network headers should be unnecessary, but with hosted TFS the NetworkCredential method
        /// just doesn't work.  Watch it in Fiddler and it just isn't adding the Authentication header at all.
        /// </summary>
        /// <param name="webClient"></param>
        private void SetBasicAuthCredentials(WebClient webClient)
        {
            var authenticationHeader = MyTfsServer.GetBasicAuthHeader();

            webClient.Headers.Add(authenticationHeader);
        }
 private void DataBind()
 {
     try
     {
         using (var tfs = new MyTfsServer(_ciEntryPointSetting))
         {
             _projectCollections = tfs.ProjectCollections.OrderBy(i => i.Name).ToList();
             Invoke(ApplyFilter);
         }
         Settings.Save();
     }
     catch (Exception ex)
     {
         Invoke(() => _buildConfigurations.Nodes.Clear());
         _log.Error("Failed to connect to server", ex);
         MessageBox.Show(ex.Message);
     }
 }
예제 #10
0
 private void Reset()
 {
     if (_myTfsServer != null)
     {
         _myTfsServer.Dispose();
         _myTfsServer = null;
     }
     _watchedBuildDefinitions = null;
 }