slein

Hi,

I'd like to add conditions to the transitions (EventDriven + SetState) in my state machine workflow. For example the state machine should transition from state 1 to state 2 when condition x is fulfilled and to state 3 when condition y is fulfilled. Here's a simple example for this scenario:
...
<StateActivity x:Name="stateActivity1" Description="{x:Null}">

<EventDrivenActivity x:Name="eventDrivenActivity1">
<ns0:MyEventActivity x:Name="myEventActivity1" Description="{x:Null}" />
<ConditionedActivityGroup x:Name="conditionedActivityGroup1">
<SetStateActivity x:Name="setStateActivity1" TargetStateName="stateActivity2">
<ConditionedActivityGroup.WhenCondition>
<RuleConditionReference ConditionName="IsTrue" />
</ConditionedActivityGroup.WhenCondition>
</SetStateActivity>
<SetStateActivity x:Name="setStateActivity2" TargetStateName="stateActivity3">
<ConditionedActivityGroup.WhenCondition>
<RuleConditionReference ConditionName="IsFalse" />
</ConditionedActivityGroup.WhenCondition>
</SetStateActivity>
</ConditionedActivityGroup>
</EventDrivenActivity>
</StateActivity>

1. Is the use of a ConditionedActivityGroupActivity the right way to handle this
2. How do I have to define the UntilCondition that it's executed exactly once

3. What happens if a when condition can be fulfilled by more that one SetStateActivity Is an exception thrown If not, which state will the state machine transition to

Thank you in advance.


Re: Windows Workflow Foundation ConditionedActivityGroup within StateMachineWorkflow

ElifOn - MSFT

I am guessing you have already considered using an If Else activity for this scanario. If not i would suggest you to consider it if that meets your needs. For UntilCondition, the easier way to do is to just have a flag and set it whenever a condition is fulfilled, so that you will make sure it will be excacuted only once.
For having more than one conditions becoming true than the latest one -whichever was executed the last- will be setting the next state to be that state mentioned in that SetState

Hope this helps

Elif






Re: Windows Workflow Foundation ConditionedActivityGroup within StateMachineWorkflow

slein

Thanks!

Yes, I have also considered to take an IfElse activity instead but I thought it would be easier to use a CAG when having more than two cases ..

Can you explain the use of a flag for the UntilCondition a little bit more in detail Do I have to write a custom activity for this





Re: Windows Workflow Foundation ConditionedActivityGroup within StateMachineWorkflow

ElifOn - MSFT

In your workflow add the flag bool Executed=false, you can do the following 2 options:

1. in the when condition of every child you may check whatever your rule is besides Executed ==false so that you make sure nothing is yet executed. Set the executed flag to true when you are executing that child ( e.g. add a code activity which sets it to true)

2. the logic above, plus in your until condition check if the executed ==true so that it executes until executed ==true.

Hope this helps

Elif






Re: Windows Workflow Foundation ConditionedActivityGroup within StateMachineWorkflow

Shelly Guo - MSFT

The CAG activity is a good choice if more than one conditions can be true. It sounds to me though that in your case, only one condition can be true (you can't go to two different states at the same time), in which case, I think IfElse would be more appropriate. You may want to give it a second thought.

Thanks.

Shelly