zouxk 5 years ago
parent 35ddf4a071
commit c05b16986f

@ -163,6 +163,7 @@
<ClCompile Include="bs_wl_check.cpp" />
<ClCompile Include="epm_register_handler.cxx" />
<ClCompile Include="bs_custom_main.cxx" />
<ClCompile Include="jd_add_attachments.cpp" />
<ClCompile Include="jd_batch_process.cpp" />
<ClCompile Include="jd_clear_field.cpp" />
<ClCompile Include="jd_schedule_joint.cpp" />

@ -79,6 +79,9 @@
<ClCompile Include="jd_batch_process.cpp">
<Filter>epm-handler</Filter>
</ClCompile>
<ClCompile Include="jd_add_attachments.cpp">
<Filter>epm-handler</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="epm_register_handler.h">

@ -48,6 +48,7 @@ int bs_test_release_check(EPM_rule_message_t msg);
int bs_bypass(void *retValType);
int jd_schedule_joint(EPM_action_message_t msg);
int jd_batch_process(EPM_action_message_t msg);
int jd_add_attachments(EPM_action_message_t msg);
////<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣǩ<CFA2><C7A9><EFBFBD><E6B1BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȥ
//int qtmc_sign_ir(EPM_action_message_t msg);

@ -152,6 +152,14 @@ extern DLLAPI int CUST_init_module(int *decision, va_list args)
} else {
printf("register jd_batch_process successfully\n");
}
ifail = EPM_register_action_handler("jd_add_attachments", "jd_add_attachments",
(EPM_action_handler_t)jd_add_attachments);
if (ifail) {
printf("register jd_add_attachments failed\n");
} else {
printf("register jd_add_attachments successfully\n");
}
//if(ifail == ITK_ok)
//{

@ -0,0 +1,116 @@
#include "epm_handler_common.h"
#include <tc\tc_macros.h>
#include <tc\emh.h>
#include <tc\preferences.h>
#include <property\propdesc.h>
#include <epm\epm.h>
#include <epm\epm_toolkit_tc_utils.h>
#include <tccore\item.h>
#include <tccore\grmtype.h>
#include <tccore\grm.h>
#include <tccore\imantype.h>
#include <sa\am.h>
#include <sa\sa.h>
#include <tccore\aom.h>
#include <tccore\aom_prop.h>
#include <property\prop_errors.h>
#include <tccore\workspaceobject.h>
#include <qry\qry.h>
#include <bom\bom_attr.h>
#include <bom\bom.h>
#include <epm\signoff.h>
#include <pom\pom\pom.h>
#include <pom\pom\pom_errors.h>
#include <fclasses\tc_date.h>
#include <epm\cr.h>
#include <cfm\cfm.h>
#include <sa\am.h>
#include "tc/envelope.h"
#include <stdio.h>
#include "ae/dataset.h"
#include <ctype.h>
#include <string.h>
#include <string>
#include <iostream>
#include <iterator>
#include <map>
#include <vector>
#include "ce/ce.h"
#include <time.h>
#include <windows.h>
#include <iostream>
#include <sql.h>
#include <sqlext.h>
#include "string"
#include "sstream"
#include <sa/tcfile.h>
#include <tccore/aom.h>
#include <sa/tcfile_cache.h>
#include <form/form.h>
#include "ctime"
#include "tchar.h"
#include <iostream>
#include <string>
#include <fstream>
using namespace std;
extern "C" int POM_AM__set_application_bypass(logical bypass);
int jd_add_attachments(EPM_action_message_t msg) {
POM_AM__set_application_bypass(true);
tag_t root_task, *attachments;
int att_cnt;
EPM_ask_root_task(msg.task, &root_task);
EPM_ask_attachments(root_task, EPM_target_attachment, &att_cnt, &attachments);
TC_argument_list_t * arguments = msg.arguments;
int arg_cnt = TC_number_of_arguments(arguments);
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;
}
const char *relation = paras["realtion"].c_str();
const char *item_rev = paras["item_rev"].c_str();
printf("relation:%s\n", relation);
printf("item_rev:%s\n", item_rev);
vector<tag_t> csjh_rev;
vector<int> csjh_type;
for (int i = 0;i < att_cnt;i++) {
char *att_type;
AOM_ask_value_string(attachments[i], "object_type", &att_type);
if (tc_strcmp(att_type, "JD2_GTSYWTSRevision") == 0) {
tag_t *csjh;
int csjh_cnt;
AOM_ask_value_tags(attachments[i], relation, &csjh_cnt, &csjh);
for (int ii = 0;ii < csjh_cnt;ii++) {
char *item_type;
AOM_ask_value_string(csjh[ii], "object_type", &item_type);
if (tc_strcmp(item_type, item_rev) == 0) {
tag_t *csjh_revs;
int rev_cnt;
char *date;
AOM_ask_value_tags(csjh[i], "revision_list", &rev_cnt, &csjh_revs);
AOM_ask_value_string(csjh_revs[rev_cnt - 1], "date_released", &date);
if (date == NULL || tc_strcmp(date, "") == 0) {
csjh_rev.push_back(csjh_revs[rev_cnt - 1]);
csjh_type.push_back(EPM_target_attachment);
}
MEM_free(csjh_revs);
}
}
MEM_free(csjh);
}
}
if (csjh_rev.size() > 0) {
tag_t *atts = &csjh_rev[0];
int *types = &csjh_type[0];
EPM_add_attachments(root_task, csjh_rev.size(), atts, types);
}
POM_AM__set_application_bypass(false);
return 0;
}

