PercentComplete and PercentWorkComplete

Hi @kashif.iqbal / @alexanderefremov1,

How are you?

After recalculating the PercentComplete and PercentWorkComplete are set to zero.

using System;
using Aspose.Tasks;
using Aspose.Tasks.Saving;

namespace ConsoleApp1
{
class Program
{
static void Main(string[] args)
{
License license = new License();
license.SetLicense(“Aspose.Tasks.lic”);

        Project project = new Project("template.mpp") { CalculationMode = CalculationMode.None };
        project.Set(Prj.StartDate, new DateTime(2018, 1, 1));

        Task tsk1 = project.RootTask.Children.Add("Task - 01");
        Task tsk2 = tsk1.Children.Add("Task - 01.01");
        Task tsk3 = tsk2.Children.Add("Task - 01.01.001");
        tsk3.Set(Tsk.Start, new DateTime(2018, 1, 1, 9, 0, 0));
        tsk3.Set(Tsk.Duration, project.GetDuration(60, TimeUnitType.Day));
        tsk3.Set(Tsk.Type, TaskType.FixedDuration);
        tsk3.Set(Tsk.ConstraintDate, new DateTime(2018, 1, 1, 9, 0, 0));

        tsk3.Set(Tsk.PercentComplete, 10);
        tsk3.Set(Tsk.PercentWorkComplete, 11);
        tsk3.Set(Tsk.PhysicalPercentComplete, 12);

        Console.WriteLine("PercentComplete: " + tsk3.Get(Tsk.PercentComplete));
        Console.WriteLine("PercentWorkComplete: " + tsk3.Get(Tsk.PercentWorkComplete));
        Console.WriteLine("PhysicalPercentComplete: " + tsk3.Get(Tsk.PhysicalPercentComplete));

        Console.WriteLine("---------------------------------------------------");

        project.Recalculate();

        Console.WriteLine("PercentComplete: " + tsk3.Get(Tsk.PercentComplete));
        Console.WriteLine("PercentWorkComplete: " + tsk3.Get(Tsk.PercentWorkComplete));
        Console.WriteLine("PhysicalPercentComplete: " + tsk3.Get(Tsk.PhysicalPercentComplete));

        project.Save(@"output.xml", Aspose.Tasks.Saving.SaveFileFormat.XML);
        project.Save(@"output.mpp", Aspose.Tasks.Saving.SaveFileFormat.MPP);

        Console.ReadKey();
    }

}
}

What am I doing wrong?

Attached: TemplateOutput.zip (45.9 KB)

I really need urgency, in that case.

Tks,

@FabioMartins,

I have tested the sample code shared by you and have been able to observe the issue. An issue with ID TASKSNET-3084 has been created in our issue tracking system to further investigate and resolve the issue. This thread has been linked with the issue so that you may be notified once the issue will be fixed.

Hi, any news?

@FabioMartins,

I have verified the issue status from our issue tracking system and like to share that it has just recently been created in our issue tracking system and is pending for investigation in our issue tracking system. I request for your patience till the time the issue gets resolved.

Hi, any news?

I really need urgency in this case…

@FabioMartins,

I regret to inform that issue is pending for detail investigation. I also like to inform as per our company policy, the first priority for investigation is given to the Paid Support i.e. Enterprise and Priority Support on first come first serve basis. After that the issues from normal support forum are scheduled for investigation on first come first serve basis. I request for your patience. We will share good news with you soon regarding ETA.

@FabioMartins Hello!
In order to get correct values of percent complete/percent work complete after recalculating one must set task’s Duration/ActualDuration and Work/ActualWork values. Please, see comments in the code below

Project project = new Project("template.mpp") { CalculationMode = CalculationMode.None };
project.Set(Prj.StartDate, new DateTime(2018, 1, 1));

Task tsk1 = project.RootTask.Children.Add("Task - 01");
Task tsk2 = tsk1.Children.Add("Task - 01.01");
Task tsk3 = tsk2.Children.Add("Task - 01.01.001");
tsk3.Set(Tsk.Start, new DateTime(2018, 1, 1, 9, 0, 0));
tsk3.Set(Tsk.Duration, project.GetDuration(60, TimeUnitType.Day));
// in order to calculate PercentComplete Tsk.ActualDuration must be set
tsk3.Set(Tsk.ActualDuration, project.GetDuration(6, TimeUnitType.Day));

// in order to calculate PercentWorkComplete Tsk.Work and Tsk.ActualWork must be set
tsk3.Set(Tsk.Work, project.GetDuration(60, TimeUnitType.Day));
// 11% = 6 days * 480 minutes per day + 1% = 228 minutes
tsk3.Set(Tsk.ActualWork, project.GetDuration(TimeSpan.FromMinutes(6 * 480 + 228).TotalMinutes, TimeUnitType.Minute));
tsk3.Set(Tsk.Type, TaskType.FixedDuration);
tsk3.Set(Tsk.ConstraintDate, new DateTime(2018, 1, 1, 9, 0, 0));

tsk3.Set(Tsk.PercentComplete, 10);
tsk3.Set(Tsk.PercentWorkComplete, 11);
tsk3.Set(Tsk.PhysicalPercentComplete, 12);

Console.WriteLine("PercentComplete: " + tsk3.Get(Tsk.PercentComplete));
Console.WriteLine("PercentWorkComplete: " + tsk3.Get(Tsk.PercentWorkComplete));
Console.WriteLine("PhysicalPercentComplete: " + tsk3.Get(Tsk.PhysicalPercentComplete));

Console.WriteLine("---------------------------------------------------");

project.Recalculate();

Console.WriteLine("PercentComplete: " + tsk3.Get(Tsk.PercentComplete));
Console.WriteLine("PercentWorkComplete: " + tsk3.Get(Tsk.PercentWorkComplete));
Console.WriteLine("PhysicalPercentComplete: " + tsk3.Get(Tsk.PhysicalPercentComplete));