Issue 11) In MS Project 3013- I can't set Actual End date


Hi

I am dongsoon park.
If I export data with MS Project 2013, There is no data in actual end date.
But I seted data to actual end date.

Please test MS Project 2013.
see the issue 11 in the attched PPT File.

Please help me.

[jar]
aspose-tasks-7.0.0-jdk16.jar

Hi Dongsoon,


I have tried to re-produce the issue 11 here however using “aspose-tasks-7.0.0-jdk16.jar”, an exception is raised as shown below:

“ParentProject is null. Update project references is required”.

Could you please confirm which version are you using for testing, Aspose.Tasks for Java 6.9.0 or 7.0.0? If you are using AT 7.0.0, please send us the sample project again as here with your previous sample project I get output without any error by using 6.9.0. Otherwise I get error as shown in the image while using AT 7.0.0.

Thank you in advance for your cooperation in this regard.



Hi

I send you sample code.

1. Execute GMPWbsTestBasic.java
2. see the result.mpp

Thanks you for your kind response.

Hi Dongsoon,


For setting the actual start/finish date we also need to set the early start/finish and late start/finish as well. Could you please modify the code as given below and let us know the feedback?

public static String createMSProject2(String preferredLang, String xmlPath, String xmlFileName, String newFileName)
throws IOException
{


String xmlFileFullPath = xmlPath + xmlFileName;

String newFileFullPath = xmlPath + newFileName;

HashMap<Integer, Task> levTask = new HashMap<Integer, Task>();

HashMap<String, Task> taskList = new HashMap<String, Task>();

long OneSec = 10000000;// microsecond * 10

long OneMin = 60 * OneSec;

long OneHour = 60 * OneMin;


try {


// license

String licPath = “D:\TEMP\acttest\”;

FileInputStream fstream = new FileInputStream(licPath + GMPWbsConstants.MPP_LIC_FILE_NAME);

com.aspose.tasks.License license = new com.aspose.tasks.License();

license.setLicense(fstream);


// search XML data

LinkedHashMap<String, GMPWbsImportAttrVO> hmData = GMPWbsExpImpUtil.getXMLData(xmlFileFullPath);

GMPWbsExpImpUtil.getViewData(hmData);


// Date Format

SimpleDateFormat format = new SimpleDateFormat(GMPWbsConstants.FORMAT_DATE);


// MS Project Template read

Project prj = new Project(xmlPath + “MSProject_Export_Template_basic.mpp”);

prj.setMinutesPerDay(60 * 8);


// MS Project Export start

int rowNo = 0;

for (Map.Entry<String, GMPWbsImportAttrVO> entry : hmData.entrySet()) {

String key = entry.getKey();

GMPWbsImportAttrVO obj = entry.getValue();


// get data

String activityID = PMSUtil.nvl(obj.getActivityID(), “”); // ActivityID

activityID = GMPWbsExpImpUtil.convertActivityID(activityID, “”);

String level = PMSUtil.nvl(obj.getNodeLevel(), “”); // Level

String name = “”;

String performer = “”; // Task performer

if (GMPWbsConstants.LANG_KO.equalsIgnoreCase(preferredLang)) {

name = PMSUtil.nvl(obj.getNameKo(), “”);

performer = PMSUtil.nvl(obj.getPerformerKo(), “”);

} else if (GMPWbsConstants.LANG_EN.equalsIgnoreCase(preferredLang)) {

name = PMSUtil.nvl(obj.getNameEn(), “”);

performer = PMSUtil.nvl(obj.getPerformerEn(), “”);

} else {

name = PMSUtil.nvl(obj.getNameCn(), “”);

performer = PMSUtil.nvl(obj.getPerformerCn(), “”);

}

String planDuration = PMSUtil.nvl(obj.getPlanDuration(), “”); // planduration

String planStart = PMSUtil.nvl(obj.getPlanStart(), “”); // planstart

String planEnd = PMSUtil.nvl(obj.getPlanEnd(), “”); // plan end

String realEnd = PMSUtil.nvl(obj.getRealEnd(), “”); // real end


// set Task

Task newTask = new Task();

newTask.setId(rowNo);

newTask.setUid(rowNo);

newTask.setWbs(activityID);

newTask.setWbsLevel(String.valueOf(Integer.parseInt(level) + 1));

newTask.setOutlineLevel(Integer.parseInt(level) + 1);

if (!"".equals(planStart)) {

newTask.setStart(format.parse(planStart));


newTask.setActualStart(newTask.getStart()); // <-- add this to set early/late dates for completed tasks

newTask.setEarlyStart(newTask.getStart());

newTask.setLateStart(newTask.getStart());



}

if (!"".equals(planEnd)) {

newTask.setFinish(format.parse(planEnd));

}

if (!"".equals(realEnd)) {


// newTask.setActualStart(format.parse(realEnd));

Date actualFinish = format.parse(realEnd);

newTask.setActualFinish(actualFinish);

newTask.setEarlyFinish(actualFinish);// <-- add this to set early/late dates for completed tasks

newTask.setLateFinish(actualFinish);


}

newTask.setDurationFormat(TimeUnitType.Day);

newTask.setDuration(Long.parseLong(planDuration) * OneHour * 8);


Task parentTask = null;

if (level.equals(“0”))

parentTask = prj.getRootTask();

else

parentTask = levTask.get(Integer.parseInt(level) - 1);

levTask.put(Integer.parseInt(level), newTask);

parentTask.getChildren().add(newTask);


// if (!"".equals(performer)) {

// Resource rsc = prj.addResource(performer);

// prj.addResourceAssignment(newTask, rsc);

// }


taskList.put(activityID, newTask);


System.out.println(level + “:” + " activityID = " + newTask.getWbs() + " " + newTask.getOutlineNumber()

+ “(” + newTask.getWbs().length() + “)” + ", Id = " + newTask.getId() + ", Uid = "

+ newTask.getUid() + ", Dur = " + newTask.getDuration() + “:”

+ (Long.parseLong(planDuration) * OneHour * 8) + ", St Dte = " + newTask.getStart()

+ ", Fnsh Dte = " + newTask.getFinish() + ", duration old = " + planDuration + ", Actual Finish = " + newTask.getActualFinish());


rowNo++;

}


// predecesor connect

LinkedHashMap<String, String> precedeList = GMPWbsExpImpUtil.getPrecedingactivityIDList(xmlFileFullPath);

ChildTasksCollector collector = new ChildTasksCollector();

TaskUtils.apply(prj.getRootTask(), collector, 0);

List tasks = collector.getTasks();


for (Map.Entry<String, String> entry : precedeList.entrySet()) {


String activityID = entry.getKey();

String precedingactivityID = entry.getValue();

activityID = GMPWbsExpImpUtil.convertActivityID(activityID, “”);

precedingactivityID = GMPWbsExpImpUtil.convertActivityID(precedingactivityID, “”);


Task activityTask = (Task) taskList.get(activityID);

Task procedeTask = (Task) taskList.get(precedingactivityID);

if (activityTask != null && procedeTask != null) {


TaskLink newLink = new TaskLink(procedeTask, activityTask, TaskLinkType.FinishToStart);

prj.addTaskLink(newLink);

}

}


// We need to recalculate the IDs only as UIDs were set correctly.

prj.calcTaskIds();

prj.calcTaskUids();

prj.calcResourceStartFinish();

prj.updateReferences();


// Save MS PRoject File

prj.save(newFileFullPath, SaveFileFormat.MPP);


} catch (Exception ex) {

ex.printStackTrace();

}


return newFileName;


}