流程实例管理接口
流程实例操作相关接口
基本用法
IWorkflowInstanceManager 接口对象通过 Engine 对象获取,在表单后台的自定义代码界面可以通过以下方式调用 IWorkflowInstanceManager 的任何方法。
WorkflowTemplate node = this.Engine.WorkflowTemplate.GetDraftTemplate("sxlsbdew4xu273");
接口列表
创建一个流程实例
功能描述
创建流程实例。
接口定义
string CreateInstance(
string bizObjectId,
string schemaCode,
int workflowVersion,
string instanceId,
string originator,
bool isChildInstance,
string parentInstanceID,
string parentActivityName,
int parentActivityTokenId,
bool notify);
参数
| 参数名称 |
是否必填 |
类型 |
描述 |
bizObjectId |
是 |
string |
业务对象的 ID。 |
schemaCode |
是 |
string |
流程模板编码。 |
workflowVersion |
是 |
int |
流程版本号。 |
instanceId |
是 |
string |
流程实例的 ID,如果为空则由 Engine 自动生成。 |
originator |
是 |
string |
发起人。 |
isChildInstance |
是 |
bool |
是否为子实例。 |
parentInstanceID |
是 |
string |
子实例对应的父实例 ID。 |
parentActivityName |
是 |
string |
子实例对应的父实例 Activity ID。 |
parentActivityTokenId |
是 |
int |
子实例对应的父实例 TokenID。 |
notify |
是 |
bool |
消息提醒标志,默认为 true。 |
返回值
| 类型 |
描述 |
string |
创建成功返回实例 ID,否则返回 NullInstanceID。 |
示例
string instanceId = this.Engine.WorkflowInstanceManager.CreateInstance(
"bizObjectId",
"schemaCode",
10,
"instanceId",
"发起人用户 Id",
true,
"父流程 Id",
"父流程中的活动名称",
123,
true);
创建流程实例
功能描述
创建流程实例。
接口定义
string CreateInstanceByDefault(
string bizObjectId,
string schemaCode,
string originator);
参数
| 参数名称 |
是否必填 |
类型 |
描述 |
bizObjectId |
是 |
string |
数据实例 ID。 |
schemaCode |
是 |
string |
流程模板编码。 |
originator |
是 |
string |
发起人。 |
返回值
示例
string instanceId = this.Engine.WorkflowInstanceManager.CreateInstanceByDefault(
"bizObjectId",
"schemaCode",
"发起人用户 Id");
获取流程实例状态
功能描述
获取流程实例状态。
接口定义
WorkflowInstance GetWorkflowInstance(string instanceId);
参数
| 参数名称 |
是否必填 |
类型 |
描述 |
instanceId |
是 |
string |
流程实例 ID。 |
返回值
| 类型 |
描述 |
WorkflowInstance |
流程实例上下文。 |
示例
H3.Workflow.Instance.WorkflowInstance instance = this.Engine.WorkflowInstanceManager.GetWorkflowInstance("流程实例 Id");
根据 BizObjectID 获取流程实例集合
功能描述
根据业务对象 ID 获取流程实例集合。
接口定义
WorkflowInstance[] GetWorkflowInstancesByBizObject(string schemaCode, string bizObjectId);
参数
| 参数名称 |
是否必填 |
类型 |
描述 |
schemaCode |
是 |
string |
数据模型编码。 |
bizObjectId |
是 |
string |
业务实例 ID。 |
返回值
| 类型 |
描述 |
WorkflowInstance[] |
当前数据绑定的流程实例集合。 |
示例
H3.Workflow.Instance.WorkflowInstance[] instances = this.Engine.WorkflowInstanceManager.GetWorkflowInstancesByBizObject("表单编码", "业务数据 Id");
获取父流程工作流信息
功能描述
获取父流程工作流信息。
接口定义
ParentInstanceInfo GetParentInstanceInfo(string instanceId);
参数
| 参数名称 |
是否必填 |
类型 |
描述 |
instanceId |
是 |
string |
流程实例 ID。 |
返回值
| 类型 |
描述 |
ParentInstanceInfo |
父流程实例信息。 |
示例
H3.Workflow.Instance.ParentInstanceInfo parentInstance = this.Engine.WorkflowInstanceManager.GetParentInstanceInfo("流程实例 Id");
删除流程实例
功能描述
删除流程实例。
接口定义
void RemoveInstance(string instanceId, bool autoUpdateBizObject);
参数
| 参数名称 |
是否必填 |
类型 |
描述 |
instanceId |
是 |
string |
需删除的流程实例 ID。 |
autoUpdateBizObject |
是 |
bool |
是否更新 BO.WorkflowInstanceId 字段。 |
返回值
无。
示例
this.Engine.WorkflowInstanceManager.RemoveInstance("流程实例 Id", true);
发送消息驱动流程实例运行
功能描述
发送消息驱动流程实例运行。
接口定义
WorkflowInstanceChangeSet SendMessage(Message message);
参数
| 参数名称 |
是否必填 |
类型 |
描述 |
message |
是 |
Message |
发送给流程实例的消息。 |
返回值
| 类型 |
描述 |
WorkflowInstanceChangeSet |
消息处理结果。 |
示例
H3.Workflow.Messages.ActivateInstanceMessage activiteinstanceMessage = new H3.Workflow.Messages.ActivateInstanceMessage(this.Request.InstanceId);
this.Request.Engine.WorkflowInstanceManager.SendMessage(activiteinstanceMessage);
发起流程实例
功能描述
发起流程实例。
接口定义
WorkflowInstanceChangeSet OriginateInstance(
string userId,
string schemaCode,
int workflowVersion,
string bizObjectId,
string instanceId,
AccessMethod accessPoint,
bool finishStartActivity,
string destActivityCode,
bool returnWorkItem,
out string workItemId,
out string errorMessage);
参数
| 参数名称 |
是否必填 |
类型 |
描述 |
userId |
是 |
string |
用户 ID。 |
schemaCode |
是 |
string |
数据模型编码。 |
workflowVersion |
是 |
int |
流程模板版本号。 |
bizObjectId |
是 |
string |
数据模型实例 ID。 |
instanceId |
是 |
string |
流程实例 ID。 |
accessPoint |
是 |
AccessMethod |
接入方式。 |
finishStartActivity |
是 |
bool |
是否自动提交第一个活动。 |
destActivityCode |
是 |
string |
自动提交后的目标活动节点。 |
returnWorkItem |
是 |
bool |
是否返回工作项。 |
workItemId |
是 |
out string |
工作项 ID。 |
errorMessage |
是 |
out string |
错误信息。 |
返回值
| 类型 |
描述 |
WorkflowInstanceChangeSet |
流程状态集合。 |
示例
string bizObjectId = "XXXXXXX-XXXX-XXX";
string instanceId = "XXXX-XXX-XXXXX";
string workItemID = string.Empty;
string errorMsg = string.Empty;
H3.Workflow.Template.WorkflowTemplate wfTemp = this.Request.Engine.WorkflowTemplateManager.GetDefaultWorkflow(bizData.Schema.SchemaCode);
this.Request.Engine.WorkflowInstanceManager.OriginateInstance(
this.Request.UserContext.UserId,
bizData.Schema.SchemaCode,
wfTemp.WorkflowVersion,
bizObjectId,
instanceId,
H3.Workflow.WorkItem.AccessMethod.Web,
true,
string.Empty,
true,
out workItemID,
out errorMsg);