Adding requirements

The following example describes how to add requirements. 

1. Localize external namespaces.

using System;

using System.Collections.Generic;

using System.Text;

2. Set up the namespace, provide the login information, and define the project name.

namespace AddRequirement

{

class Program

{

static void Main (string[] args)

{

long cookie = -1;

ttsoapcgi ttsdk = null;

 

try

{

string username = "username";

string password = "password";

string ProjectName = "ProjectName";

3. Create an instance of the ttsoapcgi class, which is generated from the ttsoapcgi.wsdl file.

ttsdk = new ttsoapcgi();

4. Set the URL that the ttsdk object connects to if you are not using the default URL from the WSDL file.

ttsdk.Url = "http://localhost:80/scripts/ttsoapcgi.exe";

5. Select the Helix ALM project to connect to and set proj to reference it.

CProject[] projects = ttsdk.getProjectList(username, password);

CProject proj = null;

 

foreach (CProject p in projects)

{

if (p.database.name.Equals(projectName))

{

proj = p;

break;

}

}

6. Log in to the project.

cookie = ttsdk.ProjectLogon(proj, username, password);

7. Create a CRequirement object and enter the requirement information.

You must provide data for all required fields to correctly initialize the object.

CRequirement req = new CRequirement();

req.summary = "Example requirement 1";

req.type = "Functional Requirement";

req.enteredBy = "LastName, FirstName MiddleInitial";

req.description =

"First line of description.\r\n" +

"Second line of description.\r\n";

8. Finish adding the requirement and catch exceptions.

ttask.addRequirement(cookie, req);

Console.WriteLine("Successfully added the new requirement.");

 

}

catch (Exception e)

{

Console.WriteLine("An exception occurred:");

Console.WriteLine(e.Message);

}

9. End the session and log out of the Helix ALM SDK.

finally

{

if (ttsdk != null && cookie != -1)

{

ttsdk.DatabaseLogoff(cookie);

}

Console.WriteLine("Press any key to exit.");

Console.ReadKey();

}