ManualStart- ManualFinish- ManualDuration not showing in XML

I’ve been setting the manual properties of tasks in my project as seen below :


                Task task = new Task("Test " + count);
            TimeSpan duration = TimeSpan.FromMilliseconds(t.Duration);

            task.IsManual = <span style="color:blue;">true</span>;
            task.ManualStart = t.StartDate;
            task.ManualDuration = duration;
            task.ManualFinish = t.StartDate.Add(duration);</pre><pre style="font-family: Consolas; font-size: 13px; background-color: white; background-position: initial initial; background-repeat: initial initial;"><br></pre><pre style="font-family: Consolas; font-size: 13px; background-color: white; background-position: initial initial; background-repeat: initial initial;">For some reason, when I write to xml, the ManualStart, ManualDuration, and ManualFinish are not showing in the xml.</pre><pre style="font-family: Consolas; font-size: 13px; background-color: white; background-position: initial initial; background-repeat: initial initial;">The isManual does show up.</pre><pre style="font-family: Consolas; font-size: 13px; background-color: white; background-position: initial initial; background-repeat: initial initial;">If I use the "Actual" properties, it does show in the xml.</pre><pre style="font-family: Consolas; font-size: 13px; background-color: white; background-position: initial initial; background-repeat: initial initial;">I'm using Aspose.Tasks 4.9 for .NET </pre><pre style="font-family: Consolas; font-size: 13px; background-color: white; background-position: initial initial; background-repeat: initial initial;"><br></pre><pre style="font-family: Consolas; font-size: 13px; background-color: white; background-position: initial initial; background-repeat: initial initial;">Any potential solutions?</pre><pre style="font-family: Consolas; font-size: 13px; background-color: white; background-position: initial initial; background-repeat: initial initial;"><br></pre><pre style="font-family: Consolas; font-size: 13px; background-color: white; background-position: initial initial; background-repeat: initial initial;">Thanks in advance!</pre></div>

Hi Jacob,


I have tried to reproduce this issue at my end using the latest version of Aspose.Tasks for .NET 5.1.0, but was unable to observe this issue. The mentioned fields are visible in the output xml file. Could you please try it with the latest version of Aspose.Tasks for .NET 5.1.0 and let us know your feedback?

If the problem still persists at your end with the latest version of Aspose.Tasks, I would request you to please provide us some sample runnable code in the form of a console application that exhibits this problem. It’ll help us investigate the issue and assist you further.

Hi,


Before I spend the time to turn the code into a console app could you answer a few questions. Are there any requirements when setting up the root task, task, or project for the manual start, manual end, and manual duration to appear in the XML? Is there anything special I have to do when I write the file? An example would be helpful.

I have attached a .cs file that does most of the work for generating the data.
GetProgramsProject is the method that is initially called from another class located in another file.


Thanks,

Jacob


Hi Jacob,


We are sorry for the delayed response.

Please spare us little time to investigate the issue as we are discussing the issue with the development team. We will soon share our findings with you as soon as some feedback is received.

Hi Jacob,


Thanks for your patience.

I have analyzed your code and found that Project.UpdateReferences is not called. If you call this function before saving the project as XML, "ManualStart, ManualFinish and ManualDuration " will be saved in resultant XML.

I would also like to share that these properties were introduced in MSP 2010 whose SaveVersion is 14. If you are creating new project and then writing task and properties, then you must set SaveVersion to 14. Following sample code demonstrates this scenario:


//create a project instance
Project newProject = new Project();
newProject.SaveVersion = 14;

//Define Tasks
Task rootTsk = new Task();
Task task1 = new Task(“Task1”);
task1.Start = DateTime.Now;
TimeSpan duration = TimeSpan.FromHours(8);
task1.IsManual = true;
task1.ManualStart = DateTime.Now;
task1.ManualDuration = duration;
task1.ManualFinish = task1.ManualStart.Add(duration);

//add tsk1 to the rootTsk
rootTsk.Children.Add(task1);

//set rootTsk as root task of the project
newProject.RootTask = rootTsk;

//perform recalculations
newProject.CalcTaskIds();
newProject.CalcTaskUids();
newProject.UpdateReferences();
newProject.Save(@“FromNewProject.xml”, Aspose.Tasks.Saving.SaveFileFormat.XML);


If you are using some existing project then you need to check the SaveVersion before adding these properties otherwise these will not be written to resultant XML file. Following sample code demonstrate this test:

//create a project reader instance
ProjectReader projectReader = new ProjectReader();

//call read method of project reader object to get project object
Project existingProject = projectReader.Read(@“Project1.mpp”);

//Define Tasks
Task rootTsk = new Task();
Task task1 = new Task(“Task1”);
task1.Start = DateTime.Now;
TimeSpan duration = TimeSpan.FromHours(8);

if (existingProject.SaveVersion >= 14)
{
task1.IsManual = true;
task1.ManualStart = DateTime.Now;
task1.ManualDuration = duration;
task1.ManualFinish = task1.ManualStart.Add(duration);
}

//add tsk1 to the rootTsk
rootTsk.Children.Add(task1);

//set rootTsk as root task of the project
existingProject.RootTask = rootTsk;

//perform recalculations
existingProject.CalcTaskIds();
existingProject.CalcTaskUids();
existingProject.UpdateReferences();
existingProject.Save(@“FromExistingProject.xml”, Aspose.Tasks.Saving.SaveFileFormat.XML);

Please give a try to the above sample codes and let us know your feedback.