Timephased Data Generation for Different Work Contours

Timephased Data Generation for Different Work Contours

Aspose.Tasks for .NET provides the facility to generate timephased data for different work contours of an assigned resource.The generated data is obtained using TimeScaleData which takes the project start and finish dates as input parameters.

The following piece of code assigns different types of work contours to an assigned resource and displays its timephased data.

 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}
Subscribe to Aspose Product Updates

Get monthly newsletters & offers directly delivered to your mailbox.