Hello.
I’ve got a problem when I try to add a predecessor to a task. The task start date is not updated when I add the predecessor (TaskLink).
Here is my code:
namespace Aspose_Tasks
{
class Program
{
static void Main(string[] args)
{
Aspose.Tasks.License license = new Aspose.Tasks.License();
license.SetLicense(“Aspose.Tasks.lic”);
ProjectReader reader = new ProjectReader();
Project project = reader.Read(“ProjectTeste.mpp”);
project.StartDate = new DateTime(2015, 3, 23);
project.NewTaskStartDate = TaskStartDateType.CurrentDate;
Aspose.Tasks.Task task = project.AddTask(“Tarefa1”);
task.IsManual = false;
task.Type = TaskType.FixedDuration;
task.DurationFormat = TimeUnitType.Day;
task.Duration = new TimeSpan(16, 0, 0);
Aspose.Tasks.Resource resource = project.AddResource(“res1”);
resource.StandardRate = 10;
resource.MaterialLabel = “un”;
resource.Type = ResourceType.Material;
Aspose.Tasks.ResourceAssignment assignment = project.AddResourceAssignment(task, resource);
assignment.PeakUnits = 200;
assignment.Work = new TimeSpan(300, 0, 0);
Aspose.Tasks.Task task2 = project.AddTask(“Tarefa2”);
task2.IsManual = false;
task2.Type = TaskType.FixedDuration;
task2.DurationFormat = TimeUnitType.Day;
task2.Duration = new TimeSpan(80, 0, 0);
resource = project.AddResource(“res2”);
resource.StandardRate = 12;
resource.MaterialLabel = “un”;
resource.Type = ResourceType.Material;
assignment = project.AddResourceAssignment(task2, resource);
assignment.Work = new TimeSpan(300, 0, 0);
//Recalculate task IDs
project.UpdateReferences();
project.CalcTaskIds();
project.CalcTaskUids();
Aspose.Tasks.TaskLink pred = new TaskLink(task, task2, TaskLinkType.FinishToStart);
pred.LagFormat = TimeUnitType.Day;
pred.LinkLag = 10 * 60 * 16;
project.TaskLinks.Add(pred);
Aspose.Tasks.Task.Recalculate(project.RootTask);
//Save the Project as XML
project.Save(“OutputProject.mpp”, Aspose.Tasks.Saving.SaveFileFormat.MPP);
}
}
}
And the result of this application is showed in attached file MSProjectResult.PNG.
As you can see, the information is written in MSProject but the dates are not updated as they should.