Hello,
I’m having problems assigning a “percent complete” to a task with an assigment.
- My task.start date is different to its assignement.start, so I must use an assignement.delay to visualise the correct date on MS Project
- The percent complete doesn’t work if I’m using the assignement.delay!! … I dont know why but the pencent complete is always = 0 on MSProject if I use a delay (even if the xml is correct, and the percent complete is well writen)
- If I don’t use the assignement.delay but instead a timephasedata = 0, then the percent complete is correct on MSProject but the assignment start date is equal to the task start date which is not what i want
Can you help me with this ? Why I can’t set a percent complet to a task with an assignment delay??? Please verify the xml using MS Project!
Thanks
My code:
Sub testPC()
Dim project As New Aspose.Tasks.Project()
project.StartDate = New DateTime(2014, 9, 1, 8, 0, 0)
'project.FinishDate = New DateTime(2011, 12, 31, 17, 0, 0)
project.MinutesPerDay = 8 * 60
project.MinutesPerWeek = 5 * 8 * 60
project.DaysPerMonth = 20
project.DefaultStartTime = New DateTime(1, 1, 1, 8, 0, 0)
project.DefaultFinishTime = New DateTime(1, 1, 2, 17, 0, 0)
project.DurationFormat = TimeUnitType.Hour
project.WorkFormat = TimeUnitType.Hour
project.CalculateAfterEdit = False
project.Calendar = Calendar.MakeStandardCalendar
Dim res As Aspose.Tasks.Resource = project.AddResource(“person1”)
Dim task As New Aspose.Tasks.Task(“New Task”)
'task = project.AddTask(“New Task”)
task.Uid = 1
task.Id = 1
task.Type = TaskType.FixedDuration
task.Start = New DateTime(2014, 9, 1, 8, 0, 0)
task.Duration = New TimeSpan(64 * 8, 0, 0)
'task.Finish = project.Calendar.GetFinishDateByStartAndWork(task.Start, task.Duration)
task.Finish = New DateTime(2014, 11, 30, 17, 0, 0)
task.DurationFormat = TimeUnitType.Day
task.Calendar = New Calendar(“Standard”)
task.PercentComplete = 35
task.ActualStart = task.Start
Dim ass As New ResourceAssignment(task, res)
ass.Work = New TimeSpan(100, 0, 0)
ass.Start = New DateTime(2014, 10, 1, 8, 0, 0)
ass.Finish = New DateTime(2014, 10, 31, 17, 0, 0)
'ass.Delay = 102960
ass.WorkContour = WorkContourType.Contoured
ass.TimephasedData = New List(Of TimephasedData)()
Dim td As New TimephasedData()
td.Uid = ass.Uid
td.Start = New DateTime(2014, 9, 1, 8, 0, 0)
td.Finish = New DateTime(2014, 9, 30, 17, 0, 0)
td.TimephasedDataType = TimephasedDataType.AssignmentRemainingWork
td.Value = “PT0H0M0S”
td.Unit = TimeUnitType.Month
ass.TimephasedData.Add(td)
td = New TimephasedData()
td.Uid = ass.Uid
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 = “PT100H0M0S”
td.Unit = TimeUnitType.Month
ass.TimephasedData.Add(td)
project.RootTask.Children.Add(task)
project.ResourceAssignments.Add(ass)
project.CalcResourceAssignmentUids()
project.CalcResourceAssignmentIds()
project.CalcTaskIds()
project.CalcTaskUids()
project.UpdateReferences()
'Dim fileName = “c:\testing.xml”
project.Save(“c:\testing.xml”, Saving.SaveFileFormat.XML)
End Sub