none
How to use the EnumerateResources building block activity?

    Question

  • How do I use the EnumerateResourcesActivity?  I added it to a custom workflow, and give it an xpath filter.  I see that the TotalResultsCount is indeed positive, but I can't get access to the enumerated resources.  I tried adding an EnumerateResourceIterationActivity just after the EnumerateResources, but the CurrentItem always returned null.  What am I missing? 

    Friday, April 24, 2009 8:12 PM

Answers

  • The EnumerateResourcesIterationActivity should not be used.  This activity will be removed from the product in the next release.
    The EnumerateResourcesActivity can be used to retrieve the number of results of an enumeration, as well as the individual resources returned by the enumeration.

    In order to get the results of the enumeration, you need to bind a child activity to the EnumerateResourcesActivity, which will iterate over the result set and perform the operations you need on that result set.

    For example, if I have defined a code activity, IterateEnumerationResult, which will retrieve each result of the enumeration and perform some operation (write result to a log, check for some condition etc.), I can add it as a child activity to the EnumerateResourcesActivity in the Designer.cs as follows:  

    this.EnumerateResourcesActivity1.Activities.Add(this.IterateEnumerationResult);
    

    This will then result in the child activity, IterateEnumerationResult, executing against each result returned by the EnumerateResourcesActivity. 

    Within the child activity I could then have the following code to actually retrieve the current result:

    ResourceType result = EnumerateResourcesActivity.GetCurrentIterationItem((CodeActivity)sender) as ResourceType;
    Hopefully this helps.

    Thanks,
    Nima
    • Marked as answer by Joe Zamora Tuesday, April 28, 2009 9:11 PM
    Monday, April 27, 2009 10:16 PM
  • Hi Joe!
    Unfortunately I'm still waiting for Brjann Brekkans new VHD so I'm not able to test this but too me it looks like the EnumerateResourcesActivity has got the wrong designer so you’re not able to add a EnumerateResourceIterationActivity to it
    declaratively but since EnumerateResourcesActivity inherits from CompositeActivity you should be able to add it programmatically using the Activities property.


    Henrik Nilsson - Cortego http://blog.softconstruction.se
    • Marked as answer by Joe Zamora Tuesday, April 28, 2009 9:11 PM
    Monday, April 27, 2009 2:55 PM

