Hi Steve,
We are sorry for a delayed response.
In order to set the percent complete value for a task, please use the SetPercentComplete method after the recalculations as shown in the example given below.
Sample Code:
Project prj = new Project();
prj.StartDate = new DateTime(2012, 8, 27);
Task Approval = new Task("Approval");
Task ScopeDocument = new Task("Scope document");
ScopeDocument.Start = new DateTime(2012, 8, 27);
ScopeDocument.Duration = new TimeSpan(0, 24, 0, 0);
ScopeDocument.ConstraintType = ConstraintType.StartNoEarlierThan;
ScopeDocument.ConstraintDate = new DateTime(2012, 8, 27);
Task ApprovalToProceed = new Task("Approval to proceed");
ApprovalToProceed.Start = new DateTime(2012, 8, 30);
ApprovalToProceed.Duration = new TimeSpan(0, 8, 0, 0);
ApprovalToProceed.ConstraintType = ConstraintType.StartNoEarlierThan;
ApprovalToProceed.ConstraintDate = new DateTime(2012, 8, 30);
Approval.Children.Add(ScopeDocument);
Approval.Children.Add(ApprovalToProceed);
prj.RootTask.Children.Add(Approval);
Recalculate(prj);
Task.Recalculate(prj.RootTask);
ScopeDocument.SetPercentComplete(60);
ApprovalToProceed.SetPercentComplete(90);
prj.Save("CreateNewTasks2.xml", Aspose.Tasks.Saving.SaveFileFormat.XML);
This wont compile :
Hi Steve,
project.CalcTaskIds();
project.CalcTaskUids();
project.CalcResourceIds();
project.CalcResourceUids();
project.CalcResourceAssignmentIds();
project.CalcResourceAssignmentUids();
project.CalcCalendarUids();
project.UpdateReferences();
}
Thanks for the quick reply, however the routine now crashes on line
|
Stack Trace:
|
Hi I’ve now downloaded version 6.0 and whatever I do I cant get the code to create an export to XML with percent completes and resources. If I have created a simple 1 task plan and used SetPercentComplete(60) (say) then the xml file created correctly opens in MS project with the right data and my task is 60% complete
Hi Steve,
Project project = new Project();
Task task1 = project.AddTask(“Task1”); // adds after the last project’s task
task1.Start = new DateTime(2013, 11, 25);
task1.Duration = new TimeSpan(16, 0, 0);
task1.SetPercentComplete(50);
Resource rsc = project.AddResource(“Resource 1”);
ResourceAssignment assgn = new ResourceAssignment(task1, rsc);
project.AddResourceAssignment(task1, rsc);
project.Save(“TestXml20.xml”, Aspose.Tasks.Saving.SaveFileFormat.XML);
Thanks for the quick reply, it was all going so well until I tried adding a second task as a ‘child’ of task 1 so…
Hi Steve,
Project project = new Project();
Task task1 = project.AddTask(“Task1”); // adds after the last project’s task
task1.Start = new DateTime(2013, 11, 25);
task1.Duration = new TimeSpan(16, 0, 0);
//Define task 2
Task task2 = project.AddTask(“Task2”);
Resource rsc = project.AddResource(“Resource 1”);
project.AddResourceAssignment(task2,rsc);
task2.SetPercentComplete(70);
task2.OutlineIndent();
project.Save(“TestXml20.xml”, Aspose.Tasks.Saving.SaveFileFormat.XML);
Thanks for the reply. I’ll wait until the fix is available before carrying on. I need to be sure it will work before I commit too much more time. Hopefully the fix will be available very soon
Hi Steve,
The issues you have found earlier (filed as TASKS-33497) have been fixed in this update.
This message was posted using Notification2Forum from Downloads module by Aspose Notifier.
The issues you have found earlier (filed as ) have been fixed in this Aspose.Words for JasperReports 18.3 update.