ParentProject ... and update references

Hi,

Just a quick check ... after a project has been read into the Project Object. Are all references updated? For example, has project.UpdateReferences been called so tasks have valid ParentProject and ParentTask references.

Also, when I create a new task, is there any reason why I cannot just set the ParentProject and ParentTask properties directly w/o using UpdateReferences.

I guess what I'm really asking is ... does project.UpdateReferences do anything more than just set the ParentProject and ParentTask properties.

Regards, Bruce

Hi Bruce,

Thank you a lot for your questions. See my answers below.

BruceMcNaughton:

Just a quick check ... after a project has been read into the Project Object. Are all references updated? For example, has project.UpdateReferences been called so tasks have valid ParentProject and ParentTask references.

A: Yes we use the project.UpdateReferences in end of the project data reading, so the tasks' ParentProject and ParentTask has to be updated.

BruceMcNaughton:

Also, when I create a new task, is there any reason why I cannot just set the ParentProject and ParentTask properties directly w/o using UpdateReferences.

A: You can call the project's UpdateReferences, the task's UpdateReferences method or just set the ParentProject and the ParentTask for the task by hand on your choice. Note that UpdateReferences are recursive methods, so the same method for all children tasks is called. You can set the properties by hand to make your application work faster or just call the method once when all changes are finished.

BruceMcNaughton:

I guess what I'm really asking is ... does project.UpdateReferences do anything more than just set the ParentProject and ParentTask properties.

A: Now the Project's and Task's UpdateReferences methods do nothing except the tasks' ParentProject and ParentTask properties setting for all tasks in the project or for all children of the task. And we are not going to change the behavior.


For resources' Start and Finish dates recalculation we use Project's CalcResourceStartFinish public method and we use some internal methods for other project's recalculations (like ACWP etc). We are working to make them public currently.

Hi Sergey,

I did not see a task.UpdateReferences ... maybe it's internal (also not in the help file).

I'll set them manually when I create a new task ... to avoid going through the entire tree each time.

Many thanks, Regards, Bruce

Hi Bruce,


Sorry for mess, in our last release the method is still internal.

Hi Sergey,

Any idea when an interim version or the next release will be? I could use the .TAG if available and be able to understand what else might be available to use.

Thanks in advance.

Regards, Bruce

Hi Bruce,


We are going to release the new version in end of the month as usual. The interim build will be ready next week.

Sorry for delay.

Hi Bruce,

The task’s TAG implementation is still under consideration. But we have implemented XML data reading/writing events for project and tasks’ data customization. The interim build is still on its way, meanwhile you can use the code below as the TAG’s issue workaround. Note, that the events will be available from the interim build only.

private Dictionary<Task, string> tags = new Dictionary<Task, string>();
// or Hashtable tags = new Hashtable();<o:p></o:p>
///
///
///
[Test]
public void TestEventHandlers()
{
    Project project;
    ProjectReader reader = new ProjectReader();
    ProjectWriter writer = new ProjectWriter();
    string project_name = folder_name + "\\tags.xml";
    project = reader.Read("..\\..\\..\\testdata\\EarnedValues\\ACWP2010.xml");
    ChildTasksCollector collector = new ChildTasksCollector();
    TaskUtils.Apply(project.RootTask, collector, 0);
    foreach (Task task in collector.Tasks)
        tags.Add(task, string.Format("TAG: '{0}'.", task.Name));
    writer.SetProjectXMLCreationFinishedEventHandler(new ProjectXMLCreationFinished(ProjectCreationHandler));
    writer.SetTaskXMLCreationFinishedEventHandler(new TaskXMLCreationFinished(TaskWriteHandler));
    writer.Write(project, project_name, TasksDataFormat.XML);
    reader.SetProjectXMLParsingStartedEventHandler(new ProjectXMLParsingStarted(ProjectParsingHandler));
    reader.SetTaskXMLParsingFinishedEventHandler(new TaskXMLParsingFinished(TaskReadHandler));
    Project project1 = reader.Read(project_name);
    foreach (Task task in collector.Tasks)
    {
        Task task1 = project1.GetTaskByUid(task.Uid);
        Assert.IsNotNull(task1);
        Assert.AreEqual(tags[task], tags[task1]);
    }
}
private void TaskWriteHandler(XmlElement element, Task task)
{
    XmlElement tag = element.OwnerDocument.CreateElement("Tag");
    tag.InnerText = tags[task].ToString();
    element.AppendChild(tag);
}
private void TaskReadHandler(XmlElement element, Task task)
{
    XmlNodeList list = element.GetElementsByTagName("Tag");
    if (list.Count > 0)
        tags.Add(task, list[0].InnerText);
}

