Hi,
Remaining Work and Actual Work values are not summarizing correctly. The following code should produce a MPP file with a the Main Parent 1 task set to have 15 hours of Remaining Work and 5 hours of Actual Work. However, it’s showing as 18.3 hours of Remaining Work and 1.7 of Actual Work. Any ideas as to why? Am I doing something wrong? See code below, also I‘ve attached the template and sample output file.
Project project = new Project("New Project 2010.mpp");
project.Set(Prj.ScheduleFromStart, true);
project.Set(Prj.StartDate, DateTime.Now);
Task mainParent = project.RootTask.Children.Add("Main Parent 1");
mainParent.Set(Tsk.IsSummary, true);
mainParent.Set(Tsk.DisplayAsSummary, true);
mainParent.Set(Tsk.Uid, 1);
// Add new task and assign attribute value
Task parent1 = mainParent.Children.Add("New Task Parent 1");
parent1.Set(Tsk.IsSummary, true);
parent1.Set(Tsk.DisplayAsSummary, true);
parent1.Set(Tsk.Uid, 2);
Task parent2 = mainParent.Children.Add("New Task Parent 2");
parent2.Set(Tsk.Uid, 3);
Task child1 = parent1.Children.Add("New Task Child 1");
child1.Set(Tsk.Duration, project.GetDuration(1));
child1.Set(Tsk.Uid, 4);
Duration _budgetDuration = new Duration();
_budgetDuration = _budgetDuration.Convert(TimeUnitType.Hour);
child1.Set(Tsk.Work, _budgetDuration.Add(10));
Duration _actualDuration = new Duration();
_actualDuration = _actualDuration.Convert(TimeUnitType.Hour);
child1.Set(Tsk.ActualWork, _actualDuration.Add(5));
child1.Set(Tsk.Start, DateTime.Now);
Task parent3 = mainParent.Children.Add("New Task Parent 3");
parent3.Set(Tsk.IsSummary, true);
parent3.Set(Tsk.DisplayAsSummary, true);
parent3.Set(Tsk.Uid, 5);
Task child2 = parent3.Children.Add("New Task Child 2");
child2.Set(Tsk.Duration, project.GetDuration(1));
child2.Set(Tsk.Uid, 6);
child2.Set(Tsk.Work, _budgetDuration.Add(10));
child2.Set(Tsk.ActualWork, _actualDuration.Add(0));
child2.Set(Tsk.Start, DateTime.Now);
project.Recalculate();
MPPSaveOptions mppSaveOptions = new MPPSaveOptions();
mppSaveOptions.WriteViewData = true;
//Save the project as MPP project file
project.Save("result.mpp", mppSaveOptions);
I’ve downloaded a trial version of 9.2.1 of which I have a temporary license for evaluation. I’m using VS 2010 and MS Project 2010.
Thanks, Calvin