# Get TimePhasedData for task in timescale Hour

Hi,

We need your help for sure!

We need to get the hourly rate of work.See the example in the attachment “Print-MPP.jpg”
how do we get for example the work value 1.07h of hour 13?

The print is in Portuguese language!

Print-MPP.jpg (85.9 KB)

As you may have noticed, ResourceAssignment.TimephasedData contains timephased data split by daily intervals.
You can calculate values for the given interval by dividing work value of daily TimephasedData by number of intervals.

For example, in simple cases the following code can be used:

``````ResourceAssignment ra = ... // get resource assignment
var calendar = ra.Resource.Get(Rsc.Calendar);
var td = ra.TimephasedData[0]; // get timephased data for the specific day.

// we are going to calculate work for interval 13-14 h.
var intervalStart = td.Start.Date + new TimeSpan(13, 0, 0);
var intervalFinish = td.Start.Date + new TimeSpan(14, 0, 0);

var tdDuration = calendar.GetWorkingHours(td.Start, td.Finish).WorkingHours;
var tdLoad = td.ValueToDuration.TotalSeconds / tdDuration.TotalSeconds;

var intervalDuration = calendar.GetWorkingHours(intervalStart, intervalFinish).WorkingHours;
var intervalWork = TimeSpan.FromSeconds(tdLoad * intervalDuration.TotalSeconds);

Console.WriteLine("Work for interval 13-14: {0}", intervalWork);
``````
1 Like

Hi @vasiliysinitsyn,

Taks for your help! We need for one more help.

I have a schedule task as shown in image 1 (My schedule is in Portuguese)
image.png (26.8 KB)

For the day 04/08/2022, the distribution of work per hour is arranged according to image 2 (My work schedule goes from 09:00 to 12:00 and 13:00 to 17:00).
image.png (15.7 KB)

When executing the GetTimephasedData function for the ResourceAssignment passing Aspose.Tasks.Asn.Start, Aspose.Tasks.Asn.Finish and Aspose.Tasks.TimephasedDataType.AssignmentWork as parameters, I get in the returned list a timephased record for 08/04 /2022 according to image below
image.png (38.8 KB)

Through the code below, I can’t get the distribution of work as shown in MS Project. The difference is that I use the ResourceAssignment TimephasedData of type AssignmentWork from image 3. For all intervals, including 17-18, the algorithm below calculates 1.43 hours. I want to retrieve 4 hours for the range 17-18 and 1.07 for the other ranges, as shown in image below.
image.png (26.8 KB)

``````    ResourceAssignment ra = ... // get resource assignment
var calendar = ra.Resource.Get(Rsc.Calendar);
var td = ra.TimephasedData[0]; // get timephased data for the specific day.

// we are going to calculate work for interval 17-18 h.
var intervalStart = td.Start.Date + new TimeSpan(17, 0, 0);
var intervalFinish = td.Start.Date + new TimeSpan(18, 0, 0);

var tdDuration = calendar.GetWorkingHours(td.Start, td.Finish).WorkingHours;
var tdLoad = td.ValueToDuration.TotalSeconds / tdDuration.TotalSeconds;

var intervalDuration = calendar.GetWorkingHours(intervalStart, intervalFinish).WorkingHours;
var intervalWork = TimeSpan.FromSeconds(tdLoad * intervalDuration.TotalSeconds);

Console.WriteLine("Work for interval 17-18: {0}", intervalWork);
``````

If necessary, I can attach the MPP file and indicate the task where the problem is.

@DinoPortoCarneiro,
could you attach the sample MPP file please?

@vasiliysinitsyn,

Attached is the mpp file.
Thanks a lot!

Project Test 2022.zip (250.7 KB)

@DinoPortoCarneiro,
thank you for the file.

Yes, I see that the considered assignment has 4h work in 17-18 h period,
and in TimephasedData all work in the given day is summed and resulting
timephased data item is
{ Start: 08.04.2022 9:00:00, Finish: 08.04.2022 18:00:00, Value: PT11H28M0S }.

My proposed solution only works in simple cases where work contour is “flat”, i.e. work load is constant all day and thus it doesn’t work for this assignment.

Looks like we need to change our API either by improving TimephasedData generation for these cases (in this case there should be two TDs:
{ Start: 08.04.2022 9:00:00, Finish: 08.04.2022 17:00:00, Value: PT8H28M0S }
{ Start: 08.04.2022 17:00:00, Finish: 08.04.2022 18:00:00, Value: PT4H0M0S }) or by adding method which calculates work for the specified date time interval.

A ticket with ID TASKSNET-10629 has been created to further fix the issue. This thread has been linked with the issue so that you may be notified once the issue will be fixed.

We use ASPONE.TASK offline ( Aspose.Tasks for .NET) . When the fix is ​​done, will a new version of aspose be available for us to use? Where can we download this new version with the fix?

Thank you for your energy in helping us!

Please review our free support policies.

No estimations on when a fix can or will be delivered will be given at any point. If an estimated date is supplied, then this cannot be guaranteed and should not be relied upon for internal planning.

As a rough estimate, the fix will not be available before version 22.10.

You will be notified when the version with the fix will be available. You will be able to download it via nuget or using url Aspose.Tasks for .NET.

The issues you have found earlier (filed as TASKSNET-10629) have been fixed in this update.