3

I am assigned a task on K2 Blackpearl that involves programmatically stopping the process of certain workitems directly without using the product's interface as it does not serve the purpose.

The problem is that in this business requirement, a specific proponent can have multiple document uploads which was possible by making a custom application that reads rows from an excel file and uploading to K2 automatically.

The developers of this solution are no longer present and the details of their work are unavailable.

I am just told that stopping of processes can be done using a custom console application.

Can someone please teach me the right path? I have no prior experience on K2 so this is a huge task for me as I am unfamiliar with its flow.

1 Answer 1

8

K2 APIs are very well documented with sample code and demo applications you can download from K2 underground.

The answer to your question is here: k2underground.com/forums/p/12082/35429.aspx

I've pulled out the relevant lines of code:

// references

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using SourceCode.Workflow.Management;
using SourceCode.Hosting.Client.BaseAPI;

// code

// connection string
SCConnectionStringBuilder scBuilder = new SCConnectionStringBuilder();
scBuilder.Authenticate = true;
scBuilder.IsPrimaryLogin = true;
scBuilder.Integrated = true;
scBuilder.Host = "localhost";
scBuilder.Port = 5555;

// connect to K2 Server
WorkflowManagementServer wfmServer = new WorkflowManagementServer();

wfmServer.CreateConnection();
wfmServer.Connection.Open(scBuilder.ConnectionString);

// optionally get a list of process instances to explore
/*
ProcessInstances procInst = 
  wfmServer.GetProcessInstancesAll(string.Empty, string.Empty, string.Empty);
*/

// when you've got a proc inst you're interested in, stop it.
int _procInstId = 123; // get this from your process instance context
wfmServer.StopProcessInstances(_procInstId);

You can find more code samples here: Tim Byrne's blog re: K2

Out of dozens of available namespaces in the API, the most common namespaces in use are (by the way, the name of the company is SourceCode):

> Sourcecode.Workflow.Client
> SourceCode.Workflow.Management
> SourceCode.SmartObjects.Client

Hope that helps.

1
  • Hi sherif, thanks for the response. I'll check this solution. :) Dec 12, 2010 at 14:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.