Hello
I am currently using the evaluation version of Aspose Task for .net 2.1.1
(dll version is 2.1.1.1)
I encounter a problem trying to read links between tasks of my MPP File.
By example, I would like to get predecessors of a task.
The only way I found is to use the method GetPredecessors :
project1.GetPredecessors(vCurrentTask); which is supposed to return an arraylist of predecessors for the given task.
Unfortunately the method never finds any of the predecessors.
Is there a bug or should I use another method or property of the task ?
Thanks
Sylvain Gantois
U can use Predecessors property of the task that will return relations. Iterate through the relations and use TaskIDValue property of the relation in order to get the predecessor task ID.
My previous reply was with respect to dll version 1.6.2.0. For the dll version 2.1.1.1 that you are using, there seems some issue with GetPredecessor() function that is supposed to accept a task object and return a list of its predecessor tasks. However, you can use TaskLinks property of the project that will return a list of all the TaskLinks of the project to be stored as an ArrayList. This ArrayList can further be traversed to obtain the respective predecessor and successor tasks. An example is listed below.
ArrayList arrTLnk = project.TaskLinks;
foreach( TaskLink TLnk in arr TLnk)
{
//get predecessor task
Task tskp = tlnk.PredTask;
//get successor task
Task tsks = tlnk.SuccTask;
//get name of the predecessor task
string strtskp = tskp.Name;
//get name of the successor task
string strtsks = tsks.Name;
}