You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
JK_ITK/jf_itk/jk_auto_create_process.cpp

97 lines
3.0 KiB

/*#include "tc_log.h"
#include "ocilib.h"
#include "string_utils.h"
//#include <ics/ics2.h>
//#include <ict/ict_userservice.h>
#include <iostream>
#include <tc/tc_macros.h>
#include <epm/epm_task_template_itk.h>
#include <sa/user.h>
using namespace std;
extern "C" int POM_AM__set_application_bypass(logical bypass);*/
#include <epm/epm_task_template_itk.h>
#include <iostream>
#include <sa/user.h>
#include <tccore/aom_prop.h>
#include <epm/signoff.h>
using namespace std;
extern "C" int POM_AM__set_application_bypass(logical bypass);
#define DOFREE(obj) \
{ \
if(obj) \
{ \
MEM_free(obj); \
obj = NULL; \
} \
}
int jk_auto_create_process(EPM_action_message_t msg)
{
tag_t targetTag,new_process = NULLTAG;;
tag_t template_tag;
tag_t *attachments = NULL,user_tag;
attachments = (tag_t *) MEM_alloc(1);
ITK__convert_uid_to_tag("nbaxT1swYvbLjA",&targetTag);
attachments[0]=targetTag;
int* att_types = NULL;
att_types = (int*) MEM_alloc (1);
att_types[0] = EPM_target_attachment;
cout<<"查找流程模板并发起..."<<endl;
ITKCALL( EPM_find_template( "00001测试自动发起流程",PROCESS_TEMPLATE, &template_tag ) );
cout<<"创建流程"<<endl;
ITKCALL( EPM_create_process("新流程的名称", "", template_tag, 1, attachments, att_types, &new_process));
cout<<"指派人员"<<endl;
ITKCALL( SA_find_user( "admin", &user_tag ));
int cnt_task=0;tag_t * tasks=NULLTAG;
ITKCALL(EPM_ask_tasks( new_process, EPM_started, &cnt_task, &tasks ));
cout<<"设置责任方.."<<endl;
for(int i=0;i<cnt_task;i++)
{
tag_t subtask=tasks[i];
char * sub_task_object_type=NULL;
ITKCALL( AOM_ask_value_string( subtask , "object_type" , &sub_task_object_type ));
if( strstr(sub_task_object_type, "DoTask" ) != NULL )//如果是编制节点
{
ITKCALL( EPM_assign_responsible_party( subtask, user_tag));//设置编制节点的责任方
}else if( strstr(sub_task_object_type, "ReviewTask" ) != NULL )//如果是审核节点
{
POM_AM__set_application_bypass( TRUE );
tag_t tmp_select_signoff_task = NULLTAG;
ITKCALL( EPM_ask_sub_task( subtask , EPM_select_signoff_team_task , &tmp_select_signoff_task ));
tag_t login_group = NULLTAG;
int mem_cnt = 0;
tag_t * members = NULL;
int signoff_cnt = 0;
tag_t * signoffs = NULL;
ITKCALL( SA_ask_user_login_group( user_tag , &login_group ));
ITKCALL( SA_find_groupmembers( user_tag , login_group , &mem_cnt , &members ));
ITKCALL( EPM_create_adhoc_signoff( tmp_select_signoff_task , members[0] , &signoff_cnt , &signoffs ) );
ITKCALL( EPM_set_adhoc_signoff_selection_done( tmp_select_signoff_task , true ) );
if( signoffs )
{
MEM_free( signoffs );
signoffs = NULL;
}
ITKCALL(EPM_trigger_action(tmp_select_signoff_task,EPM_complete_action, ""));
POM_AM__set_application_bypass( FALSE );
}
}
//设置审核节点的指派人
//指派流程人员
/*if(attachments!=NULL)
{
MEM_free(attachments);
attachments=NULL;
}
if(att_types!=NULL)
{
MEM_free(att_types);
att_types=NULL;
}
DOFREE(tasks);*/
return 0;
}