Definición del tipo de enlace
La propiedad LinkType expuesta por la clase Tasklink se usa para recuperar o definir el tipo de enlace entre dos tareas. Lee y escribe uno de los valores definidos por el tipo de enumeración de TasklinkType.
Definición del tipo de enlace
Para definir el tipo de enlace en el proyecto Microsoft: En el menú Ver, seleccione más vistas y luego Formulario de entrada de tarea.
- Haga doble clic en la tarea deseada.
- Seleccione la pestaña predecesor.
Definición del enlace Tipo en el proyecto Microsoft
Tipo de enlace de configuración con Aspose.Tasks
La muestra de código que se proporciona a continuación establece un tipo de enlace como “Inicio de arranque”, el tipo de enlace predeterminado es “Finalizar a arranque”.
1// Create new project and add tasks
2System::SharedPtr<Project> project = System::MakeObject<Project>();
3System::SharedPtr<Task> pred = project->get_RootTask()->get_Children()->Add(u"Task 1");
4System::SharedPtr<Task> succ = project->get_RootTask()->get_Children()->Add(u"Task 2");
5
6// Link tasks with link type set to Start to Start
7System::SharedPtr<TaskLink> link = project->get_TaskLinks()->Add(pred, succ);
8link->set_LinkType(Aspose::Tasks::TaskLinkType::StartToStart);
Getting Link Type with Aspose.Tasks
The code sample given below display link types by traversing the task links in the project and printing the result to a console window.
1// Create project instance
2System::String dataDir = RunExamples::GetDataDir(System::Reflection::MethodBase::GetCurrentMethod(ASPOSE_CURRENT_FUNCTION)->get_DeclaringType().get_FullName());
3System::SharedPtr<Project> project1 = System::MakeObject<Project>(dataDir + u"GetTaskLinkType.mpp");
4
5// Display task link types
6auto allinks = project1->get_TaskLinks();
7
8{
9 auto tsklnk_enumerator = (allinks)->GetEnumerator();
10 decltype(tsklnk_enumerator->get_Current()) tsklnk;
11 while (tsklnk_enumerator->MoveNext() && (tsklnk = tsklnk_enumerator->get_Current(), true))
12 {
13 System::Console::WriteLine(System::ObjectExt::ToString(tsklnk->get_LinkType()));
14 }
15}