I create TaskLinks which look correct in the debugger, but when I
call AddTaskLink(link), it will only add a link the first time
it's called.
There is no exception, but TaskLinks.Count is always 1.
This is version 3.4.0.0 of Aspose.Tasks
TaskLink link = new TaskLink(start, target, TaskLinkType.FinishToStart);
prj.AddTaskLink(link);
Hi,
I have tried to repeat the issue at my side. I used an XML project as a template, loaded it and added two task links using the code below:
using System;
using Aspose.Tasks;
namespace TestTaskLinks
{
class Program
{
static void Main(string[] args)
{
ProjectReader reader = new ProjectReader();
Project prj = reader.Read("Template.xml");
Task task1 = prj.GetTaskByUid(1);
Task task2 = prj.GetTaskByUid(2);
Task task3 = prj.GetTaskByUid(3);
TaskLink link1 = new TaskLink(task1, task2, TaskLinkType.FinishToStart);
link1.LinkLag = 10 * 60 * 8;
TaskLink link2 = new TaskLink(task1, task3, TaskLinkType.FinishToStart);
prj.AddTaskLink(link1);
prj.AddTaskLink(link2);
(new ProjectWriter()).Write(prj, "result.xml", TasksDataFormat.XML);
Console.WriteLine(string.Format("Project links count = {0}", prj.TaskLinks.Count));
Console.Read();
}
}
}
Please see a resulting screen shot attached. Note that the dates were converted to 2000 year as I did not loaded any license.
Please provide us with your full code sample if you have a different result.
Save Editcancel
I have a table of tasks that I want to link and I iterate through the tasks in the prj.RootTask.Children arraylist looking for tasks to connect.
If I use this line:
prj.AddTaskLink(link); only the first link is added. If I use
prj.TaskLinks.Add(link); it works for all links.
Joe
Hi Joe,
We need some time to analyze the problem as we can not repeat it in common case.
But be noted that AddTaskLink method just checks that the linked tasks are not Null and the link was not added before to the array and then adds the link by the same way as you did.
Sorry for your inconvenience.