We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Duration is incorrect when more than 2 resources be assigned to task


Please run the below code:

public class TestTaskWithTwoResource {
private static SimpleDateFormat formatter2 = new SimpleDateFormat("MM/dd/yy hh:mm:ss");
public static void main(String[] args) throws ParseException {
FileInputStream fstream = null;
try {
// Create a stream object containing the license file
fstream = new FileInputStream("Aspose.Tasks.lic");
// Instantiate the License class
License license = new License();
// Set the license through the stream object
} catch (FileNotFoundException e) {
} catch (Exception e) {
}finally {
try {
} catch (IOException e) {
Project asProject = new Project("Empty_Project.mpp");

asProject.set(Prj.START_DATE, formatter2.parse("7/6/16 08:00:00"));
com.aspose.tasks.Resource test1Resource = asProject.getResources().add("test1");
com.aspose.tasks.Resource test2Resource = asProject.getResources().add("test2");

Task f1 = asProject.getRootTask().getChildren().add("Sub Task");
Date startDate = formatter2.parse("7/6/16 08:00:00");
f1.set(Tsk.START, startDate);
f1.set(Tsk.DURATION, asProject.getDuration(2, TimeUnitType.Day));
ResourceAssignment ra1 = asProject.getResourceAssignments().add(f1, test1Resource);
ra1.set(Asn.START, startDate);
ra1.set(Asn.WORK, asProject.getDuration(16, TimeUnitType.Hour));
ra1.set(Asn.PERCENT_WORK_COMPLETE, 100);
ResourceAssignment ra2 = asProject.getResourceAssignments().add(f1, test2Resource);
ra2.set(Asn.START, startDate);
ra2.set(Asn.WORK, asProject.getDuration(16, TimeUnitType.Hour));
ra2.set(Asn.PERCENT_WORK_COMPLETE, 100);
asProject.save("test_task_with_two_resource.mpp", SaveFileFormat.MPP);

The Duration, Finish and Actual Finish is incorrect. I think the correct value of Duration is 2 days, Finish and Actual Finish is 7/7/16.
The attachment is the output file.

Best Regards!

Hi Zhencheng,

Thank you for contacting Aspose support again.

I have executed the code and opened the output file in MSP 2010 as shown in the attached image. It is observed that duration is 2 days as expected. It seems to be MSP specific issue and need further investigation. Could you please share which version of MSP and Aspose.Tasks for Java are you using?

Hi kashif,

My version of MSP is 2013 and Aspose.Tasks for Java is 9.5.0.

Best Regards!

Hi Zhencheng,

This issue is re-produced while using MSP 2013 and logged under Id: TASKSJAVA-260 for further investigation by the product team. You will be automatically notified once any update is received in this regard.

Hi Zhencheng,

We have investigated the issue at our end and it came out to be related to the difference of versions of MSP. At present, this limitation is known to us and it can’t be resolved further due to the unavaiability of further details about the differences in MSP 2010 and MSP 2013. You may please use a blank MSP 2013 file as input template that should work fine in this case.