#include #include "libxl.h" #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "kutil.h" using namespace std; //int Connor_SetECNTaskNodes(EPM_action_message_t msg) { // //检查文件夹和文件是否存在 不存在则创建 // const char* directory_path = "D:\\log"; // const char* file_path = "D:\\log\\Connor_SetECNTaskNodes.log"; // CreateDirectoryAndFile(directory_path, file_path); // //打开日志文件,设置为追加模式 // auto logFile = std::make_unique("D:\\log\\Connor_SetECNTaskNodes.log", std::ios::app); // logFile->is_open(); // //获取当前时间 // auto now = std::chrono::system_clock::now(); // std::time_t time1 = std::chrono::system_clock::to_time_t(now); // std::string timeStr = std::ctime(&time1); // *logFile << "[" << timeStr.substr(0, timeStr.size() - 1) << "] "; // *logFile << "=========================Aks_Autosignuser===================" << std::endl; // *logFile << "===================================" << std::endl; // *logFile << "开始执行是否跳过节点Handler 开始" << std::endl; // *logFile << "===================================" << std::endl; // tag_t rootTask_tag = NULLTAG; // tag_t task = NULLTAG; // tag_t* attachments = NULLTAG; // char* arg = NULL, * argflag = NULL, * argvalue = NULL; // int arg_cnt = TC_number_of_arguments(msg.arguments); // char* cheakName = NULL; // task = msg.task; // ITKCALL(EPM_ask_root_task(task, &rootTask_tag)); // if (arg_cnt > 0) // { // for (int i = 0; i < arg_cnt; i++) // { // arg = TC_next_argument(msg.arguments); // ITKCALL(ITK_ask_argument_named_value((const char*)arg, &argflag, &argvalue)); // if (strcmp(argflag, "checkTaskNameInForm") == 0) { // if (argvalue != NULL) // { // printf("获取的值%s:", argvalue); // cheakName = argvalue; // // } // } // } // /* // * 去目标下的变更通知版本(LD6_CNRevision)下任务分配表关系(LD6_WorkFRelation) // * 下寻找类型为LD6_CNForm或者LD6_CIForm,获取表单上的表属性ld6_ChangeTable, // * 找到表属性上的表行LD6_TableRow,获取表行上ld6_ChangeTaskName属性值与此handler的 // * checkTaskNameInForm参数值相同的行,并找到此行上ld6_YNChange的属性值,如果为是, // * 则将此任务节点启动,如果为否,则将此节点提升或完成 // */ // int doc_num = 0; // tag_t* doc_tags = NULLTAG; // ITKCALL(EPM_ask_attachments(rootTask_tag, EPM_target_attachment, &doc_num, &doc_tags)); // for (int i = 0; i < doc_num; i++) // { // char* type = NULL; // ITKCALL(AOM_ask_value_string(doc_tags[i], "object_type", &type)); // if (strcmp(type, "LD6_CNRevision") == 0) // { // //查找指定关系 // printf("查找指定关系\n"); // int gx_num; tag_t* gx_obj; // ITKCALL(AOM_ask_value_tags(doc_tags[i], "LD6_WorkFRelation", &gx_num, &gx_obj)); // for (int j = 0; j < gx_num; j++) // { // char* form = NULL; // ITKCALL(AOM_ask_value_string(gx_obj[i], "object_type", &form)); // printf("form=&s\n", form); // if (strcmp(form, "LD6_CNForm") == 0 || strcmp(form, "LD6_CIForm") == 0) // { // printf("获取表格属性"); // //获取表格属性 // int rownum; tag_t* tableRownum = NULL; // ITKCALL(AOM_ask_table_rows(gx_obj[i], "ld6_ChangeTable", &rownum, &tableRownum)); // for (int z = 0; z < rownum; z++) // { // tag_t rowTag = tableRownum[z]; // char* taskName = NULL; // ITKCALL(AOM_ask_value_string(rowTag, "ld6_ChangeTaskName", &taskName)); // printf("taskName=%s\n", taskName); // if (strcmp(taskName, cheakName) == 0) // { // //获取属性值 // char* isSkip = NULL; // ITKCALL(AOM_ask_value_string(rowTag, "ld6_YNChange", &isSkip)); // printf("获取到ld6_YNChange的属性为:%s\n", isSkip); // if (strcmp(isSkip, "是") == 0) // { // //执行结束 // return ITK_ok; // } // else // { // //跳过当前节点 // printf("开始提升节点\n"); // tag_t* process = NULLTAG;//流程节点 // int processnum;//节点数量 // ITKCALL(AOM_ask_value_tags(rootTask_tag, "fnd0StartedTasks", &processnum, &process)); // ITKCALL(EPM_promote_task(process[0], "")); // //执行结束 // return ITK_ok; // // } // break; // } // } // break; // } // } // } // } // } // else // { // EMH_store_error_s1(EMH_severity_user_error, EMH_USER_error_base, "流程参数设置有误,请检查后重新执行"); // return -1; // } // // // return ITK_ok; //} // Assuming the necessary headers and definitions for ITKCALL, TC_number_of_arguments, etc. are included elsewhere int Connor_SetECNTaskNodes(EPM_action_message_t msg) { // Check if the directory and file exist, create them if they don't const char* directory_path = "D:\\log"; const char* file_path = "D:\\log\\Connor_SetECNTaskNodes.log"; CreateDirectoryAndFile(directory_path, file_path); // Open the log file in append mode auto logFile = std::make_unique(file_path, std::ios::app); if (!logFile->is_open()) { std::cerr << "Failed to open log file." << std::endl; return -1; } // Get the current time auto now = std::chrono::system_clock::now(); std::time_t time1 = std::chrono::system_clock::to_time_t(now); std::string timeStr = std::ctime(&time1); timeStr = timeStr.substr(0, timeStr.size() - 1); // Remove trailing newline // Log the start of the function *logFile << "[" << timeStr << "] "; *logFile << "=========================Connor_SetECNTaskNodes===================" << std::endl; *logFile << "===================================" << std::endl; *logFile << "开始执行是否跳过节点Handler 开始" << std::endl; *logFile << "===================================" << std::endl; tag_t rootTask_tag = NULLTAG; tag_t task = NULLTAG; tag_t* attachments = NULLTAG; char* arg = NULL, * argflag = NULL, * argvalue = NULL; int arg_cnt = TC_number_of_arguments(msg.arguments); char* cheakName = NULL; task = msg.task; ITKCALL(EPM_ask_root_task(task, &rootTask_tag)); if (arg_cnt > 0) { *logFile << "[" << timeStr << "] " << "解析参数开始" << std::endl; for (int i = 0; i < arg_cnt; i++) { arg = TC_next_argument(msg.arguments); ITKCALL(ITK_ask_argument_named_value((const char*)arg, &argflag, &argvalue)); if (strcmp(argflag, "checkTaskNameInForm") == 0) { if (argvalue != NULL) { *logFile << "[" << timeStr << "] " << "获取的值: " << argvalue << std::endl; cheakName = argvalue; } } } *logFile << "[" << timeStr << "] " << "解析参数结束" << std::endl; int doc_num = 0; tag_t* doc_tags = NULLTAG; ITKCALL(EPM_ask_attachments(rootTask_tag, EPM_target_attachment, &doc_num, &doc_tags)); for (int i = 0; i < doc_num; i++) { char* type = NULL; ITKCALL(AOM_ask_value_string(doc_tags[i], "object_type", &type)); if (strcmp(type, "LD6_CNRevision") == 0) { *logFile << "[" << timeStr << "] " << "查找指定关系开始" << std::endl; int gx_num; tag_t* gx_obj; ITKCALL(AOM_ask_value_tags(doc_tags[i], "LD6_WorkFRelation", &gx_num, &gx_obj)); for (int j = 0; j < gx_num; j++) { char* form = NULL; ITKCALL(AOM_ask_value_string(gx_obj[j], "object_type", &form)); *logFile << "[" << timeStr << "] " << "表单类型: " << form << std::endl; if (strcmp(form, "LD6_CNForm") == 0 || strcmp(form, "LD6_CIForm") == 0) { *logFile << "[" << timeStr << "] " << "获取表格属性开始" << std::endl; int rownum; tag_t* tableRownum = NULL; ITKCALL(AOM_ask_table_rows(gx_obj[j], "ld6_ChangeTable", &rownum, &tableRownum)); for (int z = 0; z < rownum; z++) { tag_t rowTag = tableRownum[z]; char* taskName = NULL; ITKCALL(AOM_ask_value_string(rowTag, "ld6_ChangeTaskName", &taskName)); *logFile << "[" << timeStr << "] " << "表行任务名称: " << taskName << std::endl; if (strcmp(taskName, cheakName) == 0) { char* isSkip = NULL; ITKCALL(AOM_ask_value_string(rowTag, "ld6_YNChange", &isSkip)); *logFile << "[" << timeStr << "] " << "获取到ld6_YNChange的属性值: " << isSkip << std::endl; if (strcmp(isSkip, "是") == 0) { *logFile << "[" << timeStr << "] " << "执行结束" << std::endl; return ITK_ok; } else { *logFile << "[" << timeStr << "] " << "开始提升节点" << std::endl; ITKCALL(EPM_promote_task(task, "")); *logFile << "[" << timeStr << "] " << "节点提升成功" << std::endl; *logFile << "[" << timeStr << "] " << "执行结束" << std::endl; return ITK_ok; } break; } } *logFile << "[" << timeStr << "] " << "获取表格属性结束" << std::endl; break; } } *logFile << "[" << timeStr << "] " << "查找指定关系结束" << std::endl; } } } else { *logFile << "[" << timeStr << "] " << "流程参数设置有误,请检查后重新执行" << std::endl; EMH_store_error_s1(EMH_severity_user_error, EMH_USER_error_base, "流程参数设置有误,请检查后重新执行"); return -1; } *logFile << "[" << timeStr << "] " << "函数执行结束" << std::endl; return ITK_ok; }