|
|
#include "HTTPRequest.hpp"
|
|
|
#include "util.h"
|
|
|
using namespace std;
|
|
|
|
|
|
DWORD WINAPI sendRequest(void *uid) {
|
|
|
try {
|
|
|
char *pref_values;
|
|
|
PREF_ask_char_value("jd2_server_ip", 0, &pref_values);
|
|
|
if (strlen(pref_values) != 0) {
|
|
|
stringstream ss;
|
|
|
ss << "http://";
|
|
|
ss << pref_values;
|
|
|
ss << ":8880/api/deleteJob?uid=";
|
|
|
ss << (char *)uid;
|
|
|
printf("request url====>%s\n", ss.str().c_str());
|
|
|
http::Request request(ss.str().c_str());
|
|
|
const http::Response response = request.send("GET");
|
|
|
std::cout << std::string(response.body.begin(), response.body.end()) << '\n'; // print the result
|
|
|
} else {
|
|
|
printf("jd2_server_ip error\n");
|
|
|
}
|
|
|
} catch (const std::exception& e) {
|
|
|
std::cerr << "Request failed, error: " << e.what() << '\n';
|
|
|
}
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
int jd_batch_process(EPM_action_message_t msg) {
|
|
|
|
|
|
int ifail = EPM_go, att_count, tag_cnt, rel_cnt, type = EPM_reference_attachment;
|
|
|
tag_t rootTask, *attachments, win, top, *tags, tag, *rels, job, process_template, new_process;
|
|
|
char *val;
|
|
|
EPM_ask_root_task(msg.task, &rootTask);
|
|
|
EPM_ask_job(msg.task, &job);
|
|
|
EPM_ask_attachments(rootTask, EPM_target_attachment, &att_count, &attachments);
|
|
|
if (att_count < 2) {
|
|
|
return 0;
|
|
|
}
|
|
|
printf("att_count:%d\n", att_count);
|
|
|
AOM_ask_value_tag(job, "process_template", &process_template);
|
|
|
vector<tag_t> process_vec;
|
|
|
|
|
|
stringstream form_names;
|
|
|
for (int i = 0; i < att_count; i++) {
|
|
|
|
|
|
char *object_string, *object_type;
|
|
|
AOM_ask_value_string(attachments[i], "object_type", &object_type);
|
|
|
AOM_ask_value_string(attachments[i], "object_string", &object_string);
|
|
|
printf("object_type:%s object_string:%s\n", object_type, object_string);
|
|
|
if (isTypeOf(attachments[i], "Form")) {
|
|
|
char *name;
|
|
|
AOM_ask_value_string(attachments[i], "object_string", &name);
|
|
|
form_names << name;
|
|
|
continue;
|
|
|
}
|
|
|
tag_t new_process;
|
|
|
ITKCALL(EPM_create_process(object_string, "", process_template, 1, &attachments[i], &type, &new_process));
|
|
|
process_vec.push_back(new_process);
|
|
|
}
|
|
|
int sub_cnt;
|
|
|
tag_t *tasks;
|
|
|
EPM_ask_sub_tasks(rootTask, &sub_cnt, &tasks);
|
|
|
map<string, vector<tag_t>> task_map;
|
|
|
for (int i = 0;i < sub_cnt;i++) {
|
|
|
char *task_name, *task_type;
|
|
|
AOM_ask_value_string(tasks[i], "object_name", &task_name);
|
|
|
AOM_ask_value_string(tasks[i], "object_type", &task_type);
|
|
|
vector<tag_t> tags;
|
|
|
if (tc_strcmp("EPMDoTask", task_type) == 0) {
|
|
|
tag_t assignee;
|
|
|
|
|
|
AOM_ask_value_tag(tasks[i], "fnd0Assignee", &assignee);
|
|
|
tags.push_back(assignee);
|
|
|
} else {
|
|
|
tag_t *signoffs;
|
|
|
int signoff_cnt;
|
|
|
AOM_ask_value_tags(tasks[i], "valid_signoffs", &signoff_cnt, &signoffs);
|
|
|
printf("name:%s valid cnt:%d\n", task_name, signoff_cnt);
|
|
|
for (int j = 0;j < signoff_cnt;j++) {
|
|
|
tag_t member;
|
|
|
AOM_ask_value_tag(signoffs[j], "group_member", &member);
|
|
|
tags.push_back(member);
|
|
|
}
|
|
|
}
|
|
|
task_map[task_name] = tags;
|
|
|
}
|
|
|
|
|
|
for (auto i = 0;i < process_vec.size();i++) {
|
|
|
|
|
|
ITKCALL(AOM_refresh(process_vec[i], false));
|
|
|
|
|
|
tag_t root;
|
|
|
EPM_ask_root_task(process_vec[i], &root);
|
|
|
|
|
|
|
|
|
EPM_ask_sub_tasks(root, &sub_cnt, &tasks);
|
|
|
for (auto j = 0;j < sub_cnt;j++) {
|
|
|
char *task_name, *task_type;
|
|
|
AOM_ask_value_string(tasks[j], "object_name", &task_name);
|
|
|
if (task_map[task_name].size() == 0)
|
|
|
continue;
|
|
|
AOM_ask_value_string(tasks[j], "object_type", &task_type);
|
|
|
if (tc_strcmp("EPMDoTask", task_type) == 0) {
|
|
|
EPM_assign_responsible_party(tasks[j], task_map[task_name][0]);
|
|
|
} else {
|
|
|
|
|
|
tag_t sub_task;
|
|
|
int *types = (int*)MEM_alloc(task_map[task_name].size());
|
|
|
|
|
|
EPM_ask_sub_task(tasks[j], "select-signoff-team", &sub_task);
|
|
|
if (sub_task) {
|
|
|
for (int k = 0;k < task_map[task_name].size();k++) {
|
|
|
int temp_cnt;
|
|
|
tag_t *temp;
|
|
|
EPM_create_adhoc_signoff(sub_task, task_map[task_name][k], &temp_cnt, &temp);
|
|
|
|
|
|
}
|
|
|
EPM_set_adhoc_signoff_selection_done(sub_task, true);
|
|
|
|
|
|
if (j == 0) {
|
|
|
EPM_trigger_action(tasks[0], EPM_complete_action, "");
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
printf("<EFBFBD><EFBFBD>ʼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ת<EFBFBD><EFBFBD>ΪĿ<EFBFBD><EFBFBD>\n");
|
|
|
int ref_cnt;
|
|
|
tag_t *refs;
|
|
|
tag_t root_task1;
|
|
|
for (int i = 0;i < att_count;i++) {
|
|
|
if (isTypeOf(attachments[i], "Form")) {
|
|
|
continue;
|
|
|
}
|
|
|
EPM_ask_root_task(process_vec[i], &root_task1);
|
|
|
EPM_ask_attachments(root_task1, EPM_reference_attachment, &ref_cnt, &refs);
|
|
|
char *name1;
|
|
|
AOM_ask_value_string(attachments[i], "object_string", &name1);
|
|
|
for (int ii = 0;ii < ref_cnt; ii++) {
|
|
|
char *name2;
|
|
|
AOM_ask_value_string(refs[ii], "object_string", &name2);
|
|
|
if (tc_strcmp(name1, name2) == 0) {
|
|
|
printf("object_string======>%s\n", name1);
|
|
|
tag_t *new_atts = (tag_t *)MEM_alloc(sizeof(tag_t));
|
|
|
new_atts[0] = attachments[i];
|
|
|
int types[1];
|
|
|
types[0] = EPM_target_attachment;
|
|
|
int types1[1];
|
|
|
types1[0] = EPM_reference_attachment;
|
|
|
ITKCALL(EPM_add_attachments(root_task1, 1, new_atts, types));
|
|
|
EPM_remove_attachments_from_att_type(root_task1, 1, new_atts, types1);
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
if (isTypeOf(attachments[i], "ItemRevision")) {
|
|
|
int form_cnt;
|
|
|
tag_t *forms;
|
|
|
char *name;
|
|
|
AOM_ask_value_tags(attachments[i], "IMAN_master_form_rev", &form_cnt, &forms);
|
|
|
if (form_cnt > 0) {
|
|
|
AOM_ask_value_string(forms[0], "object_string", &name);
|
|
|
if (form_names.str().find(name) != string::npos) {
|
|
|
tag_t *new_atts = (tag_t *)MEM_alloc(sizeof(tag_t));
|
|
|
new_atts[0] = forms[0];
|
|
|
int types[1];
|
|
|
types[0] = EPM_target_attachment;
|
|
|
ITKCALL(EPM_add_attachments(root_task1, 1, new_atts, types));
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
EMH_clear_errors();
|
|
|
cout << "batch success" << endl;
|
|
|
char *uid;
|
|
|
ITK__convert_tag_to_uid(job, &uid);
|
|
|
printf("start delete job_uid======>%s\n", uid);
|
|
|
HANDLE thread = CreateThread(NULL, 0, sendRequest, uid, 0, NULL);
|
|
|
CloseHandle(thread);
|
|
|
return 0;
|
|
|
} |