Free Support Forum -

Incorrect parent durationFormat when have childs

Hello… i have a code that can add childs to parent task but when i make it i obtain an incorrect parent durationFormat but this happens only when have childs.

This is an image of the result…



Thanks for writing to Aspose.Tasks support team.

Following is a sample code which creates a new project and then adds tasks and sub tasks to it. This project is saved to disc and then opened in MS Project. It can be observed that all the parent tasks contain proper duration according to the sub-tasks.

Please give it a try and let us know your feedback.

Project project = new Project();
DateTime dt = DateTime.Parse(“04-Mar-2013”);
project.StartDate = dt;
for (int iSum = 0; iSum < 3; iSum++)
dt = project.StartDate;
Task task = new Task("Summary Task " + (iSum + 1));
for (int i = 0; i < 5; i++)
dt = dt.AddDays(1);
Task ChildTask = new Task("Sub Task " + (i+1));
ChildTask.ActualStart = dt;
ChildTask.Duration = new TimeSpan(16, 0, 0);
project.FinishDate = dt.AddDays(3);
ProjectWriter prjWriter = new ProjectWriter();
prjWriter.Write(project, “test.xml”, TasksDataFormat.XML);

Thanks… works very well.