GotSpeech.NET

The online community for Microsoft Speech Server developers
Welcome to GotSpeech.NET Sign in | Join | Help
in Search
Computer-Talk

Problem with passing variable between Workflows that contain Sub-Workflows

Last post 07-02-2008, 8:17 AM by JonHoward. 11 replies.
Sort Posts: Previous Next
  •  04-18-2008, 11:06 AM 5246

    Problem with passing variable between Workflows that contain Sub-Workflows

    Ok, here is the situation:

    We have a MainWorkflow which invokes a number of other workflows. Lets call this Workflow A. From A, I invoke a login workflow which contains all the authentication code. When this workflow completes, we will know all the users info. This is Workflow B.

    From Workflow B, we must pass the user info back to workflow A, so that when workflow C is invoked, the user info is available to be passed to workflow C.

    From Workflow C, we will have other sub-workflows that will be invoked that must also have access to this user info.

    We have tried using Dependency Properties but to no Avail.

    Any help would be much apperciated.

    NOTE: We have read Marshall's blog post about passing variables from one workflow to another, and that is where we heard of Dependency Properties.
     

  •  04-18-2008, 11:38 AM 5251 in reply to 5246

    Re: Problem with passing variable between Workflows that contain Sub-Workflows

    Did you tried with using InstanceDependencey properties.

    Please try this one : http://gotspeech.net/blogs/marshallharrison/archive/2008/01/14/creating-subflows.aspx.

     

    Thanks,

    Suresh. 


    Suresh S
    Tech Lead
  •  04-18-2008, 11:38 AM 5252 in reply to 5246

    Re: Problem with passing variable between Workflows that contain Sub-Workflows

    Hi Jon

    I had a similar question a while back...hopefully this thread will help you....

    http://gotspeech.net/forums/thread/3530.aspx

     

    Brian


    Brian Campbell
    Speech Developer
    Micro Design Centre Inc.
    905-918-3027
  •  04-18-2008, 11:57 AM 5253 in reply to 5246

    Re: Problem with passing variable between Workflows that contain Sub-Workflows

    Hello John,

    One way to handle this situation is to create a Dictionary as a property in the main or parent workflow like this...

    private Dictionary<string, object> _session = new Dictionary<string, object>();

    public Dictionary<String, Object> Session
    {
      
    get { return _session; }
      
    set { _session = value; }
    }

    You can then add any Key/Value pair that is used as a parameter anywhere in the callflow like this...

    <parentWorkflow>.Session.Add("SomeParameter", someValue);

    Then in your sub-workflows use this syntax like this...

    Activity workflowActivity = this;
    while (workflowActivity.Parent != null)
    {
        workflowActivity = workflowActivity.Parent;
    }
    _parentWorkFlow = (
    SomeWorkFlow)workflowActivity;
    string subWorkFlowParameter = _parentWorkFlow.Session["SomeParameter"].ToString();

    This works especially well when you need to maintain session information for the life of the call session.  Once the Session dictionary is loaded you can use what is in that object anywhere in the call flow or any sub-call flow.  This is kind of a Web page paradigm.

     Also look into the use of InstanceDependencyProperty for passing in parameters to custom workflows in a SpeechSequenceActivity.  They work the same as a DependencyProperty but they are part of the Microsoft.SpeechServer.Dialog namespace.  I have used them with no problems.

    Let me know how it works.

    kstep

  •  04-18-2008, 3:58 PM 5259 in reply to 5253

    Re: Problem with passing variable between Workflows that contain Sub-Workflows

    So as a follow up statement:

    The problem we were encountering had to do with the way we initially set up our project. We started a MainWorkflow, and from this invoked all of our other Workflows (which were created as VoiceResponseWorkflow files). This seemed to be the reason we could not pass parameters back and forth from the Mainworkflow to all of the other sub-workflows.

     Instead, we needed to create all the other sub-workflows as VoiceResponseSequenceActivity files. When we created the sub-workflows as activities and complied the project, the sub-workflows appeared in the toolbox under the Project Components section. This enabled us to drag the specific activity (purple gear icon) onto the Mainworkflow. We could then pass parameters from one activity back to the Mainworkflow, and then from the Mainworkflow to the activities.

     This was done via the code that was posted above by kstep. So, a word to the wise, use VoiceResponseSequenceActivity files instead of VoiceResponseWorkflow files if you plan on passing parameters from one to the other.
     


     

  •  05-09-2008, 10:34 AM 5471 in reply to 5259

    Re: Problem with passing variable between Workflows that contain Sub-Workflows

    I've recently found that nesting of VoiceResponseSequencyActivity files will cause some major performance problems due to deep cloning of the activities.

    Still working on this issue - I'll blog and post more info once I'm finished.


    Marshall Harrison
    Microsoft MVP, Office Communications Server


    www.GoldSys.com
    W: 303.447.2774
    H: 904.342-6205

    the gotspeech guy
  •  05-09-2008, 11:13 AM 5472 in reply to 5471

    Re: Problem with passing variable between Workflows that contain Sub-Workflows

    I read a post you made about this earlier. Eagerly awaiting your blog post to see what it is you discovered.
  •  05-09-2008, 1:59 PM 5495 in reply to 5253

    Re: Problem with passing variable between Workflows that contain Sub-Workflows

    kstep,

     

    What are you declaring _parentWorkFlow as? I have tried to use this but am missing something along the way.

     

    _parentWorkFlow = (InTouchWorkflow)workflowActivity;

     

    thanks

    Rick

     

     

  •  05-09-2008, 3:19 PM 5496 in reply to 5495

    Re: Problem with passing variable between Workflows that contain Sub-Workflows

    Hello Rick,

     _parentWorkFlow is a private local variable.  It is created inside your custom speech activity like this...

    private YourMainWorkflow _parentWorkFlow;

    Activity workflowActivity = this;
    while (workflowActivity.Parent != null)
    {
        workflowActivity = workflowActivity.Parent;
    }
    _parentWorkFlow = (
    YourMainWorkflow)workflowActivity;
    string subWorkFlowParameter = _parentWorkFlow.Session["SomeParameter"].ToString();

  •  05-09-2008, 3:45 PM 5497 in reply to 5496

    Re: Problem with passing variable between Workflows that contain Sub-Workflows

    Thanks I will give this a try.

     

    Rick

     

  •  07-02-2008, 5:26 AM 6127 in reply to 5246

    Re: Problem with passing variable between Workflows that contain Sub-Workflows

    Hey Jon

     I have read these posts and I have to say they helped me solve a problem in a way, but i have a question, the Main Workflow (u mentioned as Workflow A) what type of Workflow is it? I mean is it just a .NET workflow application or is it a Speech Application?


    Best Regards
    Omar Sultan
  •  07-02-2008, 8:17 AM 6130 in reply to 6127

    Re: Problem with passing variable between Workflows that contain Sub-Workflows

    Hi Omar,

    The Main Workflow (Workflow A) is a Voice Response Sequential Workflow. 

View as RSS news feed in XML