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);