작업 제약 조건 처리

작업 제약은 Microsoft Project Project의 일정을 정의하고 작업을 시작하거나 완료 해야하는시기를 정의하는 데 사용됩니다. 제약 조건은 융통성이있을 수 있습니다. 가능한 빨리 또는 가능한 빨리 또는 융통성이 없거나 융통성이 없습니다. 융통성없는 제약은 특정 날짜와 관련이 있습니다.

제약 조건으로 작업

제약 조건 및 제약 초대 속성은 제약 조건을 처리하기 위해 정적 클래스 TSK 클래스에 의해 노출됩니다.

Microsoft Project에서 제약 조건 설정

Microsoft Project에서 제약을 설정하려면 :

  1. 보기 메뉴에서 더 많은보기를 선택한 다음 작업 입력 양식을 선택하십시오.
  2. 작업 입력 양식에서 작업을 두 번 클릭하십시오.
  3. 고급 탭을 선택하십시오.
  4. 제약 조건 유형 목록에서 옵션을 선택하여 제약 조건을 설정하고 제약 조건 날짜 목록의 날짜를 설정하십시오.

Aspose.Tasks로 제약 조건 설정

제약 조건 날짜는 제약 유형이 가능한 한 빨리 또는 가능한 한 늦게 인 경우 NA입니다. 날짜 값의 경우 na와 동일한 날짜 값의 경우, Aspose.Tasks 는 평가 버전에서 “1/1/2000"값을 사용하고 라이센스가있는 제품의 DateTime.minValue를 사용합니다. 아래의 경우 소스 프로젝트 파일을 입력으로 가져 와서 각 경우 각각의 다양한 작업에 다른 유형의 제약 조건을 적용합니다. 다음 코드 예제는 다른 제약 유형의 적용을 보여줍니다.

아래 코드 샘플은 세트가 시작되도록 설정된 제약 조건 유형을 설정합니다.

 1// The path to the documents directory.
 2System::String dataDir = RunExamples::GetDataDir(System::Reflection::MethodBase::GetCurrentMethod(ASPOSE_CURRENT_FUNCTION)->get_DeclaringType().get_FullName());
 3    
 4// Create project instance
 5System::SharedPtr<Project> project = System::MakeObject<Project>(dataDir + u"ConstraintStartNoEarlierThan.mpp");
 6    
 7// Set constraint Start No Earlier Than on task with Id 1
 8System::SharedPtr<Task> summary = project->get_RootTask()->get_Children()->GetById(1);
 9summary->Set<ConstraintType>(Tsk::ConstraintType(), Aspose::Tasks::ConstraintType::StartNoEarlierThan);
10summary->Set(Tsk::ConstraintDate(), System::DateTime(2016, 12, 1, 9, 0, 0));
11    
12// Save project as pdf
13System::SharedPtr<SaveOptions> o = System::MakeObject<PdfSaveOptions>();
14o->set_StartDate(project->Get<System::DateTime>(Prj::StartDate()));
15o->set_Timescale(Aspose::Tasks::Visualization::Timescale::ThirdsOfMonths);
16project->Save(dataDir + u"project_StartNoEarlierThan_out.pdf", o);

The code samples below set the constraint type set to Finish No Earlier Than.

 1// Set constraint Finish No Earlier Than on task with Id 2
 2System::SharedPtr<Task> first = project1->get_RootTask()->get_Children()->GetById(2);
 3first->Set<ConstraintType>(Tsk::ConstraintType(), Aspose::Tasks::ConstraintType::FinishNoEarlierThan);
 4first->Set(Tsk::ConstraintDate(), System::DateTime(2016, 12, 1, 18, 0, 0));
 5    
 6// Save project as pdf
 7System::SharedPtr<SaveOptions> options = System::MakeObject<PdfSaveOptions>();
 8options->set_StartDate(project1->Get<System::DateTime>(Prj::StartDate()));
 9options->set_Timescale(Aspose::Tasks::Visualization::Timescale::ThirdsOfMonths);
10project1->Save(dataDir + u"project_FinishNoEarlierThan_out.pdf", options);

