We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Dates clarification

We are planning to use Aspose, and currently we are using trial version.

But using the trial version we are unable access project dates(start and finish) property to get resource timephased data.

Also we are unable to access resource dates property.
Please suggest the solution.

Waiting for your response.

Thanks in advance

Hi Shivi,


Thank you for writing to Aspose support team.

Aspose.Tasks provides rich features to read/write and manipulate project files. Following are few sample codes which can be used to retrieve the required information.

public static void Email_714619_ProjectInfo()<o:p></o:p>

{

Project project = new Project("file.mpp");

if (project.Get(Prj.ScheduleFromStart))

Console.WriteLine("Project Finish Date : " + project.Get(Prj.StartDate).ToShortDateString());

else

Console.WriteLine("Project Finish Date : " + project.Get(Prj.FinishDate).ToShortDateString());

Console.WriteLine(project.Get(Prj.Author));

Console.WriteLine(project.Get(Prj.LastAuthor));

Console.WriteLine(project.Get(Prj.Revision));

Console.WriteLine(project.Get(Prj.Keywords));

Console.WriteLine(project.Get(Prj.Comments));

}

public static void Email_714619_TimePhasedData()

{

Project project = new Project("Template2010.mpp");

project.Set(Prj.StartDate, new DateTime(2013, 10, 30, 9, 0, 0));

project.Set(Prj.NewTasksAreManual, false);

Task task = project.RootTask.Children.Add("Task");

Resource rsc = project.Resources.Add("Rsc");

rsc.Set(Rsc.StandardRate, 10);

rsc.Set(Rsc.OvertimeRate, 15);

// 6 days duration

task.Set(Tsk.Duration, project.GetDuration(6));

ResourceAssignment assn = project.ResourceAssignments.Add(task, rsc);

assn.Set(Asn.Stop, DateTime.MinValue);

assn.Set(Asn.Resume, DateTime.MinValue);

// backloaded contour increases task duration from 6 to 10 days

assn.Set(Asn.WorkContour, WorkContourType.BackLoaded);

project.SetBaseline(BaselineType.Baseline);

task.Set(Tsk.PercentComplete, 50);

List<TimephasedData> td = assn.GetTimephasedData(assn.Get(Asn.Start), assn.Get(Asn.Finish), TimephasedDataType.AssignmentRemainingWork).ToList();

Console.WriteLine(td.Count);

Console.WriteLine(td[0].Value);

Console.WriteLine(td[1].Value);

Console.WriteLine(td[2].Value);

Console.WriteLine(td[3].Value);

Console.WriteLine(td[4].Value);

Console.WriteLine(td[5].Value);

Console.WriteLine(td[6].Value);

}

As you are using trial version, you may get different dates than the actual dates in the project file. It is trial version limitation and you may get temporary license for 30 days to test all the features without any limitations. Please visit How to get temporary license section to get this license.

You may also visit the documentation section for more samples on Aspose.Tasks API.

Should you have any other query in this regard, please feel free to write us back.

Hello ,


Thanks for your reply,

I tried doing it in the same way as suggested by you but still i am having problem in getting timephased data.
The start and end date is comming as null.

I have attached my sample solution, please have look and let me know what is missing at my end or what wrong m doing.


Also here is the code sample for quick review:
Imports Aspose

Partial Class TimephasedData
Inherits System.Web.UI.Page


Protected Sub GetTimePhasedData_Click(sender As Object, e As System.EventArgs) Handles GetTimePhasedData.Click
Dim project As New Aspose.Tasks.Project(HttpContext.Current.Server.MapPath(“temp\ProjectTest.MPP”))
Dim task As Aspose.Tasks.Task = project.RootTask.Children.GetByUid(1)
Dim resource As Aspose.Tasks.Resource = project.Resources.GetByUid(1)
Dim TimephasedVal = resource.GetTimephasedData(project.Get(Aspose.Tasks.Prj.StartDate).ToShortDateString(), project.Get(Aspose.Tasks.Prj.FinishDate).ToShortDateString(), Tasks.TimephasedDataType.AssignmentBaselineWork)
End Sub
End Class

Thanks in advance.

Hi Shivi,


Thank you for writing to Aspose support team again.

If we thoroughly investigate the resource in the MPP project file, we can notice that resource does not contain time-phased data for AssignmentBaselineWork. The resource in the sample MPP project contains time phased data of type ResourceBaselineWork and ResourceBaselineCost only. You may please give a try to the following sample code and let us know the feedback.

Project project = new Project(“ProjectTest.mpp”);<o:p></o:p>

Task task = project.RootTask.Children.GetByUid(1);

Resource resource = project.Resources.GetByUid(1);

DateTime start = project.Get(Prj.StartDate);

DateTime finish = project.Get(Prj.FinishDate);

//TimephasedDataCollection TimephasedVal = resource.GetTimephasedData(project.Get(Prj.StartDate), project.Get(Prj.FinishDate), TimephasedDataType.AssignmentBaselineWork);

TimephasedDataCollection ResourceBaselineWorkTimephasedVal = resource.GetTimephasedData(project.Get(Prj.StartDate), project.Get(Prj.FinishDate), TimephasedDataType.ResourceBaselineWork);

TimephasedDataCollection ResourceBaselineCostTimephasedVal = resource.GetTimephasedData(project.Get(Prj.StartDate), project.Get(Prj.FinishDate), TimephasedDataType.ResourceBaselineCost);