Hi,
Hi Etienne,
Hi Kashif,
Hi Etienne,
<span style=“font-size: 9pt; font-family: “Courier New”;”>Project asProject = <span style=“font-size:9.0pt;font-family:“Courier New”;mso-fareast-font-family:“Times New Roman”;
color:navy”>new <span style=“font-size: 9pt; font-family: “Courier New”;”>Project(<span style=“font-size:9.0pt;font-family:“Courier New”;mso-fareast-font-family:“Times New Roman”;
color:green”>“Project_blank.mpp”<span style=“font-size: 9pt; font-family: “Courier New”;”>);
asProject.setCalculationMode(CalculationMode.<span style=“font-size:9.0pt;font-family:“Courier New”;mso-fareast-font-family:“Times New Roman”;
color:#660E7A”>None<span style=“font-size: 9pt; font-family: “Courier New”;”>);
<span style=“font-size:9.0pt;font-family:“Courier New”;mso-fareast-font-family:
“Times New Roman”;color:gray”>// Setting basic task info - no problem
<span style=“font-size: 9pt; font-family: “Courier New”;”>com.aspose.tasks.Task asTask = asProject.getRootTask().getChildren().add(<span style=“font-size:9.0pt;font-family:“Courier New”;mso-fareast-font-family:“Times New Roman”;
color:green”>“Task1”<span style=“font-size: 9pt; font-family: “Courier New”;”>);
asTask.set(Tsk.<span style=“font-size:9.0pt;font-family:“Courier New”;
mso-fareast-font-family:“Times New Roman”;color:#660E7A”>ID<span style=“font-size: 9pt; font-family: “Courier New”;”>, <span style=“font-size:9.0pt;font-family:“Courier New”;
mso-fareast-font-family:“Times New Roman”;color:blue”>1<span style=“font-size: 9pt; font-family: “Courier New”;”>);
asTask.set(Tsk.<span style=“font-size:9.0pt;font-family:“Courier New”;
mso-fareast-font-family:“Times New Roman”;color:#660E7A”>UID<span style=“font-size: 9pt; font-family: “Courier New”;”>, <span style=“font-size:9.0pt;font-family:“Courier New”;
mso-fareast-font-family:“Times New Roman”;color:blue”>1<span style=“font-size: 9pt; font-family: “Courier New”;”>);
asTask.set(Tsk.<span style=“font-size:9.0pt;font-family:“Courier New”;
mso-fareast-font-family:“Times New Roman”;color:#660E7A”>IS_MANUAL<span style=“font-size: 9pt; font-family: “Courier New”;”>, <span style=“font-size:9.0pt;font-family:“Courier New”;
mso-fareast-font-family:“Times New Roman”;color:navy”>new <span style=“font-size: 9pt; font-family: “Courier New”;”>NullableBool(<span style=“font-size:9.0pt;font-family:
“Courier New”;mso-fareast-font-family:“Times New Roman”;color:navy”>true<span style=“font-size: 9pt; font-family: “Courier New”;”>));
asTask.set(Tsk.<span style=“font-size:9.0pt;font-family:“Courier New”;
mso-fareast-font-family:“Times New Roman”;color:#660E7A”>DURATION<span style=“font-size: 9pt; font-family: “Courier New”;”>, asProject.getDuration(<span style=“font-size:9.0pt;
font-family:“Courier New”;mso-fareast-font-family:“Times New Roman”;color:blue”>2<span style=“font-size: 9pt; font-family: “Courier New”;”>, TimeUnitType.<span style=“font-size:9.0pt;
font-family:“Courier New”;mso-fareast-font-family:“Times New Roman”;color:#660E7A”>Day<span style=“font-size: 9pt; font-family: “Courier New”;”>));
asTask.set(Tsk.<span style=“font-size:9.0pt;font-family:“Courier New”;
mso-fareast-font-family:“Times New Roman”;color:#660E7A”>MANUAL_DURATION<span style=“font-size: 9pt; font-family: “Courier New”;”>, asProject.getDuration(<span style=“font-size:9.0pt;
font-family:“Courier New”;mso-fareast-font-family:“Times New Roman”;color:blue”>2<span style=“font-size: 9pt; font-family: “Courier New”;”>, TimeUnitType.<span style=“font-size:9.0pt;
font-family:“Courier New”;mso-fareast-font-family:“Times New Roman”;color:#660E7A”>Day<span style=“font-size: 9pt; font-family: “Courier New”;”>));
Date start = <span style=“font-size:9.0pt;font-family:“Courier New”;
mso-fareast-font-family:“Times New Roman”;color:navy”>null<span style=“font-size: 9pt; font-family: “Courier New”;”>;
Date finish = <span style=“font-size:9.0pt;font-family:“Courier New”;
mso-fareast-font-family:“Times New Roman”;color:navy”>null<span style=“font-size: 9pt; font-family: “Courier New”;”>;
<span style=“font-size:9.0pt;font-family:“Courier New”;mso-fareast-font-family:
“Times New Roman”;color:navy”>try <span style=“font-size: 9pt; font-family: “Courier New”;”>{
start = <span style=“font-size:9.0pt;font-family:“Courier New”;mso-fareast-font-family:“Times New Roman”;
color:navy”>new <span style=“font-size: 9pt; font-family: “Courier New”;”>SimpleDateFormat(<span style=“font-size:9.0pt;font-family:“Courier New”;mso-fareast-font-family:“Times New Roman”;
color:green”>“MM/dd/yyyy HH:mm:ss”<span style=“font-size: 9pt; font-family: “Courier New”;”>).parse(<span style=“font-size:9.0pt;font-family:“Courier New”;
mso-fareast-font-family:“Times New Roman”;color:green”>“11/14/2016
08:00:00”<span style=“font-size: 9pt; font-family: “Courier New”;”>);
finish = <span style=“font-size:9.0pt;font-family:“Courier New”;mso-fareast-font-family:“Times New Roman”;
color:navy”>new <span style=“font-size: 9pt; font-family: “Courier New”;”>SimpleDateFormat(<span style=“font-size:9.0pt;font-family:“Courier New”;mso-fareast-font-family:“Times New Roman”;
color:green”>“MM/dd/yyyy HH:mm:ss”<span style=“font-size: 9pt; font-family: “Courier New”;”>).parse(<span style=“font-size:9.0pt;font-family:“Courier New”;
mso-fareast-font-family:“Times New Roman”;color:green”>“11/15/2016
17:00:00”<span style=“font-size: 9pt; font-family: “Courier New”;”>);
} <span style=“font-size:9.0pt;font-family:“Courier New”;mso-fareast-font-family:
“Times New Roman”;color:navy”>catch <span style=“font-size: 9pt; font-family: “Courier New”;”>(ParseException
e) {
e.printStackTrace();
}
asTask.set(Tsk.<span style=“font-size:9.0pt;font-family:“Courier New”;
mso-fareast-font-family:“Times New Roman”;color:#660E7A”>START<span style=“font-size: 9pt; font-family: “Courier New”;”>, start);
asTask.set(Tsk.<span style=“font-size:9.0pt;font-family:“Courier New”;
mso-fareast-font-family:“Times New Roman”;color:#660E7A”>MANUAL_START<span style=“font-size: 9pt; font-family: “Courier New”;”>, start);
asTask.set(Tsk.<span style=“font-size:9.0pt;font-family:“Courier New”;
mso-fareast-font-family:“Times New Roman”;color:#660E7A”>FINISH<span style=“font-size: 9pt; font-family: “Courier New”;”>, finish);
asTask.set(Tsk.<span style=“font-size:9.0pt;font-family:“Courier New”;
mso-fareast-font-family:“Times New Roman”;color:#660E7A”>MANUAL_FINISH<span style=“font-size: 9pt; font-family: “Courier New”;”>, finish);
asTask.set(Tsk.<span style=“font-size:9.0pt;font-family:“Courier New”;
mso-fareast-font-family:“Times New Roman”;color:#660E7A”>WORK<span style=“font-size: 9pt; font-family: “Courier New”;”>, asProject.getDuration(<span style=“font-size:9.0pt;
font-family:“Courier New”;mso-fareast-font-family:“Times New Roman”;color:blue”>16<span style=“font-size: 9pt; font-family: “Courier New”;”>, TimeUnitType.<span style=“font-size:9.0pt;
font-family:“Courier New”;mso-fareast-font-family:“Times New Roman”;color:#660E7A”>Hour<span style=“font-size: 9pt; font-family: “Courier New”;”>));
asTask.set(Tsk.<span style=“font-size:9.0pt;font-family:“Courier New”;
mso-fareast-font-family:“Times New Roman”;color:#660E7A”>ACTUAL_START<span style=“font-size: 9pt; font-family: “Courier New”;”>, start);
asTask.set(Tsk.<span style=“font-size:9.0pt;font-family:“Courier New”;
mso-fareast-font-family:“Times New Roman”;color:#660E7A”>ACTUAL_WORK<span style=“font-size: 9pt; font-family: “Courier New”;”>, asProject.getDuration(<span style=“font-size:9.0pt;
font-family:“Courier New”;mso-fareast-font-family:“Times New Roman”;color:blue”>8<span style=“font-size: 9pt; font-family: “Courier New”;”>, TimeUnitType.<span style=“font-size:9.0pt;
font-family:“Courier New”;mso-fareast-font-family:“Times New Roman”;color:#660E7A”>Hour<span style=“font-size: 9pt; font-family: “Courier New”;”>));
asTask.set(Tsk.<span style=“font-size:9.0pt;font-family:“Courier New”;
mso-fareast-font-family:“Times New Roman”;color:#660E7A”>REMAINING_WORK<span style=“font-size: 9pt; font-family: “Courier New”;”>, asProject.getDuration(<span style=“font-size:9.0pt;
font-family:“Courier New”;mso-fareast-font-family:“Times New Roman”;color:blue”>8<span style=“font-size: 9pt; font-family: “Courier New”;”>, TimeUnitType.<span style=“font-size:9.0pt;
font-family:“Courier New”;mso-fareast-font-family:“Times New Roman”;color:#660E7A”>Hour<span style=“font-size: 9pt; font-family: “Courier New”;”>));
asTask.set(Tsk.<span style=“font-size:9.0pt;font-family:“Courier New”;
mso-fareast-font-family:“Times New Roman”;color:#660E7A”>PERCENT_COMPLETE<span style=“font-size: 9pt; font-family: “Courier New”;”>, <span style=“font-size:9.0pt;font-family:“Courier New”;
mso-fareast-font-family:“Times New Roman”;color:blue”>50<span style=“font-size: 9pt; font-family: “Courier New”;”>);
asTask.set(Tsk.<span style=“font-size:9.0pt;font-family:“Courier New”;
mso-fareast-font-family:“Times New Roman”;color:#660E7A”>PERCENT_WORK_COMPLETE<span style=“font-size: 9pt; font-family: “Courier New”;”>, <span style=“font-size:9.0pt;font-family:“Courier New”;
mso-fareast-font-family:“Times New Roman”;color:blue”>50<span style=“font-size: 9pt; font-family: “Courier New”;”>);
Resource asResource = asProject.getResources().add(<span style=“font-size:9.0pt;font-family:“Courier New”;mso-fareast-font-family:“Times New Roman”;
color:green”>“John Doe”<span style=“font-size: 9pt; font-family: “Courier New”;”>);
asProject.recalculate();
asProject.save(<span style=“font-size:9.0pt;font-family:“Courier New”;
mso-fareast-font-family:“Times New Roman”;color:green”>“Project_task_info_ok.mpp”<span style=“font-size: 9pt; font-family: “Courier New”;”>, SaveFileFormat.<span style=“font-size:9.0pt;
font-family:“Courier New”;mso-fareast-font-family:“Times New Roman”;color:#660E7A”>MPP<span style=“font-size: 9pt; font-family: “Courier New”;”>);
<span style=“font-size:9.0pt;font-family:“Courier New”;mso-fareast-font-family:
“Times New Roman”;color:gray”>// Setting assignment info - messes up initial
information
<span style=“font-size: 9pt; font-family: “Courier New”;”>ResourceAssignment ra =
asProject.getResourceAssignments().add(asTask, asResource);
ra.set(Asn.<span style=“font-size:9.0pt;font-family:“Courier New”;
mso-fareast-font-family:“Times New Roman”;color:#660E7A”>START<span style=“font-size: 9pt; font-family: “Courier New”;”>, start);
ra.set(Asn.<span style=“font-size:9.0pt;font-family:“Courier New”;
mso-fareast-font-family:“Times New Roman”;color:#660E7A”>WORK<span style=“font-size: 9pt; font-family: “Courier New”;”>, asProject.getDuration(<span style=“font-size:9.0pt;
font-family:“Courier New”;mso-fareast-font-family:“Times New Roman”;color:blue”>16<span style=“font-size: 9pt; font-family: “Courier New”;”>, TimeUnitType.<span style=“font-size:9.0pt;
font-family:“Courier New”;mso-fareast-font-family:“Times New Roman”;color:#660E7A”>Hour<span style=“font-size: 9pt; font-family: “Courier New”;”>));
ra.set(Asn.<span style=“font-size:9.0pt;font-family:“Courier New”;
mso-fareast-font-family:“Times New Roman”;color:#660E7A”>PERCENT_WORK_COMPLETE<span style=“font-size: 9pt; font-family: “Courier New”;”>, <span style=“font-size:9.0pt;font-family:“Courier New”;
mso-fareast-font-family:“Times New Roman”;color:blue”>50<span style=“font-size: 9pt; font-family: “Courier New”;”>);
ra.set(Asn.<span style=“font-size:9.0pt;font-family:“Courier New”;
mso-fareast-font-family:“Times New Roman”;color:#660E7A”>ACTUAL_START<span style=“font-size: 9pt; font-family: “Courier New”;”>, start);
ra.set(Asn.<span style=“font-size:9.0pt;font-family:“Courier New”;
mso-fareast-font-family:“Times New Roman”;color:#660E7A”>ACTUAL_WORK<span style=“font-size: 9pt; font-family: “Courier New”;”>, asProject.getDuration(<span style=“font-size:9.0pt;
font-family:“Courier New”;mso-fareast-font-family:“Times New Roman”;color:blue”>8<span style=“font-size: 9pt; font-family: “Courier New”;”>, TimeUnitType.<span style=“font-size:9.0pt;
font-family:“Courier New”;mso-fareast-font-family:“Times New Roman”;color:#660E7A”>Hour<span style=“font-size: 9pt; font-family: “Courier New”;”>));
asProject.recalculate();
asProject.save(<span style=“font-size:9.0pt;font-family:“Courier New”;
mso-fareast-font-family:“Times New Roman”;color:green”>“Project_task_with_assignment_ok.mpp”<span style=“font-size: 9pt; font-family: “Courier New”;”>, SaveFileFormat.<span style=“font-size:9.0pt;
font-family:“Courier New”;mso-fareast-font-family:“Times New Roman”;color:#660E7A”>MPP<span style=“font-size: 9pt; font-family: “Courier New”;”>);
Hi Kashif,
Hi Etienne,