locked
Messaging and ASP.net RRS feed

  • Question

  • Does anyone know where I can get examples of how to work WF into asp.net such that I can have an activity which emails something out and pauses the workflow at that step, then the asp.net page can resume it sending back a value?

    I can do this with a console app, but I'm just not sure how with WCF\asp.net...?

    Thanks,
    Steve

    Sunday, May 23, 2010 11:56 PM

Answers

  • Hi,

    To confirm, you want to have an ASP.NET application that hosts a workflow, and on one page you want to initiate the workflow, and the workflow will send out an email. After it sends the email, it will pause. Then, on another page, you want to send some data into the workflow and resume it. Does that sound right?

    You say you can do this from a console app, but are unsure how to do it from an ASP.NET page?

    Are you using persistence in your console app? Are you using WorkflowApplication as the host?

    Basically the steps you would need to do are like this:

    One the first page, create a WorkflowApplication using your workflow definition, configure a PersistenceStore, and then start the workflow. The workflow would run the custom activity that sends the email, and then you would get to s second custom activity that creates a bookmark. This would cause the workflow to go idle and be persisted. Then on the second page, you would create the WorkflowApplication, Configure the persistence, and then resume the bookmark, which would send the data into the workflow and resume it.

    There is a sample that shows these steps and how to do persistence with WorkflowApplication, called Persisting a Workflow Application. It uses a console application and not ASP.NET, but it has all of the steps needed. You could move those steps over to an ASP.NET host.

    Does this info help? you mention WCF in your message above, were you thinking of using a Workflow Service and just calling that from your ASP.NET app? That would be another approach. I can provide some details on that if needed, just let me know.

    Thanks,

    Steve Danielson [Microsoft]
    This posting is provided "AS IS" with no warranties, and confers no rights.
    Use of included script samples are subject to the terms specified at http://www.microsoft.com/info/cpyright.htm

     

    Monday, May 24, 2010 2:59 PM

