Timephased Data Generation for Different Work Contours
When managing project schedules, it is often necessary to analyze how work is distributed over time for different resource assignments. Aspose.Tasks for .NET makes this possible by generating timephased data for resource assignments based on different work contours. This enables developers to simulate, track, and report resource usage more accurately.
Timephased Data Generation for Work Contours
A work contour defines how work is allocated across the duration of a task. Aspose.Tasks for .NET allows you to apply various contours (such as Flat, Back Loaded, Front Loaded, Turtle, Bell, etc.) and generate corresponding timephased data.The generated data is retrieved using the TimeScaleData
method, which requires the project start and finish dates as input parameters.
Code Example
The following example assigns different types of work contours to a resource and retrieves its timephased data for analysis:
1Project project = new Project("New Project.mpp");
2
3// Get the first task of the Project
4Task task = project.RootTask.Children.GetById(1);
5
6// Get the First Resource Assignment of the Project
7ResourceAssignment firstRA = project.ResourceAssignments.ToList()[0];
8
9// Flat contour is default contour
10Console.WriteLine("Flat contour");
11
12var tdList = task.GetTimephasedData(project.Get(Prj.StartDate), project.Get(Prj.FinishDate));
13foreach (TimephasedData td in tdList)
14{
15 Console.WriteLine(td.Start.ToShortDateString() + " " + td.Value);
16}
17
18// Change contour
19firstRA.Set(Asn.WorkContour, WorkContourType.Turtle);
20Console.WriteLine("Turtle contour");
21tdList = task.GetTimephasedData(project.Get(Prj.StartDate), project.Get(Prj.FinishDate));
22foreach (TimephasedData td in tdList)
23{
24 Console.WriteLine(td.Start.ToShortDateString() + " " + td.Value);
25}
26
27// Change contour
28firstRA.Set(Asn.WorkContour, WorkContourType.BackLoaded);
29Console.WriteLine("BackLoaded contour");
30tdList = task.GetTimephasedData(project.Get(Prj.StartDate), project.Get(Prj.FinishDate));
31foreach (TimephasedData td in tdList)
32{
33 Console.WriteLine(td.Start.ToShortDateString() + " " + td.Value);
34}
35
36// Change contour
37firstRA.Set(Asn.WorkContour, WorkContourType.FrontLoaded);
38Console.WriteLine("FrontLoaded contour");
39tdList = task.GetTimephasedData(project.Get(Prj.StartDate), project.Get(Prj.FinishDate));
40foreach (TimephasedData td in tdList)
41{
42 Console.WriteLine(td.Start.ToShortDateString() + " " + td.Value);
43}
44
45// Change contour
46firstRA.Set(Asn.WorkContour, WorkContourType.Bell);
47Console.WriteLine("Bell contour");
48tdList = task.GetTimephasedData(project.Get(Prj.StartDate), project.Get(Prj.FinishDate));
49foreach (TimephasedData td in tdList)
50{
51 Console.WriteLine(td.Start.ToShortDateString() + " " + td.Value);
52}
53
54// Change contour
55firstRA.Set(Asn.WorkContour, WorkContourType.EarlyPeak);
56Console.WriteLine("EarlyPeak contour");
57tdList = task.GetTimephasedData(project.Get(Prj.StartDate), project.Get(Prj.FinishDate));
58foreach (TimephasedData td in tdList)
59{
60 Console.WriteLine(td.Start.ToShortDateString() + " " + td.Value);
61}
62
63// Change contour
64firstRA.Set(Asn.WorkContour, WorkContourType.LatePeak);
65Console.WriteLine("LatePeak contour");
66tdList = task.GetTimephasedData(project.Get(Prj.StartDate), project.Get(Prj.FinishDate));
67foreach (TimephasedData td in tdList)
68{
69 Console.WriteLine(td.Start.ToShortDateString() + " " + td.Value);
70}
71
72// Change contour
73firstRA.Set(Asn.WorkContour, WorkContourType.DoublePeak);
74Console.WriteLine("DoublePeak contour");
75tdList = task.GetTimephasedData(project.Get(Prj.StartDate), project.Get(Prj.FinishDate));
76foreach (TimephasedData td in tdList)
77{
78 Console.WriteLine(td.Start.ToShortDateString() + " " + td.Value);
79}
In this code, each work contour is applied to the resource assignment, and the generated timephased data is displayed. This makes it easy to see how work is spread across the assignment duration depending on the contour type.
FAQ
Q: What is a work contour in Microsoft Project?
- A work contour defines how the effort of a resource is distributed over the duration of a task. For example, Flat applies uniform work, while Bell distributes effort more heavily in the middle.
Q: How does Aspose.Tasks generate timephased data?
- It uses the
TimeScaleData
method, which takes project start and finish dates to calculate work distribution for each assignment.
Q: Can I generate timephased data for multiple assignments at once?
- Yes. You can iterate through all resource assignments in a project and generate timephased data for each.
Q: Do I need Microsoft Project installed to generate timephased data?
- No. Aspose.Tasks works independently and does not require Microsoft Project to read, calculate, or export timephased data.
Conclusion
In this article, we explored how to generate timephased data for different work contours of resource assignments using Aspose.Tasks for .NET. By applying various contours and retrieving corresponding data, developers can better analyze resource workloads, improve project forecasting, and generate detailed usage reports programmatically.