private void ProjectCreationHandler(XmlDocument doc, Project project)
{
    XmlComment comment = doc.CreateComment("Custom project comment.");
    doc.DocumentElement.InsertBefore(comment, doc.DocumentElement.FirstChild);
}

private void ProjectParsingHandler(XmlDocument doc, Project project)
{
    XmlNode node = doc.DocumentElement.FirstChild;
    Assert.IsInstanceOf(typeof(XmlComment), node);
    Assert.AreEqual("Custom project comment.", node.InnerText);
}

Let us know if it works for you.
Sorry for delay and inconvenience.

Hi Sergey,

I apologise for the misunderstanding ... I don't see how the above actually helps with what I needed for the TAG property.

The TAG object reference I proposed was only to help me implement extra properties and methods to extend the calculations for the task object. I envisioned this only used after the project has been loaded and all of these objects released prior to saving the project. I am currently calculating the work and cost rollups and calculating the start and finish dates for tasks when TaskLinks are added. The results of these calculations goes back into the normal task objects (start, finish, cost, work, etc.)

All I need is a place in the task object to store an object reference. I could use this object reference to help calculating the critical path (forward pass and backward pass).

I'd like to see what you have made available for the project and task XML. This might be useful at least to help with testing.

Again sorry about the confusion with the TAG object reference ... If you are still considering adding the TAG property and you decide not to add it - just let me know and I'll find another way.

Regards, Bruce

Hi Bruce,


I have put the sample code above just to show a way to store custom task’s information outside task in global dictionary object. For one project, the task’s UID can be used as the dictionary key. Of course, there are other ways to achieve the same. This is why we don’t like to add the TAG property to the Task class. It’s not a problem of course, we just don’t like the idea because of architectural consideration as other classes don’t have the property and other products too…

Sorry for making you confused and for inconvenience. We have added Calendar’s GetNextWorkingDayStart and GetPreviousWorkingDayEnd methods but the interim build is still not ready.

Hi Sergey,

Many thanks.. Ok. I'll take the performance Hit and make my own task object manager to manage extended calculations. I really hope all of the calculations I need eventually will be included in Aspose.Tasks so I can retire this extra set of objects.

I may have misunderstood the sample code you provided. Does this actually indicate that a task object is just a wrapper for a XML element for a Task? same for a project?

As I've indicated, my analysis of some of the calculations seems to indicate that some task state or status information is needed. This would be much easier to use if the information were in (or closely related to the task object) - especially for forward and backward calculations (I could be wrong...). (Or you may have an entirely different approach to doing these calculations).

Let me know when the interim build is ready and I'll give the new additions a try.

Thanks again for your help!!

Regards, Bruce

Hi Bruce,


I am extremely sorry for the delay, we just had some technical problem with the interim build here.

You can find the interim build in the attachment.

We are trying to keep our open API as close to MS Project Automation object model and Project Data XML Interchage Schema as possible, so you can consider our classes as some kind of wrappers of the schema elements, but functionality is slightly different as for example we have to keep MPP and XML data in the same objects.

Thank you a lot for cooperation and again sorry for the delay.

Hi Sergey,

I had time in the early part of August for testing. I have been unavailable for the past two weeks. Should I wait for the next release before starting to test again? When will it be available?

Regards, Bruce

Hi Bruce,


Sorry for my late response, but I understand that you need more the build than my answer. I extremely hope that it’ll be ready shortly. Hope to be back soon.

Hi Sergey,

Many thanks ... I'll resume testing with the new version!!

Regards, Bruce