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

Free Support Forum - aspose.com

Actual Start can not be set correctly

HI,

Please run the code as 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("2/6/16 08:00:00"));

asProject.setCalculationMode(CalculationMode.None);

com.aspose.tasks.Resource test1Resource = asProject.getResources().add("test1");
Task f1 = asProject.getRootTask().getChildren().add("Release 5.0");

Date startDate = formatter2.parse("2/6/2017");
Date finishDate = formatter2.parse("2/10/2017");
Date actualStartDate = formatter2.parse("2/8/2017");

f1.set(Tsk.START, startDate);
f1.set(Tsk.FINISH, finishDate);
f1.set(Tsk.DURATION, asProject.getDuration(5, TimeUnitType.Day));

f1.set(Tsk.ACTUAL_START, actualStartDate);
f1.set(Tsk.ACTUAL_WORK, asProject.getDuration(30, TimeUnitType.Hour));
f1.set(Tsk.PERCENT_COMPLETE, 75);
ResourceAssignment ra1 = asProject.getResourceAssignments().add(f1, test1Resource);
ra1.set(Asn.START, startDate);
ra1.set(Asn.ACTUAL_START, actualStartDate);
ra1.set(Asn.ACTUAL_WORK, asProject.getDuration(30, TimeUnitType.Hour));
ra1.set(Asn.PERCENT_WORK_COMPLETE, 75);//

asProject.recalculate();

asProject.save("test_create_actual.mpp", SaveFileFormat.MPP);
System.out.println("ok");

}
}

I have set the actual start to "2/8/2017", why the result of actual start is "2/6/2017"?


Best Regards!
zhencheng.guo


Hi Zhencheng,


Thank you for writing to Aspose support team.

I have checked the scenario by repeating the same steps using Microsoft Project 2010 (MSP). Following steps are performed.

  1. Create a task
  2. Set duration to 5
  3. Set start/finish dates as per your sample
  4. Create resource and assign it to the task
  5. Now check the behavior of Start and Actual Start in MSP. You will observe that when Start date is changed, it automatically changes the Actual Start, and if we change Actual Start, it automatically changes the Start date.

Aspose.Tasks is also behaving in the similar manner and it seems that its not an issue with the Api. Please give it a try and share the feedback.

Hi kashif,


Please run this as 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(“2/6/16 08:00:00”));

asProject.setCalculationMode(CalculationMode.None);
Task f1 = asProject.getRootTask().getChildren().add(“Release 5.0”);

Date startDate = formatter2.parse(“2/6/2017”);
Date finishDate = formatter2.parse(“2/10/2017”);
Date actualStartDate = formatter2.parse(“2/8/2017”);

f1.set(Tsk.START, startDate);
f1.set(Tsk.FINISH, finishDate);
f1.set(Tsk.DURATION, asProject.getDuration(5, TimeUnitType.Day));
f1.set(Tsk.WORK, asProject.getDuration(40, TimeUnitType.Hour));

f1.set(Tsk.ACTUAL_START, actualStartDate);
f1.set(Tsk.ACTUAL_WORK, asProject.getDuration(30, TimeUnitType.Hour));
f1.set(Tsk.PERCENT_COMPLETE, 75);
asProject.recalculate();

asProject.save(“test_create_actual.mpp”, SaveFileFormat.MPP);
System.out.println(“ok”);

}
}

You will find the actual start can be set to ‘2/8/2017’ correctly because of no resource related to task.


Hi Zhencheng,


You may please open this test_create_actual.mpp in MSP and add a resource. Link this resource with this task and set all the desired dates. Please send that MPP (which is also the required MPP output using Aspose.Tasks) containing all dates as per your requirement for our consumption here. It will help us to review the required output MPP file and provide assistance accordingly.