更新されたタスクデータをMPPに書き込む方法

Contents
[ Hide Show ]

.NETのAspose.Tasksを使用すると、 タスクを更新し、更新されたデータをMicrosoft Project MPPファイルに書き戻すことができます。

タスクデータの更新

次のコードスニペットは、プロジェクトのタスクデータを更新し、MPPファイルに書き戻す方法を示しています。このアクティビティに関与するステップは次のとおりです。

  1. プロジェクトクラスのインスタンスを作成します。

  2. ソースMPPファイルをロードします。

a Task and add it to the root task.

  1. Update the task parameters such as Deadline, NotesText, etc.

  2. Add additional tasks to the root task.

  3. Save the project.

The following code finds a task’s original and external ID through the cross project.

 1Project project = new Project("New Project.mpp");
 2
 3// Set project start date
 4project.Set(Prj.StartDate, new DateTime(2012, 07, 29, 8, 0, 0));
 5
 6// Add summary task and set its properties
 7Task summary = project.RootTask.Children.Add("Summary task");
 8Task task = summary.Children.Add("First task");
 9task.Set(Tsk.Duration, project.GetDuration(3));
10task.Set(Tsk.Deadline, task.Get(Tsk.Start).AddDays(10));
11task.Set(Tsk.NotesText, "The first task.");
12task.Set(Tsk.DurationFormat, TimeUnitType.MinuteEstimated);
13task.Set(Tsk.ConstraintType, ConstraintType.FinishNoLaterThan);
14task.Set(Tsk.ConstraintDate, task.Get(Tsk.Deadline).AddDays(-1));
15
16
17// Create 10 new sub tasks for summary task
18for (int i = 0; i < 10; i++)
19{
20    Task subTask = summary.Children.Add(string.Format("Task{0}", i + 2));
21    subTask.Set(Tsk.Duration, task.Get(Tsk.Duration).Add(project.GetDuration(i + 1)));
22    subTask.Set(Tsk.DurationFormat, TimeUnitType.Day);
23    subTask.Set(Tsk.Deadline, task.Get(Tsk.Deadline).AddDays(i + 1));
24}
25
26project.Save("UpdateTaskData_out.mpp", SaveFileFormat.MPP);
Subscribe to Aspose Product Updates

Get monthly newsletters & offers directly delivered to your mailbox.