asposeProject.TaskLinks.Add

Hello,

I have a performance problem when I include the links in the tasks.
I have the project with about three thousand tasks, and when I include the links, the process greatly increases the total execution time of the process.

In the
link = asposeProject.TaskLinks.Add (predecessor, successor, taskLink, lag);
that’s where the delay happens.

In a project with about 3,000 tasks the process ran for about 9 hours and did not end.

How can I improve this time by assigning the link?

Follow the code:

if (context.SyncConfig.SyncLigacoes && context.SyncConfig.SyncExportar)
{
Project asposeProject = context.AsposeData;
while (context.AsposeData.TaskLinks.Count > 0)
asposeProject.TaskLinks.Remove(context.AsposeData.TaskLinks.First());

ChildTasksCollector collector = new ChildTasksCollector();
TaskUtils.Apply(asposeProject.RootTask, collector, 1);

asposeProject.CalculationMode = CalculationMode.Manual;

Dictionary<string, TaskLinkType> listLink = new Dictionary<string, TaskLinkType>();
listLink.Add("II", TaskLinkType.StartToStart);
listLink.Add("IF", TaskLinkType.StartToStart);
listLink.Add("FF", TaskLinkType.StartToStart);
listLink.Add("FI", TaskLinkType.StartToStart);

TaskLinkType taskLink;
Task predecessora;
Task sucessora;
Duration lag ;
TaskLink link;

foreach (PrjSyncTarefaRelac taskRelac in context.ProjetoTerceiro.TarefaRelacs)
{
	predecessora = PrjSyncTarefaUtils.getTaskObj(taskRelac.Predecessora);
	sucessora = PrjSyncTarefaUtils.getTaskObj(taskRelac.Sucessora);

	taskLink = (listLink.ContainsKey(taskRelac.TipoLigacao)) ? listLink[taskRelac.TipoLigacao] : TaskLinkType.FinishToStart;

	if (predecessora != null && sucessora != null)
	{
		lag = asposeProject.GetDuration(RMSConvert.ToDouble(taskRelac.Defasagem), TimeUnitType.Day);
		link = asposeProject.TaskLinks.Add(predecessora, sucessora, taskLink, lag);
		link.LagFormat = TimeUnitType.Day;
	}
}
asposeProject.CalculationMode = CalculationMode.Automatic;

}

@Helem

It is requested to please provide sample project file so that we could investigate the issue in detail. You may share the file in private by sending in message. The message button shall appear by clicking on my user name.

1 Like

Hello,
the project is attached.

@Helem

We are unable to locate attached project file. You may share the file using GDrive or DropBox.

Follows the shared file link:

@Helem

We do not have permission to download file at this link. Please provide open link so that any of us could access and download.

Here is the link to the shared file:
https://we.tl/t-JHRnZN9olN

@Helem

Thank you for providing the project file.
Initially, we have tried to check the performance issue and the output project file is successfully generated in 10 to 15 minutes.
We are working on this and shall update you as soon as we have more information to share.

In my environment the process has been running for more than 25 hours for 5000 tasks and has not finished generating the file.

@Helem

Please let us know which OS, VS version and MS Project version is used to run this application.

@MuzammilKhan

Windows 7 Professional - Service Pack 1
Aspose.Tasks 2018 version 18.4

@Helem

We have logged this issue under ID “TASKSNET-2789” for further investigation. You will automatically be informed here once we have more information to share.

Good Morning,
I downloaded version 18.10 of Aspose.Tasks.dll, and the process has the same behavior as version 18.4.

@Helem

We are working on this issue and we will update you as soon as we have more information to share.

Hello @Helem,

Please try to set project calculation mode to CalculationMode.None and call project.Recalculate() when task links are already added.

@Helem

You may use CalculationMode.None, please try the sample given below:

// save project calculation mode
var temp = project.CalculationMode;

project.CalculationMode = CalculationMode.None;

// the loop starts
// add 3000 links 
// the loop ends

project.Recalculate();

// restore project calc mode
project.CalculationMode = tmp;

Furthermore, please feel free to write back to us if the issue persists or any additional information is required.