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: