Пример #1
0
        public static void ConnectTFServer(TFSCmdletBase cmdlet, string url, ICredentials credentials)
        {
            try
            {
                Uri uri =
                    new Uri(url);
                
                TfsConfigurationServer tfsServer =
                    new TfsConfigurationServer(
                        uri,
                        credentials);
                
                cmdlet.WriteVerbose(
                    cmdlet,
                    "Connected, checking the connection");
                
                try {
                    tfsServer.EnsureAuthenticated();
                }
                catch (Exception eTfsServerConnected) {
                    
                    cmdlet.WriteError(
                        cmdlet,
                        "Failed to connect to server '" +
                        url +
                        "'." +
                        eTfsServerConnected.Message,
                        "FailedToConnect",
                        ErrorCategory.InvalidResult,
                        true);
                }
                
                CurrentData.CurrentServer = tfsServer;
                
                cmdlet.WriteVerbose(cmdlet,
                                    "Connected to: '" +
                                    url + 
                                    "'");
                
                cmdlet.WriteObject(cmdlet, tfsServer);
            }
//            catch (TeamFoundationServerUnauthorizedException ex)
//            {
//                // handle access denied
//            }
//            catch (TeamFoundationServiceUnavailableException ex)
//            {
//                // handle service unavailable
//            }
            catch (WebException ex)
            {
                // handle other web exception
            }
        }
Пример #2
0
        public static void ConnectTFServer(TFSCmdletBase cmdlet, string url, ICredentials credentials)
        {
            try
            {
                Uri uri =
                    new Uri(url);

                TfsConfigurationServer tfsServer =
                    new TfsConfigurationServer(
                        uri,
                        credentials);

                cmdlet.WriteVerbose(
                    cmdlet,
                    "Connected, checking the connection");

                try {
                    tfsServer.EnsureAuthenticated();
                }
                catch (Exception eTfsServerConnected) {
                    cmdlet.WriteError(
                        cmdlet,
                        "Failed to connect to server '" +
                        url +
                        "'." +
                        eTfsServerConnected.Message,
                        "FailedToConnect",
                        ErrorCategory.InvalidResult,
                        true);
                }

                CurrentData.CurrentServer = tfsServer;

                cmdlet.WriteVerbose(cmdlet,
                                    "Connected to: '" +
                                    url +
                                    "'");

                cmdlet.WriteObject(cmdlet, tfsServer);
            }
//            catch (TeamFoundationServerUnauthorizedException ex)
//            {
//                // handle access denied
//            }
//            catch (TeamFoundationServiceUnavailableException ex)
//            {
//                // handle service unavailable
//            }
            catch (WebException ex)
            {
                // handle other web exception
            }
        }
Пример #3
0
        public static void OpenProject(TFSCmdletBase cmdlet, string[] projectNames)
        {
            string currentProjectName = string.Empty;

            try {
                if (null != projectNames && 0 < projectNames.Length)
                {
                    foreach (string projectName in projectNames)
                    {
                        currentProjectName = projectName;

                        ITestManagementService testMgmtSvc =
                            (ITestManagementService)CurrentData.CurrentCollection.GetService(typeof(ITestManagementService));

                        WorkItemStore store =
                            (WorkItemStore)CurrentData.CurrentCollection.GetService(typeof(WorkItemStore));

                        ITestManagementTeamProject project =
                            testMgmtSvc.GetTeamProject(projectName);

                        cmdlet.WriteVerbose(
                            cmdlet,
                            "Connected to the project '" +
                            projectNames +
                            "'");

                        CurrentData.CurrentProject = project;

                        cmdlet.WriteObject(cmdlet, project);
                    }
                }
                else
                {
                    cmdlet.WriteError(
                        cmdlet,
                        "A wrong name or names were provided for project search",
                        "WrongProjectName",
                        ErrorCategory.InvalidArgument,
                        true);
                }
            }
            catch (Exception eOpenProject) {
                cmdlet.WriteError(
                    cmdlet,
                    "Failed to connect to project '" +
                    currentProjectName +
                    "'." +
                    eOpenProject.Message,
                    "FailedToConnect",
                    ErrorCategory.InvalidResult,
                    true);
            }
        }
Пример #4
0
        public static void NewTestPlan(TFSCmdletBase cmdlet, string name)
        {
            try {
                ITestPlan testPlan =
                    CurrentData.CurrentProject.TestPlans.Create();
                testPlan.Name = name;
                testPlan.Save();

                CurrentData.CurrentTestPlan = testPlan;

                cmdlet.WriteObject(cmdlet, testPlan);
            }
            catch (Exception eNewTestPlan) {
                Console.WriteLine(eNewTestPlan.Message);
            }
        }
