Hi,
Aspose Tasks Java 9.6.0
I’ve got the following piece of code that will insert a new task but not specify any information (except the ID in CalculationMode.None).
The empty MPP file that I’m using as a start is set to have new tasks created in Manual Scheduling mode.
I would expect the task not to have any values for duration & start date/end date in CalculationMode.None ; however, what happens is as follows:
- CalculationMode.Automatic: Task is created in Manual mode, duration & date fields are filled in (OK).
- CalculationMode.Manual: Task is created in Manual mode, duration & date fields are empty (I guess it’s OK)
- CalculationMode.None: Task is created in AutoScheduled mode (NOT ok!), duration & date fields are NOT empty (NOT ok, but caused by the task being inserted in auto-scheduled mode).
So my question is: Why are tasks created in auto-scheduled mode when using CalculationMode.None? How to create tasks in Manually Scheduled mode when using CalculationMode.None?
Attached are the empty MPP file as well as the 3 mpp files generated in various CalculationMode by the following test code.
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();
}
}
createInCalculationModeNone();
createInCalculationModeManual();
createInCalculationModeAutomatic();
}
private static void createInCalculationModeNone() {
Project asProject = new Project(“C:\temp\Project_blank.mpp”);
asProject.setCalculationMode(CalculationMode.None);
com.aspose.tasks.Task asTask = asProject.getRootTask().getChildren().add(“Task1”);
asTask.set(Tsk.ID, 1);
asProject.save(“c:\temp\output_none.mpp”, SaveFileFormat.MPP);
}
private static void createInCalculationModeManual() {
Project asProject = new Project(“C:\temp\Project_blank.mpp”);
asProject.setCalculationMode(CalculationMode.Manual);
com.aspose.tasks.Task asTask = asProject.getRootTask().getChildren().add(“Task1”);
asProject.save(“c:\temp\output_manual.mpp”, SaveFileFormat.MPP);
}
private static void createInCalculationModeAutomatic() {
Project asProject = new Project(“C:\temp\Project_blank.mpp”);
asProject.setCalculationMode(CalculationMode.Automatic);
com.aspose.tasks.Task asTask = asProject.getRootTask().getChildren().add(“Task1”);
asProject.save(“c:\temp\output_automatic.mpp”, SaveFileFormat.MPP);
}
Kind Regards,
Etienne.