Sign In  Sign Up Live-Chat

New Aspose.Tasks with MS Project 2007 MPP format support available for public testing

Last post 08-25-2009, 3:59 PM by MPMM. 75 replies.
Page 1 of 6 (76 items)   1 2 3 4 5 Next > ... Last »
Sort Posts: Previous Next
  •  02-02-2009, 1:43 PM 162991

    New Aspose.Tasks with MS Project 2007 MPP format support available for public testing

    Attachment: Present (inaccessible)

    Working with new version of Aspose.Tasks

     

    Aspose.Tasks now based on MPP and XML formats (instead of MPX as previous releases) and as a result doesn’t have a lot of limitations brought by old and obsolete MPX format. It supports most of features and properties of MPP/XML files.

     

    Public API of Aspose.Tasks was changed to make it simpler and more convenient for managing projects.

     

    These MS Project formats are supported:

    • MS Project 2003 MPP binary format (read-only).
    • MS Project 2007 MPP binary format (read-only).
    • MS Project XML format (read/write).

     

    Simple Programmers Guide

    Opening Files

     

    This example shows how to open projects in MPP and XML formats:

     

    [C#]

     

    ProjectReader reader = new ProjectReader();

    Project project = reader.Read(new FileStream("project.mpp", FileMode.Open));

     

    ProjectReader reader = new ProjectReader();

    Project project = reader.Read(new FileStream("project.xml", FileMode.Open));

     

    [VB]

     

    Dim reader As ProjectReader = New ProjectReader()

    Dim project As Project = reader.Read(New FileStream("project.mpp", FileMode.Open))

     

    Dim reader As ProjectReader = New ProjectReader()

    Dim project As Project = reader.Read(New FileStream("project.xml", FileMode.Open))

     

    Saving project in XML format

     

    In this example we will save project to a file in XML format:

     

    [C#]

     

    ProjectWriter writer = new ProjectWriter();

    writer.Write(project, new FileStream("new_prj.xml", FileMode.Create, FileAccess.Write), TasksDataFormat.XML);

     

    [VB]

     

    Dim writer As ProjectWriter = New ProjectWriter()

    writer.Write(project,New FileStream("new_prj.xml",FileMode.Create,FileAccess.Write),TasksDataFormat.XML)

     

    Creating simple project from scratch

     

    This example shows full process of creating project with calendar, tasks and resources:

     

    // Create new empty project

    Project project = new Project();

     

    // Create calendars and add it to our project

    Calendar cal1 = Calendar.MakeStandardCalendar();

    cal1.Uid = 1;

    cal1.Name = "Cal1";

    Calendar cal2 = Calendar.MakeStandardCalendar();

    cal2.Uid = 2;

    cal2.Name = "Cal2";

    project.Calendars.Add(cal1);

    project.Calendars.Add(cal2);

     

    // Create 5 tasks

    Task task1 = new Task("task1");

    Task task2 = new Task("task2");

    Task task3 = new Task("task3");

    Task task4 = new Task("task4");

    Task task5 = new Task("task5");

     

    // Add first task as Root all other

    // tasks as it’s children tasks

    project.RootTask = task1;

    task1.Children.Add(task2);

    task1.Children.Add(task4);

    task1.Children.Add(task5);

    task2.Children.Add(task3);

     

    // Tasks 1 and 2 will use calendar “Cal1”

    task1.Calendar = cal1;

    task2.Calendar = cal1;

     

    // Tasks 3 and 5 will use calendar “Cal2”

    task3.Calendar = cal2;

    task5.Calendar = cal2;

     

    // Task 5 will be started after the finish of Task 4

    project.TaskLinks.Add(new TaskLink(task4, task5, TaskLinkType.FinishToStart));

     

    // Create 2 resources and also add it to the project

    Resource res1 = new Resource("resource1");

    res1.Uid = 1;

    Resource res2 = new Resource("resource2");

    res2.Uid = 2;

    project.Resources.Add(res1);

    project.Resources.Add(res2);

     

    // Resource can use own customized calendars

    res1.Calendar = cal2;

    res2.Calendar = cal1;

     

    // Now assign resources to tasks

    project.ResourceAssignments.Add(new ResourceAssignment(task2, res1));

    project.ResourceAssignments.Add(new ResourceAssignment(task4, res2));

    project.ResourceAssignments.Add(new ResourceAssignment(task3, res1));

     

    // IDs and UIDs should be recalculated

    // after we finished project managing

    project.CalcTaskIds();

    project.CalcTaskUids();

    project.CalcResourceIds();

    project.CalcResourceUids();

    project.CalcResourceAssignmentIds();

    project.CalcResourceAssignmentUids();

     

    // Now we can write created project to a file

    // as shown in the previous example

     


    Writing extended attributes to XML project

     

    There 2 parts of each extended attribute should be added to a project ExtendedAttributeDefinition and ExtendedAttribute.

     

    // Read XML project

    ProjectReader reader = new ProjectReader();

    Project project = reader.Read(new FileStream("_3.xml", FileMode.Open));

     

    ArrayList eads = project.ExtendedAttributes;

    if (eads == null)

    {

        eads = new ArrayList();

        project.ExtendedAttributes = eads;

    }

     

    // Create extended attribute definition

    ExtendedAttributeDefinition ead = new ExtendedAttributeDefinition();

    ead.FieldId = ((int)ExtendedAttributeTask.Start7).ToString();

    ead.FieldName = "Start7";

    eads.Add(ead);

     

    // Get task with OutlineNumber 1.4

    Task task_1_4 = (Task)((Task)project.RootTask.Children[0]).Children[3];

     

    // Create Start7 field

    ArrayList eas = task_1_4.ExtendedAttribute;

    if (eas == null)

    {

        eas = new ArrayList();

        task_1_4.ExtendedAttribute = eas;

    }

     

    string dateTimeFormat = "yyyy-MM-ddTHH:mm:ss";

     

    ExtendedAttribute ea = new ExtendedAttribute();

    ea.FieldId = ead.FieldId;

    ea.Value = XmlConvert.ToString(DateTime.Now, dateTimeFormat);

    eas.Add(ea);

     

    ProjectWriter writer = new ProjectWriter();

    writer.Write(project, new FileStream("_3_.xml", FileMode.Create, FileAccess.Write), TasksDataFormat.XML);

     

    All values should be converted to a string.

    • Text value stored “as is”.
    • Boolean (Flag1-Flag10) should be stored as “0” or “1”.
    • Double values like Cost1-Cost10 should be multiplied by 100.0d and converted to string using XmlConvert.ToString(cost1 * 100.0d).
    • DateTime converted to string as described above.
    • TimeSpan values use next formula:

     

    string ts = "PT" + Math.Round(elementVal.TotalHours) + "H" +

            elementVal.Minutes + "M" + elementVal.Seconds + "S";

     



    Alexey Zhilin
    Team Leader
    Aspose Tyumen Team
    About Us
    Contact Us
     
  •  02-08-2009, 11:12 AM 163999 in reply to 162991

    Re: New Aspose.Tasks with MS Project 2007 MPP format support available for public testing

    Can you please post an example of working with custom fields in a task?
     
  •  02-09-2009, 2:19 PM 164216 in reply to 163999

    Re: New Aspose.Tasks with MS Project 2007 MPP format support available for public testing

    Hello Alan,

    ExtendedAttributes property wasn't implemented for the Task class in the previous version but now it's available. Could you please download updated Aspose.Tasks.2.0.0.zip in the first post and check it. Post here in case of any other problems with custom fields.

    Alexey Zhilin
    Team Leader
    Aspose Tyumen Team
    About Us
    Contact Us
     
  •  02-09-2009, 7:21 PM 164255 in reply to 162991

    Re: New Aspose.Tasks with MS Project 2007 MPP format support available for public testing

    Hi,

    Attempting to import a 2007 project (mpp format) and addressed the following issues in the RootTask and its children:

    - OutlineNumber and Wbs always return null.
    - The date fields in the tasks (e.g. Start and Finish), day and month are correct, but the year always on 2000.

    Regards,
    Lewis, MPMM
     
  •  02-10-2009, 1:35 PM 164472 in reply to 164255

    Re: New Aspose.Tasks with MS Project 2007 MPP format support available for public testing

    Hello Lewis,

    - OutlineNumber is calculated property. We couldn't find it in the mpp (2007) records yet. It is rather possible that new mpp format doesn't contain such property at all.
    - Wbs property has very strange behavior. Sometimes it works but in most cases returns null. It should be investigated and fixed.
    - Year 2000 is standard limitation of evaluation version but now it works more accurately and doesn't reset time vaules.

    Alexey Zhilin
    Team Leader
    Aspose Tyumen Team
    About Us
    Contact Us
     
  •  02-11-2009, 2:57 AM 164572 in reply to 164255

    Re: New Aspose.Tasks with MS Project 2007 MPP format support available for public testing

    Hello Lewis,

    Reading Wbs property from MPP12 files (Project 2007) has been fixed. New version is available for download in the first post.

    Alexey Zhilin
    Team Leader
    Aspose Tyumen Team
    About Us
    Contact Us
     
  •  02-11-2009, 9:21 AM 164662 in reply to 164216

    Re: New Aspose.Tasks with MS Project 2007 MPP format support available for public testing

    Alexey,

     

    Can you post some brief code for working with extendedattributes? It appears to be working but I am havig issues with getting data into the ea.

    Thanks,

    Alan

     
  •  02-12-2009, 5:38 AM 164865 in reply to 164662

    Re: New Aspose.Tasks with MS Project 2007 MPP format support available for public testing

    Hello Alan,

    I will post it in a few hours together with information about identifiers (ExtendedAttribute.FieldId) used for standard extended attributes.

    Alexey Zhilin
    Team Leader
    Aspose Tyumen Team
    About Us
    Contact Us
     
  •  02-12-2009, 2:05 PM 164986 in reply to 164662

    Re: New Aspose.Tasks with MS Project 2007 MPP format support available for public testing

    Hello Alan,

    Aspose.Tasks has been updated so please check new version and API reference. There are 2 new enumerations ExtendedAttributeTask and ExtendedAttributeResource with all know identifiers were added. Also I have wrote short example which shows how to find attribute by Id and read it.

    Alexey Zhilin
    Team Leader
    Aspose Tyumen Team
    About Us
    Contact Us
     
  •  02-13-2009, 4:24 AM 165074 in reply to 164986

    Re: New Aspose.Tasks with MS Project 2007 MPP format support available for public testing

    Thanks Alexey.

     

    Let me give a concrete example of what I am facing in the field right now. My client has a project with 22,000 tasks. They need data moved into a built-in custom task (say Finish6 or Start7) and I need to know how to push their data into those specific, MS Project defined, tasks and then read those tasks. Your code provides a starting point but I would imagine others are facing the same issue that I am.

    I know you are a developer and busy but if you could illustrate how to address the writing side, it would be very much appreciated.

     

     

     
  •  02-13-2009, 11:35 AM 165180 in reply to 165074

    Re: New Aspose.Tasks with MS Project 2007 MPP format support available for public testing

    The post has been updated. Please check new example and additional information about values conversion. Aspose.Tasks also was updated because there was small problem in EA scheme creation.

    Alexey Zhilin
    Team Leader
    Aspose Tyumen Team
    About Us
    Contact Us
     
  •  02-14-2009, 10:28 PM 165250 in reply to 165180

    Re: New Aspose.Tasks with MS Project 2007 MPP format support available for public testing

    Attachment: Present (inaccessible)
    Alexey,

    This code is throwing a null ref exception on the final line:

    ProjectReader reader = new ProjectReader();
    FileStream fs = new FileStream(@"c:\temp\test.xml", FileMode.Open);
    Project project = reader.Read(fs);

    The test.xml file can be opened in MS Project and was actually created by Aspose.Tasks. The FileStream is valid.
     
  •  02-14-2009, 10:47 PM 165251 in reply to 165180

    Re: New Aspose.Tasks with MS Project 2007 MPP format support available for public testing

    Alexey,

    I can confirm that the EA work you guys did was successful. I am adding in extension methods to make it all easier but it did work. Thank you.

    A couple of suggestions:

    1. Can you add a reference to the parent project in the Task object?

    2. As you move forward, can you use generics rather than ArrayList? This eliminates boxing/unboxing and makes it a lot easier to use the code with stuff like LINQ.

    3. It would be good to have Save/Open
    methods in the project task and hide the reader/writer objects. That said, I will probably add extension methods to handle this issue.

    Alan
     
  •  02-15-2009, 4:05 PM 165277 in reply to 162991

    Re: New Aspose.Tasks with MS Project 2007 MPP format support available for public testing

    Hi Alcurs,

    Just trying to export the xml from your "Creating simple project" example using the ProjectWriter, the retruned xml can be read by MSPorject but read it using:
    Project project = reader.Read(new FileStream(filePath, FileMode.Open));
    return an exception: Object reference not set to an instance of an Object.

    Regards,
    Lewis, MPMM
     
  •  02-15-2009, 11:40 PM 165292 in reply to 165251

    Re: New Aspose.Tasks with MS Project 2007 MPP format support available for public testing

    Hello Alan,

    1. Do you mean parent project or parent task?

    2. We would be more than happy to change code and use generics but unfortunately there are customers who still use .NET 1.1. Anyway, we are thinking about such possibility.

    Alexey Zhilin
    Team Leader
    Aspose Tyumen Team
    About Us
    Contact Us
     
Page 1 of 6 (76 items)   1 2 3 4 5 Next > ... Last »
View as RSS news feed in XML