3、流程实例管理
更新时间: 2024-05-06 浏览次数: {{ hits }}

类名

H3.DataModel.IWorkflowInstanceManager

接口清单

序号

接口名称

说明

1

CreateInstance

创建一个流程实例

2

CreateInstanceByDefault

创建一个默认的流程实例

3

GetWorkflowInstance

获取一个流程实例

4

GetWorkflowInstancesByBizObject

根据业务对象ID获取流程实例集合

5

GetParentInstanceInfo

获得父流程的工作流信息

6

RemoveInstance

删除流程实例

7

SendMessage

发送消息给流程实例,以驱动流程实例的运行

基本用法

上述清单中的接口均归属在this.Engine.WorkflowInstanceManager下,如要获取一个流程实例,可使用如下代码形式:

H3.Workflow.Instance.WorkflowInstance instance = this.Engine.WorkflowInstanceManager.GetWorkflowInstance("XXX");

其他接口使用方式与此类似。

接口说明

1. CreateInstance(string bizObjectId, string schemaCode, int workflowVersion, string instanceId, string originator, bool isChildInstance, string parentInstanceID, string parentActivityName, int parentActivityTokenId, bool notify)

1.1. 说明

创建一个流程实例。

1.2. 参数

参数名

说明

bizObjectId

业务对象ID

schemaCode

表单编码

workflowVersion

流程版本号

instanceId

流程实例ID,如果为空则会自动生成

originator

发起人

isChildInstance

是否是子实例

parentInstanceID

如果是子实例,则该项为父实例的ID

parentActivityName

如果是子实例,则该项为发起该实例的父实例的活动ID

parentActivityTokenId

如果是子实例,则该项为发起该实例的父实例的TokenID

notify

发送消息提醒标志,默认为true

1.3. 返回值

类型

说明

string

创建的实例ID

2. CreateInstanceByDefault(string bizObjectId, string schemaCode, string originator)

2.1. 说明

创建一个默认的流程实例。

2.2. 参数

参数名

说明

bizObjectId

业务对象ID

schemaCode

表单编码

originator

发起人

2.3. 返回值

类型

说明

string

创建的实例ID

3. GetWorkflowInstance(string instanceId)

3.1. 说明

获取一个流程实例。

3.2. 参数

参数名

说明

instanceId

实例ID

3.3. 返回值

类型

说明

H3.Workflow.Instance.WorkflowInstance

流程实例对象

4. GetWorkflowInstancesByBizObject(string schemaCode, string bizObjectId)

4.1. 说明

根据业务对象ID获取流程实例集合。

4.2. 参数

参数名

说明

schemaCode

表单编码

bizObjectId

业务对象ID

4.3. 返回值

类型

说明

H3.Workflow.Instance.WorkflowInstance[]

流程实例对象集合

5. GetParentInstanceInfo(string instanceId)

5.1. 说明

获得父流程的工作流信息。

5.2. 参数

参数名

说明

instanceId

实例ID

5.3. 返回值

类型

说明

H3.Workflow.Instance.ParentInstanceInfo

父流程模板的基本信息

6. RemoveInstance(string instanceId, bool autoUpdateBizObject)

6.1. 说明

删除流程实例。

6.2. 参数

参数名

说明

instanceId

要删除的流程实例ID

autoUpdateBizObject

删除之后,是否需要更新业务对象关联的流程实例ID

6.3. 返回值

类型

说明

7. SendMessage(Message message)

7.1. 说明

发送消息给流程实例,以驱动流程实例的运行。

7.2. 参数

参数名

说明

message

发送给流程实例的消息,详见H3.Workflow.Messages.Message

7.3. 返回值

类型

说明

H3.Workflow.Messages.WorkflowInstanceChangeSet

消息处理结果

7.4. 示例

重新激活流程:

H3.Workflow.Messages.ActivateInstanceMessage actInsMessage = new H3.Workflow.Messages.ActivateInstanceMessage("流程Id");
this.Engine.WorkflowInstanceManager.SendMessage(actInsMessage);

结束流程:

H3.Workflow.Instance.WorkflowInstance instance = this.Engine.WorkflowInstanceManager.GetWorkflowInstance("流程Id");
H3.Workflow.Messages.FinishInstanceMessage cancelMessage = new H3.Workflow.Messages.FinishInstanceMessage("流程Id",(int)instance.FinalTokenId);
this.Engine.WorkflowInstanceManager.SendMessage(cancelMessage);

取消流程:

H3.Workflow.Messages.CancelInstanceMessage cancelMessage = new H3.Workflow.Messages.CancelInstanceMessage("流程Id", false);
this.Engine.WorkflowInstanceManager.SendMessage(cancelMessage);