Can't get percent complete export working

Last post 01-10-2012, 8:11 AM by aspose.notifier. 5 replies.
Sort Posts: Previous Next
  •  10-19-2011, 1:22 PM 336628

    Can't get percent complete export working

    Attachment: Present (inaccessible)
    I am creating a project XML file from scratch, and I'm having trouble setting the completion percentage on my tasks. I'm not sure the real differences between "PercentComplete", "PercentWorkComplete", and "PhysicalPercentComplete", but I just want to change whatever one shows up in the "Task Information" popup in Microsoft Project (screenshot included).

    I tried setting the percent complete by using task.PercentComplete, which didn't seem to work. So I set all three like so:

    task.PercentComplete = 90;
    task.PercentWorkComplete = 90;
    task.PhysicalPercentComplete = 90;

    When I view the project xml file as plain text, i see "90" in multiple places that look correct, but when I open it in MS Project, the percent complete in the Task Information popup is still 0%.

    Can anyone provide some insight as to why this might be happening? Thanks in advance.
     
  •  10-21-2011, 6:01 AM 337328 in reply to 336628

    Re: Can't get percent complete export working

    Hi Brian,

    You need to assign resources to the task to change percent complete as you can see in the following example.

    static void Main(string[] args)

    {

        License license = new License();

        license.SetLicense(@"Aspose.Total.Product.Family.lic");

     

        Project project = new Project();

        project.StartDate = new DateTime(2010, 12, 15, 8, 0, 0);

        project.FinishDate = new DateTime(2011, 12, 31, 17, 0, 0);

        project.MinutesPerDay = 8 * 60;

        project.MinutesPerWeek = 5 * 8 * 60;

        project.DaysPerMonth = 20;

        project.DefaultStartTime = new DateTime(1, 1, 1, 8, 0, 0);

        project.DefaultFinishTime = new DateTime(1, 1, 2, 17, 0, 0);

        project.DurationFormat = TimeUnitType.Hour;

        project.WorkFormat = TimeUnitType.Hour;

     

        Calendar standard = new Calendar("Standard");

        standard = Calendar.MakeStandardCalendar(standard);

        project.Calendars.Add(standard);

        project.Calendar = standard;

     

        Calendar employeeCalendar = new Calendar("Employee");

        employeeCalendar.BaseCalendar = standard;

        project.Calendars.Add(employeeCalendar);

     

        //Create root task.

        Task root = new Task();

        root.Uid = project.NextTaskUid;

        root.Type = TaskType.FixedUnits;

        project.RootTask = root;

     

        //Create a new completed task.

        Task task = new Task("New task.");

        task.Uid = project.NextTaskUid;

        task.Type = TaskType.FixedUnits;

        task.Start = new DateTime(2010, 12, 15, 8, 0, 0);

        task.Duration = new TimeSpan(80, 0, 0);

        task.Finish = standard.GetFinishDateByStartAndWork(task.Start, task.Duration);

        task.DurationFormat = TimeUnitType.Day;

        task.Work = task.Duration;

        task.RegularWork = task.Work;

     

        task.ActualStart = task.Start;

        task.ActualFinish = task.Finish;

        task.ActualDuration = task.Duration;

        task.ActualWork = task.Work;

        task.PercentComplete = 90;

     

        project.RootTask.Children.Add(task);

     

        //Create a root resource.

        Resource res = new Resource();

        res.Uid = project.NextResourceUid;

        project.Resources.Add(res);

     

        //Create a new resource.

        Resource resource = new Resource();

        resource.Name = "Employee";

        resource.Type = ResourceType.Work;

        resource.Work = new TimeSpan(72, 0, 0);

        resource.RegularWork = resource.Work;

        resource.ActualWork = resource.Work;

        resource.Uid = project.NextResourceUid;

        resource.Calendar = employeeCalendar;

        project.Resources.Add(resource);

     

        //Create a resource assignment.

        ResourceAssignment resourceAssignment = new ResourceAssignment();

        resourceAssignment.Uid = project.NextResourceAssignmentUid;

        resourceAssignment.Task = task;

        resourceAssignment.Resource = resource;

        resourceAssignment.ActualWork = resource.Work;

        resourceAssignment.Work = resource.Work;

        resourceAssignment.RegularWork = resource.Work;

        resourceAssignment.Start = task.Start;

        resourceAssignment.Finish = task.Finish;

        resourceAssignment.ActualStart = resourceAssignment.Start;

        resourceAssignment.ActualFinish = resourceAssignment.Finish;

        resourceAssignment.Units = 1;

        project.ResourceAssignments.Add(resourceAssignment);

     

        project.CalcCalendarUids();

        project.CalcTaskIds();

        project.CalcResourceIds();

        project.CalcResourceAssignmentIds();

     

        ProjectWriter writer = new ProjectWriter();

        writer.Write(project, "Project1.xml", TasksDataFormat.XML);

     

    }

     

     

    Please feel free to contact us in case you have further comments or questions.

    Best Regards,


    Muhammad Ijaz
    Support Developer, Aspose Sialkot Team
    Contact Us
    http://www.aspose.com
    Your File Format Experts

    Keep in touch! We're on Twitter and Facebook
     
  •  11-01-2011, 9:24 AM 339397 in reply to 337328

    Re: Can't get percent complete export working

    Thanks for the response. Why would I need to add a resource in order to change the completion percentage though? If I go straight to project, I can double click on a task, change the percent complete, and it's done. No need to create/assign resources there.
     
  •  11-03-2011, 11:38 AM 339980 in reply to 339397

    Re: Can't get percent complete export working

    Hi,

    That might be due to some internal dependencies. The concerned team will provide you more details on this shortly.

    Many Thanks

    Muhammad Sabir
    Support Assistant Manager
    Aspose Sialkot Team
    http://www.aspose.com
    Aspose - Your File Format Experts

    Keep in touch! We're on Twitter and Facebook
     
  •  11-03-2011, 1:52 PM 340022 in reply to 339397

    Re: Can't get percent complete export working

    Hi Brian,

    You can use the following code to change the percentage of a task without a resource or create a new task with percent complete value.

    License license = new License();

    license.SetLicense(@"Aspose.Total.Product.Family.lic");

     

    Project project = new Project();

    project.StartDate = new DateTime(2010, 12, 15, 8, 0, 0);

    project.FinishDate = new DateTime(2011, 12, 31, 17, 0, 0);

    project.MinutesPerDay = 8 * 60;

    project.MinutesPerWeek = 5 * 8 * 60;

    project.DaysPerMonth = 20;

    project.DefaultStartTime = new DateTime(1, 1, 1, 8, 0, 0);

    project.DefaultFinishTime = new DateTime(1, 1, 2, 17, 0, 0);

    project.DurationFormat = TimeUnitType.Hour;

    project.WorkFormat = TimeUnitType.Hour;

     

    Calendar standard = new Calendar("Standard");

    standard = Calendar.MakeStandardCalendar(standard);

    project.Calendars.Add(standard);

    project.Calendar = standard;

     

    //Create root task.

    Task root = new Task();

    root.Uid = project.NextTaskUid;

    root.Type = TaskType.FixedUnits;

    project.RootTask = root;

     

    //Create a new 90% completed task.

    Task task = new Task("New task.");

    task.Uid = project.NextTaskUid;

    task.Type = TaskType.FixedUnits;

    task.Start = new DateTime(2010, 12, 15, 8, 0, 0);

    task.Duration = new TimeSpan(80, 0, 0);

    task.Finish = standard.GetFinishDateByStartAndWork(task.Start, task.Duration);

    task.DurationFormat = TimeUnitType.Day;

    task.Work = task.Duration;

    task.RegularWork = task.Work;

     

    task.ActualStart = task.Start;

    task.ActualFinish = task.Finish;

    task.ActualDuration = task.Duration;

    task.ActualWork = new TimeSpan(72, 0, 0); ;

     

    project.RootTask.Children.Add(task);

     

    project.CalcCalendarUids();

    project.CalcTaskIds();

     

    ProjectWriter writer = new ProjectWriter();

    writer.Write(project, "Project1.xml", TasksDataFormat.XML);

     

     A new issue to add method to change task progress has also been logged into our issue tracking system as TASKS-22450. We will keep you updated on this issue in this thread.

    Please feel free to contact us in case you have further comments or questions.

    Best Regards,


    Muhammad Ijaz
    Support Developer, Aspose Sialkot Team
    Contact Us
    http://www.aspose.com
    Your File Format Experts

    Keep in touch! We're on Twitter and Facebook
     
  •  01-10-2012, 8:11 AM 354140 in reply to 336628

    Re: Can't get percent complete export working

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


    This message was posted using Notification2Forum from Downloads module by aspose.notifier.
     
View as RSS news feed in XML