Hi,
Please run the code below:
public class TestCreateActual {
private static SimpleDateFormat formatter2 = new SimpleDateFormat(“MM/dd/yy”);
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
license.setLicense(fstream);
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}finally {
try {
fstream.close();
} catch (IOException e) {
e.printStackTrace();
}
}
Project asProject = new Project(“Empty_Project.mpp”);
asProject.set(Prj.START_DATE, formatter2.parse(“7/6/16 08:00:00”));
//asProject.set(Prj.FINISH_DATE, formatter2.parse(“12/30/02 08:00:00”));
asProject.setCalculationMode(CalculationMode.None);
com.aspose.tasks.Resource test1Resource = asProject.getResources().add(“test1”);
com.aspose.tasks.Resource test2Resource = asProject.getResources().add(“test2”);
com.aspose.tasks.Resource test3Resource = asProject.getResources().add(“test3”);
Task f1 = asProject.getRootTask().getChildren().add(“Release 5.0”);
Date startDate = formatter2.parse(“7/6/16”);
Date finishDate = formatter2.parse(“7/6/16”);
f1.set(Tsk.START, startDate);
f1.set(Tsk.FINISH, finishDate);
f1.set(Tsk.DURATION, asProject.getDuration(1, TimeUnitType.Day));
f1.set(Tsk.ACTUAL_START, startDate);
f1.set(Tsk.ACTUAL_WORK, asProject.getDuration(3, TimeUnitType.Hour));
ResourceAssignment ra1 = asProject.getResourceAssignments().add(f1, test1Resource);
ra1.set(Asn.START, startDate);
ra1.set(Asn.ACTUAL_START, startDate);
ra1.set(Asn.ACTUAL_WORK,
asProject.getDuration(1, TimeUnitType.Hour));
ResourceAssignment ra2 = asProject.getResourceAssignments().add(f1, test2Resource);
ra2.set(Asn.START, startDate);
ra2.set(Asn.ACTUAL_START, startDate);
ra2.set(Asn.ACTUAL_WORK,
asProject.getDuration(1, TimeUnitType.Hour));
ResourceAssignment ra3 = asProject.getResourceAssignments().add(f1, test3Resource);
ra3.set(Asn.START, startDate);
ra3.set(Asn.ACTUAL_START, startDate);
ra3.set(Asn.ACTUAL_WORK,
asProject.getDuration(1, TimeUnitType.Hour));
asProject.recalculate();
asProject.save(“test_create_actual.mpp”, SaveFileFormat.MPP);
System.out.println(“ok”);
}
}
Why the "%Complete" is "0%" and "Actual Duration" is "0"? I think the correct value is "12%" and "0.13".
Best Regards!
zhencheng.guo