|
|
#include"kutil.h"
|
|
|
#define debug true
|
|
|
#define ITK_err 919012
|
|
|
|
|
|
int Connor_Review_Person(EPM_action_message_t msg) {
|
|
|
int ifail = ITK_ok, arg_cnt = 0, att_cnt = 0, task_count = 0, ifTabel = 0;//0不是table属性,1是table属性
|
|
|
char* arg = NULL, * argflag = NULL, * argvalue = NULL;
|
|
|
string type, proName;
|
|
|
string processNameRel;
|
|
|
vector<string> types;
|
|
|
vector<string> proNames;
|
|
|
tag_t* attachments = NULLTAG, task_tag = NULLTAG, rootTask_tag = NULLTAG, * task_tags = NULLTAG;
|
|
|
set<string> sh_set;
|
|
|
|
|
|
WriteLog(debug, "开始执行:提取table属性作为审核节点的审核人(Connor_Review_Person) ...");
|
|
|
arg_cnt = TC_number_of_arguments(msg.arguments);
|
|
|
if (arg_cnt > 0) {
|
|
|
for (int i = 0; i < arg_cnt; i++) {
|
|
|
arg = TC_next_argument(msg.arguments);
|
|
|
ITKCALL(ifail = ITK_ask_argument_named_value(arg, &argflag, &argvalue));
|
|
|
if (strcmp(argflag, "From") == 0) {
|
|
|
type.assign(argvalue);
|
|
|
}
|
|
|
else if (strcmp(argflag, "Person") == 0) {
|
|
|
proName.assign(argvalue);
|
|
|
}
|
|
|
MEM_free(argflag);
|
|
|
MEM_free(argvalue);
|
|
|
}
|
|
|
}
|
|
|
else {
|
|
|
EMH_store_error_s1(EMH_severity_error, ITK_err, "未配置流程参数");
|
|
|
ifail = 1;
|
|
|
goto end;
|
|
|
}
|
|
|
{
|
|
|
Split(type, ";", types);
|
|
|
if (types.size() == 0) {
|
|
|
EMH_store_error_s1(EMH_severity_error, ITK_err, "未配置流程参数:-From");
|
|
|
goto end;
|
|
|
}
|
|
|
if (strstr(proName.c_str(), ".") != NULL) {
|
|
|
ifTabel = 1;
|
|
|
Split(proName, ".", proNames);
|
|
|
if (proNames.size() == 0) {
|
|
|
EMH_store_error_s1(EMH_severity_error, ITK_err, "未配置流程参数:-Person");
|
|
|
goto end;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
//拿到当前节点
|
|
|
task_tag = msg.task;
|
|
|
if (task_tag == NULLTAG) {
|
|
|
goto end;
|
|
|
}
|
|
|
ITKCALL(ifail = EPM_ask_root_task(task_tag, &rootTask_tag));
|
|
|
//获取目标下所有对象
|
|
|
ITKCALL(ifail = EPM_ask_attachments(rootTask_tag, EPM_target_attachment, &att_cnt, &attachments));
|
|
|
if (att_cnt == 0) {
|
|
|
goto end;
|
|
|
}
|
|
|
char* task_type = NULL;
|
|
|
WSOM_ask_object_type2(task_tag, &task_type);
|
|
|
printf("当前节点的类型为:%s\n", task_type);
|
|
|
char* processName;
|
|
|
EPM_ask_name2(task_tag, &processName);
|
|
|
printf("获取的流程节点名称 ==== %s \n", processName);
|
|
|
int ifPromote = 0;
|
|
|
if (strcmp("EPMReviewTask", task_type) == 0) {
|
|
|
vector<string> ans;
|
|
|
Split(processName, "_", ans);
|
|
|
processNameRel.append(ans[0]);
|
|
|
}
|
|
|
else if (strcmp("EPMAcknowledgeTask", task_type) == 0) {
|
|
|
processNameRel.append(processName);
|
|
|
}
|
|
|
for (int i = 0; i < att_cnt; i++)
|
|
|
{
|
|
|
tag_t attachment = attachments[i];
|
|
|
|
|
|
for each (string type in types)
|
|
|
{
|
|
|
if (!isTypeOf(attachment, type.c_str()))
|
|
|
{
|
|
|
continue;
|
|
|
}
|
|
|
if (ifTabel == 0) {
|
|
|
char** values = NULL;
|
|
|
int value_count = 0;
|
|
|
AOM_ask_value_strings(attachment, proName.c_str(), &value_count, &values);
|
|
|
for (int j = 0; j < value_count; j++) {
|
|
|
if (sh_set.insert(values[j]).second == false) {
|
|
|
continue;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
else if (ifTabel == 1) {
|
|
|
printf("取表的内容=====\n");
|
|
|
tag_t* tags = NULL, * rows = NULLTAG;
|
|
|
int value_count = 0;
|
|
|
int tags_count = 0;
|
|
|
//得到表
|
|
|
printf("表名为:%s====表行为:%s=====表列为:%s\n", proNames[0].c_str(), proNames[1].c_str(), proNames[2].c_str());
|
|
|
AOM_ask_value_tags(attachment, proNames[0].c_str(), &tags_count, &tags);
|
|
|
//得到行
|
|
|
printf("取行的数据===\n");
|
|
|
for (int j = 0; j < tags_count; j++) {
|
|
|
char* cellValue = NULL;
|
|
|
char* isFlag = NULL, * changeName;
|
|
|
AOM_ask_value_string(tags[j], proNames[2].c_str(), &cellValue);
|
|
|
AOM_ask_value_string(tags[j], "ld6_YNChange", &isFlag);
|
|
|
AOM_ask_value_string(tags[j], "ld6_ChangeTaskName", &changeName);
|
|
|
|
|
|
//printf("得到的更改项为:%s\n", changeName);
|
|
|
if (strcmp(changeName, processNameRel.c_str()) != 0) {
|
|
|
continue;
|
|
|
}
|
|
|
printf("isFlag为:%s\n", isFlag);
|
|
|
printf("得到的用户名ID为:%s\n", cellValue);
|
|
|
if (strcmp(changeName, processNameRel.c_str()) == 0 && (strcmp("否", isFlag) == 0)) {
|
|
|
ifPromote++;
|
|
|
continue;
|
|
|
}
|
|
|
if (strcmp("是", isFlag) != 0) {
|
|
|
continue;
|
|
|
}
|
|
|
if (strcmp("", cellValue) == 0 || strcmp(" ", cellValue) == 0) {
|
|
|
continue;
|
|
|
}
|
|
|
|
|
|
string userID = cellValue;
|
|
|
if (strstr(cellValue, "(") != NULL) {
|
|
|
vector<string> vec1;
|
|
|
Split(cellValue, "(", vec1);
|
|
|
if (strstr(vec1[1].c_str(), ")") != NULL) {
|
|
|
vector<string> vec2;
|
|
|
Split(vec1[1], ")", vec2);
|
|
|
userID = vec2[0];
|
|
|
}
|
|
|
}
|
|
|
if (strstr(cellValue, "(") != NULL) {
|
|
|
vector<string> vec1;
|
|
|
Split(cellValue, "(", vec1);
|
|
|
if (strstr(vec1[1].c_str(), ")") != NULL) {
|
|
|
vector<string> vec2;
|
|
|
Split(vec1[1], ")", vec2);
|
|
|
userID = vec2[0];
|
|
|
}
|
|
|
}
|
|
|
printf("最终用户名ID为:%s\n", userID.c_str());
|
|
|
if (sh_set.insert(userID).second == false) {
|
|
|
continue;
|
|
|
}
|
|
|
}
|
|
|
//AOM_ask_table_rows(tags[0], proNames[2].c_str(), &value_count, &rows);
|
|
|
/*for (int j = 0; j < value_count; j++) {
|
|
|
char* cellValue = NULL;
|
|
|
AOM_ask_value_string(rows[j], proNames[2].c_str(), &cellValue);
|
|
|
if (sh_set.insert(cellValue).second == false) {
|
|
|
continue;
|
|
|
}
|
|
|
}*/
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
//EPM_ask_sub_tasks(rootTask_tag, &task_count, &task_tags);
|
|
|
//printf("子任务数量:%d\n", task_count);
|
|
|
//printf("审核人数:%d\n", sh_set.size());
|
|
|
//for (int i = 0; i < task_count; i++) {
|
|
|
// char* task_type = NULL;
|
|
|
// WSOM_ask_object_type2(task_tags[i], &task_type);
|
|
|
// printf("当前节点的类型为:%s\n", task_type);
|
|
|
// if (strcmp("EPMReviewTask", task_type) == 0) {
|
|
|
// char* object_name = NULL;
|
|
|
// int mem_cnt = 0, signoff_cnt = 0;
|
|
|
// tag_t user_tag = NULLTAG, login_group = NULLTAG, * members = NULLTAG, * signoffs = NULLTAG, select_signoff_tag = NULLTAG;
|
|
|
// AOM_ask_value_string(task_tags[i], "object_name", &object_name);//对象名称
|
|
|
// EPM_ask_sub_task(task_tags[i], "select-signoff-team", &select_signoff_tag);
|
|
|
// printf("当前节点的名称为:%s\n", object_name);
|
|
|
// if (strcmp("审核", object_name) == 0) {
|
|
|
// for (set<string>::iterator it = sh_set.begin(); it != sh_set.end(); it++) {
|
|
|
// printf("添加:%s\n", it->c_str());
|
|
|
// ITKCALL(SA_find_user2(it->c_str(), &user_tag));
|
|
|
// 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(select_signoff_tag, members[0], &signoff_cnt, &signoffs));
|
|
|
// }
|
|
|
// if (sh_set.size() > 0) {
|
|
|
// ITKCALL(EPM_set_adhoc_signoff_selection_done(select_signoff_tag, true));
|
|
|
// }
|
|
|
// }
|
|
|
// DOFREE(object_name);
|
|
|
// DOFREE(members);
|
|
|
// DOFREE(signoffs);
|
|
|
// }
|
|
|
//}
|
|
|
printf("审核人的数量为:%d======ifPromote为:%d\n", sh_set.size(), ifPromote);
|
|
|
if (strcmp("EPMAcknowledgeTask", task_type) == 0) {
|
|
|
int mem_cnt = 0, signoff_cnt = 0,signmem_count = 0, * attach_type;
|
|
|
tag_t user_tag = NULLTAG, login_group = NULLTAG, * members = NULLTAG, * signoffs = NULLTAG, select_signoff_tag = NULLTAG, *attachmentTags = NULLTAG;
|
|
|
EPM_ask_sub_task(task_tag, "select-signoff-team", &select_signoff_tag);
|
|
|
//EPM_ask_sub_task(task_tags[i], "select-signoff-team", &cur_perform_task);
|
|
|
EPM_ask_all_attachments(select_signoff_tag, &signmem_count, &attachmentTags, &attach_type);
|
|
|
if (signmem_count == 0) {
|
|
|
for (set<string>::iterator it = sh_set.begin(); it != sh_set.end(); it++) {
|
|
|
printf("添加:%s\n", it->c_str());
|
|
|
ITKCALL(SA_find_user2(it->c_str(), &user_tag));
|
|
|
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(select_signoff_tag, members[0], &signoff_cnt, &signoffs));
|
|
|
}
|
|
|
if (sh_set.size() > 0) {
|
|
|
ITKCALL(EPM_set_adhoc_signoff_selection_done(select_signoff_tag, true));
|
|
|
}
|
|
|
if (sh_set.size() == 0 && ifPromote != 0) {
|
|
|
POM_AM__set_application_bypass(true);
|
|
|
ITKCALL(EPM_promote_task(task_tag, ""));
|
|
|
POM_AM__set_application_bypass(false);
|
|
|
|
|
|
}
|
|
|
}
|
|
|
DOFREE(members);
|
|
|
DOFREE(signoffs);
|
|
|
}
|
|
|
else if (strcmp("EPMReviewTask", task_type) == 0) {
|
|
|
if (sh_set.size() == 0 && ifPromote != 0) {
|
|
|
POM_AM__set_application_bypass(true);
|
|
|
ITKCALL(EPM_promote_task(task_tag, ""));
|
|
|
POM_AM__set_application_bypass(false);
|
|
|
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
end:
|
|
|
DOFREE(attachments);
|
|
|
types.clear();
|
|
|
sh_set.clear();
|
|
|
set<string>().swap(sh_set);
|
|
|
WriteLog(debug, "执行结束:提取table属性作为审核节点的审核人(Connor_Review_Person)...");
|
|
|
return ifail;
|
|
|
} |