コード例 #1
0
        private void ImportProject(StreamWriter streamWriter, SpiraSoapService.SoapServiceClient spiraClient, TestLink testLinkApi)
        {
            try
            {
                streamWriter.WriteLine(String.Format("Importing Test Link project '{0}' to Spira...", this.testLinkProjectName));

                //Get the project info from the TestLink API
                TestProject tlProject = testLinkApi.GetProject(this.testLinkProjectName);
                if (tlProject == null)
                {
                    throw new ApplicationException(String.Format("Empty project data returned by TestLink for project '{0}' so aborting import", this.testLinkProjectId));
                }

                RemoteProject remoteProject = new RemoteProject();
                remoteProject.Name    = tlProject.name;
                remoteProject.Website = tlProject.notes;
                remoteProject.Active  = tlProject.active;

                //Reconnect and import the project
                spiraClient.Connection_Authenticate2(Properties.Settings.Default.SpiraUserName, Properties.Settings.Default.SpiraPassword, "TestLinkImporter");
                remoteProject = spiraClient.Project_Create(remoteProject, null);
                streamWriter.WriteLine("New Project '" + remoteProject.Name + "' Created");
                int projectId = remoteProject.ProjectId.Value;

                this.newProjectId = remoteProject.ProjectId.Value;
            }
            catch (Exception exception)
            {
                streamWriter.WriteLine("General error importing data from TestLink to Spira The error message is: " + exception.Message);
                throw;
            }
        }
コード例 #2
0
        private void ImportProject(StreamWriter streamWriter, SpiraSoapService.SoapServiceClient spiraClient, APIClient testRailApi)
        {
            try
            {
                streamWriter.WriteLine(String.Format("Importing Test Rail project {0} to Spira...", this.testRailProjectId));

                //Get the project info from the TestRail API
                JObject project = (JObject)testRailApi.SendGet("get_project/" + this.testRailProjectId);
                if (project == null)
                {
                    throw new ApplicationException(String.Format("Empty project data returned by TestRail for project '{0}' so aborting import", this.testRailProjectId));
                }

                RemoteProject remoteProject = new RemoteProject();
                remoteProject.Name    = project["name"].Value <string>();
                remoteProject.Website = project["url"].Value <string>();
                remoteProject.Active  = !project["is_completed"].Value <bool>();

                //Reconnect and import the project
                spiraClient.Connection_Authenticate2(Properties.Settings.Default.SpiraUserName, Properties.Settings.Default.SpiraPassword, "TestRailImporter");
                remoteProject = spiraClient.Project_Create(remoteProject, null);
                streamWriter.WriteLine("New Project '" + remoteProject.Name + "' Created");
                int projectId = remoteProject.ProjectId.Value;

                this.newProjectId = remoteProject.ProjectId.Value;
            }
            catch (APIException exception)
            {
                streamWriter.WriteLine("Unable to access the TestRail API. The error message is: " + exception.Message);
                throw;
            }
            catch (Exception exception)
            {
                streamWriter.WriteLine("General error importing data from TestRail to Spira The error message is: " + exception.Message);
                throw;
            }
        }