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.
Hi,
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));
project.RootTask.Children.Add(task);
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);
task.Children.Add(ChildTask);
}
}
project.FinishDate = dt.AddDays(3);
project.CalcTaskIds();
project.CalcTaskUids();
project.UpdateReferences();
ProjectWriter prjWriter = new ProjectWriter();
prjWriter.Write(project, “test.xml”, TasksDataFormat.XML);