How to get all the resources belong to one summary task from C# or

J

Jiang

Hi, All
I want to know is there an easy way to get all the resources belong to one
summary task? these resources should the collection of all the subtasks of
the summary task.
currently my way is:
get all the subtasks thru TaskParentUID.
and get all the resources from the subtasks...
get all the subtasks thru TaskParentUID from subtaks....
....
this would be extremely complicated..
Is there an easy way to get all the resources to a summary Task?
Thanks
 
J

John

Jiang said:
Hi, All
I want to know is there an easy way to get all the resources belong to one
summary task? these resources should the collection of all the subtasks of
the summary task.
currently my way is:
get all the subtasks thru TaskParentUID.
and get all the resources from the subtasks...
get all the subtasks thru TaskParentUID from subtaks....
...
this would be extremely complicated..
Is there an easy way to get all the resources to a summary Task?
Thanks

Jiang,
I'm not sure why you feel it is so complicated. There is no property for
the task object at summary level to get all subtask resources. If I were
doing it, I would set up an outer loop to cycle through all summary
lines. An inner loop would then gather resource names of each task
object or resource name of each assignment object. The result could be
compounded into a string or stored in an array.

John
Project MVP
 
J

Jiang

Thanks John.
Why I thought it is complicated is that for a subtask, It also maybe a
summary task, so there are still subsubtasks for this subtask ... and loop
again...
So, I want to know is there a easy way to achieve this?
currently I first loop all the 1 level summary task and find all the
subtask(incluing sub summary task) thru TaskParentUID, and loop the inner
task again...

Thanks.
 
J

John

Jiang said:
Thanks John.
Why I thought it is complicated is that for a subtask, It also maybe a
summary task, so there are still subsubtasks for this subtask ... and loop
again...
So, I want to know is there a easy way to achieve this?
currently I first loop all the 1 level summary task and find all the
subtask(incluing sub summary task) thru TaskParentUID, and loop the inner
task again...

Thanks.

Jiang,
Yes if you have multiple indentures in your file, it could get a little
complex - but that just makes it more interesting. There is no "simple"
way to do it but here's something you might try.
1. Find the highest level of indenture and start there (e.g. outline
level 10)
2. Loop through that level and write the resources names to an array or
to a spare text field at the parent outline level, but be careful, spare
text fields can only hold a maximum of 255 characters. Note: filtering
each level and then looping on just that selected set can help simplify
things. Track the ID value to know when you hit a new group of subtasks
(i.e. different parent)
3. Iterate to the next level up and repeat step 2
4. Keep going until you're at outline level 1, then you're done

Hope this helps.
John
Project MVP
 
R

Rod Gill

In VBA and I'm sure in C# you can use recursive programming. Create a Sub to
handle all Tasks under one summary. Pass it the Summary Task as an object.
If you encounter another summary task, call the same routine with the new
summary task. The code will call itself as many times as needed.

This code sets the value of every task in the project.

Sub Test()
Dim Tsk As Task
DoSummaryTask ActiveProject.ProjectSummaryTask
End Sub

Sub DoSummaryTask(Tsk As Task)
Dim subTsk As Task
Tsk.Text1 = "Handled"
For Each subTsk In Tsk.OutlineChildren
If subTsk.Summary Then
DoSummaryTask subTsk
Else
subTsk.Text1 = "Handled"
End If
Next subTsk
End Sub


--

Rod Gill
Microsoft MVP for Project

Author of the only book on Project VBA, see:
http://www.projectvbabook.com
 
J

Jiang

Thanks Gill.
It is really a simple way.
but I can only use OLEDB, no PIA. So I can't get Task, Project such COM
object.
And I found that there are no TaskParentUID this filed in Tasks table.
but the user manual there was.
So, I had to get all these tasks from Assignment Table...oops
 
J

Jiang

Thank you John.
yeah, I use recursion to solve this problem.
Is there missing TaskParentUID in Tasks Table?
The Spec said there has, but actually not.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top