How can i set custom values to TimephasedData?

I need to set custom values to TimephasedData of a assignmet, but i can’t do that. Always, the result of TimephasedData from a assignment is the total amount distributed equally in the period. How can i set this values manually, like in this example?


assignment.TimeScaleData(project.StartDate, project.FinishDate)[0].Value = “PT100H0M0S”;
assignment.TimeScaleData(project.StartDate, project.FinishDate)[1].Value = “PT50H0M0S”;
assignment.TimeScaleData(project.StartDate, project.FinishDate)[2].Value = “PT50H0M0S”;
assignment.TimeScaleData(project.StartDate, project.FinishDate)[3].Value = “PT300H0M0S”;


Hi Augusto,


Thank you for contacting Aspose support team.

You may please use following sample code to set custom values to TimephasedData and let us know the feedback.


static public void Task_T2()
{
Project project = new Project();
project.StartDate = new DateTime(2014, 9, 24);
Resource person1 = project.AddResource(“Person 1”);
Aspose.Tasks.Task task1 = new Aspose.Tasks.Task(“Task 1”);
task1.Type = TaskType.FixedDuration;
task1.DurationFormat = TimeUnitType.Day;
ResourceAssignment assn1 = new ResourceAssignment(task1, person1);
assn1.WorkContour = WorkContourType.Contoured;
assn1.TimephasedData = new List();
TimephasedData td = new TimephasedData();
td.Start = new DateTime(2014, 9, 24, 8, 0, 0);
td.Finish = td.Start.AddDays(1);
td.TimephasedDataType = TimephasedDataType.AssignmentRemainingWork;
td.Value = TimeSpanToTDString(TimeSpan.FromHours(0));
assn1.TimephasedData.Add(td);

td = new TimephasedData();
td.Start = new DateTime(2014, 9, 25, 8, 0, 0);
td.Finish = td.Start.AddDays(1);
td.TimephasedDataType = TimephasedDataType.AssignmentRemainingWork;
td.Value = TimeSpanToTDString(TimeSpan.FromHours(7));
assn1.TimephasedData.Add(td);

td = new TimephasedData();
td.Start = new DateTime(2014, 9, 26, 8, 0, 0);
td.Finish = td.Start.AddDays(1);
td.TimephasedDataType = TimephasedDataType.AssignmentRemainingWork;
td.Value = TimeSpanToTDString(TimeSpan.FromHours(4));

assn1.TimephasedData.Add(td);

td = new TimephasedData();
td.Start = new DateTime(2014, 9, 29, 8, 0, 0);
td.Finish = td.Start.AddDays(1);
td.TimephasedDataType = TimephasedDataType.AssignmentRemainingWork;
td.Value = TimeSpanToTDString(TimeSpan.FromHours(0));
assn1.TimephasedData.Add(td);

td = new TimephasedData();
td.Start = new DateTime(2014, 9, 30, 8, 0, 0);
td.Finish = td.Start.AddHours(9);
td.TimephasedDataType = TimephasedDataType.AssignmentRemainingWork;
td.Value = TimeSpanToTDString(TimeSpan.FromHours(6));
assn1.TimephasedData.Add(td);

td = new TimephasedData();
td.Start = new DateTime(2014, 10, 1, 8, 0, 0);
td.Finish = td.Start.AddHours(9);
td.TimephasedDataType = TimephasedDataType.AssignmentRemainingWork;
td.Value = TimeSpanToTDString(TimeSpan.FromHours(0));
assn1.TimephasedData.Add(td);

assn1.Work = new TimeSpan(17, 0, 0);
task1.Start = project.StartDate;
task1.Finish = td.Finish;
task1.Duration = project.Calendar.GetWorkingHours(task1.Start, task1.Finish).WorkingHours;

project.RootTask.Children.Add(task1);
project.ResourceAssignments.Add(assn1);

project.CalcResourceAssignmentIds();
project.CalcResourceAssignmentUids();
project.CalcTaskIds();
project.CalcTaskUids();
project.UpdateReferences();

project.Save(“saved.xml”, SaveFileFormat.XML);
}
static private string TimeSpanToTDString(TimeSpan timeSpan)
{
return string.Format(“PT{0}H{1}M{2}S)”, timeSpan.Hours, timeSpan.Minutes, timeSpan.Seconds);
}