Відсоток повних розрахунків

Microsoft Project показує відсоток завдання, яке було виконано. Відсоток може бути доданий вручну керівником проекту або автоматично обчислюватися програмою. Aspose.Tasks для C ++ підтримує кілька відсоткових обчислень, пов’язаних із завданнями.

відсотки

Клас TSK розкриває ряд властивостей, що використовуються для обчислення відсотків:

Щоб побачити фізичний відсоток, завершений у проекті Microsoft:

  1. У формі запису завдання, у меню вставити, виберіть стовпчик.
  2. Додайте стовпець.

Щоб побачити завершений відсоток у проекті Microsoft:

  1. У формі запису завдань двічі клацніть потрібний стовпець.

Отримання відсотків

Наступний приклад коду демонструє, як отримати відсотки роботи, що стосуються завдань.

 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"TaskPercentageCompletion.mpp");
 4    
 5// Access tasks and display percentage completion
 6auto tasks = project1->get_RootTask()->get_Children();
 7    
 8{
 9    auto tsk1_enumerator = (tasks)->GetEnumerator();
10    decltype(tsk1_enumerator->get_Current()) tsk1;
11    while (tsk1_enumerator->MoveNext() && (tsk1 = tsk1_enumerator->get_Current(), true))
12    {
13        System::Console::WriteLine(tsk1->Get<int32_t>(Tsk::PercentComplete()));
14        System::Console::WriteLine(System::Convert::ToString(tsk1->Get<int32_t>(Tsk::PercentWorkComplete())));
15        System::Console::WriteLine(System::Convert::ToString(tsk1->Get<int32_t>(Tsk::PhysicalPercentComplete())));
16    }
17}

Changing Task Progress

Aspose.Tasks for C++ API supports changing a task’s progress in terms of its percentage completion through the Task class’ SetPercentComplete() method. This method takes an integer argument as input for the percentage work completed.

The following piece of code shows how to change the progress of a task.

1System::SharedPtr<Project> project = System::MakeObject<Project>();
2System::Console::WriteLine(u"Project Calculation mode is Automatic: {0}", System::ObjectExt::Box<bool>(System::ObjectExt::Equals(project->get_CalculationMode(), Aspose::Tasks::CalculationMode::Automatic)));
3    
4System::SharedPtr<Task> task = project->get_RootTask()->get_Children()->Add(u"Task");
5task->Set<Duration>(Tsk::Duration(), project->GetDuration(2));
6task->Set<int32_t>(Tsk::PercentComplete(), 50);
Subscribe to Aspose Product Updates

Get monthly newsletters & offers directly delivered to your mailbox.