@ -1,4 +1,3 @@
#include "HTTPRequest.hpp"
#include "epm_handler_common.h"
#include <tc\tc_macros.h>
@ -53,43 +52,12 @@
#include "tchar.h"
#include <iostream>
#include <string>
#include <fstream>
#include <fstream>
#include <boost/thread/thread.hpp>
using namespace std;
extern "C" int POM_AM__set_application_bypass(logical bypass);
string GBKToUTF8(const char* strGBK) {
int len = MultiByteToWideChar(CP_ACP, 0, strGBK, -1, NULL, 0);
wchar_t* wstr = new wchar_t[len + 1];
memset(wstr, 0, len + 1);
MultiByteToWideChar(CP_ACP, 0, strGBK, -1, wstr, len);
len = WideCharToMultiByte(CP_UTF8, 0, wstr, -1, NULL, 0, NULL, NULL);
char* str = new char[len + 1];
memset(str, 0, len + 1);
WideCharToMultiByte(CP_UTF8, 0, wstr, -1, str, len, NULL, NULL);
string strTemp = str;
if (wstr) delete[] wstr;
if (str) delete[] str;
return strTemp;
}
string Utf8ToGbk(const char *src_str) {
int len = MultiByteToWideChar(CP_UTF8, 0, src_str, -1, NULL, 0);
wchar_t* wszGBK = new wchar_t[len + 1];
memset(wszGBK, 0, len * 2 + 2);
MultiByteToWideChar(CP_UTF8, 0, src_str, -1, wszGBK, len);
len = WideCharToMultiByte(CP_ACP, 0, wszGBK, -1, NULL, 0, NULL, NULL);
char* szGBK = new char[len + 1];
memset(szGBK, 0, len + 1);
WideCharToMultiByte(CP_ACP, 0, wszGBK, -1, szGBK, len, NULL, NULL);
string strTemp(szGBK);
if (wszGBK) delete[] wszGBK;
if (szGBK) delete[] szGBK;
return strTemp;
}
DWORD WINAPI sendRequest(void* para) {
void sendRequest(char *uid) {
try {
char *pref_values;
PREF_ask_char_value("jd2_server_ip", 0, &pref_values);
@ -97,8 +65,8 @@ DWORD WINAPI sendRequest(void* para) {
stringstream ss;
ss << "http://";
ss << pref_values;
ss << ":8888/api/deleteJob?uid=";
ss << (char *)para;
ss << ":8888/api/batchJob?uid=";
ss << uid;
printf("request url====>%s\n", ss.str().c_str());
http::Request request(ss.str().c_str());
const http::Response response = request.send("GET");
@ -107,137 +75,12 @@ DWORD WINAPI sendRequest(void* para) {
} catch (const std::exception& e) {
std::cerr << "Request failed, error: " << e.what() << '\n';
}
return 0;
}
int jd_batch_process(EPM_action_message_t msg) {
POM_AM__set_application_bypass(true);
tag_t root_task, *attachments, process_template, new_process, job, *do_tasks, *signoff_tasks, *valids;
int att_count = 0, type = EPM_target_attachment, do_cnt, signoff_cnt, valid_cnt;
char *att_name, *process_name, *temp_str, **names, *uid;
map<string, tag_t> do_designee;
map<string, vector<tag_t>> signoff_designee;
ITEM_attached_object_t *rev_attachments;
stringstream ss;
EPM_ask_root_task(msg.task, &root_task);
EPM_ask_job(msg.task, &job);
EPM_ask_attachments(root_task, EPM_target_attachment, &att_count, &attachments);
if (att_count > 1) {
EPM_get_type_tasks(job, eEPMDoTask, &do_cnt, &do_tasks);
EPM_get_type_tasks(job, eEPMSelectSignoffTask, &signoff_cnt, &signoff_tasks);
printf("do task size====>%d\n", do_cnt);
printf("signoff task size====>%d\n", signoff_cnt);
for (int i = 0;i < do_cnt;i++) {
char *task_name, *designee_name;
tag_t designee;
string temp;
EPM_ask_name2(do_tasks[i], &task_name);
temp = Utf8ToGbk(task_name);
printf("do task name====>%s\n", temp);
AOM_ask_value_tag(do_tasks[i], "fnd0Assignee", &designee);
if (designee != NULLTAG) {
ss << temp;
ss << i;
AOM_ask_value_string(designee, "user_name", &designee_name);
temp = Utf8ToGbk(designee_name);
printf("do designee name====>%s\n", temp);
do_designee[ss.str()] = designee;
ss.str("");
}
}
for (int i = 0;i < signoff_cnt;i++) {
char *task_name, *designee_name;
tag_t parent, designee_tag;
string temp;
vector<tag_t> designee;
EPM_ask_parent_task(signoff_tasks[i], &parent);
EPM_ask_name2(parent, &task_name);
temp = Utf8ToGbk(task_name);
printf("signoff task name====>%s\n", temp);
AOM_ask_value_tags(parent, "valid_signoffs", &valid_cnt, &valids);
for (int ii = 0;ii < valid_cnt;ii++) {
AOM_ask_value_tag(valids[ii], "fnd0Assignee", &designee_tag);
AOM_ask_value_string(designee_tag, "user_name", &designee_name);
temp = Utf8ToGbk(designee_name);
printf("signoff designee name====>%s\n", temp);
designee.push_back(designee_tag);
}
if (designee.size() != 0) {
ss << Utf8ToGbk(task_name);
ss << i;
signoff_designee[ss.str()] = designee;
ss.str("");
}
}
for (int i = 0;i < att_count;i++) {
AOM_ask_value_string(attachments[i], "object_string", &att_name);
printf("object_string====>%s\n", att_name);
AOM_ask_value_tag(job, "process_template", &process_template);
AOM_ask_value_string(process_template, "object_name", &temp_str);
printf("temp_str====>%s\n", Utf8ToGbk(temp_str).c_str());
EPM_create_process(att_name, "", process_template, 1, &attachments[i], &type, &new_process);
char *temp;
AOM_ask_value_string(new_process, "object_type", &temp);
printf("ÀàÐÍ===>%s\n", Utf8ToGbk(temp).c_str());
tag_t new_root_task, new_job, *new_do_tasks, *new_signoff_tasks;
int new_do_cnt, new_signoff_cnt;
EPM_ask_root_task(new_process, &new_root_task);
EPM_ask_job(new_root_task, &new_job);
EPM_get_type_tasks(new_job, eEPMDoTask, &new_do_cnt, &new_do_tasks);
EPM_get_type_tasks(new_job, eEPMSelectSignoffTask, &new_signoff_cnt, &new_signoff_tasks);
for (int ii = 0;ii < new_do_cnt;ii++) {
char *new_task_name;
string temp;
EPM_ask_name2(new_do_tasks[ii], &new_task_name);
temp = Utf8ToGbk(new_task_name);
printf("new do task name======>%s\n", temp);
ss << temp;
ss << ii;
if (do_designee.find(ss.str()) != do_designee.end()) {
printf("ÈÎÎñ\"%s\"ÒÑÖ¸ÅÉ\n", temp);
EPM_assign_responsible_party(new_do_tasks[ii], do_designee[ss.str()]);
}
ss.str("");
}
for (int ii = 0;ii < new_signoff_cnt;ii++) {
char *new_task_name;
string temp;
tag_t parent, member;
int temp_cnt, mem_cnt;
tag_t *temp_signoffs;
EPM_ask_parent_task(new_signoff_tasks[ii], &parent);
EPM_ask_name2(parent, &new_task_name);
temp = Utf8ToGbk(new_task_name);
printf("new signoff task name====>%s\n", temp);
ss << temp;
ss << ii;
if (signoff_designee.find(ss.str()) != signoff_designee.end()) {
printf("ÈÎÎñ\"%s\"ÒÑÖ¸ÅÉ\n", temp);
int user_cnt = signoff_designee[ss.str()].size();
for (int iii = 0;iii < user_cnt;iii++) {
SA_find_groupmember_by_user(signoff_designee[ss.str()][iii], &mem_cnt, &temp_signoffs);
EPM_create_adhoc_signoff(new_signoff_tasks[ii], temp_signoffs[0], &temp_cnt, &temp_signoffs);
if (temp_cnt) {
MEM_free(temp_signoffs);
}
}
EPM_set_adhoc_signoff_selection_done(new_signoff_tasks[ii], true);
}
ss.str("");
}
}
ITK__convert_tag_to_uid(job, &uid);
printf("delete job_uid======>%s\n", uid);
HANDLE hHandle;
hHandle = CreateThread(NULL, 0, sendRequest, uid, 0, NULL);
CloseHandle(hHandle);
return 0;
}
POM_AM__set_application_bypass(false);
char *uid;
ITK__convert_tag_to_uid(msg.task, &uid);
printf("delete job_uid======>%s\n", uid);
sendRequest(uid);
return 0;
}

@ -4,26 +4,19 @@ e:\work\vs_workspace\jditk\hezon_itk\HTTPRequest.hpp(199): warning C4267: “参
e:\work\vs_workspace\jditk\hezon_itk\epm_handler_common.h : warning C4819: 该文件包含不能在当前代码页(936)中表示的字符。请将该文件保存为 Unicode 格式以防止数据丢失
E:\work\include12_2\pom/pom/pom.h(806): warning C4819: 该文件包含不能在当前代码页(936)中表示的字符。请将该文件保存为 Unicode 格式以防止数据丢失
E:\work\include12_2\pom/pom/pom.h(5417): warning C4819: 该文件包含不能在当前代码页(936)中表示的字符。请将该文件保存为 Unicode 格式以防止数据丢失
jd_batch_process.cpp(219): warning C4267: “初始化”: 从“size_t”转换到“int”可能丢失数据
jd_batch_process.cpp(137): warning C4477: “printf”: 格式字符串“%s”需要类型“char *”的参数,但可变参数 1 拥有了类型“std::string”
jd_batch_process.cpp(144): warning C4477: “printf”: 格式字符串“%s”需要类型“char *”的参数,但可变参数 1 拥有了类型“std::string”
jd_batch_process.cpp(158): warning C4477: “printf”: 格式字符串“%s”需要类型“char *”的参数,但可变参数 1 拥有了类型“std::string”
jd_batch_process.cpp(164): warning C4477: “printf”: 格式字符串“%s”需要类型“char *”的参数,但可变参数 1 拥有了类型“std::string”
jd_batch_process.cpp(196): warning C4477: “printf”: 格式字符串“%s”需要类型“char *”的参数,但可变参数 1 拥有了类型“std::string”
jd_batch_process.cpp(200): warning C4477: “printf”: 格式字符串“%s”需要类型“char *”的参数,但可变参数 1 拥有了类型“std::string”
jd_batch_process.cpp(214): warning C4477: “printf”: 格式字符串“%s”需要类型“char *”的参数,但可变参数 1 拥有了类型“std::string”
jd_batch_process.cpp(218): warning C4477: “printf”: 格式字符串“%s”需要类型“char *”的参数,但可变参数 1 拥有了类型“std::string”
jd_batch_process.cpp(120): warning C4101: “rev_attachments”: 未引用的局部变量
jd_batch_process.cpp(117): warning C4101: “names”: 未引用的局部变量
jd_batch_process.cpp(117): warning C4101: “process_name”: 未引用的局部变量
jd_batch_process.cpp(208): warning C4101: “member”: 未引用的局部变量
C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.CppBuild.targets(1189,5): warning MSB8012: TargetPath(E:\work\vs_workspace\jditk\x64\Release\HEZON_ITK.dll) does not match the Linker's OutputFile property value (E:\work\vs_workspace\jditk\x64\Release\bs.dll). This may cause your project to build incorrectly. To correct this, please make sure that $(OutDir), $(TargetName) and $(TargetExt) property values match the value specified in %(Link.OutputFile).
C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.CppBuild.targets(1191,5): warning MSB8012: TargetName(HEZON_ITK) does not match the Linker's OutputFile property value (bs). This may cause your project to build incorrectly. To correct this, please make sure that $(OutDir), $(TargetName) and $(TargetExt) property values match the value specified in %(Link.OutputFile).
jd_signoff.obj : warning LNK4006: "class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __cdecl GBKToUTF8(char const *)" (?GBKToUTF8@@$$FYA?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@PEBD@Z) 已在 jd_batch_process.obj 中定义;已忽略第二个定义
jd_signoff.obj : warning LNK4006: "class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __cdecl GBKToUTF8(char const *)" (?GBKToUTF8@@YA?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@PEBD@Z) 已在 jd_batch_process.obj 中定义;已忽略第二个定义
util.obj : warning LNK4006: "bool __cdecl isTypeOf(unsigned int,char const *)" (?isTypeOf@@$$FYA_NIPEBD@Z) 已在 jd_signoff.obj 中定义;已忽略第二个定义
util.obj : warning LNK4006: "bool __cdecl isTypeOf(unsigned int,char const *)" (?isTypeOf@@YA_NIPEBD@Z) 已在 jd_signoff.obj 中定义;已忽略第二个定义
MSVCRT.lib(default_local_stdio_options.obj) : warning LNK4006: __local_stdio_printf_options 已在 libassy_jt.lib(libassy_jt.dll) 中定义;已忽略第二个定义
libboost_thread-vc140-mt-x64-1_72.lib(thread.obj) : warning LNK4006: "public: __cdecl std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >(void)" (??0?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QEAA@XZ) 已在 libassy_jt.lib(libassy_jt.dll) 中定义;已忽略第二个定义
libboost_thread-vc140-mt-x64-1_72.lib(thread.obj) : warning LNK4006: "public: __cdecl std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::~basic_string<char,struct std::char_traits<char>,class std::allocator<char> >(void)" (??1?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QEAA@XZ) 已在 libassy_jt.lib(libassy_jt.dll) 中定义;已忽略第二个定义
libboost_thread-vc140-mt-x64-1_72.lib(thread.obj) : warning LNK4006: "public: class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > & __cdecl std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::operator=(char const *)" (??4?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QEAAAEAV01@PEBD@Z) 已在 libcppbindings.lib(libcppbindings.dll) 中定义;已忽略第二个定义
libboost_thread-vc140-mt-x64-1_72.lib(thread.obj) : warning LNK4006: "public: char const * __cdecl std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::c_str(void)const " (?c_str@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QEBAPEBDXZ) 已在 libassy_jt.lib(libassy_jt.dll) 中定义;已忽略第二个定义
libboost_date_time-vc140-mt-x64-1_72.lib(greg_month.obj) : warning LNK4006: "public: __cdecl std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >(void)" (??0?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QEAA@XZ) 已在 libassy_jt.lib(libassy_jt.dll) 中定义;已忽略第二个定义
libboost_date_time-vc140-mt-x64-1_72.lib(greg_month.obj) : warning LNK4006: "public: __cdecl std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::~basic_string<char,struct std::char_traits<char>,class std::allocator<char> >(void)" (??1?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QEAA@XZ) 已在 libassy_jt.lib(libassy_jt.dll) 中定义;已忽略第二个定义
libboost_date_time-vc140-mt-x64-1_72.lib(greg_month.obj) : warning LNK4006: "public: class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > & __cdecl std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::operator=(char const *)" (??4?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QEAAAEAV01@PEBD@Z) 已在 libcppbindings.lib(libcppbindings.dll) 中定义;已忽略第二个定义
libboost_date_time-vc140-mt-x64-1_72.lib(greg_month.obj) : warning LNK4006: "public: char const * __cdecl std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::c_str(void)const " (?c_str@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QEBAPEBDXZ) 已在 libassy_jt.lib(libassy_jt.dll) 中定义;已忽略第二个定义
正在创建库 E:\work\vs_workspace\jditk\x64\Release\\bs.lib 和对象 E:\work\vs_workspace\jditk\x64\Release\\bs.exp
jd_signoff.obj : warning LNK4248: 无法解析 typeref 标记(01000016)(为“_jmethodID”);映像可能无法运行
jd_clear_field.obj : warning LNK4248: 无法解析 typeref 标记(01000017)(为“_jmethodID”);映像可能无法运行

Binary file not shown.

Binary file not shown.

Binary file not shown.
Loading…
Cancel
Save