All replies

  • Hi Joe!
    Unfortunately I'm still waiting for Brjann Brekkans new VHD so I'm not able to test this but too me it looks like the EnumerateResourcesActivity has got the wrong designer so you’re not able to add a EnumerateResourceIterationActivity to it
    declaratively but since EnumerateResourcesActivity inherits from CompositeActivity you should be able to add it programmatically using the Activities property.


    Henrik Nilsson - Cortego http://blog.softconstruction.se
    • Marked as answer by Joe Zamora Tuesday, April 28, 2009 9:11 PM
    Monday, April 27, 2009 2:55 PM
  • I believe Nima will be posting a code sample here soon.
    AhmadAW
    Monday, April 27, 2009 9:35 PM
  • The EnumerateResourcesIterationActivity should not be used.  This activity will be removed from the product in the next release.
    The EnumerateResourcesActivity can be used to retrieve the number of results of an enumeration, as well as the individual resources returned by the enumeration.

    In order to get the results of the enumeration, you need to bind a child activity to the EnumerateResourcesActivity, which will iterate over the result set and perform the operations you need on that result set.

    For example, if I have defined a code activity, IterateEnumerationResult, which will retrieve each result of the enumeration and perform some operation (write result to a log, check for some condition etc.), I can add it as a child activity to the EnumerateResourcesActivity in the Designer.cs as follows:  

    this.EnumerateResourcesActivity1.Activities.Add(this.IterateEnumerationResult);
    

    This will then result in the child activity, IterateEnumerationResult, executing against each result returned by the EnumerateResourcesActivity. 

    Within the child activity I could then have the following code to actually retrieve the current result:

    ResourceType result = EnumerateResourcesActivity.GetCurrentIterationItem((CodeActivity)sender) as ResourceType;
    Hopefully this helps.

    Thanks,
    Nima
    • Marked as answer by Joe Zamora Tuesday, April 28, 2009 9:11 PM
    Monday, April 27, 2009 10:16 PM
  • Thanks Nima for giving some information about this. I Hope you don't plan on removing the EnumerateResourcesActivity as well...
    Henrik Nilsson - Cortego http://blog.softconstruction.se
    Tuesday, April 28, 2009 4:27 AM
  • Thanks Henrik and Nima for your help.

    Henrik is right that you can't add child activities to EnumerateResources in the designer. 

    Okay, I realize I won't be able to use EnumerateResourceIteration in the future, but it should work for now, right?  I mean, it sounds like it already does everything that Nima suggests.

    Given the aforementioned advice, I added an EnumerateResourceIteration programmatically (in the Designer.cs file), and then added a code activity to that:

    #region Test

    this.codeActivity1 = new System.Workflow.Activities.CodeActivity();

    this.enumerateResourceIterationActivity1 = new Microsoft.ResourceManagement.Workflow.Activities.EnumerateResourceIterationActivity();

    //

    // codeActivity1

    //

    this.codeActivity1.Name = "codeActivity1";

    this.codeActivity1.ExecuteCode += new System.EventHandler(this.logEnumeration);

    //

    // enumerateResourceIterationActivity1

    //

    this.enumerateResourceIterationActivity1.Activities.Add(this.codeActivity1);

    this.enumerateResourceIterationActivity1.CurrentItem = null;

    this.enumerateResourceIterationActivity1.Name = "enumerateResourceIterationActivity1";

     

    this.enumerateResourcesActivity1.Activities.Add(this.enumerateResourceIterationActivity1);

    #endregion


    Now, in my logEnumeration method, I tried to access the Resource iteration a couple of different ways:

    ResourceType currentItem = EnumerateResourcesActivity.GetCurrentIterationItem(

        (CodeActivity)sender) as ResourceType;

     

    ResourceType currentItem = enumerateResourceIterationActivity1.CurrentItem;


    However, both times, my currentItem is null.  Remember that, in the same method, TotalResultsCount is nonzero.

    I'm probably still doing something wrong.  Any ideas?

    Thanks!
    Joe
    Tuesday, April 28, 2009 7:12 AM
  • Maybe the EnumerateResourcesActivity has other parameter requirements except the XPath parameter.
    For example maybe the Selection or ActorID parameters are required in order to get the resources and not just a resource count. Nima could you shed som light on this?

    I also wonder if the EnumerateResourcesActivity will get a better designer in the next version, maybe get the same designer/validator as the Replicator activity?

    Henrik Nilsson - Cortego http://blog.softconstruction.se
    Tuesday, April 28, 2009 8:53 AM
  • Aha!  I got it to work with Nima's instructions.  Turns out that the code activity cannot be embedded in a child activity.  The code activity must be a direct child of the EnumerateResourcesActivity.  Thanks Nima and Henrik for your help!

    Add this to Designer.cs:

    #region

     

    Test

    this

     

    .codeActivity1 = new System.Workflow.Activities.CodeActivity();

    //

    // codeActivity1

    //

    this

     

    .codeActivity1.Name = "codeActivity1";

    this

     

    .codeActivity1.ExecuteCode += new System.EventHandler(this.logEnumeration);

    this

     

    .enumerateResourcesActivity1.Activities.Add(this.codeActivity1);

    #endregion


    And then simply add this to the code method:

    ResourceType

     

    currentItem = EnumerateResourcesActivity.GetCurrentIterationItem(

    (

    CodeActivity)sender) as ResourceType;


    Thanks again for your help!
    Joe
    Tuesday, April 28, 2009 9:11 PM
  • Hi all,

    I have a query about this which maybe you can help me withI have the EnumerateResourcesActivity set up as per Nima's reccomendation, with a direct child which  and evrything works as you say, which is great. However, I have an issue in that for each iteration that is returned by the EnumerateResourcesActivity I want to perform an update on that resource.

    I have an updateresourcesactivity at the end of my workflow and not surprisingly the only resource that gets updated is the last on to be returned, since the workflow moves on to that activity after the EnumerateResourceActivity is complete.

    My question is, how do I invoke an updateresource activity in my direct child of the enumerateresourcesactivity which gtes called for each iteration rather than just the last one returned.

    Thanks!

    James
    James McAlonan
    Friday, November 13, 2009 8:47 PM
  • Hi James!
    I'm not sure my advise could help because I haven't worked with this activity for a while now. Anyway this activity works as the Replicator activity so you'll probably be able to add a Sequence activity as the direct child activity and within the sequence activity you can add any number of child activities.

    //Henrik
    Henrik Nilsson Blog: http://www.idmcrisis.com Company: Cortego (http://www.cortego.se)
    Friday, November 13, 2009 8:55 PM
  • Thanks for that Henrik,

    I guess what I'm trying to figure out is which one of the following approaches to take:

    1. somehow invoke an updateresourceactivity for each iteration of the enumerateresourcesactivity
    2. Popualte a collection of resources returned during each iteration of enumerateresourcesactivity and then use a While loop to loop through the collection, with the update resourcesactivity as a child of the while activity

    Thanks,

    James


    James McAlonan
    Saturday, November 14, 2009 7:51 PM
  • I recommend you to try the first approach first by adding an SequenceActivity to the EnumerateResourcesActivity and the UpdateResourceActivity as one of the child activities of the SequenceActivity.

    Henrik Nilsson Blog: http://www.idmcrisis.com Company: Cortego (http://www.cortego.se)
    Saturday, November 14, 2009 7:58 PM
  • OK I'll give that a go, thanks for the advice,

    how do I do I add a sequence activity to the enumerateresourcesactivity? Is that the same as just adding an activity after it in the design surface? Any pointers greatly appreciated, as I have only been working with workflows for about 2 weeks and I have a lot to learn :-)

    Cheers,

    James


    James McAlonan
    Saturday, November 14, 2009 8:03 PM
  • Unfortunately they haven't fixed the designer for the EnumerateResourcesActivity yet so you'll have to add child activities using code but if you build up how you wish to have your activities in the designer replacing the EnumerateResourcesActivity with a ReplicatorActivity you can see how the code is built up withing the ...designer.cs file.

    Example:

    // This activity could be added directly to the design surface so this code will appear in the ...designer.cs.
    EnumerateResourcesActivity erActivity = new EnumerateResourcesActivity();

    // These has to be added using code.
    SequenceActivity sActivity = new SequenceActivity();
    CodeActivity cActivity = new CodeActivity();
    UpdateResourceActivity urActivity = new UpdateResourceActivity();

    erActivity.Activities.Add(sActivity);
    sActivity.Activities.Add(cActivity);
    sActivity.Activities.Add(urActivity);


    //Henrik

    Henrik Nilsson Blog: http://www.idmcrisis.com Company: Cortego (http://www.cortego.se)
    Saturday, November 14, 2009 8:24 PM
  • Hi Henrik,

    I've set this up, and it compiles correctly. However it looks like I'm back to the situation where I get a null result from
     

    ResourceType currentItem = EnumerateResourcesActivity.GetCurrentIterationItem(

        (CodeActivity)sender) as ResourceType;

    This is where the code activity is a child of the sequence activity, rather than a direct child of the enumerateresourcesactivity. So it looks like the code must be a direct child of the enumerateresourcesactivity. Here is my code in case you can spot an obvious howler. I code in VB.Net:

    From designer

    enumerate resources activity

     

    'EnumerateUsers

     

    '

     

    Me.EnumerateUsers.Activities.Add(Me.sequenceActivity1)

     

    Me.EnumerateUsers.ActorId = New System.Guid("00000000-0000-0000-0000-000000000000")

     

    Me.EnumerateUsers.Name = "EnumerateUsers"

     

    Me.EnumerateUsers.PageSize = 100

     

    Me.EnumerateUsers.Selection = Nothing

     

    Me.EnumerateUsers.SortingAttributes = Nothing

     

    Me.EnumerateUsers.TotalResultsCount = 0

    activitybind2.Name =

    "BacklinkUsersDept"

    activitybind2.Path =

    "EnumerateUsers_XPathFilter1"

     

    Me.EnumerateUsers.SetBinding(Microsoft.ResourceManagement.Workflow.Activities.EnumerateResourcesActivity.XPathFilterProperty, CType(activitybind2, System.Workflow.ComponentModel.ActivityBind))



    The other activities, updateusers is my updateresourceactivity, CodeEnumerateUsers is what runs for each iteration of the enumerateresourcesactivity and sequenceactivity1 as my sequence activity:

     

    '

     

    'CodeEnumerateUsers

     

    '

     

    Me.CodeEnumerateUsers.Name = "CodeEnumerateUsers"

     

    AddHandler Me.CodeEnumerateUsers.ExecuteCode, AddressOf Me.CodeEnumerateUsers_ExecuteCode

     

    '

     

    'sequenceActivity1

     

    '

     

    Me.sequenceActivity1.Activities.Add(Me.CodeEnumerateUsers)

     

    Me.sequenceActivity1.Activities.Add(Me.UpdateUsers)

     

    Me.sequenceActivity1.Name = "sequenceActivity1"


     

    '

     

    'UpdateUsers

     

    '

     

    Me.UpdateUsers.ActorId = New System.Guid("00000000-0000-0000-0000-000000000000")

     

    Me.UpdateUsers.Name = "UpdateUsers"

    activitybind1.Name =

    "BacklinkUsersDept"

    activitybind1.Path =

    "UpdateUsers_ResourceId1"

     

    Me.UpdateUsers.UpdateParameters = Nothing

     

    Me.UpdateUsers.SetBinding(Microsoft.ResourceManagement.Workflow.Activities.UpdateResourceActivity.ResourceIdProperty, CType(activitybind1, System.Workflow.ComponentModel.ActivityBind))



    Cheers,

    James


    James McAlonan
    Sunday, November 15, 2009 10:22 AM
  • Hi James!
    You can't do a type conversion of the sender to CodeActivity since the direct child is a SequenceActivity and the EnumerateResourcesActivity doesn't know about the CodeActivity so if you do like this instead I believe it should work:

    ResourceType currentItem = EnumerateResourcesActivity.GetCurrentIterationItem(sequenceActivity1 ) as ResourceType;

    Please let me know if it works.

    Edit: This could also be a way of solving it...
    ResourceType currentItem = EnumerateResourcesActivity.GetCurrentIterationItem( (SequenceActivity)this.Parent ) as ResourceType;


    //Henrik
    Henrik Nilsson Blog: http://www.idmcrisis.com Company: Cortego (http://www.cortego.se)
    Sunday, November 15, 2009 11:15 AM
  • Hi Henrik,

    unfortunately neither option works :-(

    Option 1, the vb version of which is:

     

    Dim result As ResourceType = TryCast(EnumerateResourcesActivity.GetCurrentIterationItem(DirectCast(sender, SequenceActivity)), ResourceType)

    throws an error as follows:

    "Unable to cast object of type 'System.Workflow.Activities.CodeActivity' to type 'System.Workflow.Activities.SequenceActivity'."

    Option 2, the vb version of which is:

     

    Dim result As ResourceType = TryCast(EnumerateResourcesActivity.GetCurrentIterationItem(DirectCast(Me.Parent, SequenceActivity)), ResourceType)

    doesn't throw an error, bur result is null

    Cheers,

    James


    James McAlonan
    Sunday, November 15, 2009 8:54 PM
  • Hi James!
    Sorry, I realized the first option I gave you is wrong... The sender is always a CodeActivity so it can't be converted to a Sequence.

    Unless it really needs a CodeActivity as it's direct child activity (I don't believe so) you should be able to get a reference to the direct child activity and use that. Right now it feels I've got to try this out myself and I'll try that tonight (it's morning here right now) but I recommend you to try with different objects and casts, for example.

    Activity a1 = (Activity)Sender;
    CodeActivity a2 = (CodeActivity)Sender;
    CompositeActivity a3 = (CompositeActivity)((CodeActivity)Sender).Parent;
    SequenceActivity a4 = (SequenceActivity )((CodeActivity)Sender).Parent;

    By the way, have you bound the EnumerateResourcesActivity.ActorId property to the parent workflow?

    //Henrik
    Henrik Nilsson Blog: http://www.idmcrisis.com Company: Cortego (http://www.cortego.se)
    Monday, November 16, 2009 6:16 AM
  • Hi Henrik,

    I'll try that, and thanks for your help on this. I really must get a good course on workflows. Give me MV provisioning code and it's no issue but this is all new :-) I haven't bound the EnumerateResourcesActivity.ActorId property to the parent workflow. Is this something that is required for the scenario to work?

    It's morning here too - I'm in Ireland.

    Cheers,

    James
    James McAlonan
    Monday, November 16, 2009 8:13 AM
  • I've got it working!!!
    After having a look at the SequenceActivity it turns out the GetCurrentIterationItem method is static so you'll have to call it using the Type and not the instance that has been my belief.

    First of all if you create your activities like this...

    -Your custom activity
    --EnumerateResourceActivity erActivity
    ---SequenceActivity sActivity
    ----CodeActivity cActivity
    ----More activities...

    Then you'll need to hook an eventhandler to the CodeActivity cActivity:
    this.cActivity.ExecuteCode += new System.EventHandler(this.cActivity_ExecuteCode);


    And then you need to implement the method (this is what I got working):
    void cActivity_ExecuteCode(object sender, EventArgs e)
    {
                SequenceActivity s = (SequenceActivity)((CodeActivity)sender).Parent;
                ResourceType resource = EnumerateResourcesActivity.GetCurrentIterationItem(s) as ResourceType;
    }
    The reason you need to use sender is because a new instance of the sActivity and all it's children is created for each found resource that is about to be iterated and in order to get the current instance we must use sender.Parent because the sender is the CodeActivity instance within the iteration.

    //Henrik

    Henrik Nilsson Blog: http://www.idmcrisis.com Company: Cortego (http://www.cortego.se)
    Monday, November 16, 2009 9:08 AM
  • Nice one Henrik!

    I already have the eventhendler for the cActivity_ExecuteCode in the designer - is this enough?

    It is now enumerating the resources correctly but I am getting a postProcessingError when the workflow is invoked as follows:

    CompositeActivity cannot transition to 'Closed' Status when there are active child context still exist for child activity

    Have you ever seen this - I must be missing something obvious again

    Cheers,

    James
    James McAlonan
    Monday, November 16, 2009 12:07 PM
  • It could be because you haven't set the ActorId property of the EnumerateResourcesActivity but I'm not 100% sure this is needed but I have this method for my custom activity.


    protected override void InitializeProperties()
            {
                // Try to get parent workflow.
                SequentialWorkflow containingWorkflow = null;
                if (!SequentialWorkflow.TryGetContainingWorkflow(this, out containingWorkflow))
                {
                    throw new InvalidOperationException("Could not get parent workflow!");
                }
    
                this.erActivity.ActorId = containingWorkflow.ActorId;
                
                
                base.InitializeProperties();
            }

    Edit: But it sound like your overriding the Execute method of your custom activity and return a...
    return ActivityExecutionStatus.Closed; 

    If thats true I recommend you to remove that whole method and make sure it works then you could try this instead:
     
    return ActivityExecutionStatus.Executing;

    Henrik Nilsson Blog: http://www.idmcrisis.com Company: Cortego (http://www.cortego.se)
    Monday, November 16, 2009 12:11 PM
  • Hi Henrik,

    still not getting this to complete but I reckon I am nearly there. I feel the issue is somewhere in the relationship to the UpdateResourceActivity. When I'm debugging I am finding that UpdateUsers.ResourceId never gets assigned a value - updateusers is my updateresourceactivity.

    So, the code which updates the users is as follows:

    Private Sub CodeEnumerateUsers_ExecuteCode(ByVal sender As Object, ByVal e As EventArgs)

            'Get the current result from EnumerateResources Activity

            Dim sequenceActivity1 As SequenceActivity = DirectCast(DirectCast(sender, CodeActivity).Parent, SequenceActivity)

            Dim result As ResourceType = TryCast(EnumerateResourcesActivity.GetCurrentIterationItem(sequenceActivity1), ResourceType)

     

             If ManagerBeingChanged Then

     

                UpdateUsers.ResourceId = result.ObjectID.GetGuid

                UpdateUsers.UpdateParameters = New UpdateRequestParameter(0) {New UpdateRequestParameter("Manager", UpdateMode.Modify, ManagerValue)}

     

             End If

      

        End Sub

    So, UpdateUsers.ResourceID always seems to be an empty guid, even though result.objectID is assigned a value. I have a ResourceID property assigned to my updateusers activity and it seems to be there that things are falling over. My designer code is as follows:

    <Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _

    Partial Class BacklinkUsersDept

     

        'NOTE: The following procedure is required by the Workflow Designer

        'It can be modified using the Workflow Designer. 

        'Do not modify it using the code editor.

        <System.Diagnostics.DebuggerNonUserCode()> _

        Private Sub InitializeComponent()

            Me.CanModifyActivities = True

            Dim activitybind1 As System.Workflow.ComponentModel.ActivityBind = New System.Workflow.ComponentModel.ActivityBind

            Dim activitybind2 As System.Workflow.ComponentModel.ActivityBind = New System.Workflow.ComponentModel.ActivityBind

            Dim activitybind3 As System.Workflow.ComponentModel.ActivityBind = New System.Workflow.ComponentModel.ActivityBind

            Me.UpdateUsers = New Microsoft.ResourceManagement.Workflow.Activities.UpdateResourceActivity

            Me.CodeEnumerateUsers = New System.Workflow.Activities.CodeActivity

            Me.sequenceActivity1 = New System.Workflow.Activities.SequenceActivity

            Me.EnumerateUsers = New Microsoft.ResourceManagement.Workflow.Activities.EnumerateResourcesActivity

            Me.DetermineRequestParameters = New System.Workflow.Activities.CodeActivity

            Me.GetCurrentRequest = New Microsoft.ResourceManagement.Workflow.Activities.CurrentRequestActivity

            '

            'UpdateUsers

            '

            Me.UpdateUsers.ActorId = New System.Guid("00000000-0000-0000-0000-000000000000")

            Me.UpdateUsers.Name = "UpdateUsers"

            activitybind1.Name = "BacklinkUsersDept"

            activitybind1.Path = "UpdateUsers_ResourceId1"

            Me.UpdateUsers.UpdateParameters = Nothing

            Me.UpdateUsers.SetBinding(Microsoft.ResourceManagement.Workflow.Activities.UpdateResourceActivity.ResourceIdProperty, CType(activitybind1, System.Workflow.ComponentModel.ActivityBind))

            '

            'CodeEnumerateUsers

            '

            Me.CodeEnumerateUsers.Name = "CodeEnumerateUsers"

            AddHandler Me.CodeEnumerateUsers.ExecuteCode, AddressOf Me.CodeEnumerateUsers_ExecuteCode

            '

            'sequenceActivity1

            '

            Me.sequenceActivity1.Activities.Add(Me.CodeEnumerateUsers)

            Me.sequenceActivity1.Activities.Add(Me.UpdateUsers)

            Me.sequenceActivity1.Name = "sequenceActivity1"

            '

            'EnumerateUsers

            '

            Me.EnumerateUsers.Activities.Add(Me.sequenceActivity1)

            Me.EnumerateUsers.ActorId = New System.Guid("00000000-0000-0000-0000-000000000000")

            Me.EnumerateUsers.Name = "EnumerateUsers"

            Me.EnumerateUsers.PageSize = 100

            Me.EnumerateUsers.Selection = Nothing

            Me.EnumerateUsers.SortingAttributes = Nothing

            Me.EnumerateUsers.TotalResultsCount = 0

            activitybind2.Name = "BacklinkUsersDept"

            activitybind2.Path = "EnumerateUsers_XPathFilter1"

            Me.EnumerateUsers.SetBinding(Microsoft.ResourceManagement.Workflow.Activities.EnumerateResourcesActivity.XPathFilterProperty, CType(activitybind2, System.Workflow.ComponentModel.ActivityBind))

            '

            'DetermineRequestParameters

            '

            Me.DetermineRequestParameters.Name = "DetermineRequestParameters"

            AddHandler Me.DetermineRequestParameters.ExecuteCode, AddressOf Me.DetermineRequestParameters_ExecuteCode

            '

            'GetCurrentRequest

            '

            activitybind3.Name = "BacklinkUsersDept"

            activitybind3.Path = "GetCurrentRequest_CurrentRequest1"

            Me.GetCurrentRequest.Name = "GetCurrentRequest"

            Me.GetCurrentRequest.SetBinding(Microsoft.ResourceManagement.Workflow.Activities.CurrentRequestActivity.CurrentRequestProperty, CType(activitybind3, System.Workflow.ComponentModel.ActivityBind))

            '

            'BacklinkUsersDept

            '

            Me.Activities.Add(Me.GetCurrentRequest)

            Me.Activities.Add(Me.DetermineRequestParameters)

            Me.Activities.Add(Me.EnumerateUsers)

            Me.Name = "BacklinkUsersDept"

            Me.CanModifyActivities = False

     

        End Sub

        Private sequenceActivity1 As System.Workflow.Activities.SequenceActivity

        Private DetermineRequestParameters As System.Workflow.Activities.CodeActivity

        Private EnumerateUsers As Microsoft.ResourceManagement.Workflow.Activities.EnumerateResourcesActivity

        Private GetCurrentRequest As Microsoft.ResourceManagement.Workflow.Activities.CurrentRequestActivity

        Private CodeEnumerateUsers As System.Workflow.Activities.CodeActivity

        Private UpdateUsers As Microsoft.ResourceManagement.Workflow.Activities.UpdateResourceActivity

     

     End Class



    This is the ResourceID property assigned to the updateusers activity:

    Public Shared UpdateUsers_ResourceId1Property As System.Workflow.ComponentModel.DependencyProperty = DependencyProperty.Register("UpdateUsers_ResourceId1", GetType(System.Guid), GetType(BacklinkUsersDeptActivity.BacklinkUsersDept))

         <System.ComponentModel.DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Visible)> _

            <System.ComponentModel.BrowsableAttribute(True)> _

                <System.ComponentModel.CategoryAttribute("Parameters")> _

                    Public Property UpdateUsers_ResourceId1() As System.Guid

            Get

                Return CType(MyBase.GetValue(BacklinkUsersDeptActivity.BacklinkUsersDept.UpdateUsers_ResourceId1Property), System.Guid)

     

            End Get

            Set(ByVal value As System.Guid)

                MyBase.SetValue(BacklinkUsersDeptActivity.BacklinkUsersDept.UpdateUsers_ResourceId1Property, value)

             End Set

        End Property

     

     


    I'm sure my daft error is in here somewhere. If you've got it working, what is different in my configuration?

    Cheers,

    James


     


    I'm sure my daft error is in here somewhere. If you've got it working, what is different in my configuration?

    Cheers,

    James



    I'm sure my daft error is in here somewhere. If you've got it working, what is different in my configuration?

    Cheers,

    James


    James McAlonan
    Monday, November 16, 2009 5:31 PM
  • Hi James!
    Remember what I said earlier today about activities are duplicated from the original one for each iteration?
    Having a look of what I did to get the SequenceActivity instance from the current iteration...

    Dim sequenceActivity1 As SequenceActivity = DirectCast (DirectCast (sender, CodeActivity).Parent, SequenceActivity)

    You'll have to do the same thing to get your UpdateUsers activity instance from the current iteration (I'm not sure I'm getting the VB syntax correct here):

    Dim updateUsers1 As UpdateResourceActivity = sequenceActivity1.Activities.OfType< UpdateResourceActivity >().First()

    Anyway, what I'm doing here is using a generics "query" to get the first UpdateResourceActivity that is a children of sequenceActivity1 i.e. the SequenceActivity of the current iteration. You don't need a cast here since we handle that in the query

    //Henrik

    Henrik Nilsson Blog: http://www.idmcrisis.com Company: Cortego (http://www.cortego.se)
    Monday, November 16, 2009 6:34 PM
  • Hi Henrik,

    whats the c# syntax? I have a converter which can resolve it to VB correctly.

    Thanks!

    James
    James McAlonan
    Monday, November 16, 2009 8:45 PM
  • It's exactly as I did it above...
    sequenceActivity1.Activities.OfType< UpdateResourceActivity >().First()

    BTW: I've just made a blog post about the EnumerateResourcesActivity Problem... http://idmcrisis.com/

    Henrik Nilsson Blog: http://www.idmcrisis.com Company: Cortego (http://www.cortego.se)
    Monday, November 16, 2009 9:29 PM
  • I'm getting close now! Now it is doing something strange, but it's progress!

    So, remember way back to my original problem where it was only the last object returned by the enumerate resourcesactivity that was getting updated. Well, now lets say I have 10 results from emunerateresourcesactivity, well it is updating the last object 10 times!

    Go figure! Good blog post by the way

    Cheers,

    James
    James McAlonan
    Monday, November 16, 2009 10:12 PM
  • :-)
    This post is just too long now and we can't continue like this solving you specific problem... contact me from my blog so that I get your email...

    //Henrik

    Henrik Nilsson Blog: http://www.idmcrisis.com Company: Cortego (http://www.cortego.se)
    Monday, November 16, 2009 10:27 PM