Regarding unable to use AutoSchedule property

Hi Team,


Thanks for your response!!

I am trying to use Auto Task but it is not working.

Project projectWrite = new Project(samplePath);
Program p = new Program();
projectWrite.CalculationMode = CalculationMode.Automatic; --> It is not working Please let me know how to use this functionality.

projectWrite.Save(samplePath, SaveFileFormat.MPP);


Also,

I am unable to set the predecessor field, by using task link I will get the relation but I am retrieving value from the database for eg. : Predecessor is 2,3 for Task number 6.

How can I set the value in this case.?



Regards
Abhishek Prasd

Hi Abhishek,


It is not clear from your sample code that what option is not working. I have tried following sample code and it is working fine. Could you please explain what problem are you facing while setting the project calculation mode to Automatic? Following sample code works fine and sets project mode successfully.

<span style=“font-family: “Courier New”, Consolas, Courier, monospace; font-size: small; white-space: pre; background-color: rgb(255, 255, 255);”>Project proj = <span class=“kwrd” style=“color: rgb(0, 0, 255); font-family: “Courier New”, Consolas, Courier, monospace; font-size: small; white-space: pre;”>new<span style=“font-family: “Courier New”, Consolas, Courier, monospace; font-size: small; white-space: pre; background-color: rgb(255, 255, 255);”> Project(@“Blank2010.mpp”);<br style=“font-family: “Courier New”, Consolas, Courier, monospace; font-size: small; white-space: pre;”><span style=“font-family: “Courier New”, Consolas, Courier, monospace; font-size: small; white-space: pre; background-color: rgb(255, 255, 255);”>
proj.CalculationMode = CalculationMode.Automatic;<br style=“font-family: “Courier New”, Consolas, Courier, monospace; font-size: small; white-space: pre;”><span style=“font-family: “Courier New”, Consolas, Courier, monospace; font-size: small; white-space: pre; background-color: rgb(255, 255, 255);”>
Console.WriteLine(proj.CalculationMode);<br style=“font-family: “Courier New”, Consolas, Courier, monospace; font-size: small; white-space: pre;”><span style=“font-family: “Courier New”, Consolas, Courier, monospace; font-size: small; white-space: pre; background-color: rgb(255, 255, 255);”>
proj.CalculationMode = CalculationMode.Manual;<br style=“font-family: “Courier New”, Consolas, Courier, monospace; font-size: small; white-space: pre;”><span style=“font-family: “Courier New”, Consolas, Courier, monospace; font-size: small; white-space: pre; background-color: rgb(255, 255, 255);”>
Console.WriteLine(proj.CalculationMode);<br style=“font-family: “Courier New”, Consolas, Courier, monospace; font-size: small; white-space: pre;”><span style=“font-family: “Courier New”, Consolas, Courier, monospace; font-size: small; white-space: pre; background-color: rgb(255, 255, 255);”>
<br style=“font-family: “Courier New”, Consolas, Courier, monospace; font-size: small; white-space: pre;”>

For setting multiple predecessor for a task, please give a try to the following sample code.
Project proj = new Project();
for (int i = 0; i < 6; i++)
{
Task tsk = proj.RootTask.Children.Add("Task-" + (i + 1));
{
tsk.Set(Tsk.Start, new DateTime(2016, 8, 9));
tsk.Set(Tsk.Duration, proj.GetDuration(8, TimeUnitType.Hour));
}
}
Task Task6 = proj.RootTask.Children.GetById(6);
proj.TaskLinks.Add(proj.RootTask.Children.GetById(2), Task6);
proj.TaskLinks.Add(proj.RootTask.Children.GetById(3), Task6);
proj.Save("Output.xml", SaveFileFormat.XML);

Hi Kashif,


Thanks for your response!!

Is there a way to directly set the value to the predecessor field in the column for a particular Task,

As I am using loops to iterate the tasks and maintain the parent child relation.

Like If I have a value 4 which is predecessor for task Id 6, I just want to set 4 in the predecessor field of Id6.

Thanks
Abhishek Prasad

Hi Abhishek,


I am afraid that no such feature is available in Aspose.Tasks to set the predecessors. Please feel free to write us back if you have any other query related to Aspose.Tasks.