Preliminary study of w f Workflow

Source: Internet
Author: User

Tag: workflow Wf

Workflow

According to the definition of WfMC, a workflow is a part or whole of the automatically operated business process. It is manifested in the fact that the participants take actions on files, information or tasks according to the procedures and transmit them among participants. The official website is always abstract to reflect various situations and be more rigorous and objective. You can understand this workflow in this way and review the document process in the office in real work.


Traditional Method: Li Si filed for the project and asked Wang Erma sub-manager to approve the project. Then Zhao sat, Vice President, signed the project and ran to the top-level Director Zhang San.


Workflow operations are completely automated and electronic, saving Li Si from running such a process everywhere.


Simply put, a workflow is a series of interconnected and automatic business activities or tasks. We can regard the entire business process as a river, where the flow is a workflow.

What problems are solved:

Complex Business Process

Tedious workflows and a large number of manual Communication forms

For businesses that frequently change, call different workflows based on different dimensions as much as possible.

This frees people from the inefficiency of traditional manual forms;


Where can I use it?

In what business can such a process be used? In fact, if you understand the above concepts, you will know where to use them.


Key business processes: Order, quotation processing, procurement processing, Contract Review, Customer Hotline processing, supply chain management, etc.
Administrative Management: All administrative forms for manual circulation and processing, such as travel application, overtime application, leave application, vehicle use application, various office supplies application, purchase application, daily report and weekly report.
Personnel Management: Staff Training Arrangement, performance evaluation, job change handling, and employee archive information management.
Financial related categories: payment requests, receivables, daily reimbursement, travel reimbursement, budget and planning applications.
Customer Service: such as customer information management and after-sales service management.


In general, we can find that there will always be such a flow of files or information with consistent structure in the above business, such a workflow can be used to complete a Business Process Based on Different permissions.

 

How to use it?


Configuration environment: VS 2020. Net 4.0 windows 8.1


General Process

 

Configure workflow-Configure permissions-activate Workflow

1. Create a workflow project or create a workflow XAML

A. Create a workflow project



After the corresponding project is created, a program. CS Host Program and a XAML-configured workflow appear.


B. Create a Workflow

The difference is that there is no host program file. Directly add the corresponding workflow.

On the basis of the original project, right-click to add a new project.




2. Add Activity



Vs2010 needs to add or regenerate the active. CS file. In this case, you can add the generated activity to the sequence diagram as a tag in the left-side toolbar. At this time, the generated activity icon is displayed in the corresponding toolbar on the left.




3. Draw activity diagrams


You just need to draw activity diagrams with a large number of workflows on the left and custom activities.

In essence, a series of steps for implementing methods are defined and presented in a visualized manner. The call is to declare the workflow object in the program, and then hand over the work to the corresponding workflow.

 

Instance demo verifyuser

Activity diagram drawn




The user name and password verification process is drawn. This example only demonstrates the workflow and does not combine the corresponding business logic.

Configure the global parameter enuser


Verifyuuser


Public sealed class verifyuser: codeactivity {// defines the input parameter public inargument <userentity. user> touser {Get; set;} public outargument <userentity. user> outuser {set; get;} // if the return value of the activity is returned, the value is derived from codeactivity <tresult> // and returned from the execute method. Protected override void execute (codeactivitycontext context) {user enuser = new user (); // obtain the username enuser. username = touser. get (context ). username; // output parameter enuser. instanceid = context. workflowinstanceid; context. setvalue (outuser, enuser );}


Note that the parameter name must also be configured in the verify attribute bar of the corresponding visual interface. The local machine is enuser, and the parameters to be configured and passed in must be

Otherwise, an error is reported.



Verfiypwd


// Define the input parameter public inargument <userentity. user> touser {Get; set;} // if the return value of the activity is returned, the value is derived from codeactivity <tresult> // and returned from the execute method. Protected override void execute (codeactivitycontext context) {user enuser = new user (); // obtain PWD enuser. username = touser. get (context ). userpwd; enuser. userpwd = touser. get (context ). userpwd ;}

You only need to input parameters here, so no need to output parameters.


Host Program


/// <Summary> /// create and start a workflow-August 23, 2014 20:54:11 /// </Summary> /// <Param name = "request"> related parameters </param> /// <returns> return the workflow id </returns> Public static guid createandrun (user request) {// a generic set of key-value pairs, used to pass in the idictionary parameter <string, Object> input = new dictionary <string, object >{{ "request", request }}; // provides a host for a single instance of the workflow, that is, the created workflow. optional parameter workflowapplication application = new workflowapplication (New verifywf (), input) is input. // application. instancestore = instancestore; // set the current workflow to idle application. persistableidle = (e) => {// terminate the current workflow, instanceunloaded. set (); Return persistableidleaction. unload;}; application. unloaded = (e) => {instanceunloaded. set () ;}; // this method is called when an exception occurs. onunhandledexception = (Ex) => {console. write ("exception"); Return unhandledexceptionaction. terminate;}; guid id = application. ID; // start the current workflow application. run (); // stop the current workflow instanceunloaded. waitone (); Return ID ;}

Here is the host Program of the workflow, which is also called to enter the workflow. Similar to main in Java.

In this example, the workflow is not interrupted, so it does not need to be persisted to the database.


Effect




Http://pan.baidu.com/s/1jGJuYYa download


Conclusion

Workflow solves such a process of traditional manual form transfer. Of course, if you need to interrupt the process, you must combine persistence database. The example here is only a simple understanding of the workflow process. From passing parameters in a program to workflow processing. Similar to delegation, this method is delegated to the corresponding workflow. The workflow processes the parameters and data according to the specified steps. It is a bit similar to the template method. After defining the algorithm flow, you can rewrite the excute method for each activity by yourself. It is also equivalent to the decoupling of process processing and implementation, and suddenly feels quite good.

Besides, I am confused when studying such a new technology, especially when there are not many materials. I studied it for two days and learned about the basics only. When I think back to such a process, I searched everywhere for the image-the blind man touched the image-and then opened it.

It's a bit confusing!

Preliminary study of w f Workflow

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.