Пример #5
0
        public static void OpenProjectCollection(TFSCmdletBase cmdlet, string[] collectionNames)
        {
            try
            {
                if (null != collectionNames && 0 < collectionNames.Length) {
                    
                    foreach (string collectionName in collectionNames) {
                        
                        var projectCollectionUri =
                            new Uri(
                                CurrentData.CurrentServer.Uri.OriginalString +
                                "/" +
                                collectionName);
                        
                        cmdlet.WriteVerbose(
                            cmdlet,
                            "connecing to the collection: '" +
                            projectCollectionUri.ToString() +
                            "'");
                        
                        var projectCollection =
                            TfsTeamProjectCollectionFactory.GetTeamProjectCollection(projectCollectionUri);
                        
                        cmdlet.WriteVerbose(
                            cmdlet,
                            "Collection is connected, checking the connection");
                        
                        try {
                            projectCollection.EnsureAuthenticated();
                        }
                        catch (Exception eTfsCollectionConnected) {
                            
                            cmdlet.WriteError(
                                cmdlet,
                                "Failed to connect to collection '" +
                                projectCollectionUri.ToString() +
                                "'." +
                                eTfsCollectionConnected.Message,
                                "FailedToConnect",
                                ErrorCategory.InvalidResult,
                                true);
                        }
                        
                        cmdlet.WriteVerbose(cmdlet, "connected to the collection");
                        
                        CurrentData.CurrentCollection = projectCollection;
                        
                        cmdlet.WriteObject(cmdlet, projectCollection);
                    }
                
                } else {
                    
                    cmdlet.WriteError(
                        cmdlet,
                        "A wrong name or names were provided for collection search",
                        "WrongCollectionName",
                        ErrorCategory.InvalidArgument,
                        true);
                    
                }
            }
//            catch (TeamFoundationServerUnauthorizedException ex)
//            {
//                // handle access denied
//            }
//            catch (TeamFoundationServiceUnavailableException ex)
//            {
//                // handle service unavailable
//            }
            catch (WebException ex)
            {
                // handle other web exception
            }
            
        }
Пример #6
0
 public static void NewTestPlan(TFSCmdletBase cmdlet, string name)
 {
     try {
         ITestPlan testPlan =
             CurrentData.CurrentProject.TestPlans.Create();
         testPlan.Name = name;
         testPlan.Save();
         
         CurrentData.CurrentTestPlan = testPlan;
         
         cmdlet.WriteObject(cmdlet, testPlan);
         
     }
     catch (Exception eNewTestPlan) {
         Console.WriteLine(eNewTestPlan.Message);
     }
 }
Пример #7
0
        public static void OpenProject(TFSCmdletBase cmdlet, string[] projectNames)
        {

            string currentProjectName = string.Empty;
            
            try {
                
                if (null != projectNames && 0 < projectNames.Length) {
                    
                    foreach (string projectName in projectNames) {
                        
                        currentProjectName = projectName;
                        
                        ITestManagementService testMgmtSvc =
                            (ITestManagementService)CurrentData.CurrentCollection.GetService(typeof(ITestManagementService));
        
                        WorkItemStore store =
                            (WorkItemStore)CurrentData.CurrentCollection.GetService(typeof(WorkItemStore));
        
                        ITestManagementTeamProject project =
                            testMgmtSvc.GetTeamProject(projectName);
                        
                        cmdlet.WriteVerbose(
                            cmdlet,
                            "Connected to the project '" +
                            projectNames +
                            "'");
                        
                        CurrentData.CurrentProject = project;
                        
                        cmdlet.WriteObject(cmdlet, project);
                        
                    }
                    
                } else {
                    
                    cmdlet.WriteError(
                        cmdlet,
                        "A wrong name or names were provided for project search",
                        "WrongProjectName",
                        ErrorCategory.InvalidArgument,
                        true);
                        
                    
                }
            }
            catch (Exception eOpenProject) {
                
                cmdlet.WriteError(
                    cmdlet,
                    "Failed to connect to project '" +
                    currentProjectName +
                    "'." +
                    eOpenProject.Message,
                    "FailedToConnect",
                    ErrorCategory.InvalidResult,
                    true);
            }
        }
Пример #8
0
        public static void OpenProjectCollection(TFSCmdletBase cmdlet, string[] collectionNames)
        {
            try
            {
                if (null != collectionNames && 0 < collectionNames.Length)
                {
                    foreach (string collectionName in collectionNames)
                    {
                        var projectCollectionUri =
                            new Uri(
                                CurrentData.CurrentServer.Uri.OriginalString +
                                "/" +
                                collectionName);

                        cmdlet.WriteVerbose(
                            cmdlet,
                            "connecing to the collection: '" +
                            projectCollectionUri.ToString() +
                            "'");

                        var projectCollection =
                            TfsTeamProjectCollectionFactory.GetTeamProjectCollection(projectCollectionUri);

                        cmdlet.WriteVerbose(
                            cmdlet,
                            "Collection is connected, checking the connection");

                        try {
                            projectCollection.EnsureAuthenticated();
                        }
                        catch (Exception eTfsCollectionConnected) {
                            cmdlet.WriteError(
                                cmdlet,
                                "Failed to connect to collection '" +
                                projectCollectionUri.ToString() +
                                "'." +
                                eTfsCollectionConnected.Message,
                                "FailedToConnect",
                                ErrorCategory.InvalidResult,
                                true);
                        }

                        cmdlet.WriteVerbose(cmdlet, "connected to the collection");

                        CurrentData.CurrentCollection = projectCollection;

                        cmdlet.WriteObject(cmdlet, projectCollection);
                    }
                }
                else
                {
                    cmdlet.WriteError(
                        cmdlet,
                        "A wrong name or names were provided for collection search",
                        "WrongCollectionName",
                        ErrorCategory.InvalidArgument,
                        true);
                }
            }
//            catch (TeamFoundationServerUnauthorizedException ex)
//            {
//                // handle access denied
//            }
//            catch (TeamFoundationServiceUnavailableException ex)
//            {
//                // handle service unavailable
//            }
            catch (WebException ex)
            {
                // handle other web exception
            }
        }