K2 API 有很好的文档,您可以从 K2 地下下载示例代码和演示应用程序。
您的问题的答案在这里:k2underground.com/forums/p/12082/35429.aspx
我已经提取了相关的代码行:
// 参考
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using SourceCode.Workflow.Management;
using SourceCode.Hosting.Client.BaseAPI;
// 代码
// 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);
您可以在此处找到更多代码示例:
Tim Byrne 的博客 re: K2
在 API 中的几十个可用命名空间中,最常用的命名空间是(顺便说一下,公司的名称是 SourceCode):
> Sourcecode.Workflow.Client
> SourceCode.Workflow.Management
> SourceCode.SmartObjects.Client
希望有帮助。