|
|
#include "rb_custom.h"
|
|
|
#include "tccore\iman_msg.h"
|
|
|
|
|
|
|
|
|
|
|
|
extern "C" int POM_AM__set_application_bypass(logical bypass);
|
|
|
|
|
|
|
|
|
int len(char* p)
|
|
|
{
|
|
|
int i = 0;
|
|
|
while (*p++)i++;
|
|
|
return i;
|
|
|
}
|
|
|
|
|
|
bool isFileExists_ifstream(char* name) {
|
|
|
ifstream f(name);
|
|
|
return f.good();
|
|
|
}
|
|
|
int char2int(const char* str) {
|
|
|
const char* p = str;
|
|
|
bool neg = false;
|
|
|
int res = 0;
|
|
|
if (*str == '-' || *str == '+') {
|
|
|
str++;
|
|
|
}
|
|
|
|
|
|
while (*str != 0) {
|
|
|
if (*str < '0' || *str > '9') {
|
|
|
break;
|
|
|
}
|
|
|
res = res * 10 + *str - '0';
|
|
|
str++;
|
|
|
}
|
|
|
|
|
|
if (*p == '-') {
|
|
|
res = -res;
|
|
|
}
|
|
|
return res;
|
|
|
}
|
|
|
|
|
|
void split(char* src, const char* separator, char** dest, int* num) {
|
|
|
/*
|
|
|
src 源字符串的首地址(buf的地址)
|
|
|
separator 指定的分割字符
|
|
|
dest 接收子字符串的数组
|
|
|
num 分割后子字符串的个数
|
|
|
*/
|
|
|
char* pNext;
|
|
|
int count = 0;
|
|
|
if (src == NULL || strlen(src) == 0) //如果传入的地址为空或长度为0,直接终止
|
|
|
return;
|
|
|
if (separator == NULL || strlen(separator) == 0) //如未指定分割的字符串,直接终止
|
|
|
return;
|
|
|
pNext = (char*)strtok(src, separator); //必须使用(char *)进行强制类型转换(虽然不写有的编译器中不会出现指针错误)
|
|
|
while (pNext != NULL) {
|
|
|
*dest++ = pNext;
|
|
|
++count;
|
|
|
pNext = (char*)strtok(NULL, separator); //必须使用(char *)进行强制类型转换
|
|
|
}
|
|
|
*num = count;
|
|
|
}
|
|
|
|
|
|
int Connor_set_bypass(void* returnValue)
|
|
|
{
|
|
|
POM_AM__set_application_bypass(true);
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
int Connor_close_bypass(void* returnValue)
|
|
|
{
|
|
|
POM_AM__set_application_bypass(false);
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* bypass
|
|
|
*/
|
|
|
int Connor_bypass(EPM_action_message_t msg) {
|
|
|
ECHO("==================bypass START =======================\n");
|
|
|
int ifail = ITK_ok, arg_cnt;
|
|
|
char* argflag = NULL, *argvalue = NULL, *arg = NULL;
|
|
|
int i = 0, j = 0;
|
|
|
BOOL bypass = FALSE;
|
|
|
arg_cnt = TC_number_of_arguments(msg.arguments);
|
|
|
ECHO("参数个数为:%d\n", arg_cnt);
|
|
|
POM_AM__set_application_bypass(true);
|
|
|
if (arg_cnt > 0)
|
|
|
{
|
|
|
for (i = 0; i < arg_cnt; i++)
|
|
|
{
|
|
|
arg = TC_next_argument(msg.arguments);
|
|
|
ifail = ITK_ask_argument_named_value((const char*)arg, &argflag, &argvalue);
|
|
|
if (stricmp(argflag, "bypass") == 0)
|
|
|
{
|
|
|
if (stricmp(argvalue, "true") == 0) {
|
|
|
bypass = TRUE;
|
|
|
}
|
|
|
else if (stricmp(argvalue, "false") == 0) {
|
|
|
bypass = FALSE;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
}
|
|
|
if (argflag != NULL) {
|
|
|
MEM_free(argflag);
|
|
|
argflag = NULL;
|
|
|
}
|
|
|
if (argvalue != NULL) {
|
|
|
MEM_free(argvalue);
|
|
|
argvalue = NULL;
|
|
|
}
|
|
|
}
|
|
|
printf("bypass=%d /n", bypass);
|
|
|
POM_AM__set_application_bypass(bypass);
|
|
|
ECHO("==================bypass END =======================\n");
|
|
|
return ifail;
|
|
|
}
|
|
|
|
|
|
//物料废弃属性值修改
|
|
|
int RB_set_yxq(EPM_action_message_t msg) {
|
|
|
printf("===================================\n");
|
|
|
printf("物料废弃属性值修改 开始\n");
|
|
|
printf("===================================\n");
|
|
|
int ifail = ITK_ok;
|
|
|
printf("开超级权限\n");
|
|
|
POM_AM__set_application_bypass(true);
|
|
|
int c_sql_value_count = 0, values_count = 0;
|
|
|
char** c_sql_values, ** values;
|
|
|
ITKCALL(PREF_ask_char_values("RB3_SQL_Connect2", &c_sql_value_count, &c_sql_values));
|
|
|
if (c_sql_value_count != 3)
|
|
|
{
|
|
|
WriteLog("首选项 RB3_SQL_Connect2 配置错误 数量%d ", c_sql_value_count);
|
|
|
CloseLog();
|
|
|
return 0;
|
|
|
}
|
|
|
char* userName;
|
|
|
tag_t aUserTag = NULLTAG;//当前用户对象
|
|
|
tag_t task_tag = NULL_TAG,
|
|
|
root_task_tag = NULLTAG,
|
|
|
*attachments;
|
|
|
task_tag = msg.task;
|
|
|
int att_cnt = 0, s = 0;
|
|
|
EPM_ask_root_task(task_tag, &root_task_tag);
|
|
|
EPM_ask_attachments(root_task_tag, EPM_target_attachment, &att_cnt, &attachments);
|
|
|
if (ConnServer(c_sql_values[1], c_sql_values[2], c_sql_values[0]))//"tc11","infodba","//172.16.50.40/tc11" "TC12","infodba","172.16.68.13/tc1"
|
|
|
{
|
|
|
printf("提示:中间数据表访问失败\n");
|
|
|
return ifail;
|
|
|
}
|
|
|
else {
|
|
|
printf("提示:中间数据表访问成功\n");
|
|
|
if (att_cnt > 0)
|
|
|
{
|
|
|
for (int i = 0; i < att_cnt; i++)
|
|
|
{
|
|
|
tag_t tagt = NULLTAG;
|
|
|
char* type, *id;
|
|
|
char* user_id;
|
|
|
date_t yxq;
|
|
|
char JF_CJSJ[16] = "\0";
|
|
|
tagt = attachments[i];//
|
|
|
ITKCALL(AOM_ask_value_string(tagt, "object_type", &type));
|
|
|
ITKCALL(AOM_ask_value_string(tagt, "item_id", &id));
|
|
|
printf("获取用户\n");
|
|
|
s = POM_get_user(&userName, &aUserTag);
|
|
|
POM_tag_to_uid(aUserTag, &user_id);
|
|
|
//SA_ask_user_identifier2(aUserTag, &user_id);
|
|
|
printf("id=%s\n", id);
|
|
|
printf("user_id=%s\n", user_id);
|
|
|
if (((strstr(type, "Revision") != NULL) || (strstr(type, "revision") != NULL))
|
|
|
&& (strstr(type, "Master") == NULL) && (strstr(type, "master") == NULL)) {
|
|
|
ITKCALL(AOM_ask_value_date(tagt, "rb3_yxq", &yxq));
|
|
|
printf("yxq.year=%d\n", yxq.year);
|
|
|
if (yxq.year == 0) {
|
|
|
date_t createDate;
|
|
|
ITKCALL(AOM_ask_value_date(tagt, "creation_date", &createDate));
|
|
|
printf("createDate=%d-%d_%d\n", createDate.year, createDate.month, createDate.day);
|
|
|
if (createDate.month + 1 <= 9) {
|
|
|
createDate.month = createDate.month + 3;
|
|
|
sprintf(JF_CJSJ, "%d-%d-%d", createDate.year, createDate.month + 1, createDate.day);
|
|
|
}
|
|
|
else {
|
|
|
createDate.year = createDate.year + 1;
|
|
|
createDate.month = createDate.month - 9;
|
|
|
sprintf(JF_CJSJ, "%d-%d-%d", createDate.year, createDate.month + 1, createDate.day);
|
|
|
|
|
|
}
|
|
|
printf("JF_CJSJ=%s\n", JF_CJSJ);
|
|
|
AOM_lock(tagt);
|
|
|
ITKCALL(AOM_set_value_date(tagt, "rb3_yxq", createDate));
|
|
|
AOM_save(tagt);
|
|
|
AOM_unlock(tagt);
|
|
|
}
|
|
|
else {
|
|
|
sprintf(JF_CJSJ, "%d-%d-%d", yxq.year, yxq.month + 1, yxq.day);
|
|
|
}
|
|
|
printf("JF_CJSJ=%s\n", JF_CJSJ);
|
|
|
}
|
|
|
char sql1[1024] = "\0";
|
|
|
sprintf(sql1, "insert into RB_YXQ_VALUE(ITEM_ID,USER_ID,YXQ,STATU) values ('%s','%s',to_date ('%s' ,'YYYY-MM-DD' ),'1')", id, user_id, JF_CJSJ);
|
|
|
printf("提示:sql1==%s\n", sql1);
|
|
|
if (ExecuteSQLNoInputParam(sql1) == -1)
|
|
|
{
|
|
|
printf("提示:有效期插入数据库 失败, %s \n", sql1);
|
|
|
}
|
|
|
else {
|
|
|
ExecuteSQLNoInputParam("commit");
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
DisConnServer();
|
|
|
printf("数据库连接断开\n");
|
|
|
printf("关超级权限\n");
|
|
|
POM_AM__set_application_bypass(false);
|
|
|
printf("===================================\n");
|
|
|
printf("物料废弃属性值修改 结束\n");
|
|
|
printf("===================================\n");
|
|
|
return ifail;
|
|
|
}
|
|
|
|
|
|
//判断流程节点状态
|
|
|
int RB_Process_statu(EPM_rule_message_t msg) {
|
|
|
POM_AM__set_application_bypass(true);
|
|
|
printf("********RB_Process_statu开始********\n");
|
|
|
int ifail = EPM_go, att_cnt = 0, i = 0, arg_cnt = 0;
|
|
|
tag_t task_tag = NULL_TAG, rootTask_tag = NULL_TAG, *attachments;
|
|
|
task_tag = msg.task;
|
|
|
if (task_tag == NULLTAG)
|
|
|
{
|
|
|
return -1;
|
|
|
}
|
|
|
ITKCALL(EPM_ask_root_task(task_tag, &rootTask_tag));
|
|
|
EPM_ask_attachments(rootTask_tag, EPM_target_attachment, &att_cnt, &attachments);
|
|
|
for (int i = 0; i < att_cnt; i++)
|
|
|
{
|
|
|
tag_t tagt = NULLTAG;
|
|
|
char* type, *task_type, *task_name, *child_task_name, *rev_type, *child_task_type, *statu_name;
|
|
|
int count = 0, task_count = 0;
|
|
|
tag_t* tagets, *task_tagets;
|
|
|
int n_referencers = 0;
|
|
|
int* levels;
|
|
|
tag_t* referencers;
|
|
|
char** relations;
|
|
|
tagt = attachments[i];//
|
|
|
boolean flag = true;
|
|
|
ITKCALL(AOM_ask_value_string(tagt, "object_type", &type));
|
|
|
printf("type=%s\n", type);
|
|
|
if (((strstr(type, "Revision") != NULL) || (strstr(type, "revision") != NULL))
|
|
|
&& (strstr(type, "Master") == NULL) && (strstr(type, "master") == NULL)
|
|
|
&& (strstr(type, "BOM") == NULL) && (strstr(type, "bom") == NULL) && (strstr(type, "Bom") == NULL)) {
|
|
|
ITKCALL(AOM_ask_value_tags(tagt, "RB3_BGSQ", &count, &tagets));
|
|
|
if (count > 0) {
|
|
|
for (int k = 0; k < count; k++)
|
|
|
{
|
|
|
ITKCALL(AOM_ask_value_string(tagets[k], "object_type", &rev_type));
|
|
|
if (strcmp("RB3_GGQQRevision", rev_type) == 0) {
|
|
|
ITKCALL(WSOM_where_referenced(tagets[k], 1, &n_referencers, &levels, &referencers, &relations));
|
|
|
if (n_referencers > 0)
|
|
|
{
|
|
|
for (int j = 0; j < n_referencers; j++) {
|
|
|
ITKCALL(AOM_ask_value_string(referencers[j], "object_type", &task_type));
|
|
|
ITKCALL(AOM_ask_value_string(referencers[j], "object_name", &task_name));
|
|
|
printf("task_type=%s\n", task_type);
|
|
|
printf("task_name=%s\n", task_name);
|
|
|
if (strcmp("EPMTask", task_type) == 0 && strcmp("A02 变更申请流程", task_name) == 0) {
|
|
|
ITKCALL(AOM_ask_value_string(referencers[j], "fnd0Status", &statu_name));
|
|
|
if (strcmp("已发布", statu_name) == 0) {
|
|
|
break;
|
|
|
}
|
|
|
ITKCALL(AOM_ask_value_tags(referencers[j], "fnd0StartedTasks", &task_count, &task_tagets));
|
|
|
printf("task_count=%d\n", task_count);
|
|
|
for (int p = 0; p < task_count; p++)
|
|
|
{
|
|
|
ITKCALL(AOM_ask_value_string(task_tagets[p], "object_name", &child_task_name));
|
|
|
printf("child_task_name=%s\n", child_task_name);
|
|
|
if (strcmp("完成确认", child_task_name) == 0) {
|
|
|
flag = false;
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if (flag) {
|
|
|
ifail = EPM_nogo;
|
|
|
EMH_store_error_s1(EMH_severity_information, 278701, "设计变更申请流程未走到完成确认节点,不可以发起流程");//错误弹窗
|
|
|
POM_AM__set_application_bypass(false);
|
|
|
return ifail;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
else {
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
break;
|
|
|
}
|
|
|
POM_AM__set_application_bypass(false);
|
|
|
printf("********RB_Process_statu结束********\n");
|
|
|
return ifail;
|
|
|
}
|
|
|
|
|
|
//流程提升
|
|
|
int RB_Promote(EPM_action_message_t msg)
|
|
|
{
|
|
|
POM_AM__set_application_bypass(true);
|
|
|
printf("********RB_Promote开始********\n");
|
|
|
int ifail = ITK_ok, att_cnt = 0, i = 0, arg_cnt = 0;
|
|
|
tag_t task_tag = NULL_TAG, rootTask_tag = NULL_TAG, *attachments;
|
|
|
task_tag = msg.task;
|
|
|
if (task_tag == NULLTAG)
|
|
|
{
|
|
|
return -1;
|
|
|
}
|
|
|
ITKCALL(EPM_ask_root_task(task_tag, &rootTask_tag));
|
|
|
EPM_ask_attachments(rootTask_tag, EPM_target_attachment, &att_cnt, &attachments);
|
|
|
for (int i = 0; i < att_cnt; i++)
|
|
|
{
|
|
|
tag_t tagt = NULLTAG;
|
|
|
char* type, *task_type, *task_name, *rev_type, *child_task_type, *child_task_name;
|
|
|
int count = 0, task_count = 0;
|
|
|
tag_t* tagets, *task_tagets;
|
|
|
int n_referencers = 0;
|
|
|
int* levels;
|
|
|
tag_t* referencers;
|
|
|
char** relations;
|
|
|
tagt = attachments[i];//
|
|
|
ITKCALL(AOM_ask_value_string(tagt, "object_type", &type));
|
|
|
printf("type=%s\n", type);
|
|
|
if (((strstr(type, "Revision") != NULL) || (strstr(type, "revision") != NULL))
|
|
|
&& (strstr(type, "Master") == NULL) && (strstr(type, "master") == NULL)
|
|
|
&& (strstr(type, "BOM") == NULL) && (strstr(type, "bom") == NULL) && (strstr(type, "Bom") == NULL)) {
|
|
|
ITKCALL(AOM_ask_value_tags(tagt, "RB3_BGSQ", &count, &tagets));
|
|
|
for (int k = 0; k < count; k++)
|
|
|
{
|
|
|
ITKCALL(AOM_ask_value_string(tagets[k], "object_type", &rev_type));
|
|
|
if (strcmp("RB3_GGQQRevision", rev_type) == 0) {
|
|
|
ITKCALL(WSOM_where_referenced(tagets[k], 1, &n_referencers, &levels, &referencers, &relations));
|
|
|
if (n_referencers > 0)
|
|
|
{
|
|
|
for (int j = 0; j < n_referencers; j++) {
|
|
|
ITKCALL(AOM_ask_value_string(referencers[j], "object_type", &task_type));
|
|
|
ITKCALL(AOM_ask_value_string(referencers[j], "object_name", &task_name));
|
|
|
printf("task_type=%s\n", task_type);
|
|
|
printf("task_name=%s\n", task_name);
|
|
|
if (strcmp("EPMTask", task_type) == 0 && strcmp("A02 变更申请流程", task_name) == 0) {
|
|
|
ITKCALL(AOM_ask_value_tags(referencers[j], "child_tasks", &task_count, &task_tagets));
|
|
|
for (int p = 0; p < task_count; p++)
|
|
|
{
|
|
|
ITKCALL(AOM_ask_value_string(task_tagets[p], "object_type", &child_task_type));
|
|
|
printf("child_task_type=%s\n", child_task_type);
|
|
|
if (strcmp("EPMReviewTask", child_task_type) == 0) {
|
|
|
ITKCALL(AOM_ask_value_string(task_tagets[p], "object_name", &child_task_name));
|
|
|
printf("child_task_name=%s\n", child_task_name);
|
|
|
if (strcmp("完成确认", child_task_name) == 0) {
|
|
|
ITKCALL(EPM_promote_task(task_tagets[p], ""));
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
POM_AM__set_application_bypass(false);
|
|
|
printf("********RB_Promote结束********\n");
|
|
|
return ITK_ok;
|
|
|
}
|
|
|
|
|
|
//未设置审核人员流程提升
|
|
|
int RB_Promote_predecess(EPM_action_message_t msg) {
|
|
|
printf("===================================\n");
|
|
|
printf("未设置审核人员流程提升 开始 \n");
|
|
|
printf("===================================\n");
|
|
|
int ifail = ITK_ok;
|
|
|
int perform_count = 0;
|
|
|
int* attach_type;
|
|
|
tag_t* perform_attaches = NULLTAG, user_tag;
|
|
|
printf("开超级权限\n");
|
|
|
POM_AM__set_application_bypass(true);
|
|
|
|
|
|
char* task_name;
|
|
|
tag_t itemrevision = NULLTAG;
|
|
|
char* rev_id, *rev_name, *proj_id;
|
|
|
//流程节点相关
|
|
|
tag_t current_task = NULLTAG, type_tag = NULLTAG;
|
|
|
|
|
|
current_task = msg.task;
|
|
|
|
|
|
EPM_ask_name2(current_task, &task_name);
|
|
|
ECHO("节点名称=%s\n", task_name);
|
|
|
|
|
|
int count = 0;
|
|
|
tag_t* be_tag = NULLTAG, executor;
|
|
|
char* node_task_name;
|
|
|
|
|
|
ITKCALL(AOM_ask_value_tags(current_task, "child_tasks", &count, &be_tag));
|
|
|
for (int j = 0; j < count; j++)
|
|
|
{
|
|
|
EPM_ask_name2(be_tag[j], &node_task_name);
|
|
|
ECHO("node_task_name = %s\n", node_task_name);
|
|
|
if (stricmp(node_task_name, "select-signoff-team") == 0) {
|
|
|
EPM_ask_all_attachments(be_tag[j], &perform_count, &perform_attaches, &attach_type);
|
|
|
ECHO("perform_count=%d\n", perform_count);
|
|
|
if (perform_count == 0) {
|
|
|
ITKCALL(EPM_promote_task(current_task, ""));
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
printf("关闭级权限\n");
|
|
|
POM_AM__set_application_bypass(false);
|
|
|
|
|
|
printf("===================================\n");
|
|
|
printf("未设置审核人员流程提升 结束 \n");
|
|
|
printf("===================================\n");
|
|
|
return ifail;
|
|
|
}
|
|
|
|
|
|
//流程邮件提醒
|
|
|
/*
|
|
|
* 变更内容:增加流程参数email,属性值为外部人员邮箱地址,如果为多值,逗号隔开,实现发送内部人员邮箱的同时,发送外部人员的邮箱
|
|
|
* 变更人:hcj
|
|
|
* 变更时间:2024/1/31
|
|
|
*/
|
|
|
int Connor_Send_Mail_To_All_Users(EPM_action_message_t msg) {
|
|
|
bool debug = false;
|
|
|
int ifail = ITK_ok, arg_cnt = 0, att_cnt = 0, task_count = 0, user_cnt = 0;
|
|
|
char* arg = NULL, *argflag = NULL, *argvalue = NULL, *task_name = NULL, *task_type = NULL;
|
|
|
char* user_id = NULL, *user_name = NULL, *job_name = NULL;
|
|
|
tag_t task_tag = NULLTAG, rootTask_tag = NULLTAG, user_tag = NULLTAG;
|
|
|
tag_t* attachments = NULL, *task_tags = NULL;
|
|
|
arg_cnt = TC_number_of_arguments(msg.arguments);
|
|
|
vector<tag_t> all_user_tags;
|
|
|
vector<string> mail_addrs;
|
|
|
tag_t memberTag = NULLTAG;
|
|
|
SIGNOFF_TYPE_t memberType;
|
|
|
char* outPersonMailAddress = NULL;
|
|
|
ITKCALL(POM_get_user(&user_name, &user_tag));
|
|
|
ITKCALL(SA_ask_user_identifier2(user_tag, &user_id));
|
|
|
DOFREE(user_id);
|
|
|
printf("=============================================================\n");
|
|
|
printf("开始执行:Connor_Send_Mail_To_All_Users\n");
|
|
|
printf("=============================================================\n");
|
|
|
printf("开超级权限\n");
|
|
|
POM_AM__set_application_bypass(true);
|
|
|
task_tag = msg.task;
|
|
|
if (task_tag == NULLTAG) {
|
|
|
goto end;
|
|
|
}
|
|
|
//获取外部人员邮箱号
|
|
|
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, "email") == 0) {
|
|
|
outPersonMailAddress = argvalue;
|
|
|
}
|
|
|
MEM_free(argflag);
|
|
|
MEM_free(argvalue);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
char* task_uid;
|
|
|
POM_tag_to_uid(task_tag, &task_uid);
|
|
|
time_t t;
|
|
|
struct tm* lt;
|
|
|
time(&t);//获取Unix时间戳。
|
|
|
lt = localtime(&t);//转为时间结构。
|
|
|
char year[128] = "\0"; //当前年份
|
|
|
sprintf(year, "%d-%d-%d", lt->tm_year + 1900, lt->tm_mon + 1, lt->tm_mday);
|
|
|
ITKCALL(ifail = EPM_ask_root_task(task_tag, &rootTask_tag));
|
|
|
ITKCALL(ifail = AOM_ask_value_string(rootTask_tag, "job_name", &job_name));
|
|
|
printf("流程名称:%s\n", job_name);
|
|
|
ITKCALL(ifail = EPM_ask_name2(task_tag, &task_name));
|
|
|
ITKCALL(ifail = AOM_ask_value_string(task_tag, "task_type", &task_type));
|
|
|
if (ifail != ITK_ok) {
|
|
|
DOFREE(task_name);
|
|
|
DOFREE(task_type);
|
|
|
}
|
|
|
ECHO("task_type = %s\n", task_type);
|
|
|
if (strcmp("EPMDoTask", task_type) == 0) {
|
|
|
tag_t user_tag = NULLTAG;
|
|
|
ITKCALL(ifail = AOM_ask_value_tag(task_tag, "fnd0Performer", &user_tag));
|
|
|
if (user_tag == NULLTAG) {
|
|
|
printf("未找到执行者\n");
|
|
|
}
|
|
|
char* user_name = NULL, *task_state = NULL;
|
|
|
ITKCALL(ifail = AOM_ask_value_string(user_tag, "user_name", &user_name));
|
|
|
ITKCALL(ifail = AOM_ask_value_string(task_tag, "task_state", &task_state));
|
|
|
printf(">> DO任务信息:%s|%s\n", user_name, task_state);
|
|
|
all_user_tags.push_back(user_tag);
|
|
|
DOFREE(user_name);
|
|
|
DOFREE(task_state);
|
|
|
}
|
|
|
else if (strcmp("EPMPerformSignoffTask", task_type) == 0 || strcmp("EPMAcknowledgeTask", task_type) == 0) {
|
|
|
int reviewer_cnt = 0;
|
|
|
tag_t* reviewers = NULL;
|
|
|
int count = 0;
|
|
|
tag_t* be_tag = NULLTAG;
|
|
|
char* node_task_name;
|
|
|
int* attach_type;
|
|
|
ITKCALL(AOM_ask_value_tags(task_tag, "predecessors", &count, &be_tag));
|
|
|
for (int j = 0; j < count; j++)
|
|
|
{
|
|
|
EPM_ask_name2(be_tag[j], &node_task_name);
|
|
|
ECHO("node_task_name = %s\n", node_task_name);
|
|
|
if (stricmp(node_task_name, "select-signoff-team") == 0) {
|
|
|
EPM_ask_all_attachments(be_tag[j], &reviewer_cnt, &reviewers, &attach_type);
|
|
|
ECHO("perform_count=%d\n", reviewer_cnt);
|
|
|
for (int k = 0; k < reviewer_cnt; k++) {
|
|
|
tag_t reviewer = reviewers[k];
|
|
|
tag_t user_tag = NULLTAG;
|
|
|
tag_t group_tag = NULLTAG;
|
|
|
EPM_signoff_decision_t decision;
|
|
|
char* comment = NULL, *date_str = NULL, *group_full_name = NULL, *user_name = NULL;
|
|
|
date_t date;
|
|
|
ITKCALL(EPM_ask_signoff_member(reviewer, &memberTag, &memberType));
|
|
|
ITKCALL(SA_ask_groupmember_user(memberTag, &user_tag));
|
|
|
if (user_tag == NULLTAG) {
|
|
|
printf(">> %d. 未指派用户\n", k + 1);
|
|
|
continue;
|
|
|
}
|
|
|
ITKCALL(ifail = AOM_ask_value_string(user_tag, "user_name", &user_name));
|
|
|
|
|
|
all_user_tags.push_back(user_tag);
|
|
|
DOFREE(comment);
|
|
|
DOFREE(user_name);
|
|
|
DOFREE(group_full_name);
|
|
|
DOFREE(date_str);
|
|
|
}
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
DOFREE(reviewers);
|
|
|
}
|
|
|
else {
|
|
|
printf(">> 未知任务类型\n");
|
|
|
}
|
|
|
DOFREE(task_name);
|
|
|
DOFREE(task_type);
|
|
|
user_cnt = all_user_tags.size();
|
|
|
printf("处理用户数据:%d\n", user_cnt);
|
|
|
for (int i = 0; i < user_cnt; i++) {
|
|
|
tag_t mail_user = all_user_tags[i], person_tag = NULLTAG;
|
|
|
char* user_str = NULL, *mail_str = NULL;
|
|
|
ITKCALL(ifail = AOM_ask_value_tag(mail_user, "person", &person_tag));
|
|
|
if (ifail != ITK_ok || person_tag == NULLTAG) {
|
|
|
continue;
|
|
|
}
|
|
|
ITKCALL(ifail = AOM_ask_value_string(person_tag, "PA9", &mail_str));
|
|
|
if (ifail != ITK_ok) {
|
|
|
continue;
|
|
|
}
|
|
|
ITKCALL(ifail = AOM_ask_value_string(mail_user, "user_name", &user_str));
|
|
|
printf(">> %d. %s -> %s\n", i + 1, user_str, mail_str);
|
|
|
if (mail_str == NULL || strcmp("", mail_str) == 0 || std::find(mail_addrs.begin(), mail_addrs.end(), mail_str) != mail_addrs.end()) {
|
|
|
printf(">> Skip\n");
|
|
|
}
|
|
|
else {
|
|
|
mail_addrs.push_back(mail_str);
|
|
|
}
|
|
|
DOFREE(user_str);
|
|
|
DOFREE(mail_str);
|
|
|
}
|
|
|
|
|
|
//解析外部邮箱人员地址
|
|
|
if (outPersonMailAddress!=NULL) {
|
|
|
vector<string> mailaddressVector;
|
|
|
Split(outPersonMailAddress, ";", mailaddressVector);
|
|
|
for (int i = 0; i < mailaddressVector.size(); i++) {
|
|
|
mail_addrs.push_back(mailaddressVector[i]);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
user_cnt = mail_addrs.size();
|
|
|
|
|
|
|
|
|
printf("发送邮件:%d", user_cnt);
|
|
|
for (int i = 0; i < user_cnt; i++) {
|
|
|
char cmd[1024] = "";
|
|
|
char jarfile[512] = "";
|
|
|
string mail_addr = mail_addrs[i];
|
|
|
WriteLog(">> %d. 发送邮件给[%s]", i + 1, mail_addr.c_str());
|
|
|
sprintf(jarfile, "%s\\bin\\EMailSender.jar", getenv("TC_ROOT"));
|
|
|
strcpy_s(cmd, "java -jar ");
|
|
|
strcat_s(cmd, jarfile);
|
|
|
strcat_s(cmd, " \"");
|
|
|
strcat_s(cmd, mail_addr.c_str());
|
|
|
strcat_s(cmd, "\" \"【TeamCenter】流程任务提醒\" \"");
|
|
|
strcat_s(cmd, "收到");
|
|
|
strcat_s(cmd, job_name);
|
|
|
strcat_s(cmd, "任务,请尽快处理!!\"");
|
|
|
printf("CMD:%s", cmd);
|
|
|
system(cmd);
|
|
|
printf("执行完成");
|
|
|
}
|
|
|
printf("关超级权限\n");
|
|
|
POM_AM__set_application_bypass(false);
|
|
|
end:
|
|
|
DOFREE(job_name);
|
|
|
DOFREE(attachments);
|
|
|
all_user_tags.clear();
|
|
|
printf("=============================================================\n");
|
|
|
printf("执行结束:Connor_Send_Mail_To_All_Users\n");
|
|
|
printf("=============================================================\n");
|
|
|
return ITK_ok;
|
|
|
}
|
|
|
|
|
|
/*
|
|
|
|
|
|
int Connor_Set_Mail_Statu(EPM_action_message_t msg) {
|
|
|
bool debug = false;
|
|
|
int ifail = ITK_ok, arg_cnt = 0, att_cnt = 0, task_count = 0, user_cnt = 0;
|
|
|
char* arg = NULL, * argflag = NULL, * argvalue = NULL, * task_name = NULL, * task_type = NULL;
|
|
|
char* user_id = NULL, * user_name = NULL, * job_name = NULL;
|
|
|
tag_t task_tag = NULLTAG, rootTask_tag = NULLTAG, user_tag = NULLTAG;
|
|
|
tag_t* attachments = NULL, * task_tags = NULL;
|
|
|
arg_cnt = TC_number_of_arguments(msg.arguments);
|
|
|
vector<tag_t> all_user_tags;
|
|
|
vector<string> mail_addrs;
|
|
|
ITKCALL(POM_get_user(&user_name, &user_tag));
|
|
|
ITKCALL(SA_ask_user_identifier2(user_tag, &user_id));
|
|
|
DOFREE(user_id);
|
|
|
WriteLog("=============================================================");
|
|
|
WriteLog("开始执行:Connor_Set_Mail_Statu");
|
|
|
WriteLog("=============================================================");
|
|
|
printf("开超级权限\n");
|
|
|
POM_AM__set_application_bypass(true);
|
|
|
task_tag = msg.task;
|
|
|
if (task_tag == NULLTAG) {
|
|
|
goto end;
|
|
|
}
|
|
|
char* task_uid;
|
|
|
POM_tag_to_uid(task_tag, &task_uid);
|
|
|
ITKCALL(ifail = EPM_ask_root_task(task_tag, &rootTask_tag));
|
|
|
ITKCALL(ifail = AOM_ask_value_string(rootTask_tag, "job_name", &job_name));
|
|
|
WriteLog("流程名称:%s", job_name);
|
|
|
ITKCALL(ifail = EPM_ask_sub_tasks(rootTask_tag, &task_count, &task_tags));
|
|
|
for (int i = 0;i < task_count;i++) {
|
|
|
tag_t sub_task = task_tags[i];
|
|
|
ITKCALL(ifail = EPM_ask_name2(sub_task, &task_name));
|
|
|
ITKCALL(ifail = AOM_ask_value_string(sub_task, "task_type", &task_type));
|
|
|
if (ifail != ITK_ok) {
|
|
|
DOFREE(task_name);
|
|
|
DOFREE(task_type);
|
|
|
continue;
|
|
|
}
|
|
|
WriteLog("%d. 读取任务信息 %s -> %s", i + 1, task_name, task_type);
|
|
|
if (strcmp("EPMDoTask", task_type) == 0) {
|
|
|
tag_t user_tag = NULLTAG;
|
|
|
ITKCALL(ifail = AOM_ask_value_tag(sub_task, "fnd0Performer", &user_tag));
|
|
|
if (user_tag == NULLTAG) {
|
|
|
WriteLog("未找到执行者");
|
|
|
continue;
|
|
|
}
|
|
|
char* user_name = NULL, * task_state = NULL;
|
|
|
ITKCALL(ifail = AOM_ask_value_string(user_tag, "user_name", &user_name));
|
|
|
ITKCALL(ifail = AOM_ask_value_string(sub_task, "task_state", &task_state));
|
|
|
WriteLog(">> DO任务信息:%s|%s", user_name, task_state);
|
|
|
all_user_tags.push_back(user_tag);
|
|
|
DOFREE(user_name);
|
|
|
DOFREE(task_state);
|
|
|
}
|
|
|
else if (strcmp("EPMReviewTask", task_type) == 0 || strcmp("EPMAcknowledgeTask", task_type) == 0) {
|
|
|
int reviewer_cnt = 0;
|
|
|
tag_t* reviewers = NULL;
|
|
|
ITKCALL(ifail = EPM_ask_reviewers(sub_task, &reviewer_cnt, &reviewers));
|
|
|
for (int j = 0;j < reviewer_cnt;j++) {
|
|
|
tag_t reviewer = reviewers[j];
|
|
|
tag_t user_tag = NULLTAG;
|
|
|
tag_t group_tag = NULLTAG;
|
|
|
EPM_signoff_decision_t decision;
|
|
|
char* comment = NULL, * date_str = NULL, * group_full_name = NULL, * user_name = NULL;
|
|
|
date_t date;
|
|
|
ITKCALL(ifail = AOM_ask_value_tag(reviewer, "user", &user_tag));
|
|
|
if (user_tag == NULLTAG) {
|
|
|
WriteLog(">> %d. 未指派用户", j + 1);
|
|
|
continue;
|
|
|
}
|
|
|
ITKCALL(ifail = AOM_ask_value_tag(reviewer, "group", &group_tag));
|
|
|
ITKCALL(ifail = AOM_ask_value_string(user_tag, "user_name", &user_name));
|
|
|
ITKCALL(ifail = AOM_ask_value_string(group_tag, "full_name", &group_full_name));
|
|
|
all_user_tags.push_back(user_tag);
|
|
|
DOFREE(comment);
|
|
|
DOFREE(user_name);
|
|
|
DOFREE(group_full_name);
|
|
|
DOFREE(date_str);
|
|
|
}
|
|
|
DOFREE(reviewers);
|
|
|
}
|
|
|
else {
|
|
|
WriteLog(">> 未知任务类型");
|
|
|
}
|
|
|
DOFREE(task_name);
|
|
|
DOFREE(task_type);
|
|
|
}
|
|
|
user_cnt = all_user_tags.size();
|
|
|
WriteLog("处理用户数据:%d", user_cnt);
|
|
|
for (int i = 0;i < user_cnt;i++) {
|
|
|
tag_t mail_user = all_user_tags[i], person_tag = NULLTAG;
|
|
|
char* user_str = NULL, * mail_str = NULL;
|
|
|
ITKCALL(ifail = AOM_ask_value_tag(mail_user, "person", &person_tag));
|
|
|
if (ifail != ITK_ok || person_tag == NULLTAG) {
|
|
|
continue;
|
|
|
}
|
|
|
ITKCALL(ifail = AOM_ask_value_string(person_tag, "PA9", &mail_str));
|
|
|
if (ifail != ITK_ok) {
|
|
|
continue;
|
|
|
}
|
|
|
ITKCALL(ifail = AOM_ask_value_string(mail_user, "user_name", &user_str));
|
|
|
WriteLog(">> %d. %s -> %s", i + 1, user_str, mail_str);
|
|
|
if (mail_str == NULL || strcmp("", mail_str) == 0 || std::find(mail_addrs.begin(), mail_addrs.end(), mail_str) != mail_addrs.end()) {
|
|
|
WriteLog(">> Skip");
|
|
|
}
|
|
|
else {
|
|
|
mail_addrs.push_back(mail_str);
|
|
|
}
|
|
|
DOFREE(user_str);
|
|
|
DOFREE(mail_str);
|
|
|
}
|
|
|
user_cnt = mail_addrs.size();
|
|
|
int c_sql_value_count = 0;
|
|
|
char** c_sql_values;
|
|
|
ITKCALL(PREF_ask_char_values("RB3_SQL_Connect2", &c_sql_value_count, &c_sql_values));
|
|
|
if (c_sql_value_count != 3)
|
|
|
{
|
|
|
WriteLog("首选项 RB3_SQL_Connect2 配置错误 数量%d ", c_sql_value_count);
|
|
|
CloseLog();
|
|
|
return 0;
|
|
|
}
|
|
|
if (ConnServer(c_sql_values[1], c_sql_values[2], c_sql_values[0]))//"tc11","infodba","//172.16.50.40/tc11" "TC12","infodba","172.16.68.13/tc1"
|
|
|
{
|
|
|
printf("提示:中间数据表访问失败\n");
|
|
|
return ifail;
|
|
|
}
|
|
|
else {
|
|
|
printf("提示:中间数据表访问成功\n");
|
|
|
WriteLog("发送邮件:%d", user_cnt);
|
|
|
for (int i = 0; i < user_cnt;i++) {
|
|
|
string mail_addr = mail_addrs[i];
|
|
|
char message[512] = "\0";
|
|
|
sprintf(message, "收到%s任务,请尽快处理!!", job_name);
|
|
|
char sql1[1024] = "\0";
|
|
|
sprintf(sql1, "insert into RB_EMAIL_VALUE(TASK_UID,USER_EMAIL,EMAIL_TITLE,EMAIL_MESSAGE,STATU)values ('%s','%s','【TeamCenter】流程任务提醒','%s' ,'1')"
|
|
|
, task_uid, mail_addr.c_str(), message);
|
|
|
printf("提示:sql1==%s\n", sql1);
|
|
|
if (ExecuteSQLNoInputParam(sql1) == -1)
|
|
|
{
|
|
|
printf("提示:有效期插入数据库 失败, %s \n", sql1);
|
|
|
}
|
|
|
else {
|
|
|
ExecuteSQLNoInputParam("commit");
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
DisConnServer();
|
|
|
printf("数据库连接断开\n");
|
|
|
printf("关超级权限\n");
|
|
|
POM_AM__set_application_bypass(false);
|
|
|
end:
|
|
|
DOFREE(job_name);
|
|
|
DOFREE(attachments);
|
|
|
all_user_tags.clear();
|
|
|
WriteLog("=============================================================");
|
|
|
WriteLog("执行结束:Connor_Set_Mail_Statu");
|
|
|
WriteLog("=============================================================");
|
|
|
return ITK_ok;
|
|
|
}
|
|
|
*/
|
|
|
//java调用发布 参数1:发布的对象 参数2:发布的类型()
|
|
|
//public void setReleaseStatus(TCComponent item, String statusName)
|
|
|
// throws TCException {
|
|
|
// TCUserService userservice = this.session.getUserService();
|
|
|
//
|
|
|
// Object[] obj = new Object[2];
|
|
|
// obj[0] = item;
|
|
|
// obj[1] = statusName;
|
|
|
// userservice.call("connor_set_release_status", obj);
|
|
|
//
|
|
|
// }
|
|
|
int connor_set_release_status(void* returnValue) {
|
|
|
int ifail = ITK_ok;
|
|
|
tag_t item = NULL_TAG, release_status = NULL_TAG;
|
|
|
char* release_name = NULL;
|
|
|
tag_t* release_objs = NULL;
|
|
|
|
|
|
USERARG_get_tag_argument(&item);
|
|
|
USERARG_get_string_argument(&release_name);
|
|
|
|
|
|
int temp_count = 1;
|
|
|
release_objs = (tag_t*)MEM_alloc(temp_count * sizeof(tag_t));
|
|
|
release_objs[0] = item;
|
|
|
|
|
|
ITKCALL(ifail = RELSTAT_create_release_status(release_name, &release_status));
|
|
|
ITKCALL(ifail = RELSTAT_add_release_status(release_status, temp_count, release_objs, TRUE));
|
|
|
|
|
|
if (release_name != NULL) {
|
|
|
MEM_free(release_name);
|
|
|
}
|
|
|
|
|
|
return ITK_ok;
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//导入数据集
|
|
|
static int import_dataset_file(tag_t dataset, char* ref_name, char* ext, char* fullfilename, char* original_name)
|
|
|
{
|
|
|
int ifail = ITK_ok;
|
|
|
tag_t new_file_tag = NULLTAG;
|
|
|
IMF_file_t file_descriptor = NULL;
|
|
|
AOM_refresh(dataset, FALSE);
|
|
|
char* new_file_name = NULL;
|
|
|
char new_ds_name[WSO_name_size_c + 1] = "";
|
|
|
char* filename = NULL;
|
|
|
new_file_name = USER_new_file_name(new_ds_name, ref_name, ext, 0);
|
|
|
|
|
|
|
|
|
filename = strrchr(fullfilename, '\\') + 1;
|
|
|
if (filename == NULL)
|
|
|
return ITK_ok;
|
|
|
ECHO("IMF_import_file\n");
|
|
|
//POM_AM__set_application_bypass(true);
|
|
|
IMF_import_file(fullfilename, new_file_name, SS_BINARY, &new_file_tag, &file_descriptor);
|
|
|
ECHO("IMF_set_original_file_name\n");
|
|
|
IMF_set_original_file_name2(new_file_tag, original_name);
|
|
|
|
|
|
IMF_close_file(file_descriptor);
|
|
|
AOM_save(new_file_tag);
|
|
|
AOM_unlock(new_file_tag);
|
|
|
AOM_refresh(new_file_tag, FALSE);
|
|
|
|
|
|
//添加至命名引用
|
|
|
//POM_AM__set_application_bypass(true);
|
|
|
ITKCALL(AOM_lock(dataset));
|
|
|
ECHO("AE_remove_dataset_named_ref\n");
|
|
|
AE_remove_dataset_named_ref2(dataset, ref_name);
|
|
|
AOM_save(dataset);
|
|
|
|
|
|
ECHO("AE_add_dataset_named_ref\n");
|
|
|
//POM_AM__set_application_bypass(true);
|
|
|
AE_add_dataset_named_ref2(dataset, ref_name, AE_PART_OF, new_file_tag);
|
|
|
|
|
|
AOM_save(dataset);
|
|
|
AOM_unlock(dataset);
|
|
|
//ITKCALL( AOM_refresh( dataset, FALSE ) );
|
|
|
return ifail;
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//要挂载的对象,数据集全路径,数据集引用文件名称 不用对pdf发布
|
|
|
int importPdf2(tag_t rev_tag, tag_t rel_tag, const char* pdfFile, char* datasetName, char* pdfName) {
|
|
|
tag_t* rfTags, datasetTag = NULLTAG, relation;
|
|
|
int ifail = ITK_ok, rfCount = 0;
|
|
|
char type_class[WSO_object_type_size_c + 1], *pdfDatasetName;
|
|
|
if (datasetTag == NULLTAG) {
|
|
|
printf("没有找到PDF数据集%s,开始进行创建\n", datasetName);
|
|
|
tag_t pdfTypeTag = NULLTAG, tool = NULLTAG;
|
|
|
ITKCALL(ifail = AE_find_datasettype2("PDF", &pdfTypeTag));
|
|
|
ITKCALL(ifail = AE_create_dataset_with_id(pdfTypeTag, datasetName, "dwg", "", "", &datasetTag));//modify 2019 12 31 pdfname->datasetName 2020/10/15描述设置成dwg
|
|
|
|
|
|
ITKCALL(ifail = AE_ask_datasettype_def_tool(pdfTypeTag, &tool));
|
|
|
ITKCALL(ifail = AE_set_dataset_tool(datasetTag, tool));
|
|
|
ITKCALL(ifail = AE_set_dataset_format2(datasetTag, "PDF_Reference"));
|
|
|
ITKCALL(ifail = AOM_save(datasetTag));
|
|
|
if (datasetTag == NULLTAG) {
|
|
|
printf("创建失败\n");
|
|
|
return -1;
|
|
|
}
|
|
|
else {
|
|
|
printf("创建成功\n");
|
|
|
//POM_AM__set_application_bypass(true);
|
|
|
//ITKCALL(ifail = ITEM_attach_object_tag(rev_tag, datasetTag, rel_tag));
|
|
|
ITKCALL(ifail = GRM_create_relation(rev_tag, datasetTag, rel_tag, NULLTAG, &relation));
|
|
|
ITKCALL(GRM_save_relation(relation));
|
|
|
ITKCALL(AOM_unlock(relation));
|
|
|
//POM_AM__set_application_bypass(false);
|
|
|
if (ifail == ITK_ok) {
|
|
|
printf("挂载到版本下成功\n");
|
|
|
}
|
|
|
else {
|
|
|
printf("挂载到版本下失败\n");
|
|
|
return -1;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
else {
|
|
|
printf("找到PDF数据集%s,开始进行更新数据文件\n", pdfName);
|
|
|
}
|
|
|
char* pdfFile2 = new char[255];
|
|
|
strcpy(pdfFile2, pdfFile);
|
|
|
ITKCALL(ifail = import_dataset_file(datasetTag, "PDF_Reference", "pdf", pdfFile2, pdfName));
|
|
|
if (ifail != ITK_ok) {
|
|
|
//WriteLog(dwgName, "上传数据集文件失败");
|
|
|
printf("上传数据集文件失败\n");
|
|
|
}
|
|
|
|
|
|
return ifail;
|
|
|
}
|
|
|
|
|
|
int conventdwg2pdf(tag_t item_rev_tag, tag_t dataset, tag_t rel_tag, char* signoff)
|
|
|
{
|
|
|
int ifail = ITK_ok;
|
|
|
|
|
|
tag_t spec_dataset_rev = NULLTAG,
|
|
|
ref_object = NULLTAG;
|
|
|
char* ref_object_name = NULL;
|
|
|
AE_reference_type_t reference_type;
|
|
|
char* datasetName = NULL;
|
|
|
AOM_ask_value_string(dataset, "object_name", &datasetName);
|
|
|
|
|
|
char datasetName_temp[SS_MAXPATHLEN] = "\0";
|
|
|
POM_AM__set_application_bypass(true);
|
|
|
if (strstr(datasetName, ".dwg") != NULL) {
|
|
|
char ref_pdf_name_temp[SS_MAXPATHLEN] = "\0";
|
|
|
strncpy(ref_pdf_name_temp, datasetName, strlen(datasetName) - 4);
|
|
|
sprintf(datasetName_temp, "%s.pdf", ref_pdf_name_temp);
|
|
|
}
|
|
|
else {
|
|
|
sprintf(datasetName_temp, "%s", datasetName);
|
|
|
}
|
|
|
|
|
|
AE_ask_dataset_latest_rev(dataset, &spec_dataset_rev);
|
|
|
AOM_ask_value_string(spec_dataset_rev, "object_name", &ref_object_name);
|
|
|
printf("ref_object_name=%s\n", ref_object_name);
|
|
|
char ref_name[WSO_name_size_c + 1] = "RB3_GCAD";
|
|
|
|
|
|
AE_ask_dataset_named_ref2(spec_dataset_rev, ref_name, &reference_type, &ref_object);
|
|
|
if (ref_object == NULLTAG)
|
|
|
{
|
|
|
printf("\nref_object is NULLTAG\n");
|
|
|
return ITK_ok;
|
|
|
}
|
|
|
printf("\reference_type=%d\n", reference_type);
|
|
|
if (reference_type == AE_PART_OF)
|
|
|
{
|
|
|
char* pathname;
|
|
|
IMF_ask_file_pathname2(ref_object, SS_WNT_MACHINE, &pathname);
|
|
|
char* origin_file_name;
|
|
|
IMF_ask_original_file_name2(ref_object, &origin_file_name);
|
|
|
|
|
|
char new_ds_name[WSO_name_size_c + 1] = "";
|
|
|
char* new_file_name = USER_new_file_name(new_ds_name, ref_name, "dwg", 0);
|
|
|
char* temp_dir = getenv("TEMP");
|
|
|
char temp_file[SS_MAXPATHLEN] = "";
|
|
|
char dat_file[SS_MAXPATHLEN] = "";
|
|
|
char txttemp[SS_MAXPATHLEN] = "\0";
|
|
|
|
|
|
strcpy(temp_file, temp_dir);
|
|
|
strcat(temp_file, "\\");
|
|
|
strcat(temp_file, new_file_name);
|
|
|
printf("\ntemp_file=%s\n", temp_file);
|
|
|
strncpy(txttemp, temp_file, strlen(temp_file) - 4);
|
|
|
sprintf(dat_file, "%s.txt", txttemp);
|
|
|
FILE* fpWrite = fopen(dat_file, "w");
|
|
|
fprintf(fpWrite, "%s", signoff);
|
|
|
fclose(fpWrite);
|
|
|
IMF_export_file(ref_object, temp_file);
|
|
|
printf("\n555555555\n");
|
|
|
|
|
|
int iCnt;
|
|
|
char* user_lib_env, pTempStr[500];
|
|
|
char local_path[MAX_PATH] = "";
|
|
|
char cmd[256] = "";
|
|
|
strcpy(cmd, "start /wait cad2pdf.exe");
|
|
|
strcat(cmd, " ");
|
|
|
strcat(cmd, temp_file);//dwg文件路径
|
|
|
strcat(cmd, " ");
|
|
|
strcat(cmd, dat_file);//参数
|
|
|
printf("\n%s\n", cmd);
|
|
|
system(cmd);
|
|
|
char pdftemp[SS_MAXPATHLEN] = "\0";
|
|
|
char pdf[SS_MAXPATHLEN] = "\0";
|
|
|
if (strstr(temp_file, ".dwg") != NULL) {
|
|
|
strncpy(pdftemp, temp_file, strlen(temp_file) - 4);
|
|
|
printf("pdftemp=%s\n", pdftemp);
|
|
|
sprintf(pdf, "%s.pdf", pdftemp);
|
|
|
printf("pdf=%s\n", pdf);
|
|
|
//strcpy(user_lib_env, local_path);
|
|
|
//pdf=true;
|
|
|
|
|
|
int time_2_pdf = 0;
|
|
|
|
|
|
for (int time_2_pdf = 0; time_2_pdf < 20; time_2_pdf++)
|
|
|
{
|
|
|
Sleep(1000);
|
|
|
ifail = 1;
|
|
|
if ((_access(pdf, 0)) != -1)
|
|
|
{
|
|
|
printf("找到pdf%s\n", pdf);
|
|
|
int size_ftp = 0;
|
|
|
struct stat buf;
|
|
|
if (stat(pdf, &buf) < 0) {
|
|
|
printf("判断pdf大小失败\n");
|
|
|
}
|
|
|
else {
|
|
|
size_ftp = buf.st_size;
|
|
|
}
|
|
|
|
|
|
//pdf=true;
|
|
|
char* pdf_name;
|
|
|
AOM_ask_value_string(item_rev_tag, "object_name", &pdf_name);
|
|
|
char ref_pdf_name[SS_MAXPATHLEN] = "\0";
|
|
|
if (strstr(pdf_name, ".dwg") != NULL) {
|
|
|
char ref_pdf_name_temp[SS_MAXPATHLEN] = "\0";
|
|
|
strncpy(ref_pdf_name_temp, pdf_name, strlen(pdf_name) - 4);
|
|
|
sprintf(ref_pdf_name, "%s.pdf", ref_pdf_name_temp);
|
|
|
}
|
|
|
else {
|
|
|
sprintf(ref_pdf_name, "%s.pdf", pdf_name);
|
|
|
}
|
|
|
|
|
|
ifail = importPdf2(item_rev_tag, rel_tag, pdf, datasetName_temp, ref_pdf_name);
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
for (int x = 0; x < 5; x++)
|
|
|
{
|
|
|
if ((_access(pdf, 0)) == -1) {
|
|
|
printf("没有生成的pdf再次执行cmd\n", pdf);
|
|
|
system(cmd);
|
|
|
for (int time_2_pdf = 0; time_2_pdf < 20; time_2_pdf++)
|
|
|
{
|
|
|
Sleep(1000);
|
|
|
ifail = 1;
|
|
|
if ((_access(pdf, 0)) != -1)
|
|
|
{
|
|
|
//pdf=true;
|
|
|
printf("找到pdf%s\n", pdf);
|
|
|
int size_ftp = 0;
|
|
|
struct stat buf;
|
|
|
if (stat(pdf, &buf) < 0) {
|
|
|
printf("判断pdf大小失败\n");
|
|
|
}
|
|
|
else {
|
|
|
size_ftp = buf.st_size;
|
|
|
}
|
|
|
printf("pdf大小%s--%d\n", pdf, size_ftp);
|
|
|
char ref_pdf_name[SS_MAXPATHLEN] = "\0";
|
|
|
if (strstr(datasetName, ".dwg") != NULL) {
|
|
|
char ref_pdf_name_temp[SS_MAXPATHLEN] = "\0";
|
|
|
strncpy(ref_pdf_name_temp, datasetName, strlen(datasetName) - 4);
|
|
|
sprintf(ref_pdf_name, "%s.pdf", ref_pdf_name_temp);
|
|
|
}
|
|
|
else {
|
|
|
sprintf(ref_pdf_name, "%s.pdf", datasetName);
|
|
|
}
|
|
|
|
|
|
ifail = importPdf2(item_rev_tag, rel_tag, pdf, datasetName_temp, ref_pdf_name);
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
else {
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
printf("dwg文件路径=========>%s\n", temp_file);
|
|
|
printf("pdf文件路径=========>%s\n", pdf);
|
|
|
printf("txt文件路径=========>%s\n", dat_file);
|
|
|
//删除缓存
|
|
|
if (access(temp_file, 0) == 0)
|
|
|
{
|
|
|
|
|
|
unlink(temp_file);
|
|
|
}
|
|
|
|
|
|
if (access(pdf, 0) == 0)
|
|
|
{
|
|
|
unlink(pdf);
|
|
|
}
|
|
|
|
|
|
if (access(dat_file, 0) == 0)
|
|
|
{
|
|
|
unlink(dat_file);
|
|
|
}
|
|
|
|
|
|
|
|
|
}
|
|
|
if (datasetName != NULL) {
|
|
|
MEM_free(datasetName);
|
|
|
datasetName = NULL;
|
|
|
}
|
|
|
if (ref_object_name != NULL) {
|
|
|
MEM_free(ref_object_name);
|
|
|
ref_object_name = NULL;
|
|
|
}
|
|
|
POM_AM__set_application_bypass(false);
|
|
|
|
|
|
return ifail;
|
|
|
}
|
|
|
|
|
|
|
|
|
/*************************************************************************************************
|
|
|
*
|
|
|
*dwg转pdf
|
|
|
**************************************************************************************************/
|
|
|
int connor_dwg_to_pdf(void* returnValue) {
|
|
|
int ifail = ITK_ok;
|
|
|
tag_t item = NULL_TAG, release_status = NULL_TAG;
|
|
|
char* release_name = NULL;
|
|
|
tag_t* release_objs = NULL;
|
|
|
tag_t itemrevision = NULLTAG;
|
|
|
USERARG_get_tag_argument(&item);
|
|
|
USERARG_get_string_argument(&release_name);
|
|
|
|
|
|
//int temp_count = 1;
|
|
|
//release_objs = (tag_t*)MEM_alloc(temp_count * sizeof(tag_t));
|
|
|
//release_objs[0] = item;
|
|
|
|
|
|
itemrevision = item;
|
|
|
//获得数据集
|
|
|
tag_t relation_type = NULLTAG;
|
|
|
//tag_t attach_relation_type = NULLTAG;
|
|
|
ITKCALL(GRM_find_relation_type(TC_specification_rtype, &relation_type));
|
|
|
tag_t* secondary_objects = NULLTAG;
|
|
|
int ds_count = 0;
|
|
|
char* dataset_type = NULL, *desc_value = NULL, *file_path = NULL, *desc_path;
|
|
|
|
|
|
ITKCALL(GRM_list_secondary_objects_only(itemrevision, relation_type, &ds_count, &secondary_objects));
|
|
|
for (int j = 0; j < ds_count; j++)
|
|
|
{
|
|
|
printf("进1\n");
|
|
|
ITKCALL(AOM_ask_value_string(secondary_objects[j], "object_type", &dataset_type));
|
|
|
int des_count = 0;
|
|
|
tag_t* dess = NULL;
|
|
|
char* name;
|
|
|
|
|
|
|
|
|
if (strcmp(dataset_type, "RB3_GCAD") != 0) {
|
|
|
if (dataset_type != NULL) {
|
|
|
MEM_free(dataset_type);
|
|
|
dataset_type = NULL;
|
|
|
}
|
|
|
|
|
|
continue;
|
|
|
}
|
|
|
|
|
|
|
|
|
ITKCALL(AOM_ask_value_tags(secondary_objects[j], "ref_list", &des_count, &dess));
|
|
|
if (des_count < 1) {
|
|
|
printf("该数据集引用数量错误\n");
|
|
|
continue;
|
|
|
}
|
|
|
|
|
|
printf("开始判断类型\n");
|
|
|
if (strcmp(dataset_type, "RB3_GCAD") == 0)
|
|
|
{
|
|
|
printf("cad类型\n");
|
|
|
conventdwg2pdf(itemrevision, secondary_objects[j], relation_type, release_name);
|
|
|
|
|
|
//signoff_acad(secondary_objects[j]);
|
|
|
}
|
|
|
|
|
|
MEM_free(dataset_type);
|
|
|
|
|
|
}
|
|
|
DOFREE(secondary_objects);
|
|
|
|
|
|
if (release_name != NULL) {
|
|
|
MEM_free(release_name);
|
|
|
}
|
|
|
|
|
|
return ITK_ok;
|
|
|
}
|
|
|
std::string string_To_UTF8(const std::string& str)
|
|
|
{
|
|
|
int nwLen = ::MultiByteToWideChar(CP_ACP, 0, str.c_str(), -1, NULL, 0);
|
|
|
wchar_t* pwBuf = new wchar_t[nwLen + 1];//一定要加1,不然会出现尾巴
|
|
|
ZeroMemory(pwBuf, nwLen * 2 + 2);
|
|
|
::MultiByteToWideChar(CP_ACP, 0, str.c_str(), str.length(), pwBuf, nwLen);
|
|
|
int nLen = ::WideCharToMultiByte(CP_UTF8, 0, pwBuf, -1, NULL, NULL, NULL, NULL);
|
|
|
char* pBuf = new char[nLen + 1];
|
|
|
ZeroMemory(pBuf, nLen + 1);
|
|
|
::WideCharToMultiByte(CP_UTF8, 0, pwBuf, nwLen, pBuf, nLen, NULL, NULL);
|
|
|
std::string retStr(pBuf);
|
|
|
delete[]pwBuf;
|
|
|
delete[]pBuf;
|
|
|
pwBuf = NULL;
|
|
|
pBuf = NULL;
|
|
|
return retStr;
|
|
|
}
|
|
|
|
|
|
bool sleep_flag = true;
|
|
|
size_t req_reply(void* ptr, size_t size, size_t nmemb, void* stream)
|
|
|
{
|
|
|
if (sleep_flag) {
|
|
|
Sleep(1000);
|
|
|
sleep_flag = false;
|
|
|
}
|
|
|
|
|
|
//在注释的里面可以打印请求流,cookie的信息
|
|
|
//cout << "----->reply" << endl;
|
|
|
string* str = (string*)stream;
|
|
|
//cout << *str << endl;
|
|
|
(*str).append((char*)ptr, size * nmemb);
|
|
|
return size * nmemb;
|
|
|
}
|
|
|
string getToken(string url) {
|
|
|
CURL* curl = NULL;
|
|
|
CURLcode res;
|
|
|
string response;
|
|
|
string authorization = "Authorization:Bearer ";
|
|
|
curl = curl_easy_init();
|
|
|
|
|
|
struct curl_slist* headerlist = NULL, *headerlist2 = NULL;
|
|
|
|
|
|
// 设置表头,表头内容可能不同
|
|
|
headerlist = curl_slist_append(headerlist, "Accept-Charset: UTF-8");
|
|
|
headerlist = curl_slist_append(headerlist, "Content-Type: application/json;charset=UTF-8");
|
|
|
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headerlist);
|
|
|
|
|
|
// 设置URL
|
|
|
curl_easy_setopt(curl, CURLOPT_URL, url.c_str());
|
|
|
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, "");
|
|
|
//不接收响应头数据0代表不接收 1代表接收
|
|
|
curl_easy_setopt(curl, CURLOPT_HEADER, 1);
|
|
|
//设置数据接收和写入函数
|
|
|
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, req_reply);
|
|
|
curl_easy_setopt(curl, CURLOPT_WRITEDATA, &response);
|
|
|
|
|
|
// 设置为Post
|
|
|
curl_easy_setopt(curl, CURLOPT_POST, 1);
|
|
|
|
|
|
// 发送
|
|
|
res = curl_easy_perform(curl);
|
|
|
|
|
|
printf("Get Token response:%s\n", response.c_str());
|
|
|
//裁剪token
|
|
|
authorization.append(response.substr(response.find("authorization:") + 15, 406));//383
|
|
|
|
|
|
//printf("Authorization:%s\n", authorization);
|
|
|
if (res != CURLE_OK)
|
|
|
{
|
|
|
// 获取详细错误信息
|
|
|
const char* szErr = curl_easy_strerror(res);
|
|
|
fprintf(stderr, "curl_easy_perform() failed: %s\n", szErr);
|
|
|
}
|
|
|
|
|
|
// 清空
|
|
|
curl_easy_cleanup(curl);
|
|
|
|
|
|
// 释放表头
|
|
|
curl_slist_free_all(headerlist);
|
|
|
return authorization;
|
|
|
}
|
|
|
void do_Pust(string arg1value, string arg2value, string json_object) {
|
|
|
|
|
|
string authorization = getToken(arg2value);
|
|
|
ECHO("token:%s\n", authorization.c_str());
|
|
|
const char* curl_url = authorization.c_str();
|
|
|
CURL* curl = NULL;
|
|
|
CURLcode res;
|
|
|
//string response;
|
|
|
curl = curl_easy_init();
|
|
|
|
|
|
struct curl_slist* headerlist = NULL;
|
|
|
|
|
|
// 设置表头,表头内容可能不同
|
|
|
headerlist = curl_slist_append(headerlist, "Accept-Charset: UTF-8");
|
|
|
headerlist = curl_slist_append(headerlist, "Content-Type: application/json;charset=UTF-8");
|
|
|
headerlist = curl_slist_append(headerlist, curl_url);
|
|
|
|
|
|
//headerlist = curl_slist_append(headerlist, "Authorization:Bearer eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiI2MTc3ZWVlMmU0YjBjNTI1ZjBjOGFlODAsYWRtaW4iLCJpc3MiOiJwaXByb2plY3QuY24iLCJpYXQiOjE2MzUzMjk4NDUsImV4cCI6MTYzNTkzNDY0NX0.ZVJBEVAoN9RhW186L_iKkvRrz_UKYcE8lv78oSYjhgLmBtQe1UM-rtpET3xAtKXWwpTis_ieDHc5nphHpE9JGg");
|
|
|
//headerlist = curl_slist_append(headerlist, "Authorization:Bearer eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiI2MTgyNmYyZmU0YjBjNTI1NjU0OTdiNDAsYWRtaW4iLCJpc3MiOiJwaXByb2plY3QuY24iLCJpYXQiOjE2MzU5NDU1NDMsImV4cCI6MTYzNjU1MDM0M30.Lv0LAP2HFxi_Vbuuracw_U6OKOwZaib7wksFO1ILRQKaHBG3L6JGMv7ppSown-1qeKuoV5PkLPA0guWvhWT8hw");
|
|
|
|
|
|
|
|
|
|
|
|
// 设置URL
|
|
|
ECHO("PaiApi%s\n", arg1value.c_str());
|
|
|
curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "POST");
|
|
|
curl_easy_setopt(curl, CURLOPT_URL, arg1value.c_str());
|
|
|
curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
|
|
|
curl_easy_setopt(curl, CURLOPT_DEFAULT_PROTOCOL, "https");
|
|
|
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headerlist);
|
|
|
// 设置参数,比如"ParamName1=ParamName1Content&ParamName2=ParamName2Content&..."
|
|
|
//ECHO("TOUTF8:%s\n", string_To_UTF8(json_object).c_str());
|
|
|
string data = string_To_UTF8(json_object);
|
|
|
const char* curl_data = data.c_str();
|
|
|
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, curl_data);
|
|
|
//curl_easy_setopt(curl, CURLOPT_POSTFIELDS, string_To_UTF8(json_object).c_str());
|
|
|
//不接收响应头数据0代表不接收 1代表接收
|
|
|
//curl_easy_setopt(curl, CURLOPT_HEADER, 1);
|
|
|
//设置数据接收和写入函数
|
|
|
//curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, req_reply);
|
|
|
//curl_easy_setopt(curl, CURLOPT_WRITEDATA, &response);
|
|
|
// 设置为Post
|
|
|
//curl_easy_setopt(curl, CURLOPT_POST, 1);
|
|
|
// 发送
|
|
|
res = curl_easy_perform(curl);
|
|
|
//printf("response:%s\n",response.c_str());
|
|
|
if (res != CURLE_OK)
|
|
|
{
|
|
|
// 获取详细错误信息
|
|
|
const char* szErr = curl_easy_strerror(res);
|
|
|
fprintf(stderr, "curl_easy_perform() failed: %s\n", szErr);
|
|
|
ECHO("Err:%s\n", szErr);
|
|
|
}
|
|
|
// 清空
|
|
|
curl_easy_cleanup(curl);
|
|
|
|
|
|
// 释放表头
|
|
|
//curl_slist_free_all(headerlist);
|
|
|
}
|
|
|
int Connor_Send_Delievry_To_Pai(EPM_action_message_t msg) {
|
|
|
printf("*************************************************************\n");
|
|
|
printf("* Connor_Send_Delievry_To_Pai is strat ! *\n");
|
|
|
printf("*************************************************************\n");
|
|
|
int ifail = ITK_ok;
|
|
|
//参数相关
|
|
|
|
|
|
int att_cnt = 0, arg_cnt = 0;
|
|
|
tag_t task_tag = NULLTAG, rootTask_tag = NULLTAG, *attachments = NULLTAG;
|
|
|
//获取handler的参数的个数
|
|
|
TC_argument_list_t* arguments = msg.arguments;
|
|
|
arg_cnt = TC_number_of_arguments(msg.arguments);
|
|
|
ECHO("参数个数为:%d\n", arg_cnt);
|
|
|
map<string, string> paras;
|
|
|
for (auto i = 0; i < arg_cnt; i++)
|
|
|
{
|
|
|
char* temp_key, *temp_val;
|
|
|
ITK_ask_argument_named_value(TC_next_argument(arguments), &temp_key, &temp_val);
|
|
|
paras[temp_key] = temp_val;
|
|
|
|
|
|
}
|
|
|
vector<string> relation_types;
|
|
|
split(paras["Relation"], ",", &relation_types);
|
|
|
ECHO("relation_types num:%d\n", relation_types.size());
|
|
|
|
|
|
char* job_name = NULL;//, task_name[1024] = "", task_id[1024] = "";
|
|
|
//获取当前触发的任务
|
|
|
task_tag = msg.task;
|
|
|
//获取根流程节点
|
|
|
ITKCALL(EPM_ask_root_task(task_tag, &rootTask_tag));
|
|
|
//获取目标引用对象
|
|
|
ITKCALL(EPM_ask_attachments(rootTask_tag, EPM_target_attachment, &att_cnt, &attachments));
|
|
|
ECHO("att_cnt:%d\n", att_cnt);
|
|
|
/*ITKCALL(AOM_ask_value_string(rootTask_tag, "job_name", &job_name));
|
|
|
ECHO("job_name:%s\n", job_name);
|
|
|
char* token = NULL, * ptr = NULL, temp[1024] = "";
|
|
|
|
|
|
token = strtok(job_name, "-");
|
|
|
strcpy(task_id, token);
|
|
|
|
|
|
token = strtok(NULL, "-");
|
|
|
strcpy(task_name, token);*/
|
|
|
|
|
|
|
|
|
string json_object;
|
|
|
string json_projectUID;
|
|
|
for (int i = 0; i < att_cnt; i++) {
|
|
|
char* item_id = NULL, *object_name = NULL, *object_type = NULL, *project_uid = NULL, *taskUid = NULL;
|
|
|
ITKCALL(AOM_ask_value_string(attachments[i], "object_type", &object_type));
|
|
|
ECHO("object_type:%s\n", object_type);
|
|
|
if (strstr(object_type, paras["Target"].c_str()) != NULL) {
|
|
|
int master_num = 0, relation_num = 0;
|
|
|
tag_t* master_tags = NULLTAG, *relation_tags = NULLTAG;
|
|
|
char* deliverable_id = NULL, *deliverable_name = NULL;
|
|
|
ITKCALL(AOM_ask_value_string(attachments[i], "object_name", &object_name));
|
|
|
|
|
|
//获取版本表单 IMAN_master_form_rev
|
|
|
ITKCALL(AOM_ask_value_tags(attachments[i], "IMAN_master_form_rev", &master_num, &master_tags));
|
|
|
|
|
|
ITKCALL(AOM_ask_value_string(master_tags[0], "rb3_PaiProjectID", &project_uid));
|
|
|
ITKCALL(AOM_ask_value_string(master_tags[0], "user_data_1", &taskUid));
|
|
|
ECHO("taskUid:%s\n", item_id);
|
|
|
ECHO("task_name:%s\n", object_name);
|
|
|
ECHO("project_uid:%s\n", project_uid);
|
|
|
json_object.assign("{");
|
|
|
//json_object.append("\"projectId\":\"");
|
|
|
//61a883a7e4b0b0e10cfe9b36\",");
|
|
|
/*json_object.append("\"projectId\":\"");
|
|
|
json_object.append(project_uid);
|
|
|
json_object.append("\",");*/
|
|
|
json_object.append("\"taskUid\":\"");
|
|
|
json_object.append(taskUid);
|
|
|
json_object.append("\",");
|
|
|
json_object.append("\"delivery\":[");
|
|
|
|
|
|
for (int z = 0; z < relation_types.size(); z++) {
|
|
|
ITKCALL(AOM_ask_value_tags(attachments[i], relation_types[z].c_str(), &relation_num, &relation_tags));
|
|
|
|
|
|
for (int j = 0; j < relation_num; j++) {
|
|
|
|
|
|
//获取对象类型
|
|
|
char * relationType = NULL;
|
|
|
ITKCALL(AOM_ask_value_string(relation_tags[j], "object_type", &relationType));
|
|
|
if ((strstr(relationType, "Revision") == NULL) || (strstr(relationType, "Master") != NULL)
|
|
|
|| (strstr(relationType, "master") != NULL) || (strstr(relationType, "BOM") != NULL) || (strstr(relationType, "bom") != NULL) || (strstr(relationType, "Bom") != NULL))
|
|
|
{
|
|
|
ITKCALL(POM_tag_to_uid(relation_tags[j], &deliverable_id));
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
//根据版本获取对象
|
|
|
tag_t item = NULL_TAG;
|
|
|
ITEM_ask_item_of_rev(relation_tags[j], &item);
|
|
|
ITKCALL(POM_tag_to_uid(item, &deliverable_id));
|
|
|
}
|
|
|
|
|
|
//ITKCALL(AOM_ask_value_string(relation_tags[j], "item_id", &deliverable_id));
|
|
|
ITKCALL(AOM_ask_value_string(relation_tags[j], "object_name", &deliverable_name));
|
|
|
json_object.append("{");
|
|
|
json_object.append("\"tcId\":\"");
|
|
|
json_object.append(deliverable_id);
|
|
|
json_object.append("\",\"tcName\":\"");
|
|
|
json_object.append(deliverable_name);
|
|
|
json_object.append("\"}");
|
|
|
|
|
|
if (z == relation_types.size() - 1 && j != relation_num - 1) {
|
|
|
json_object.append(",");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
}
|
|
|
json_object.append("]");
|
|
|
json_object.append("}");
|
|
|
ECHO("json_object:%s\n", json_object.c_str());
|
|
|
|
|
|
|
|
|
do_Pust(paras["SendDeliveryApi"], paras["GetTokenApi"], json_object);
|
|
|
|
|
|
if (relation_tags) {
|
|
|
MEM_free(relation_tags);
|
|
|
relation_tags = NULL;
|
|
|
}
|
|
|
if (deliverable_id) {
|
|
|
MEM_free(deliverable_id);
|
|
|
deliverable_id = NULL;
|
|
|
}
|
|
|
if (deliverable_name) {
|
|
|
MEM_free(deliverable_name);
|
|
|
deliverable_name = NULL;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (object_type) {
|
|
|
MEM_free(object_type);
|
|
|
object_type = NULL;
|
|
|
}
|
|
|
if (object_name) {
|
|
|
MEM_free(object_name);
|
|
|
object_name = NULL;
|
|
|
}
|
|
|
if (project_uid) {
|
|
|
MEM_free(project_uid);
|
|
|
project_uid = NULL;
|
|
|
}
|
|
|
if (item_id) {
|
|
|
MEM_free(item_id);
|
|
|
item_id = NULL;
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
printf("*************************************************************\n");
|
|
|
printf("* Connor_Send_Delievry_To_Pai is end ! *\n");
|
|
|
printf("*************************************************************\n");
|
|
|
return ITK_ok;
|
|
|
}
|
|
|
//std::string string_To_UTF8(const std::string& str)
|
|
|
//{
|
|
|
// int nwLen = ::MultiByteToWideChar(CP_ACP, 0, str.c_str(), -1, NULL, 0);
|
|
|
// wchar_t* pwBuf = new wchar_t[nwLen - 1];//一定要加1,不然会出现尾巴
|
|
|
// ZeroMemory(pwBuf, nwLen * 2 + 2);
|
|
|
// ::MultiByteToWideChar(CP_ACP, 0, str.c_str(), str.length(), pwBuf, nwLen);
|
|
|
// int nLen = ::WideCharToMultiByte(CP_UTF8, 0, pwBuf, -1, NULL, NULL, NULL, NULL);
|
|
|
// char* pBuf = new char[nLen + 1];
|
|
|
// ZeroMemory(pBuf, nLen + 1);
|
|
|
// ::WideCharToMultiByte(CP_UTF8, 0, pwBuf, nwLen, pBuf, nLen, NULL, NULL);
|
|
|
// std::string retStr(pBuf);
|
|
|
// delete[]pwBuf;
|
|
|
// delete[]pBuf;
|
|
|
// pwBuf = NULL;
|
|
|
// pBuf = NULL;
|
|
|
// return retStr;
|
|
|
//}
|
|
|
//std::string iso_8859_1_to_utf8(std::string& str)
|
|
|
//{
|
|
|
// string strOut;
|
|
|
// for (std::string::iterator it = str.begin(); it != str.end(); ++it)
|
|
|
// {
|
|
|
// uint8_t ch = *it;
|
|
|
// if (ch < 0x80) {
|
|
|
// strOut.push_back(ch);
|
|
|
// }
|
|
|
// else {
|
|
|
// strOut.push_back(0xc0 | ch >> 6);
|
|
|
// strOut.push_back(0x80 | (ch & 0x3f));
|
|
|
// }
|
|
|
// }
|
|
|
// return strOut;
|
|
|
//}
|
|
|
//bool sleep_flag = true;
|
|
|
//size_t req_reply(void* ptr, size_t size, size_t nmemb, void* stream)
|
|
|
//{
|
|
|
// if (sleep_flag) {
|
|
|
// Sleep(1000);
|
|
|
// sleep_flag = false;
|
|
|
// }
|
|
|
//
|
|
|
// //在注释的里面可以打印请求流,cookie的信息
|
|
|
// //cout << "----->reply" << endl;
|
|
|
// string* str = (string*)stream;
|
|
|
// //cout << *str << endl;
|
|
|
// (*str).append((char*)ptr, size * nmemb);
|
|
|
// str = NULL;
|
|
|
// return size * nmemb;
|
|
|
//}
|
|
|
//string getToken(string url) {
|
|
|
// CURL* curl = NULL;
|
|
|
// CURLcode res;
|
|
|
// string response;
|
|
|
// string authorization = "Authorization:Bearer ";
|
|
|
// curl = curl_easy_init();
|
|
|
//
|
|
|
// struct curl_slist* headerlist = NULL, * headerlist2 = NULL;
|
|
|
//
|
|
|
// // 设置表头,表头内容可能不同
|
|
|
// headerlist = curl_slist_append(headerlist, "Accept-Charset: UTF-8");
|
|
|
// headerlist = curl_slist_append(headerlist, "Content-Type: application/json;charset=UTF-8");
|
|
|
// curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headerlist);
|
|
|
//
|
|
|
// // 设置URL
|
|
|
// curl_easy_setopt(curl, CURLOPT_URL, url.c_str());
|
|
|
// curl_easy_setopt(curl, CURLOPT_POSTFIELDS, "");
|
|
|
// //不接收响应头数据0代表不接收 1代表接收
|
|
|
// curl_easy_setopt(curl, CURLOPT_HEADER, 1);
|
|
|
// //设置数据接收和写入函数
|
|
|
// curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, req_reply);
|
|
|
// curl_easy_setopt(curl, CURLOPT_WRITEDATA, (void*)&response);
|
|
|
//
|
|
|
// // 设置为Post
|
|
|
// curl_easy_setopt(curl, CURLOPT_POST, 1);
|
|
|
//
|
|
|
// // 发送
|
|
|
// res = curl_easy_perform(curl);
|
|
|
//
|
|
|
// //printf("Get Token response:%s\n", response.c_str());
|
|
|
// //裁剪token
|
|
|
// authorization.append(response.substr(response.find("authorization:") + 15, 235));
|
|
|
//
|
|
|
// //printf("Authorization:%s\n", authorization.c_str());
|
|
|
// if (res != CURLE_OK)
|
|
|
// {
|
|
|
// // 获取详细错误信息
|
|
|
// const char* szErr = curl_easy_strerror(res);
|
|
|
// fprintf(stderr, "curl_easy_perform() failed: %s\n", szErr);
|
|
|
// }
|
|
|
//
|
|
|
// // 清空
|
|
|
// curl_easy_cleanup(curl);
|
|
|
//
|
|
|
// // 释放表头
|
|
|
// curl_slist_free_all(headerlist);
|
|
|
// return authorization;
|
|
|
//}
|
|
|
//
|
|
|
//int Connor_Send_Delievry_To_Pai(EPM_action_message_t msg) {
|
|
|
// ECHO("*************************************************************\n");
|
|
|
// ECHO("* Connor_Send_Delievry_To_Pai is strat ! *\n");
|
|
|
// ECHO("*************************************************************\n");
|
|
|
// int ifail = ITK_ok;
|
|
|
// //参数相关
|
|
|
// char arg1value[1024],
|
|
|
// arg2value[1024],
|
|
|
// * argflag = NULL,
|
|
|
// * argvalue = NULL,
|
|
|
// * arg = NULL;
|
|
|
//
|
|
|
// int att_cnt = 0, arg_cnt = 0;
|
|
|
// tag_t task_tag = NULLTAG, rootTask_tag = NULLTAG, * attachments = NULLTAG;
|
|
|
// //获取handler的参数的个数
|
|
|
// arg_cnt = TC_number_of_arguments(msg.arguments);
|
|
|
// ECHO("参数个数为:%d\n", arg_cnt);
|
|
|
// if (arg_cnt > 0)
|
|
|
// {
|
|
|
// for (int j = 0;j < arg_cnt;j++)
|
|
|
// {
|
|
|
// //获取下一个参数(从0开始)
|
|
|
// arg = TC_next_argument(msg.arguments);
|
|
|
// //获取参数的名称和值
|
|
|
// ifail = ITK_ask_argument_named_value((const char*)arg, &argflag, &argvalue);
|
|
|
// if (stricmp(argflag, "SendDeliveryApi") == 0)
|
|
|
// {
|
|
|
// if (argvalue != NULL)
|
|
|
// {
|
|
|
// strcpy(arg1value, argvalue);
|
|
|
// }
|
|
|
// }
|
|
|
// if (stricmp(argflag, "GetTokenApi") == 0)
|
|
|
// {
|
|
|
// if (argvalue != NULL)
|
|
|
// {
|
|
|
// strcpy(arg2value, argvalue);
|
|
|
// }
|
|
|
// }
|
|
|
// }
|
|
|
// MEM_free(argflag);
|
|
|
// MEM_free(argvalue);
|
|
|
// }
|
|
|
//
|
|
|
// string authorization = getToken(arg2value);
|
|
|
//
|
|
|
// ECHO("token:%s\n", authorization.c_str());
|
|
|
// char* job_name = NULL, task_name[1024] = "", task_id[1024] = "";
|
|
|
// //获取当前触发的任务
|
|
|
// task_tag = msg.task;
|
|
|
// //获取根流程节点
|
|
|
// ITKCALL(EPM_ask_root_task(task_tag, &rootTask_tag));
|
|
|
// //获取目标引用对象
|
|
|
// ITKCALL(EPM_ask_attachments(rootTask_tag, EPM_target_attachment, &att_cnt, &attachments));
|
|
|
// ECHO("att_cnt:%d\n", att_cnt);
|
|
|
// ITKCALL(AOM_ask_value_string(rootTask_tag, "job_name", &job_name));
|
|
|
// ECHO("job_name:%s\n", job_name);
|
|
|
// char* token = NULL, * ptr = NULL, temp[1024] = "";
|
|
|
//
|
|
|
// token = strtok(job_name, "-");
|
|
|
// strcpy(task_id, token);
|
|
|
//
|
|
|
// token = strtok(NULL, "-");
|
|
|
// strcpy(task_name, token);
|
|
|
//
|
|
|
// ECHO("task_id:%s\n", task_id);
|
|
|
// ECHO("task_name:%s\n", task_name);
|
|
|
// string json_object;
|
|
|
// json_object.assign("{");
|
|
|
// json_object.append("\"taskId\":\"");
|
|
|
// json_object.append(task_id);
|
|
|
// json_object.append("\",");
|
|
|
// json_object.append("\"delivery\":[");
|
|
|
// for (int i = 0; i < att_cnt; i++) {
|
|
|
// char* item_id = NULL, * object_name = NULL, * object_type = NULL;
|
|
|
// ITKCALL(AOM_ask_value_string(attachments[i], "object_type", &object_type));
|
|
|
// ECHO("object_type:%s\n", object_type);
|
|
|
// if (strstr(object_type, "Revision") != NULL) {
|
|
|
// ITKCALL(AOM_ask_value_string(attachments[i], "object_name", &object_name));
|
|
|
// ITKCALL(AOM_ask_value_string(attachments[i], "item_id", &item_id));
|
|
|
// json_object.append("{");
|
|
|
// json_object.append("\"id\":\"");
|
|
|
// json_object.append(item_id);
|
|
|
// json_object.append("\",\"name\":\"");
|
|
|
// json_object.append(object_name);
|
|
|
// json_object.append("\"}");
|
|
|
// if (i != att_cnt - 1) {
|
|
|
// json_object.append(",");
|
|
|
// }
|
|
|
// }
|
|
|
// if (object_type) {
|
|
|
// MEM_free(object_type);
|
|
|
// object_type = NULL;
|
|
|
// }
|
|
|
// if (object_name) {
|
|
|
// MEM_free(object_name);
|
|
|
// object_name = NULL;
|
|
|
// }
|
|
|
// if (item_id) {
|
|
|
// MEM_free(item_id);
|
|
|
// item_id = NULL;
|
|
|
// }
|
|
|
//
|
|
|
//
|
|
|
//
|
|
|
// }
|
|
|
// json_object.append("]");
|
|
|
// json_object.append("}");
|
|
|
// ECHO("json_object:%s\n", json_object.c_str());
|
|
|
// CURL* curl = NULL;
|
|
|
// CURLcode res;
|
|
|
// string response;
|
|
|
// curl = curl_easy_init();
|
|
|
//
|
|
|
// struct curl_slist* headerlist = NULL;
|
|
|
//
|
|
|
// // 设置表头,表头内容可能不同
|
|
|
// headerlist = curl_slist_append(headerlist, "Accept-Charset: UTF-8");
|
|
|
// headerlist = curl_slist_append(headerlist, "Content-Type: application/json;charset=UTF-8");
|
|
|
// headerlist = curl_slist_append(headerlist, authorization.c_str());
|
|
|
// //headerlist = curl_slist_append(headerlist, "Authorization:Bearer eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiI2MTc3ZWVlMmU0YjBjNTI1ZjBjOGFlODAsYWRtaW4iLCJpc3MiOiJwaXByb2plY3QuY24iLCJpYXQiOjE2MzUzMjk4NDUsImV4cCI6MTYzNTkzNDY0NX0.ZVJBEVAoN9RhW186L_iKkvRrz_UKYcE8lv78oSYjhgLmBtQe1UM-rtpET3xAtKXWwpTis_ieDHc5nphHpE9JGg");
|
|
|
//
|
|
|
//
|
|
|
// // 设置URL
|
|
|
// ECHO("PaiApi%s\n", arg1value);
|
|
|
// curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "POST");
|
|
|
// curl_easy_setopt(curl, CURLOPT_URL, arg1value);
|
|
|
// curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
|
|
|
// curl_easy_setopt(curl, CURLOPT_DEFAULT_PROTOCOL, "https");
|
|
|
// curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headerlist);
|
|
|
// // 设置参数,比如"ParamName1=ParamName1Content&ParamName2=ParamName2Content&..."
|
|
|
// //ECHO("TOUTF8:%s\n", string_To_UTF8(json_object).c_str());
|
|
|
// string data = string_To_UTF8(json_object);
|
|
|
// const char* data1 = data.c_str();
|
|
|
// curl_easy_setopt(curl, CURLOPT_POSTFIELDS, data1);
|
|
|
// //不接收响应头数据0代表不接收 1代表接收
|
|
|
// curl_easy_setopt(curl, CURLOPT_HEADER, 1);
|
|
|
// //设置数据接收和写入函数
|
|
|
// curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, req_reply);
|
|
|
// curl_easy_setopt(curl, CURLOPT_WRITEDATA, (void*)&response);
|
|
|
// // 设置为Post
|
|
|
// //curl_easy_setopt(curl, CURLOPT_POST, 1);
|
|
|
// // 发送
|
|
|
// res = curl_easy_perform(curl);
|
|
|
// ECHO("response:%s\n",response.c_str());
|
|
|
// if (res != CURLE_OK)
|
|
|
// {
|
|
|
// // 获取详细错误信息
|
|
|
// const char* szErr = curl_easy_strerror(res);
|
|
|
// fprintf(stderr, "curl_easy_perform() failed: %s\n", szErr);
|
|
|
// ECHO("Err:%s\n", szErr);
|
|
|
// }
|
|
|
// // 清空
|
|
|
// curl_easy_cleanup(curl);
|
|
|
//
|
|
|
// // 释放表头
|
|
|
// curl_slist_free_all(headerlist);
|
|
|
//
|
|
|
// ECHO("*************************************************************\n");
|
|
|
// ECHO("* Connor_Send_Delievry_To_Pai is end ! *\n");
|
|
|
// ECHO("*************************************************************\n");
|
|
|
// return ITK_ok;
|
|
|
//}
|
|
|
|
|
|
bool isAttachmentSizeGreaterThan40M(const std::string& attachmentPath) {
|
|
|
std::ifstream file(attachmentPath, std::ifstream::binary);
|
|
|
if (file) {
|
|
|
// 获取文件大小
|
|
|
file.seekg(0, file.end);
|
|
|
std::streamsize size = file.tellg();
|
|
|
file.close();
|
|
|
|
|
|
// 将大小转换为MB
|
|
|
double sizeInMegaBytes = size / 1024.0 / 1024.0;
|
|
|
|
|
|
// 判断是否大于40MB
|
|
|
return sizeInMegaBytes > 40.0;
|
|
|
}
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
|
|
|
string getFiles(tag_t target, tag_t relation_type, string & contents) {
|
|
|
char* item_id = NULL;
|
|
|
ITKCALL(AOM_ask_value_string(target, "item_id", &item_id));
|
|
|
string files_path = "";
|
|
|
char* dataset_type = NULL;
|
|
|
tag_t* secondary_objects = NULLTAG;
|
|
|
int ds_count = 0;
|
|
|
ITKCALL(GRM_list_secondary_objects_only(target, relation_type, &ds_count, &secondary_objects));
|
|
|
char temp_file[SS_MAXPATHLEN] = "";
|
|
|
for (int i = 0; i < ds_count; i++)
|
|
|
{
|
|
|
printf("进1\n");
|
|
|
ITKCALL(AOM_ask_value_string(secondary_objects[i], "object_type", &dataset_type));
|
|
|
int des_count = 0;
|
|
|
tag_t* dess = NULL;
|
|
|
printf("dataset_type=%s\n", dataset_type);
|
|
|
ITKCALL(AOM_ask_value_tags(secondary_objects[i], "ref_list", &des_count, &dess));
|
|
|
if (des_count < 1) {
|
|
|
printf("该数据集引用数量错误\n");
|
|
|
continue;
|
|
|
}
|
|
|
tag_t ref_object = NULLTAG;
|
|
|
AE_reference_type_t reference_type;
|
|
|
char ref_name[WSO_name_size_c + 1] = "";
|
|
|
printf("开始判断类型\n");
|
|
|
printf("dataset_type: %s\n", dataset_type);
|
|
|
if (strcmp(dataset_type, "PDF") == 0) {
|
|
|
printf("PDF类型\n");
|
|
|
strcpy(ref_name, "PDF_Reference");
|
|
|
}
|
|
|
else if (strcmp(dataset_type, "MSExcel") == 0 || strcmp(dataset_type, "MSExcelX") == 0) {
|
|
|
printf("excel类型\n");
|
|
|
strcpy(ref_name, "excel");
|
|
|
}
|
|
|
else if (strcmp(dataset_type, "MSWord") == 0 || strcmp(dataset_type, "MSWordX") == 0) {
|
|
|
printf("word类型\n");
|
|
|
strcpy(ref_name, "word");
|
|
|
}
|
|
|
else if (strcmp(dataset_type, "RB3_GCAD") == 0) {
|
|
|
printf("CAD类型\n");
|
|
|
strcpy(ref_name, "RB3_GCAD");
|
|
|
}
|
|
|
else if (strcmp(dataset_type, "Zip") == 0) {
|
|
|
printf("ZIP类型\n");
|
|
|
strcpy(ref_name, "ZIPFILE");
|
|
|
}
|
|
|
char* datasetName = NULL;
|
|
|
char* pathname = NULL;
|
|
|
char* origin_file_name = NULL;
|
|
|
ITKCALL(AOM_ask_value_string(secondary_objects[i], "object_name", &datasetName));
|
|
|
ITKCALL(AE_ask_dataset_named_ref2(secondary_objects[i], ref_name, &reference_type, &ref_object));
|
|
|
if (ref_object == NULLTAG)
|
|
|
{
|
|
|
printf("\nref_object is NULLTAG\n");
|
|
|
return "";
|
|
|
}
|
|
|
printf("reference_type=%d\n", reference_type);
|
|
|
if (reference_type == AE_PART_OF)
|
|
|
{
|
|
|
ITKCALL(IMF_ask_file_pathname2(ref_object, SS_WNT_MACHINE, &pathname));
|
|
|
IMF_ask_original_file_name2(ref_object, &origin_file_name);
|
|
|
printf("origin_file_name=%s\n", origin_file_name);
|
|
|
printf("pathname=%s\n", pathname);
|
|
|
char* temp_dir = getenv("temp");
|
|
|
strcpy(temp_file, temp_dir);
|
|
|
strcat(temp_file, item_id);
|
|
|
strcat(temp_file, "-");
|
|
|
strcat(temp_file, origin_file_name);
|
|
|
printf("temp_file=%s\n", temp_file);
|
|
|
if (isFileExists_ifstream(temp_file))
|
|
|
{
|
|
|
cout << temp_file << "文件已经存在!" << endl;
|
|
|
remove(temp_file);
|
|
|
cout << GetLastError() << endl;
|
|
|
}
|
|
|
ITKCALL(IMF_export_file(ref_object, temp_file));
|
|
|
}
|
|
|
|
|
|
if (datasetName != NULL) {
|
|
|
MEM_free(datasetName);
|
|
|
datasetName = NULL;
|
|
|
}
|
|
|
if (pathname != NULL) {
|
|
|
MEM_free(pathname);
|
|
|
pathname = NULL;
|
|
|
}
|
|
|
if (origin_file_name != NULL) {
|
|
|
MEM_free(origin_file_name);
|
|
|
origin_file_name = NULL;
|
|
|
}
|
|
|
if (strcmp(dataset_type, "Zip") == 0) {
|
|
|
printf("压缩包类型判断文件大小\n");
|
|
|
if (isAttachmentSizeGreaterThan40M(temp_file)) {
|
|
|
if (dataset_type != NULL) {
|
|
|
MEM_free(dataset_type);
|
|
|
dataset_type = NULL;
|
|
|
}
|
|
|
contents.append("-【部分附件大小超过限制,如需请到系统中下载!】");
|
|
|
continue;
|
|
|
}
|
|
|
}
|
|
|
if (dataset_type != NULL) {
|
|
|
MEM_free(dataset_type);
|
|
|
dataset_type = NULL;
|
|
|
}
|
|
|
files_path.append(temp_file);
|
|
|
if (i < ds_count - 1) {
|
|
|
files_path.append("|");
|
|
|
}
|
|
|
}
|
|
|
if (secondary_objects != NULL) {
|
|
|
MEM_free(secondary_objects);
|
|
|
secondary_objects = NULL;
|
|
|
}
|
|
|
return files_path;
|
|
|
}
|
|
|
|
|
|
//计算分析委托单流程开始邮件提醒
|
|
|
/*
|
|
|
* 创建时间:2024/3/14
|
|
|
*/
|
|
|
int Connor_JSFX_Start_Send_Mail_To_Users(EPM_action_message_t msg) {
|
|
|
bool debug = false;
|
|
|
int ifail = ITK_ok, arg_cnt = 0, att_cnt = 0;
|
|
|
char* arg = NULL, * argflag = NULL, * argvalue = NULL;
|
|
|
tag_t task_tag = NULLTAG, root_task_tag = NULLTAG;
|
|
|
tag_t* attachments = NULL;
|
|
|
arg_cnt = TC_number_of_arguments(msg.arguments);
|
|
|
char mail_address[1024] = "";
|
|
|
printf("=============================================================\n");
|
|
|
printf("开始执行:Connor_JSFX_Send_Mail_To_Users\n");
|
|
|
printf("=============================================================\n");
|
|
|
printf("开超级权限\n");
|
|
|
POM_AM__set_application_bypass(true);
|
|
|
task_tag = msg.task;
|
|
|
//获取外部人员邮箱号
|
|
|
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, "email") == 0) {
|
|
|
strcpy(mail_address, argvalue);
|
|
|
}
|
|
|
MEM_free(argflag);
|
|
|
MEM_free(argvalue);
|
|
|
}
|
|
|
}
|
|
|
//解析外部邮箱人员地址
|
|
|
EPM_ask_root_task(task_tag, &root_task_tag);
|
|
|
EPM_ask_attachments(root_task_tag, EPM_target_attachment, &att_cnt, &attachments);
|
|
|
//邮件标题
|
|
|
string title = "";
|
|
|
//邮件内容
|
|
|
string contents = "";
|
|
|
//输入资料文件路径
|
|
|
string input_file_path = "";
|
|
|
//轴承信息文件路径
|
|
|
string info_file_path = "";
|
|
|
for (int i = 0; i < att_cnt; i++)
|
|
|
{
|
|
|
tag_t target = attachments[i];
|
|
|
char* type = NULL;
|
|
|
ITKCALL(AOM_ask_value_string(target, "object_type", &type));
|
|
|
if (strcmp("RB3_JSFXWTDRevision" , type) == 0) {
|
|
|
char* khmc = NULL;
|
|
|
char* xmmc = NULL;
|
|
|
char** yyly = NULL;
|
|
|
int yyly_num = 0;
|
|
|
ITKCALL(AOM_ask_value_string(target, "rb3_khmc", &khmc));
|
|
|
ITKCALL(AOM_ask_value_string(target, "rb3_xmmc", &xmmc));
|
|
|
ITKCALL(AOM_UIF_ask_values(target, "rb3_yyly",&yyly_num, &yyly));
|
|
|
//拼接标题
|
|
|
title.append(khmc).append("+").append(xmmc).append("+");
|
|
|
for (int i = 0; i < yyly_num; i++)
|
|
|
{
|
|
|
title.append(yyly[i]);
|
|
|
if (i < yyly_num - 1) {
|
|
|
title.append("-");
|
|
|
}
|
|
|
}
|
|
|
printf("title: %s\n", title.c_str());
|
|
|
char** jsfxxqxm = NULL;
|
|
|
char* xmbh = NULL;
|
|
|
char* bz = NULL;
|
|
|
int jsfxxqxm_num = 0;
|
|
|
ITKCALL(AOM_UIF_ask_values(target, "rb3_jsfxxqxm",&jsfxxqxm_num, &jsfxxqxm));
|
|
|
ITKCALL(AOM_ask_value_string(target, "rb3_xmbh", &xmbh));
|
|
|
ITKCALL(AOM_ask_value_string(target, "rb3_bz", &bz));
|
|
|
//拼接内容
|
|
|
contents.append("1、计算分析需求项目:");
|
|
|
for (int i = 0; i < jsfxxqxm_num; i++)
|
|
|
{
|
|
|
contents.append(jsfxxqxm[i]);
|
|
|
if (i < jsfxxqxm_num - 1) {
|
|
|
contents.append("-");
|
|
|
}
|
|
|
}
|
|
|
contents.append("2、项目编号:") .append(xmbh).append("3、备注:").append(bz);
|
|
|
printf("contents: %s\n", contents.c_str());
|
|
|
DOFREE(khmc);
|
|
|
DOFREE(xmmc);
|
|
|
DOFREE(yyly);
|
|
|
DOFREE(jsfxxqxm);
|
|
|
DOFREE(xmbh);
|
|
|
DOFREE(bz);
|
|
|
//下载附件
|
|
|
tag_t input_relation_type = NULLTAG;
|
|
|
ITKCALL(GRM_find_relation_type("RB3_Inputdata", &input_relation_type));
|
|
|
input_file_path = getFiles(target, input_relation_type,contents);
|
|
|
tag_t info_relation_type = NULLTAG;
|
|
|
ITKCALL(GRM_find_relation_type("RB3_Bearinginformation", &info_relation_type));
|
|
|
info_file_path = getFiles(target, info_relation_type, contents);
|
|
|
}
|
|
|
DOFREE(type);
|
|
|
}
|
|
|
DOFREE(attachments);
|
|
|
if (strcmp("" , mail_address) != 0
|
|
|
&& strcmp("", title.c_str()) != 0
|
|
|
&& strcmp("", contents.c_str()) != 0) {
|
|
|
char cmd[1024] = "";
|
|
|
char jarfile[512] = "";
|
|
|
WriteLog(">> 发送邮件给[%s]", mail_address);
|
|
|
sprintf(jarfile, "%s\\bin\\EMailSender.jar", getenv("TC_ROOT"));
|
|
|
strcpy_s(cmd, "java -jar ");
|
|
|
strcat_s(cmd, jarfile);
|
|
|
strcat_s(cmd, " \"");
|
|
|
strcat_s(cmd, mail_address);
|
|
|
strcat_s(cmd, "\" \"");
|
|
|
strcat_s(cmd, title.c_str());
|
|
|
strcat_s(cmd, "\" \"");
|
|
|
strcat_s(cmd, contents.c_str());
|
|
|
if (strcmp("", info_file_path.c_str()) != 0) {
|
|
|
strcat_s(cmd, "\" \"");
|
|
|
strcat_s(cmd, info_file_path.c_str());
|
|
|
if (strcmp("", input_file_path.c_str()) != 0) {
|
|
|
strcat_s(cmd, "|");
|
|
|
strcat_s(cmd, input_file_path.c_str());
|
|
|
}
|
|
|
}
|
|
|
else {
|
|
|
if (strcmp("", input_file_path.c_str()) != 0) {
|
|
|
strcat_s(cmd, "\" \"");
|
|
|
strcat_s(cmd, input_file_path.c_str());
|
|
|
}
|
|
|
}
|
|
|
strcat_s(cmd, "\"");
|
|
|
printf("CMD:%s", cmd);
|
|
|
system(cmd);
|
|
|
printf("执行完成\n");
|
|
|
}
|
|
|
printf("关超级权限\n");
|
|
|
POM_AM__set_application_bypass(false);
|
|
|
printf("=============================================================\n");
|
|
|
printf("执行结束:Connor_JSFX_Send_Mail_To_Users\n");
|
|
|
printf("=============================================================\n");
|
|
|
return ITK_ok;
|
|
|
}
|
|
|
|
|
|
//计算分析委托单流程完成邮件提醒
|
|
|
/*
|
|
|
* 创建时间:2024/3/14
|
|
|
*/
|
|
|
int Connor_JSFX_Complete_Send_Mail_To_Users(EPM_action_message_t msg) {
|
|
|
bool debug = false;
|
|
|
int ifail = ITK_ok, arg_cnt = 0, att_cnt = 0;
|
|
|
char* arg = NULL, * argflag = NULL, * argvalue = NULL;
|
|
|
tag_t task_tag = NULLTAG, root_task_tag = NULLTAG;
|
|
|
tag_t* attachments = NULL;
|
|
|
arg_cnt = TC_number_of_arguments(msg.arguments);
|
|
|
char mail_address[1024] = "";
|
|
|
printf("=============================================================\n");
|
|
|
printf("开始执行:Connor_JSFX_Complete_Send_Mail_To_Users\n");
|
|
|
printf("=============================================================\n");
|
|
|
printf("开超级权限\n");
|
|
|
POM_AM__set_application_bypass(true);
|
|
|
task_tag = msg.task;
|
|
|
//获取外部人员邮箱号
|
|
|
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, "email") == 0) {
|
|
|
strcpy(mail_address, argvalue);
|
|
|
}
|
|
|
MEM_free(argflag);
|
|
|
MEM_free(argvalue);
|
|
|
}
|
|
|
}
|
|
|
EPM_ask_root_task(task_tag, &root_task_tag);
|
|
|
EPM_ask_attachments(root_task_tag, EPM_target_attachment, &att_cnt, &attachments);
|
|
|
//邮件标题
|
|
|
string title = "";
|
|
|
//计算报告文件路径
|
|
|
string report_file_path = "";
|
|
|
for (int i = 0; i < att_cnt; i++)
|
|
|
{
|
|
|
tag_t target = attachments[i];
|
|
|
char* type = NULL;
|
|
|
ITKCALL(AOM_ask_value_string(target, "object_type", &type));
|
|
|
if (strcmp("RB3_JSFXWTDRevision", type) == 0) {
|
|
|
|
|
|
//拼接标题
|
|
|
/*
|
|
|
char* khmc = NULL;
|
|
|
char* xmmc = NULL;
|
|
|
char** yyly = NULL;
|
|
|
int yyly_num = 0;
|
|
|
ITKCALL(AOM_ask_value_string(target, "rb3_khmc", &khmc));
|
|
|
ITKCALL(AOM_ask_value_string(target, "rb3_xmmc", &xmmc));
|
|
|
ITKCALL(AOM_UIF_ask_values(target, "rb3_yyly", &yyly_num, &yyly));
|
|
|
title.append(khmc).append("+").append(xmmc).append("+");
|
|
|
for (int i = 0; i < yyly_num; i++)
|
|
|
{
|
|
|
title.append(yyly[i]);
|
|
|
if (i < yyly_num - 1) {
|
|
|
title.append("-");
|
|
|
}
|
|
|
}
|
|
|
printf("title: %s", title.c_str());
|
|
|
DOFREE(khmc);
|
|
|
DOFREE(xmmc);
|
|
|
DOFREE(yyly);
|
|
|
*/
|
|
|
string contents = "";
|
|
|
//下载附件
|
|
|
tag_t report_relation_type = NULLTAG;
|
|
|
ITKCALL(GRM_find_relation_type("RB3_Calculationreport", &report_relation_type));
|
|
|
report_file_path = getFiles(target, report_relation_type, contents);
|
|
|
tag_t* secondary_objects = NULLTAG;
|
|
|
int ds_count = 0;
|
|
|
ITKCALL(GRM_list_secondary_objects_only(target, report_relation_type, &ds_count, &secondary_objects));
|
|
|
if (ds_count > 0) {
|
|
|
char* dataset_name = NULL;
|
|
|
ITKCALL(AOM_ask_value_string(secondary_objects[0], "object_name", &dataset_name));
|
|
|
if (dataset_name != NULL) {
|
|
|
title.append(dataset_name);
|
|
|
printf("title22: %s", title.c_str());
|
|
|
MEM_free(dataset_name);
|
|
|
dataset_name = NULL;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
DOFREE(type);
|
|
|
}
|
|
|
DOFREE(attachments);
|
|
|
if (strcmp("", mail_address) != 0
|
|
|
&& strcmp("", title.c_str()) != 0) {
|
|
|
char cmd[1024] = "";
|
|
|
char jarfile[512] = "";
|
|
|
WriteLog(">> 发送邮件给[%s]", mail_address);
|
|
|
sprintf(jarfile, "%s\\bin\\EMailSender.jar", getenv("TC_ROOT"));
|
|
|
strcpy_s(cmd, "java -jar ");
|
|
|
strcat_s(cmd, jarfile);
|
|
|
strcat_s(cmd, " \"");
|
|
|
strcat_s(cmd, mail_address);
|
|
|
strcat_s(cmd, "\" \"");
|
|
|
strcat_s(cmd, title.c_str());
|
|
|
strcat_s(cmd, "\" \"");
|
|
|
strcat_s(cmd, "【计算分析委托已完成!】");
|
|
|
if (strcmp("", report_file_path.c_str()) != 0) {
|
|
|
strcat_s(cmd, "\" \"");
|
|
|
strcat_s(cmd, report_file_path.c_str());
|
|
|
}
|
|
|
strcat_s(cmd, "\"");
|
|
|
printf("CMD:%s", cmd);
|
|
|
system(cmd);
|
|
|
printf("执行完成");
|
|
|
}
|
|
|
printf("关超级权限\n");
|
|
|
POM_AM__set_application_bypass(false);
|
|
|
printf("=============================================================\n");
|
|
|
printf("执行结束:Connor_JSFX_Complete_Send_Mail_To_Users\n");
|
|
|
printf("=============================================================\n");
|
|
|
return ITK_ok;
|
|
|
}
|