Free Support Forum - aspose.com

How to read work break down structure value and level in an existing MPP

Hi,


I am new to Task product and need help in getting the work break down structure value and its level in an existing MPP. Can you please provide some example for this?

Thanks in advance!!

Hi Cornelius,


Thanks for writing to Aspose.Tasks support team.

You may please give a try to the following sample code which displays WBS value and level.

//Create a project reader instance
ProjectReader rdr = new ProjectReader();

//Call read method of project reader object to get project object
Project prj = rdr.Read(“d:\project5.mpp”);

// Create a ChildTasksCollector instance
ChildTasksCollector collector = new ChildTasksCollector();

// Collect all the tasks from RootTask using TaskUtils
TaskUtils.Apply(prj.RootTask, collector, 0);

// Parse through all the collected tasks
foreach (Task tsk in collector.Tasks)
{
Console.WriteLine(tsk.Wbs);
Console.WriteLine(tsk.WbsLevel);
}

ArrayList alTasks = prj.RootTask.Children;
foreach (Task tsk in alTasks)
{
Console.WriteLine(tsk.Wbs);
Console.WriteLine(tsk.WbsLevel);
}

Please feel free to write us back if you have any other query in this regard.