Hello,
Facing an issue with getting DurationText from MPP file. I have attached a sample MPP file here and trying to get the DurationText like “5 hrs, 10 mins, etc.” as defined in sample MPP file. Here is the code I have used:
Project project = new Project(filePath);
TaskUtils.Apply(project.RootTask, projectTasksData, 0);
for (int i = 2; i < projectTasksData.Tasks.Count; i++)
{
Aspose.Tasks.Task currentTask = projectTasksData.Tasks[i];
string duration = currentTask.Get(Tsk.DurationText); //here is the issue, always return null/blank
// I was expecting string like 5 hrs, 10 mins, etc. from above line
}
Here is my sample file:
test.zip (37.2 KB)
@srinudhulipalla,
I have observed your comments. Can you please try to use Aspose.Task latest version 19.3 and if there is still an issue than please share complete code snippet. The code snippet you have shared includes some undeclared variables so would you please share SSCCE code reproducing the issue so that we may try to reproduce and investigate it in our environment.
Hi,
I’m on latest version and still have the same issue. Here is the code and I have already attached the test.mpp in my original post.
string filePath = “C:\temp\test.mpp”;
Project project = new Project(filePath);
ChildTasksCollector projectTasksData = new ChildTasksCollector();
TaskUtils.Apply(project.RootTask, projectTasksData, 0);
for (int i = 2; i < projectTasksData.Tasks.Count; i++)
{
Aspose.Tasks.Task currentTask = projectTasksData.Tasks[i];
string duration = currentTask.Get(Tsk.DurationText); //here is the issue, always return null/blank
// I was expecting string like 5 hrs, 10 mins, etc. from above line
}
@srinudhulipalla,
I suggest you to please try using following alternate in your sample example.
currentTask.Get(Tsk.Duration).ToString();
@mudassir.fayyaz
Nope, that wouldn’t work since Duration is a TimeStamp object and when you use .ToString() it gives the TimeStamp’s time in String format and the same was noticed when I test the proposed code.
Example, in my sample MPP file Task11 and Task12 are configured as 5 hrs and 10 mins, but the .ToString() result gives like 0.62 days and 0.02 days
Will Aspse.Tasks gives the exact DurationText which is in Duration column of MPP? If not, is there any workaround for this?
@srinudhulipalla,
Please observe the following image and you can observe the time being extracted in hours for Task 11. I have used latest Aspose.Task for .NET 19.3. Can you please try using the specified version.