Hello - I'm having a problem reading all levels of MS tasks;
ArrayList collector = project.RootTask.Children; --- only brings back first level
ChildTasksCollector collector = new ChildTasksCollector(); --- Start and finish dates are wrong when reading MPP files; you have an open issue;
I know I can use:ArrayList collector = project.RootTask.Children;
foreach (Task task in collector)
{
foreach (Task lvl1 in task.Children)
{
foreach (Task lvl2 in task.Children)
{
If I need to go 8 levels deep - this would casue a lot of duplicate code;
Is there a better way of iterating through all the tasks regardless of level?
Thanks in advance
Len
Hi Len,
The best way is to use ChildTasksCollector as you can see in the following example:
Aspose.Tasks.License lic = new License();
lic.SetLicense(@"Aspose.Total.Product.Family.lic");
ProjectReader reader = new ProjectReader();
Project project = reader.Read("Project1.xml");
ChildTasksCollector collector = new ChildTasksCollector();
TaskUtils.Apply(project.RootTask, collector, 0);
foreach (Task task in collector.Tasks)
{
Console.WriteLine("\nID: " + task.Id +
"\nName: " + task.Name +
"\nStart: " + task.Start +
"\nFinish: " + task.Finish);
}
If dates are incorrect, ChildTasksCollector is not responsible for that. You can post your sample here to reproduce the issue and we will try to resolve that issue.
Best Regards,