Tâches mobiles
Microsoft Project permet de déplacer une tâche sous une autre tâche. Dans ce cas, les tâches enfants des tâches sélectionnées sont également déplacées avec elle. Aspose.Tasks pour .NET fournit la même fonctionnalité en déplaçant une tâche sous une autre tâche. Cela peut être réalisé en ajoutant la tâche sélectionnée aux enfants du nouveau parent comme indiqué dans cet article. La tâche peut être déplacée sous un parent différent ou le même parent.
Déplacer la tâche sous un autre parent
Veuillez noter que l’utilisation * calculmode.none * peut améliorer les performances lorsque vous ajoutez plusieurs tâches et appelez Recalculer la méthode une fois.
1Project project = new Project("New Project.mpp");
2project.CalculationMode = CalculationMode.Automatic;
3// Get Tasks by Ids
4Task task1 = project.RootTask.Children.GetByUid(6);
5Task task2 = project.RootTask.Children.GetByUid(3);
6// Adding Task 6 to another parent
7task2.Children.Add(task1);
8project.Save("MoveTaskUnderAnotherParent_out.mpp", SaveFileFormat.MPP);
Moving Task Under the Same Parent
The MoveToSibling method allows moving a task under the same parent to a specific position.
1Project project = new Project("New Project.mpp");
2// Move tasks with id 5 before task with id 3
3Task task = project.RootTask.Children.GetById(5);
4task.MoveToSibling(3);
5project.Save("MoveTaskUnderSameParent_out.mpp", SaveFileFormat.MPP);
Add Task To The End
To add a task to the end of the collection use -1.
1Project project = new Project("New Project.mpp");
2// Move tasks with id 2 to the end of the collection
3Task task = project.RootTask.Children.GetById(2);
4task.MoveToSibling(-1);
5project.Save("MoveTaskAtTheEnd_out.mpp", SaveFileFormat.MPP);