リソースカレンダーを使用します
Contents
[
Hide
Show
]リソースクラスは、リソースのカレンダーを設定または取得するために使用されるカレンダープロパティを公開します。このプロパティは、Aspose.Tasks.calendarオブジェクトを受け入れて返します。
リソースカレンダーの操作
Microsoftプロジェクトのリソースのカレンダーを定義するには:
- リソースシートで、目的のリソースをダブルクリックします。
- 作業時間の変更ボタンをクリックします。
Aspose.Tasks を使用してリソースカレンダーを設定
次のコード例では、標準カレンダーとリソースを作成し、カレンダーをリソースに割り当てます。
1// Create project instance and add resource
2System::SharedPtr<Project> project = System::MakeObject<Project>();
3System::SharedPtr<Resource> res = project->get_Resources()->Add(u"Resource1");
4
5// Add standard calendar and assign to resource
6System::SharedPtr<Aspose::Tasks::Calendar> cal = project->get_Calendars()->Add(u"Resource1");
7res->Set<System::SharedPtr<Calendar>>(Rsc::Calendar(), cal);
**Getting Resource Calendar using Aspose.Tasks **
The code example given below demonstrates how to get resource calendars by traversing a project’s resources.
1// Create project instance
2System::SharedPtr<Project> project1 = System::MakeObject<Project>(dataDir + u"ResourceCalendar.mpp");
3
4// Display base calendar name for all resources
5
6{
7 auto res_enumerator = (project1->get_Resources())->GetEnumerator();
8 decltype(res_enumerator->get_Current()) res;
9 while (res_enumerator->MoveNext() && (res = res_enumerator->get_Current(), true))
10 {
11 if (res->Get<System::String>(Rsc::Name()) != nullptr)
12 {
13 System::Console::WriteLine(res->Get<System::SharedPtr<Calendar>>(Rsc::Calendar())->get_BaseCalendar()->get_Name());
14 }
15 }
16}