using System; using TestFramework.ApplicationAPI; using TestFramework.AuthenticateAPI; using TestFramework; namespace Tests.wbs { /// <summary> /// Summary description for WBSTaskConstraints. /// /// This sample loads a task from RPM repository and /// assigns a constraint to this task. /// </summary> public class WBSTaskConstraints { public WBSTaskConstraints() { } public static String taskName = "IBM_CHILD_TASK"; //Session ID is use for all transaction and is get from the //Authenticate.login function. The session ID will replace // the User password while transacting public static String sessionid; public void sampleTest() { // initialize a session with the API sessionid = APISetup.SetUp(); // create a save result object SaveResult save = null; // create a task scope // this scope enables us to save information // around the task WorkElementScope tScope = new WorkElementScope(); // create a task object Task task = new Task(); // query the task task = (Task)APISetup.application.loadFromXpath( sessionid, "/Task[name='" + taskName + "']", tScope ).rpmObjectList[0]; task.constraintType = ConstraintType.FinishNoEarlierThan; task.constraintDate = new DateTime(2006,10,10,10,10,10,10); // save task into RPM repository // use a scope that includes any information added // a reload type is not necessary at this // point since we don't use this object again save = new SaveResult(); save = APISetup.application.save(sessionid, task, tScope, ReloadType.None); APISetup.checkForErrors( save ); // close connection with API APISetup.CleanUp(sessionid); } } }