Change Task's hierarchy

I have to sync MS Project data with my application, but at this context I have to change task’s hierarchy.

How is the best way to change parent tasks?

For example I have this MS Project data:

1 - Task 1
1.1 - Task 2
1.1.1 - Task 3
1.2 - Task 4
1.2.1 - Task 5
1.3 - Task 6
1.3.1 - Task 7

But I change it in my database and have to sync to MS Project like that (change hierarchy):

1 - Task 1
1.1 - Task 2
1.1.1 - Task 3
1.1.1.3 - Task 6
1.1.1.3.1 - Task 7
1.2 - Task 4
1.2.1 - Task 5

********

1- I tried to set “Parent Task” property but doesn’t work
2- With OutlineIndent or OutlineOutdent I can’t change vertical hierarchy

Thanks.

Hi Lucas,


Thank you for contacting Aspose support team.

Task in an existing MPP file can be indented using following sample code:

Project prj = new Project(@“Sample.mpp”);
ChildTasksCollector collector = new ChildTasksCollector(); // Create a ChildTasksCollector instance
TaskUtils.Apply(prj.RootTask, collector, 1); // Collect all the tasks from RootTask using TaskUtils
foreach (Task tsk in collector.Tasks)
{
switch(tsk.Get(Tsk.Id))
{
case 1:
{
tsk.Set(Tsk.OutlineLevel, 1);
break;
}
case 2:
{
tsk.Set(Tsk.OutlineLevel, 2);
break;
}
case 3:
{
tsk.Set(Tsk.OutlineLevel, 3);
break;
}
case 4:
{
tsk.Set(Tsk.OutlineLevel, 4);
break;
}
case 5:
{
tsk.Set(Tsk.OutlineLevel, 5);
break;
}
case 6:
{
tsk.Set(Tsk.OutlineLevel, 2);
break;
}
case 7:
{
tsk.Set(Tsk.OutlineLevel, 3);
break;
}
}
}
prj.Save(@“Output.mpp”, SaveFileFormat.MPP);

However this does not change the order of tasks, like task 6 and 7 are not moved above task number 4. Here OutlineIndent and OutlineIndent can be used as follows:

Project prj = new Project(@“Sample.mpp”);
prj.RootTask.Children.GetById(4).OutlineOutdent();
prj.RootTask.Children.GetById(4).OutlineIndent();
prj.RootTask.Children.GetById(6).OutlineIndent();
prj.RootTask.Children.GetById(6).OutlineIndent();
prj.Save(@“AllSteps.mpp”, SaveFileFormat.MPP);

Here in the output file you may observe that tasks order is changed as per your requirements but the Outline Number are not appropriate. I have logged this issue as Id: TASKS-33907 in our issue tracking system for further investigation by the development team. I will write back here as soon as some feedback is received in this regard.

Hi Kashif,


With OultlineIndent/Outdent function I can move the vertical hierarchy, but I can’t understand how to use this to set the exactly parent to a task.
I can use this specifically, but not with generic algorithm.

There’s no function to set directly task’s parent?
Or if I remove the task from old task Child’s list, add to new task Child’s list and set the Parent property, the Project will be recalculated?

Hi Lucas,


At present, there is no method available for setting directly task’s parent. You will have to remove the task from old task child’s list and add it to new task child’s list. Recalculations are done automatically in this case.

We also have logged an enhancement ticket with id: TASKS-33908 for moving a child task under another task. This will provide ease in moving a task under a different parent. We’ll notify you here once there is a fix version available for this enhancement.

The TaskCollection class (used in Children property) don’t have a remove function and the Add function don’t accept a Task parameter, only accept String.


How may I remove and add the same Task from TaskCollection?

Hi Lucas,


Currently this option is not available however this requirement is already logged (TASKS-33908:Provision of moving a task from one parent to other) as enhancement in our issue tracking system. If this enhancement is implemented, you may get the feature of removing task from one parent and insert it under some other parent in upcoming releases in future.

Please be patient until developers implement this enhancement and release the new dll online for download.

Hi Kashif,


How can I follow the requirement’s workflow? There is a delivery forecast?

This requirement is an impediment for my project and I’m apprehending for the deadline.

Thanks.

Hi Lucas,


This issue is already in queue for analysis by the development team. As there are many other tasks present in queue, therefore this issue is not analyzed yet and hence it is not possible to give any ETA at this point of time. As soon as this issue is analyzed and developers feedback is available, I will write back here on the forum.

Your patience and understanding is highly appreciated in this regard.

Hi Lucas,

I have requested and ETA from our development team for the fix including TASKS-33908. I’ll update you here as soon as the ETA is available in this regard.

Hi Kashif,

Do you have some new information about the ETA?
I have to give feedback to my managers about that problem and the ETA is the most important information to them.
My project's deadline is 03/15/2015 and that issue is critical.

Thanks.

Hi Lucas,

We have implemented this enhancement and it will be part of our upcoming version which is due a week time. Normally, we release the new version by first week of each month and we are on track this time as well. We’ll notify you here as soon as the fix version is available for download. Sample code that you will be able to use is as follow:

Sample Code:


Project proj = new Project(“yourmpp.mpp”);


proj.CalculationMode = CalculationMode.Automatic;


Task t6 = proj.RootTask.Children.GetByUid(6);

Task t3 = proj.RootTask.Children.GetByUid(3);

t3.Children.Add(t6); // adding Task 6 to another parent

proj.Save(“yourmpp.mpp”, SaveFileFormat.MPP);

Hi Kashif,


In my dll version there’s no overload to Add method that accept Task parameter, just string parameter. That sample don’t compile in my solution.

There is some new version newer than 8.0.0?

Hi Lucas,

Sorry for the confusion. As I mention, you will be able to use it with the upcoming version of Aspose.Tasks for .NET 8.1.0. There is no such method available in Aspose.Tasks for .NET 8.0.0.

Hi Lucas,

Aspose.Tasks for .NET 8.1.0 has been released and you can download it from here. You will now be able to use the sample code shared above. Please let us know if we can be of any additional help to you.

The issues you have found earlier (filed as TASKS-33908;TASKS-33907) have been fixed in this update.


This message was posted using Notification2Forum from Downloads module by Aspose Notifier.

The issues you have found earlier (filed as ) have been fixed in this Aspose.Words for JasperReports 18.3 update.