Hi,
Please run the code below, there are two issues:
1. The first task(summary task) have not roll up automatically, the "Start", "Finish" and so on are empty.
2. The second task(leaf task), the "Work" is 16 hours, and it has two Resources, and one Actual Work is 4 hours, and another one Actual Work is 2 hours, add up to 6 hours, the "complete" should be 38%( 6/16), why the "%complete" is 50%?
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
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");
// Task with assignments
Task task1 = asProject.getRootTask().getChildren().add("Double assignments rollup (0% complete)");
Task taskSub1 = task1.getChildren().add("16 hours work");
taskSub1.set(Tsk.START, formatter2.parse("1/3/05 08:00:00"));
taskSub1.set(Tsk.DURATION, asProject.getDuration(1, TimeUnitType.Day));
Resource elo = asProject.getResources().add("elo");
ResourceAssignment raElo = asProject.getResourceAssignments().add(taskSub1, elo);
raElo.set(Asn.START, formatter2.parse("1/3/05 08:00:00"));
raElo.set(Asn.WORK, asProject.getDuration(8, TimeUnitType.Hour));
raElo.set(Asn.ACTUAL_START, formatter2.parse("1/3/05 08:00:00"));
raElo.set(Asn.ACTUAL_WORK, asProject.getDuration(4, TimeUnitType.Hour));
Resource dwang = asProject.getResources().add("dwang");
ResourceAssignment raDwang = asProject.getResourceAssignments().add(taskSub1, dwang);
raDwang.set(Asn.START, formatter2.parse("1/3/05 08:00:00"));
raDwang.set(Asn.WORK, asProject.getDuration(8, TimeUnitType.Hour));
raDwang.set(Asn.ACTUAL_START, formatter2.parse("1/3/05 08:00:00"));
raDwang.set(Asn.ACTUAL_WORK, asProject.getDuration(2, TimeUnitType.Hour));
asProject.recalculate();
// Save the Project
asProject.save("output_test9.mpp", SaveFileFormat.MPP);
System.out.println("ok");
}