예제 #1
0
        /// <summary>
        /// The connect.
        /// </summary>
        /// <param name="uri">
        /// The uri.
        /// </param>
        /// <param name="credentials">
        /// The credentials.
        /// </param>
        /// <returns>
        /// is connected
        /// </returns>
        public bool Connect(Uri uri, ICredentials credentials, bool anotherUser)
        {
            List <CatalogNode> catalogNodes = GetCatalogNodes(uri, credentials, anotherUser);

            if (catalogNodes != null)
            {
                nodes = new List <CatalogNode>();
                foreach (CatalogNode node in catalogNodes)
                {
                    try
                    {
                        bool _isvsservice = uri.ToString().Contains("visualstudio.com");
                        using (TfsTeamProjectCollection projCollection = new TfsTeamProjectCollection(new Uri(string.Format(@"{0}/{1}", uri, (_isvsservice)? "" : node.Resource.DisplayName)), Credential))
                        {
                            projCollection.EnsureAuthenticated();
                            projCollection.Connect(ConnectOptions.None);
                            nodes.Add(node);
                        }
                    }
                    catch (TeamFoundationServiceUnavailableException ex)
                    {
                    }
                    catch (Exception ex)
                    {
                        //MessageBox.Show(ex.Message);
                    }
                }

                if (nodes.Count > 0)
                {
                    ChangeCollection(nodes[0].Resource.DisplayName);
                    tfsVersion = collection.GetVersion();
                    return(true);
                }
            }

            return(false);
        }