Dictionary parameters = new Dictionary ();
base.SetValue (Workflow1.ResultProperty, value);
switch to the workflow code-behind file workflow1.cs, right – attack code space, select “Insert Snippet” – “Other” – “Workflow” – “WorkflowDependency-Property” into a dependency property, as shown below. Since then, the system will automatically stop the insertion point to be re-established in the name of the property.
ss.RunWorkflow (wi.InstanceId);
[DesignerSerializationVisibilityAttribute (Designer SerializationVisibility.Visible)]
5, design workflow
[DescriptionAttribute ("Result")]
WorkflowRuntime wfRuntime = Application ["WorkflowRuntime"] as System.Workflow.Runtime.WorkflowRuntime;
the above steps, the system automatically opens the workflow design interface. The above analysis, we drag a ifElseActivity type of activity to the workflow designer. Then, drag the left and right branches, respectively, two code activities, the final result as shown below.
get
}
{
private void RedirectDebit (object sender, EventArgs e)
private void InitiateWorkFlow ()
Now, enter the number 200 and press “Submit” button, you will be to navigate to the following page:
{
}
start VS2008, click the menu “File”"New”"Site”, create a name for the IntroASPNET35WWF The ASP.NET 3.5 site.
parameters.Add (“Amount”, Convert.ToInt32 (TextBox1.T ext));
System.Workflow.Runtime.WorkflowRuntime workflowRuntime =
}
{
{
return ((string) (base.GetValue (Workflow1.ResultProperty)));
{
Summary
[DescriptionAttribute ("Amount")]
{< br /> WorkflowInstance wi = wfRuntime.CreateWorkflow (typeof (WorkflowLibrary2.W orkflow1), parameters);
return ((string) (base.GetValue (Workflow1.AmountProperty)));
{
< br /> Then, create a workflow instance WorkFlowInstance (Note how the parameters passed to the method of CreateWorkflow).
seven ExecuteCode activities defined code attribute value


InitiateWorkFlow ();
}
method in this event, please note the type of event parameters eventArgument become WorkflowCompletedEventArgs. This parameter has a collection called Outputparametes, which contains a collection of workflow parameters. Therefore, we can retrieve workflow parameters “Result” value to our design page for the redirect.
eight, start a workflow
press your browser Back button to return to the default page, then enter the number 50, press the “submit” button, you will be to navigate to the following page:
Through this code, we can ensure
Global.asax, and add the following code in the workflow.
{
Application ["WorkflowRuntime"] as System.Workflow.Runtime.WorkflowRuntime;
wi.Start ();
get
protected void Button1_Click (object sender, EventArgs e)
new System.Workflow.Runtime.WorkflowRuntime ();
public static DependencyProperty ResultProperty = DependencyProperty.Register (“Result”, typeof (string), typeof (Workflow1));
System.Workflow.Runtime.WorkflowRuntime workflowRuntime =
because we want to achieve in this case, the amount of RMB according to user input while the user navigates to a different a different page. Therefore, we in the default page default.asp x add some simple content, as shown below (note the use of master pages which):
{
if (this . Amount> 100)
[BrowsableAttribute (true)]
set
{
this.Result = “Debit.aspx”;
e.Result = true; < br /> private void ValidateAmount (object sender, ConditionalEventArgs e)
Next, we see the realization of underground events WorkFlowCompleted code:
[CategoryAttribute ("Amount Category")]
ManualWorkflowSchedulerService ss = wfRuntime . GetService ();
}
/ / HttpContext.Current.Session ["WorkflowID"] = wi.InstanceId;
Then, in code-behind file to create the initial charge of and start the work flow of private methods InitiateWorkFlow, as follows:
Please note that the above two properties of the data type.
}
base.SetValue (Workflow1.AmountProperty, value);
workflowRuntime.StartRuntime ();
}
Application ["WorkflowRuntime"] = workflowRuntime;
nine, observe the results

Next, add two turn ordinary pages, one page of information the bank deposits credit.aspx, another is to show loan information page debit.aspx < / strong>. When the user enters the amount is less than 100, the user is navigating to the page debit.aspx; Otherwise, the navigation to the page credit.aspx .
}
HttpContext.Current.Response.Redirect ((string) e.Ou tputParameters ["Result "]);< br /> set


workflow runtime instance is unique. Please refer to later understand the code here.
private void RedirectCredit (object sender, EventArgs e)
right-click the sample Web site, select “Add Reference.” In the “Add Reference” dialog box, switch to the “. NET” tab, select the relevant workflow shown assembly. Finally, click “OK” button (please note that these versions of the assembly is different).
static void wfRuntime_WorkflowCompleted (object sender, WorkflowCompletedEventArgs e)
workflowRuntime.StopRuntime ();
workflowRuntime.AddService (manualService);
public string Result
[DesignerSerializationVisibilityAttribute (Designer SerializationVisibility.Visible)]
public static DependencyProperty AmountProperty = DependencyProperty.Register (“Amount”, typeof (string), typeof (Workflow1));
notice that the code appears in an Amount attribute for its definition way, please read on.
Now, we briefly discuss ManualWorkflowSchedulerService. In the previous section, created during the Application_Start event in the WorkflowRuntime instance. In the Web application processes the request, will remain the object. The above code shows how the Application object in ASP.NET to retrieve the WorkflowRuntime instance. After using the GetService method used to start workflow to retrieve ManualWorkflowSchedulerService, in order to run the workflow synchronization. To this end, calls defined in the WorkflowRuntime class CreateWorkflow method, then calls returned from the CreateWorkflow call the Start method WorkflowInstance object. As the ManualWorkflowSchedulerService added to the WorkflowRuntime, so call RunWorkflow method, passing WorkflowInstance object InstanceId.
}
public string Amount
2010 年 12 月 05 日
}
given above is only an entry-level example, aims to explore the ASP.NET 3.5 Environment and WWF jointly developed the basic principles. Future article, I will continue to give ASP.NET 3.5 Environment and WWF jointly developed more complex and application examples.
The code implements the following functions:
and then add the workflow runtime WorkflowCompleted event handler function.
}
< br /> {
start a workflow instance.
this article describes an ASP.NET 3.5 Web applications using the WWF in the basic instance. Because VS2008 does not provide ready-made support for ASP.NET 3.5 Web application template, relative to the basic console workflow instance, a little bit more complex to implement. So, read below and please note the difference between the console workflow application.
switch to the workflow design surface, followed by the Properties dialog box, the activities of the conditions of the left and right branches of the two activities ExecuteCode properties of the function code name to RedirectCredit and RedirectDebit. Then double-click the function and enter the following code:
choose the left branch of the figure above ifElseActivity activities, through the “Properties” dialog box to set the trigger condition is “condition code”, then enter the name of their condition function ValidateAmount. Press the Enter key, switch to the code-behind file, enter the following code:
void Application_End (object sender, EventArgs e)
{
In this case, we want to create two working flow attributes Amount and Result. Use similar ideas to create these two properties. Finally, get the code shown below (basically automatic generation, only need to modify a property name and data type back to typeof):
C # 2010-12-05 21:13:50 0 comments Word Count: workflow programming step by step ( 11: ASP.NET 3.5 Programming Introduction to Workflow ) [Note] Section 10 of this series Listen to talk about activities on the application, fill later on.
[CategoryAttribute ("Result Category")]
[BrowsableAttribute (true)]
{
}

because we want to control only when the workflow instance is running, so add a sample Global Application Class file Global.asax. Right click the sample site, select “Add New Item.” In the “Add New Item” dialog box, select “Global Application Class” template to add the file Global.asax, as shown.
and then declare a WorkflowRuntime object and from the site of the workflow runtime object (see above for the global application class application_Start event code) loaded in it.
wfRuntime.WorkflowCompleted = new EventHandler (wfRuntime_W orkflowCompleted);
}
parameters.Add (“Result”, “”);
new System.Workflow.Runtime . Hosting.ManualWorkflowSche dulerService ();
System.Workflow.Runtime.Hosting.ManualWorkflowSche dulerService manualService =
this.Result = “Credit.aspx”;

0 share to:
According to the previous description, Our dictionary defines it as a collection object in the workflow between the host and the workflow to pass arguments. Here, we have two parameters (Amount and Result) added to the collection.
void Application_Start (object sender, EventArgs e)
Press F5 to run the console program, generally goes well, will be shown as running a snapshot.
six, define workflow properties
{
In addition, two dependency properties defined here is a typical workflow instance is passed to the parameters of the way. Moreover, the workflow host (in this case is ASP.NET web application) and workflow to pass parameters between the easiest way is to use a dictionary collection, which will be used later.

} < br /> double-click the Default.aspx page in the sample sites in the button control, and the button Click event handler function, enter the following code:
Fourth, add sequential workflow library
click menu ” File “|” add “|” New Project “, add a named WorkflowLibrary1 sequential workflow library, as shown.