The code samples below set the constraint type set to Must Start On.

 1// Set constraint Must Start On for task with Id 5
 2System::SharedPtr<Task> roof = project1->get_RootTask()->get_Children()->GetById(5);
 3roof->Set<ConstraintType>(Tsk::ConstraintType(), Aspose::Tasks::ConstraintType::MustStartOn);
 4roof->Set(Tsk::ConstraintDate(), System::DateTime(2017, 1, 1, 9, 0, 0));
 5    
 6// Save project as pdf
 7System::SharedPtr<SaveOptions> options = System::MakeObject<PdfSaveOptions>();
 8options->set_StartDate(project1->Get<System::DateTime>(Prj::StartDate()));
 9options->set_Timescale(Aspose::Tasks::Visualization::Timescale::ThirdsOfMonths);
10project1->Save(dataDir + u"project_MustStartOn_out.pdf", options);

The code samples below set the constraint type set to As Late As Possible.

1// Set constraint As Late As Possible for task with Id 11
2System::SharedPtr<Task> wallBoard = project1->get_RootTask()->get_Children()->GetById(11);
3wallBoard->Set<ConstraintType>(Tsk::ConstraintType(), Aspose::Tasks::ConstraintType::AsLateAsPossible);
4    
5// Save project as pdf
6System::SharedPtr<SaveOptions> options = System::MakeObject<PdfSaveOptions>();
7options->set_StartDate(project1->Get<System::DateTime>(Prj::StartDate()));
8options->set_Timescale(Aspose::Tasks::Visualization::Timescale::ThirdsOfMonths);
9project1->Save(dataDir + u"project_AsLateAsPossible_out.pdf", options);

The code sample below shows the constraint type set to Must Finish On.

 1// Set constraint Must Finish On for task with Id 15
 2System::SharedPtr<Task> interiorFixtures = project1->get_RootTask()->get_Children()->GetById(15);
 3interiorFixtures->Set<ConstraintType>(Tsk::ConstraintType(), Aspose::Tasks::ConstraintType::MustFinishOn);
 4interiorFixtures->Set(Tsk::ConstraintDate(), System::DateTime(2017, 3, 1, 18, 0, 0));
 5    
 6// Save project as pdf
 7System::SharedPtr<SaveOptions> options = System::MakeObject<PdfSaveOptions>();
 8options->set_StartDate(project1->Get<System::DateTime>(Prj::StartDate()));
 9options->set_Timescale(Aspose::Tasks::Visualization::Timescale::ThirdsOfMonths);
10project1->Save(dataDir + u"project_MustFinishOn_out.pdf", options);

Getting Constraints

This code sample displays any constraints found when traversing the tasks in the project to a command window.

 1System::String dataDir = RunExamples::GetDataDir(System::Reflection::MethodBase::GetCurrentMethod(ASPOSE_CURRENT_FUNCTION)->get_DeclaringType().get_FullName());
 2System::SharedPtr<Project> project1 = System::MakeObject<Project>(dataDir + u"Project2.mpp");
 3    
 4// Create a ChildTasksCollector instance
 5System::SharedPtr<ChildTasksCollector> collector = System::MakeObject<ChildTasksCollector>();
 6    
 7// Collect all the tasks from RootTask using TaskUtils
 8TaskUtils::Apply(project1->get_RootTask(), collector, 0);
 9    
10// Parse through all the collected tasks
11    
12{
13    auto tsk1_enumerator = (collector->get_Tasks())->GetEnumerator();
14    decltype(tsk1_enumerator->get_Current()) tsk1;
15    while (tsk1_enumerator->MoveNext() && (tsk1 = tsk1_enumerator->get_Current(), true))
16    {
17        if (tsk1->Get<System::DateTime>(Tsk::ConstraintDate()).ToShortDateString() == u"1/1/2000")
18        {
19            System::Console::WriteLine(u"NA");
20        }
21        else
22        {
23            System::Console::WriteLine(tsk1->Get<System::DateTime>(Tsk::ConstraintDate()).ToShortDateString());
24        }
25        
26        System::Console::WriteLine(System::ObjectExt::ToString(tsk1->Get<ConstraintType>(Tsk::ConstraintType())));
27    }
28}
Subscribe to Aspose Product Updates

Get monthly newsletters & offers directly delivered to your mailbox.