Free Support Forum - aspose.com

Percent Complete problem using delays

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 problem is:
  • 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




Hi Jerome,


Thank you for writing to Aspose support team.

I have observed that you are using old library which is already revamped. Support for the old library is discontinued and assistance is provided for new library given here.

I have tried to re-produce the issue using new library where percentage is set for a task, to whom a delayed resource is assigned. I am afraid that no issue is observed in the percentage and its set correctly. Could you please re-evaluate your scenario with the new library and let us know the feedback? Please provide complete code using new library for our analysis.

Project project = new Project();

project.Set(Prj.StartDate, DateTime.Now);

Task task = project.RootTask.Children.Add("Task1");

//Set Task Duration

task.Set(Tsk.Duration, project.GetDuration(8, TimeUnitType.Hour));

task.Set(Tsk.Start, new DateTime(2015, 2, 9));

task.Set(Tsk.PercentComplete, 100);

#region [Set Resources]

Resource rsc1 = project.Resources.Add("Resource 1");

rsc1.Set(Rsc.Type, ResourceType.Work);

#endregion [Set Resources]

#region [Set Assignments]

ResourceAssignment assgn = project.ResourceAssignments.Add(task, rsc1);

assgn.Set(Asn.Start,new DateTime(2015, 2, 10,8,0,0));

assgn.Set(Asn.Finish, new DateTime(2015, 2, 10,17,0,0));

#endregion [Set Assignments]

project.Save(@"output.xml", SaveFileFormat.XML);

Hi Muhammad, thanks fr you answer

Could you please provide me the .xml file so I can test opening it on MS Project?
Because even if the percentage is set correctly, on MS Project is still zero. could you verify?


Thank you for your help

Hi Jerome,


The output XML and snapshot of this file while opening it in MSP 2010 are attached here for your reference which shows the 100% value.

Another calculation issue is observed while assigning the delayed resource to this task. The resource assignment start/end date is not calculated properly. I have logged this issue as TASKS-34070 in our bug tracking system for further investigation by the development team. I shall write here as soon as some feedback is received in this regard.

Thanks for your answer.

The problem I’m talking about is setting a percent complete to a Task WITH a delayed assignement.

Setting percetage to a task with a simple assignement works well, but if it is delayed it doesn’t work. Could you verify?

Thank you very much for your help !

Hi Jerome,

Currently setting the assignment delay by start is not supported. Howeveer, you can set the delay explicitly. Could you please give a try to the following sample code and let us know the feedback?

Project project = new Project();

Task task = project.RootTask.Children.Add("Task1");

//Set Task Duration

task.Set(Tsk.Duration, project.GetDuration(8, TimeUnitType.Hour));

task.Set(Tsk.Start, new DateTime(2015, 2, 9));

task.Set(Tsk.PercentComplete, 100);

Resource rsc1 = project.Resources.Add("Resource 1");

rsc1.Set(Rsc.Type, ResourceType.Work);

ResourceAssignment assgn = project.ResourceAssignments.Add(task, rsc1);

assgn.Set(Asn.Delay, project.GetDuration(1, TimeUnitType.Day));

Assert.AreEqual(new DateTime(2015, 2, 10, 8, 0, 0), assgn.Get(Asn.Start), "Assignment Start");

Assert.AreEqual(new DateTime(2015, 2, 10, 17, 0, 0), assgn.Get(Asn.Finish), "Assignment Finish");

Assert.AreEqual(project.GetDuration(1), assgn.Get(Asn.Delay), "Assignment Delay");

Hi, that’s exaclty what doesn’t wrok for me! Setting an “explicit” delay and setting a percent complete. In MS Projet the percent comple is set to 0 automaticaly no matter if I set it to 100%


Hi Jerome,


I have saved the output of the above mentioned code into XML project file and opened it in MS Project. I am afraid that no issue is observed and percent complete is 100 and assignment delay is 1 as shown in attached image. Could you please explain, where the percent complete is displayed as 0? I have used Aspose.Tasks for .NET 8.5.0 during the test.

The issues you have found earlier (filed as ) have been fixed in this Aspose.Words for JasperReports 18.3 update.