Thanks kashif, it is much clear now. Even though, I have another problem.
- When I was trying to create the timephasedata of all the assignments of my project (which its information is stocked in a database), I noticed that even if the XML where correct, MS Project didn’t show any timephasedata, except the first one, and not correctly.
-
So I took the example code you send me last time and I tried to add a new task, a new assignment and a new timphasedata list to this assignment but… I don’t know why, it doesn’t work. The tasks durations are set correctly, also the assigments work, but the timpahsedata is just shown for the first assignment but this timephasesed data correspond to the second assignment. So the second one re-writes the fist one. The XML seems correct so I don’t understand why this is happening.
Can you please check and help me with this? Thanks
Here is the code:Public Sub T1ByDeveloper()
Dim project As New Project()
project.StartDate = New DateTime(2014, 9, 1)
'project.CalculateAfterEdit = False
project.Calendar = Calendar.MakeStandardCalendar
Dim person1 As Resource = project.AddResource(“Person 1”)
Dim person2 As Resource = project.AddResource(“Person 2”)
'dont use recalculations at all, set everything manually
Dim task1 As New Aspose.Tasks.Task(“Task1”)
task1.Type = Aspose.Tasks.TaskType.FixedDuration
task1.DurationFormat = TimeUnitType.Day
Dim assn1 As New ResourceAssignment(task1, person1)
assn1.WorkContour = WorkContourType.Contoured
assn1.TimephasedData = New List(Of TimephasedData)()
Dim td As New TimephasedData()
td.Start = New DateTime(2014, 10, 1, 8, 0, 0)
td.Finish = New DateTime(2014, 10, 31, 17, 0, 0)
td.TimephasedDataType = TimephasedDataType.AssignmentRemainingWork
td.Value = “PT200H0M0S”
td.Unit = TimeUnitType.Month
assn1.TimephasedData.Add(td)
td = New TimephasedData()
td.Start = New DateTime(2014, 11, 1)
td.Finish = New DateTime(2014, 11, 30)
td.TimephasedDataType = TimephasedDataType.AssignmentRemainingWork
td.Value = “PT50H0M0S”
td.Unit = TimeUnitType.Month
assn1.TimephasedData.Add(td)
assn1.Work = InlineAssignHelper(task1.Work, TimeSpan.FromHours(250))
task1.Start = project.StartDate
task1.Finish = New DateTime(2014, 12, 31, 17, 0, 0)
task1.Duration = project.Calendar.GetWorkingHours(task1.Start, task1.Finish).WorkingHours
Dim task2 As New Aspose.Tasks.Task(“Task2”)
task2.Type = Aspose.Tasks.TaskType.FixedDuration
task2.DurationFormat = TimeUnitType.Day
Dim assn2 As New ResourceAssignment(task2, person2)
assn2.WorkContour = WorkContourType.Contoured
assn2.TimephasedData = New List(Of TimephasedData)()
Dim td2 As New TimephasedData()
td2.Start = New DateTime(2014, 9, 1)
td2.Finish = New DateTime(2014, 9, 30)
td2.TimephasedDataType = TimephasedDataType.AssignmentRemainingWork
td2.Value = “PT50H0M0S”
td2.Unit = TimeUnitType.Month
assn2.TimephasedData.Add(td2)
td2 = New TimephasedData()
td2.Start = New DateTime(2014, 10, 1, 8, 0, 0)
td2.Finish = New DateTime(2014, 10, 31, 17, 0, 0)
td2.TimephasedDataType = TimephasedDataType.AssignmentRemainingWork
td2.Value = “PT100H0M0S”
td2.Unit = TimeUnitType.Month
assn2.TimephasedData.Add(td2)
assn2.Work = InlineAssignHelper(task2.Work, TimeSpan.FromHours(150))
task2.Start = project.StartDate
task2.Finish = New DateTime(2014, 11, 30, 17, 0, 0)
task2.Duration = project.Calendar.GetWorkingHours(task2.Start, task2.Finish).WorkingHours
project.RootTask.Children.Add(task1)
project.RootTask.Children.Add(task2)
project.ResourceAssignments.Add(assn1)
project.ResourceAssignments.Add(assn2)
’ //// Recalculations
project.CalcResourceAssignmentIds()
project.CalcResourceAssignmentUids()
project.CalcTaskIds()
project.CalcTaskUids()
project.UpdateReferences()
End Sub