First resource assingment with unit 1

After I create a task and add 3 resource assignments to it, the first resource doesn’t assume the unit setted to it. The others are OK. Aspose.zip (46.2 KB)

Here follows my code, the result file and the print of the resources.

  Project project = new Project("C:\\Makoski\\Teste\\Apose1\\PrjNewFileSyncProject.mpp");

  DateTime data = new DateTime(2018, 4, 9);
  project.Set(Prj.StartDate, data);
  project.Set(Prj.NewTaskStartDate, TaskStartDateType.ProjectStartDate);
  project.Set(Prj.DefaultStartTime, data.AddHours(9));
  project.Set(Prj.DefaultFinishTime, data.AddHours(18));
  project.Set(Prj.DefaultTaskType, TaskType.FixedDuration);
  project.Set(Prj.DurationFormat, TimeUnitType.Day);
  project.Set(Prj.WorkFormat, TimeUnitType.Hour);
  project.Set(Prj.MinutesPerDay, 8 * 60);

  Task task = project.RootTask.Children.Add("Task2");
  task.Set(Tsk.Duration, project.GetDuration(104, TimeUnitType.Day));
  task.Set(Tsk.Start, data);
  task.Set(Tsk.ActualStart, task.Get(Tsk.Start));
  task.Set(Tsk.Type, TaskType.FixedDuration);
  task.Set(Tsk.DurationFormat, TimeUnitType.Day);

  Resource res = project.Resources.Add("WORK1");
  res.Set(Rsc.Type, ResourceType.Work);
  res.Set(Rsc.StandardRate, 42.17M);

  Resource res2 = project.Resources.Add("WORK2");
  res2.Set(Rsc.Type, ResourceType.Work);
  res2.Set(Rsc.StandardRate, 42.17M);

  Resource res3 = project.Resources.Add("WORK3");
  res3.Set(Rsc.Type, ResourceType.Work);
  res3.Set(Rsc.StandardRate, 42.17M);

  ResourceAssignment resAssignment = project.ResourceAssignments.Add(task, res, 1.59);
  resAssignment = project.ResourceAssignments.Add(task, res2, 1.59);
  resAssignment = project.ResourceAssignments.Add(task, res3, 1.59);

  MPPSaveOptions mppSaveOptions = new MPPSaveOptions();

  project.Save("C:\\Makoski\\Teste\\Apose1\\output.mpp", mppSaveOptions);

@amakoski,

Thank you for contacting Aspose support team.

This seems to be issue with the data used in the project. When we set TaskType.FixedDuration, then setting units of a resource to 1.59 causes the resource assignment beyond the dates of the task. To resolve the issue you may set unit 1.0 for a resource assignment.

On the other hand, if you want to set the unit to 1.59, then do not set TaskType.FixedDuration for the task.

You may please modify the code accordingly and share the feedback.