Hi,
I have followed the example in the Aspose.Tasks help file that creates tasks, resources and assignments and then writes them to a project. This works fine when I write to an xml file but when I update an empty mpp file the resource names are not displayed within MS Project.
The code below exhibits the problem. Does anyone have any idea why the resource names are not visible when saved as an mpp file?
Thanks, Vincent
//
static void Main(string[] args)
{
License license = new License();
license.SetLicense(“Aspose.Tasks.lic”);
//create a project instance
ProjectReader projectReader = new ProjectReader();
Project prj = projectReader.Read(“project.mpp”);
//Define Resources
Resource rec = new Resource();
Resource rec1 = new Resource(“Res1”);
rec1.Type = ResourceType.Work;
Resource rec2 = new Resource(“Res2”);
rec2.Type = ResourceType.Material;
prj.Resources.Add(rec);
prj.Resources.Add(rec1);
prj.Resources.Add(rec2);
//define Tasks
Task rootTsk = new Task();
Task tsk1 = new Task(“Tsk1”);
Task tsk2 = new Task(“Tsk2”);
rootTsk.Children.Add(tsk1);
rootTsk.Children.Add(tsk2);
prj.RootTask = rootTsk;
//define assignment
ResourceAssignment ra1 = new ResourceAssignment(tsk1, rec1);
ResourceAssignment ra2 = new ResourceAssignment(tsk2, rec2);
prj.ResourceAssignments.Add(ra1);
prj.ResourceAssignments.Add(ra2);
//perform recalculations
prj.CalcResourceIds();
prj.CalcResourceUids();
prj.CalcResourceFields();
prj.CalcTaskIds();
prj.CalcTaskUids();
prj.CalcResourceAssignmentIds();
prj.CalcResourceAssignmentUids();
//create a project writer instance
ProjectWriter prjWriter = new ProjectWriter();
//write the stream in mpp format
prjWriter.Write(prj, “c:\project5.mpp”, TasksDataFormat.MPP);
//write the stream in XML format
prjWriter.Write(prj, “c:\project5.xml”, TasksDataFormat.XML);
}
//