State Machine Workflow - list available events
-
This seems like an obvious question to me, but I'm having trouble tracking down an answer. I am trying to put together an application that is driven by a state machine workflow behind the scenes. The UI has a menu, the contents of which change depending on the current state of the workflow. Basically, I would like the menu to reflect the list of actions available for the current state. I can query a state machine workflow to find the list of available state transitions, but that doesn't really tell me what I need to know. I guess I'm looking for a way to get hold of a list the events which the workflow will respond to in its current state. I can't be the first person to want to do this. I want the workflow to dynamically supply the options available to the user through the UI depending on its current state. What is the recommended best practice for achieving this? Is it even possible, and will I end up having to set up my own cross-reference somewhere? I am relatively new to .NET WF, but familiar with the concept of state machines and it's possible I'm expecting too much of WF.
-
This seems like an obvious question to me, but I'm having trouble tracking down an answer. I am trying to put together an application that is driven by a state machine workflow behind the scenes. The UI has a menu, the contents of which change depending on the current state of the workflow. Basically, I would like the menu to reflect the list of actions available for the current state. I can query a state machine workflow to find the list of available state transitions, but that doesn't really tell me what I need to know. I guess I'm looking for a way to get hold of a list the events which the workflow will respond to in its current state. I can't be the first person to want to do this. I want the workflow to dynamically supply the options available to the user through the UI depending on its current state. What is the recommended best practice for achieving this? Is it even possible, and will I end up having to set up my own cross-reference somewhere? I am relatively new to .NET WF, but familiar with the concept of state machines and it's possible I'm expecting too much of WF.
If you don't get an answer here try the MSDN WF forum.
Kevin
-
This seems like an obvious question to me, but I'm having trouble tracking down an answer. I am trying to put together an application that is driven by a state machine workflow behind the scenes. The UI has a menu, the contents of which change depending on the current state of the workflow. Basically, I would like the menu to reflect the list of actions available for the current state. I can query a state machine workflow to find the list of available state transitions, but that doesn't really tell me what I need to know. I guess I'm looking for a way to get hold of a list the events which the workflow will respond to in its current state. I can't be the first person to want to do this. I want the workflow to dynamically supply the options available to the user through the UI depending on its current state. What is the recommended best practice for achieving this? Is it even possible, and will I end up having to set up my own cross-reference somewhere? I am relatively new to .NET WF, but familiar with the concept of state machines and it's possible I'm expecting too much of WF.
ReadOnlyCollection<WorkflowQueueInfo> subActivities = stateMachineInstance.WorkflowInstance.GetWorkflowQueueData();
Collection<string> MessagesAllowed = new Collection<string>();
foreach (WorkflowQueueInfo queueInfo in subActivities)
{
// Cast the Queue Name to the class Event Queue Name to get the event name string
EventQueueName queuename = queueInfo.QueueName as EventQueueName;if (queuename != null) { MessagesAllowed.Add(queuename.MethodName); }
}
When WorkflowState Changed, do above to retrieve the event names of current state (MessagesAllowed has them), then update UI, it is ok. hope it can help you!