How can I know the ID of a workItem

Topics: CAB & Smart Client Software Factory
Jul 4, 2013 at 7:31 PM

I want to know all the IDs of the WorkitemsCollection in the rootworkitem.

In the debugger I can see the IDs but the value is not the one I declare.

Ex: To retrieve the module I use this Line:
WorkItem item = WorkItem.Parent.WorkItems["LookUpsAdmon"];
but if I put a breakpoint and see the values of "Item" in the ID propertie i see:

Is in the Workitem an element that show "LookUpsAdmon"? I wanna make a DB with all my WorkItems ID.

Jul 5, 2013 at 5:37 PM

It seems that the WorkItem's ID and the key used to obtain a WorkItem from the collection are not related to each other.
Based on my understanding, what you are seeing in the default ID of the WorkItem (which is a Guid.)
If you want to, I believe you can set a custom ID to the WorkItem by simply setting it in its ID property. Like this you could have the same string as the ID and as the collection key.

I hope this helps,

Damian Cherubini
Jul 5, 2013 at 6:25 PM
Hi DCherubini,

Thank you for fast reply and info

Well, do you know how can I find the list of Keys?
Jul 8, 2013 at 7:19 PM

Well, looking at the code of the Composite Application Block, it seems that the list of child Work Items is a ManagedObjectCollection, which is a collection of KeyValuePairs rather that a Dictionary. Hence, it doesn't seems to expose a method to obtain the "keys" of the objects. I'm not very familiar with this implementation, so there might be a better approach, but as a quick workaround you could iterate over the WorkItems collection using a foreach statement (as the ManagedObjectCollection class provides an enumerator) and retrieve the key for each KeyValuePair.


Damian Cherubini
Jul 9, 2013 at 11:54 PM
I can do it now, it's harder than I expect but finally I got it.

Thanks DCherubini!