How can I identify the outline code value (i.e. value of a custom column) of a particular task

Hi,

I was wondering if you could help me figure out how to get the value of a custom field of a given row. The custom field contains selected items of a dropdown list. I can enumerate over the projects ExtendedAttributes and I see them in the collection; however, there doesn't seem to be any extended attributes at the task level. There are outline codes at the task level, but I don't see a way to do the following: task.OutlineCode[0].Value. All I see are FieldId, ValueId, and ValueGuid. Ultimately, I would want to perform the following:

Task task = TaskUtils.Filter(project.RootTask, new ProductCondition(productName));

where Product is the name of the custom column and productName is the string to search for.

I am currently evaluating this product and if I can get a solution to this issue, we will definately purchase a license. I appreciate your assistance.


This message was posted using Page2Forum from Extended attributes of a task - Aspose.Tasks for .NET

Hi Wilfred,

Thanks for considering Aspose.Tasks.

I have prepared a code snippet to find the value of the outline codes for a particular tasks (in this code example, the task having UID = 1).

ProjectReader reader = new ProjectReader();
Project project = reader.Read(@“E:\OutlineCodes.mpp”);
foreach (OutlineCodeDefinition ocd in project.OutlineCodes)
foreach (OutlineValue value in ocd.Values)
{
if (getTaskOutlineCodeValue(project.GetTaskByUid(1), value.ValueId))
Console.WriteLine("Outline Code Value = " + value.Value);
}

bool getTaskOutlineCodeValue(Task tsk, int intValID)
{
foreach (OutlineCode olcode in tsk.OutlineCode)
if (olcode.ValueId == intValID)
return true;
return false;
}

Hope this will be helpful. If you mean something else, please feel free to share with us.

Kind Regards

Hi,

Thanks. That helps a little. I am actually running into an issue now where when I remove tasks and save the project file, the removed tasks are still there. Here is the code:

ProjectReader reader = new ProjectReader();

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

Task taskTree = TaskUtils.Filter(project.RootTask, new NameCondition(taskName));

RemoveChildren(taskTree.Children);

[code for RemoveChildren]

private void RemoveChildren(ArrayList children)

{

if (children.Count == 0) return;

for (int i = 0; i < children.Count; i++){

Task task = (Task)children[i];

if (task != null) {

project.RemoveTask(task);

}

RemoveChildren(task.Children);

}

}

[Code for writing to disk]

ProjectWriter writer = new ProjectWriter();

writer.Write(newProject, @"C:\\SampleProject\\Edited\\MyProjectFile.mpp", TasksDataFormat.MPP);

For some reason the saved file does not have any removed tasks. Please help.

Hi Wilfred,

Thanks for further feedback.

Could you please provide us the source project file as it will help us to reproduce the issue on our end?

Kind Regards

Ok. I attached a sample of what I'm trying to accomplish. Again, the core issue I'm experiencing now is not being able see the tasks I remove reflected in the project.

You will also be able to see how I approached the first issue that you helped me with (if you are interested)

Hi Wilfred,

Please make the following changes in your project writing code:

project.CalcTaskIds();
project.CalcTaskUids();
ProjectWriter writer = new ProjectWriter();
writer.Write(project, @“EditedProject.xml”, TasksDataFormat.XML);

Whenever, we update tasks data in the project file, we need to recalculate the Task IDs and UIDs using CalcTaskIds and CalcTaskUids methods respectively as exposed by Project object.

Many Thanks

Hi,

I'm sorry but I tried

project.CalcTaskIds(); and

project.CalcTaskUids();

Itis not working for me. So I simplified the code I attached to use the "NameCondition" provided with an Apsose sample, and used it to Filter all tasks with a TaskName of "Task Name" (which is all of them). There were still no tasks removed from the project.

private Task FindTasksByProduct(string productName) {

return TaskUtils.Filter(project.RootTask, new NameCondition("Task Name"));

//return TaskUtils.Filter(project.RootTask, new ProductCondition(productName, productExtendedAttributeFieldId, outlineCodeValueIdToValuesLookupTable));

}

Maybe it has something to do with the what is being returned from TaskUtils.Filter. Are these "copied" tasks, no longer referenced by the project. Do you have any ideas?

Is RemoveTask broken?

Hi Wilfred,

I am also experiencing the issues on running your sample application. What I understand, you want to remove tasks with some particular outline code value say “EPM”. I am preparing a sample application that will do this. Please correct me if I am wrong.

Kind Regards

Yes, that is what I’m trying to accomplish. This is fine if you wish to work with that example. However, I was trying to simplify things a little by just removing tasks with a certain task name (just to see of the RemoveTask method was working for me at all). I tried to do this with a project file, containing only two tasks and the task still were not being removed. Thank you for your help. Please let me know when you figure out what the issue is.

Hi Wilfred,

Please find attached a simple application and the input MPP + output XML just to demonstrate how you can remove tasks from the MPP project files using Aspose.Tasks for .NET.

As far as your other issue is concerned, the output XML is having some problems. It seems there are some macros in the source MPP file which are creating problems. Let me prepare a sample MPP file and a sample application to fulfill your requirements.

Many Thanks

I ran the sample that you provided and I still see the tasks with UID = 1 and UID = 2 in the xml file. I am currently using a 30 day evaluation license. Do you think that it has anything to do with that? Maybe it won't let me save changes?

Hi Wilfred,

Yes, that might be the difference. Could you please share your license file following these instructions? I just want to be sure of the exact problem.

Many Thanks

Ok. I sent it.

Any word on whether the temporary license is causing my issue?

Hi Wilfred,

I could not find any problem with the temporary license. It worked the same way as expected. I tested it with the same application and source MPP I sent you earlier. The platform for the test is as follows:

OS : Windows Vista 32-bit
.NET Framework : 3.5

The output XML is attached. Could you please recheck things on your end?

Hi,

I looked at the xml and indeed the tasks "were" removed. They just aren't getting removed when I write the output as a .mpp file. Why is this?

OS: Windows XP

.NET Framework 3.5

Hi Wilfred,

After further investigation, an issue has been found with the custom outline codes. This issue has been logged as “20407 - MPP to XML fails if there are custom outline codes in the MPP file” in our Issue Tracking System. This thread has been linked with the issue for further updates. Our development team will figure it out and you will be notified once this issue is resolved.

Sorry for the inconvenience.

Many Thanks

Hi Wilfred,

Unfortunately, full write support for MPP file format is not available at the moment. We plan to continuously incorporate the MPP write support with the future releases. So far, only common project properties (as exposed by Project object) are available for writing back to MPP file format. Currently, the full write features are available in the MS Project XML file format.

Regards

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


This message was posted using Notification2Forum from Downloads module by aspose.notifier.