Handler是用于控制流程的系统行为,分为rule handler(规则处理程序)与action handler(操作处理程序)。
rule handler可以在流程节点不同的状态中判断规则。在流程中的节点有很多的状态,比如开始、执行、完成等。
- 在这里使用rule handler实现一个提示错误信息的小例子,如何创建一个项目并引用tc的头文件和链接库配置可以参考下面这一篇文章。
- VS2015开发ITK程序环境搭建
- 创建完成后的项目结构如下
- handlerstudy.h文件内容如下,声明需要使用的方法
#pragma once
#include <ict/ict_userservice.h>
#include <tc/iman.h>
#include <tccore/custom.h>
#include <epm/epm_toolkit_tc_utils.h>
#ifdef __cplusplus
extern "C"
{
#endif
extern DLLAPI int CUST_init_module(int *, va_list);
extern DLLAPI int handlerstudy_register_callbacks();
extern EPM_decision_t cust_rulehandler(EPM_rule_message_t msg);
#ifdef __cplusplus
}
#endif
- handlerstudy.cpp文件内容如下
#include <pie/sample_err.h>
#include <ict/ict_userservice.h>
#include<tc/tc.h>
#include <bom/bom.h>
#include <tccore/aom_prop.h>
#include <tccore/custom.h>
#include "handlerstudy_cust.h"
extern DLLAPI int handlerstudy_register_callbacks()
{
printf("handlerstudy_register_callbacks");
int stat = ITK_ok;
CUSTOM_register_exit("handlerstudy", "USER_gs_shell_init_module", (CUSTOM_EXIT_ftn_t)CUST_init_module);
return stat;
}
extern DLLAPI int CUST_init_module(int *decision, va_list args)
{
printf("CUST_init_module111\n");
int stat = ITK_ok;
*decision = ALL_CUSTOMIZATIONS;
// register rule handlers
EPM_register_rule_handler("cust_rulehandler", "Sample Rule Handler", (EPM_rule_handler_t)cust_rulehandler);
return stat;
}
extern EPM_decision_t cust_rulehandler(EPM_rule_message_t msg) {
printf("rule Handler!");
//EPM_decision_t decision = EPM_go;//允许
EPM_decision_t decision = EPM_nogo;//拒绝
return decision;
}
- 生成解决方案,将生成的handlerstudy.dll文件放到%TC_ROOT%\bin下
- 在首选项TC_customization_libraries中添加生成的dll文件名称
- 启动TC胖客户端查看TAO窗口,可以看到注册的handler信息
- 在流程中的完成节点中添加注册的cust_rulehandler
- 返回值是EPM_nogo的时候,错误提示信息如下
到这里一个简单的rule handler的开发流程就完成了。