All replies

  • Hi,

    To confirm, you want to have an ASP.NET application that hosts a workflow, and on one page you want to initiate the workflow, and the workflow will send out an email. After it sends the email, it will pause. Then, on another page, you want to send some data into the workflow and resume it. Does that sound right?

    You say you can do this from a console app, but are unsure how to do it from an ASP.NET page?

    Are you using persistence in your console app? Are you using WorkflowApplication as the host?

    Basically the steps you would need to do are like this:

    One the first page, create a WorkflowApplication using your workflow definition, configure a PersistenceStore, and then start the workflow. The workflow would run the custom activity that sends the email, and then you would get to s second custom activity that creates a bookmark. This would cause the workflow to go idle and be persisted. Then on the second page, you would create the WorkflowApplication, Configure the persistence, and then resume the bookmark, which would send the data into the workflow and resume it.

    There is a sample that shows these steps and how to do persistence with WorkflowApplication, called Persisting a Workflow Application. It uses a console application and not ASP.NET, but it has all of the steps needed. You could move those steps over to an ASP.NET host.

    Does this info help? you mention WCF in your message above, were you thinking of using a Workflow Service and just calling that from your ASP.NET app? That would be another approach. I can provide some details on that if needed, just let me know.

    Thanks,

    Steve Danielson [Microsoft]
    This posting is provided "AS IS" with no warranties, and confers no rights.
    Use of included script samples are subject to the terms specified at http://www.microsoft.com/info/cpyright.htm

     

    Monday, May 24, 2010 2:59 PM
  • Oh my god, this post helped so much :)  You're understanding my scenario right...asp.net based approval process...

    Honestly I didn't know where to start...I figured that since it was an asp.net app that I'd need to call a Service initially which then would send the RequestID as a parameter into a custom activity flowchart. 

    I have my persistence (bookmarking) working, but I just don't know how to have the asp.net page resume that flow...

     

    It's the setup of the project that has me most confused.  The only two project types are Console and Service...since it's an asp.net project...I assumed I was to use Service and send in the requestID to the service to do it's processing....but you're saying I can just have xaml files sitting somewhere in my webroot to load in as WorkflowApplications?

     

    Thanks for the tips :D

    Steve

    Monday, May 24, 2010 4:47 PM
  • Ok so I moved the main xaml out to my webapp and am trying to load it like this

    IDictionary<string, object> Inputs = new Dictionary<string, object>() { { "RequestID", request.RequestID.ToString() } };
    
          var flow = ActivityXamlServices.Load(Server.MapPath("~/Workflows/LabMed.xaml"));
          WorkflowApplication app = new WorkflowApplication(flow, Inputs);
          
          app.Run();

    But the darn thing keeps throwing a 'Failed to create a 'Settings' from the text 'Assembly references and imported namespaces for internal implementation'.' Line number '6' and line position '102'.

    There's nothing in the LabMed.xaml but a WriteLine Activity.

    Monday, May 24, 2010 10:03 PM
  • How did you create the LabMed.xaml file?

    What if you make a new console workflow app and move the code above (and change it to get the xaml file from the correct path) does it work? Your code looks good.

    I have never seen that error, but it may be possible that it somehow references something in the original project where the xaml was created.

    What is the reason for using xaml workflows instead of compiled types? (which is fine, just curious about your design)

    Can you post the contents of the LabMed.xaml file here, that may give a clue.

    Thanks,

    Steve Danielson [Microsoft]
    This posting is provided "AS IS" with no warranties, and confers no rights.
    Use of included script samples are subject to the terms specified at http://www.microsoft.com/info/cpyright.htm

     

    Tuesday, May 25, 2010 1:48 AM
  • Hey Steve, thanks for the reply

    Well ideally id like the administrators to be able to create their own flows and save out the xaml to a directory in under the webroot, then the webpage would just load the request ID into that.

    The Labmed.xaml is from Add->New->Activity

    I can't seem to see the Activities in my Activity library to set those off...project is defiantly referenced in my webapp, but I can't see the namespace at all.

     

    Heres the LabMed, really it's just generic with a test Writeline

    <Activity mc:Ignorable="sap" x:Class="WebApplication1.Workflows.LabMed" sap:VirtualizedContainerService.HintSize="251,240" mva:VisualBasic.Settings="Assembly references and imported namespaces for internal implementation" xmlns="http://schemas.microsoft.com/netfx/2009/xaml/activities" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mv="clr-namespace:Microsoft.VisualBasic;assembly=System" xmlns:mva="clr-namespace:Microsoft.VisualBasic.Activities;assembly=System.Activities" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:s1="clr-namespace:System;assembly=System" xmlns:s2="clr-namespace:System;assembly=System.Xml" xmlns:s3="clr-namespace:System;assembly=System.Core" xmlns:sad="clr-namespace:System.Activities.Debugger;assembly=System.Activities" xmlns:sap="http://schemas.microsoft.com/netfx/2009/xaml/activities/presentation" xmlns:scg="clr-namespace:System.Collections.Generic;assembly=System" xmlns:scg1="clr-namespace:System.Collections.Generic;assembly=System.ServiceModel" xmlns:scg2="clr-namespace:System.Collections.Generic;assembly=System.Core" xmlns:scg3="clr-namespace:System.Collections.Generic;assembly=mscorlib" xmlns:sd="clr-namespace:System.Data;assembly=System.Data" xmlns:sl="clr-namespace:System.Linq;assembly=System.Core" xmlns:st="clr-namespace:System.Text;assembly=mscorlib" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
     <WriteLine sad:XamlDebuggerXmlReader.FileName="C:\My Dropbox\Projects\Workflows\WF\LabMed.xaml" sap:VirtualizedContainerService.HintSize="211,200" Text="Test" />
    </Activity>

     

    So if I break it all down to bare bones, it's a new asp.net 4 WebApp project with a xaml file added, and I can't seem to get the darn thing loaded :D ...so frustrating because it seems so simple...

    Thanks again for the help

    Steve

    Tuesday, May 25, 2010 3:24 AM
  • Ok, well I started from scratch, bare bones project with a simple xaml, and it seems to run!

    No idea why the code above failed...so now I guess I'll start adding functionality back and see where it dies...perhaps it's the ORM?

    Tuesday, May 25, 2010 4:10 AM