リソース割り当ての作成
Contents
[
Hide
Show
]タスクとリソースをリンクするリソース割り当て。この記事では、JavaのAspose.Tasksを使用して作成する方法について説明します。
リソース割り当ての作成
リソースクラスは、デフォルトのコンストラクターを使用するか、タスクとリソースを渡すことにより、リソース割り当てを作成する2つの異なる方法を公開します。
プログラミングサンプル:ResourceAsSignmentを直接プロジェクトに追加 次のコードサンプルは、オブジェクトをインスタンス化することなく、プロジェクトにリソース割り当てを追加します。
1// For complete examples and data files, please go to https://github.com/aspose-tasks/Aspose.Tasks-for-Java
2// The path to the documents directory.
3String dataDir = Utils.getDataDir(CreateResourceAssignments.class);
4Project project = new Project();
5Task task = project.getRootTask().getChildren().add("Task");
6
7Resource rsc = project.getResources().add("Rsc");
8
9ResourceAssignment assn = project.getResourceAssignments().add(task, rsc);
Read Shared Resource Assignments
The shared assignments are assignments of the specific resource to tasks in other projects when the current project uses a resource from a resource pool. Using Aspose.Tasks , the shared assignments can be read from MPP and taken into account when Peak\Overallocated properties are calculated. The following code example demonstrates how to read shared resource assignments.
1// suppose "test.mpp" contains resource from resource pool and assignments from other projects
2Project project = new Project(dataDir + "test.mpp");
3Resource resource = project.getResources().getByUid(1);
4// Units are calculated using assignments from other projects.
5Double units = resource.get(Rsc.PEAK_UNITS);