Why will CalculationMode.None insert new tasks in Auto-scheduled mode?

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.

Hi Etienne,


I am working on this issue and need further assistance. Could you please open each MPP file in Microsoft Project and send us the snap shot of all the three MPP files opened in MSP? Also please mention the MSP version which you are using for testing. It will help us to analyze the problem and provide assistance accordingly.

Hi Kashif,


Please find screenshot attached.

I’m using MSP 2016.

As mentioned in a separate thread, adding

<span style=“color: rgb(51, 51, 51); font-family: “Courier New”; font-size: 13px; background-color: rgb(255, 255, 255);”>asTask.set(Tsk.IS_MANUAL, new NullableBool(<b style=“color: rgb(51, 51, 51); font-family: “Courier New”; font-size: 13px; background-color: rgb(255, 255, 255);”>false<span style=“color: rgb(51, 51, 51); font-family: “Courier New”; font-size: 13px; background-color: rgb(255, 255, 255);”>));
or
<span style=“color: rgb(51, 51, 51); font-family: “Courier New”; font-size: 13px; background-color: rgb(255, 255, 255);”>asTask.set(Tsk.IS_MANUAL, new NullableBool(<b style=“color: rgb(51, 51, 51); font-family: “Courier New”; font-size: 13px; background-color: rgb(255, 255, 255);”>true<span style=“color: rgb(51, 51, 51); font-family: “Courier New”; font-size: 13px; background-color: rgb(255, 255, 255);”>));

In the method with CalculationMode.None didn’t change anything - task is still created in auto-schedule mode.

Thanks,
Etienne.

Hi Etienne,


We have tested the behavior of CalculationMode.None but are not able to reproduce the problem at our end. The output MPP file shows the task as manually scheduled in MSP 2016. We have attached the output MPP file here for your reference that is generated as result of the following code sample. Please make sure that you are using the latest version of the API at your end.

Sample Code:

<pre style=“background-color: rgb(255, 255, 255); font-family: “Courier New”; font-size: 9pt;”>private static void createInCalculationModeNone() {
Project asProject = new Project(“CalcModeIssues\Project_blank.mpp”);

asProject.setCalculationMode(CalculationMode.None);

com.aspose.tasks.Task asTask = asProject.getRootTask().getChildren().add(“Task1”);
asTask.set(Tsk.ID, 1);
asTask.set(Tsk.IS_MANUAL, new NullableBool(true));

asProject.save(“CalcModeIssues\None_2016.mpp”, SaveFileFormat.MPP);
}

Hi,

I can confirm it’s working on my env too. No idea what was wrong before. Thanks for the help!

Thank you for the feedback.