完全な計算率
Contents
[
Hide
Show
]Microsoftプロジェクトは、完了したタスクの割合を示しています。パーセンテージは、プロジェクトマネージャーによって手動で追加されるか、アプリケーションによって自動的に計算されます。 C ++のAspose.Tasksは、タスクに関連するいくつかのパーセント計算をサポートしています。
パーセンテージ
TSKクラスは、パーセンテージを計算するために使用される多くのプロパティを公開します。
- パーセントcompleteは、タスクの期間(整数)の完了した割合を表します。
- パーセントワークコムプレテは、タスクの作業(整数)の完了した割合を表します。
- PhysicalPercentCompleteは、プロジェクトマネージャー(整数)が入力した完了した割合を表します。
Microsoftプロジェクトで物理的な割合が完了するのを見るには:
- 挿入メニューから[column]を選択します。
- 列を追加します。
Microsoftプロジェクトで完了した割合を確認するには:
- タスクエントリフォームで、目的の列をダブルクリックします。
パーセンテージを取得
次のコード例は、タスクに関連する作業の割合を取得する方法を示しています。
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);