[Reprint] use C # code approval/signing K2 Blackpearl Process

Source: Internet
Author: User

The following describes how to use the code approval and signing process k2 blackpearl to explore K2 Blackpearl.

 

// Execute the action
Private void MyAction (string argAction)
{
// Create a connection object
SourceCode. Workflow. Client. Connection wfcon = new SourceCode. Workflow. Client. Connection ();
// Open the K2 connection
String k2Server = System. Configuration. ConfigurationManager. receivettings ["K2Server"];
String workflowServicePort = System. Configuration. ConfigurationManager. receivettings ["WorkflowServicePort"];
Wfcon. Open (k2Server + ":" + workflowServicePort );

// Open the current user
Wfcon. ImpersonateUser (HttpContext. Current. User. Identity. Name );

// Obtain the Process List
SourceCode. Workflow. Client. WorklistItem worklistitem = wfcon. OpenWorklistItem (SN );

/*
// Obtain the process instance id
String [] _ SN = SN. Split ('_');
Int _ ID = int. Parse (_ SN [0]);
// Obtain the process instance
SourceCode. Workflow. Client. ProcessInstance proInst = wfcon. OpenProcessInstance (_ ID );
// DataFields value assignment
ProInst. DataFields ["TaskUsers"]. Value = ddlTaskUsers. SelectedValue;
// Update DataFields
Procinst. Update ();
*/

// Search for action)
Foreach (SourceCode. Workflow. Client. Action action in worklistitem. Actions)
{
If (action. Name. Equals (argAction ))
{
// Execute the action
Action. Execute ();
}
}
Wfcon. Dispose ();
}

// Transfer
Protected void ProcRedirect (string argEmpName)
{
// Create a connection object
SourceCode. Workflow. Client. Connection wfcon = new SourceCode. Workflow. Client. Connection ();

// Open the K2 connection
String k2Server = System. Configuration. ConfigurationManager. receivettings ["K2Server"];
String workflowServicePort = System. Configuration. ConfigurationManager. receivettings ["WorkflowServicePort"];
Wfcon. Open (k2Server + ":" + workflowServicePort );

Wfcon. ImpersonateUser (HttpContext. Current. User. Identity. Name );

// Obtain the Process List
SourceCode. Workflow. Client. WorklistItem worklistitem = wfcon. OpenWorklistItem (SN );
// Transfer
Worklistitem. Redirect (argEmpName );
// Release resources
Wfcon. Dispose ();}

The flowchart is as follows:

 

 

 

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.