joniles / mpxj

Primary repository for MPXJ library

Home Page:http://www.mpxj.org/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

setUnits for resource assignment does not update the XER file

iMohannad opened this issue · comments

Hi,

I have an XER project and I am trying to update units and duration using MPXJ.
Duration gets updated successfully, however, the budgeted units for each resource assignment are not updated.

I use this code to update the units in resource assignment in .Net:

java.util.ArrayList rsrcList = (ArrayList)currentTask.getResourceAssignments();

// Get resources for this task
foreach (ResourceAssignment rsrcAssignment in rsrcList) {
       rsrcAssignment.setUnits(50);
}

How can I update the budgeted units for resource assignment successfully?

Thank you

I checked the raw data for the resulted XER file, I have found that the new units are not written correctly under TASKRSRC. So I guess it's either one of two things:

  1. I am not doing the writing correctly
  2. The library is not writing the TASKRSRC as expected.

I print the resource assignement units using rsrcAssignment.getUnits() in the program and I get the expected value. So I suspect it might be the write function from the library.

Can you help guide me in this issue?

@iMohannad thanks for opening the issue, I will take a look this week.

Update on this issue, I could get the budgeted units and set the budgeted units using this function

// reading budgeted units
foreach (ResourceAssignment rs in ls) {
  rs.getRemainingWork().getDuration();
}

// writing budgeted units
net.sf.mpxj.Duration remainingWork = net.sf.mpxj.Duration.getInstance((days)*units, TimeUnit.HOURS);
rsrcAssignment.setRemainingWork(remainingWork);
rsrcAssignment.setPlannedWork(remainingWork);

This solves this issue for me. thank you

I still do not understand what does setUnit() function do though.