Windows Workflow Foundation (wwf) Study Notes (2)
4,
Sequential Workflow With ParametersThe Workflow can contain parameters. In this way, the flow code selects and judges the subsequent execution based on the values of external parameters. In this example, select the SequentialWorkflow object and you can see that the object has the Parameters attribute. Click this attribute to find the form. Multiple Parameter objects can be defined here, includes attributes such as the object Name and Type. Direction is used to indicate whether the parameter is an input parameter or an output parameter. In this example, the amount input parameters and status output parameters are defined. In this example, the Condition attribute of ifelsebranching is executed as follows: private bool IsApproved (object sender, EventArgs e) {if (Convert. toInt32 (this. parameters ["amount"]. value) <500) return true; else return false;} Here, the final path of ifElse is determined based on the Value of the amount parameter passed by the outside world. In Code1: private void Approved (object sender, EventArgs e) {this. parameters ["status"]. value = "approved";} In Code2: private void Rejected (object sender, EventArgs e) {this. parameters ["status"]. value = "rejected";} Code1 and Code2 provide the output parameter values for the two paths respectively. Look at Program. in cs, how does one call the Dictionary <string, object> parameters = new Dictionary <string, object> (); parameters of the workflow with parameters. add ("amount", Convert. toInt32 (args [0]); // Load the workflow typeType type = typeof (SequentialWorkflowWithParameters); // Create and start an instance of the workflowworkflowRuntime. startWorkflow (type, parameters); in the workflow end event, the output parameter status value is obtained through the OutputParameters attribute. Static void OnWorkflowCompleted (object sender, WorkflowCompletedEventArgs workflowCompletedEventArgs) {// The order status is stored in the "status" "in" parameter string orderStatus = workflowCompletedEventArgs. outputParameters ["status"]. toString (); Console. writeLine ("Order was" + orderStatus); waitHandle. set ();}
Posted on Andersen's Fairy Tale reading (1152) Comments (2) EDIT favorites
Comment
Xia Lin
Posted @
At the top, I need to study this part of my work and discuss it together.
Xu hui replied to more comments
- # Re: Windows Workflow Foundation (wwf) Study Notes (2)
See the wind
Posted @
Join the WinFX team to study WinFX and reply to more comments.
# Re: Windows Workflow Foundation (wwf) Study Notes (2)