diff --git a/HEZON_ITK.VC.db b/HEZON_ITK.VC.db index d662205..ab172e8 100644 Binary files a/HEZON_ITK.VC.db and b/HEZON_ITK.VC.db differ diff --git a/HEZON_ITK/HEZON_ITK.vcxproj b/HEZON_ITK/HEZON_ITK.vcxproj index c3b813b..491fc5b 100644 --- a/HEZON_ITK/HEZON_ITK.vcxproj +++ b/HEZON_ITK/HEZON_ITK.vcxproj @@ -153,16 +153,22 @@ + + + + + + diff --git a/HEZON_ITK/HEZON_ITK.vcxproj.filters b/HEZON_ITK/HEZON_ITK.vcxproj.filters index 4b31baf..a413b68 100644 --- a/HEZON_ITK/HEZON_ITK.vcxproj.filters +++ b/HEZON_ITK/HEZON_ITK.vcxproj.filters @@ -49,6 +49,21 @@ epm-handler + + epm-handler + + + epm-handler + + + epm-handler + + + epm-handler + + + epm-handler + @@ -57,5 +72,8 @@ epm-handler + + epm-handler + \ No newline at end of file diff --git a/HEZON_ITK/bs_bom_check.cpp b/HEZON_ITK/bs_bom_check.cpp new file mode 100644 index 0000000..5ccf513 --- /dev/null +++ b/HEZON_ITK/bs_bom_check.cpp @@ -0,0 +1,79 @@ +#include "util.h" + +boolean judge(tag_t top,string &status,string &name) +{ + int line_cnt; + tag_t *lines; + char *val; + BOM_line_ask_child_lines(top, &line_cnt, &lines); + for (int j = 0; j < line_cnt; j++) + { + AOM_UIF_ask_value(lines[j], "jd2_last_release_status", &val); + printf("status:%s\n", val); + string temp = val; + if (temp.length()>0&&status.find(val) != -1) + { + AOM_ask_value_string(lines[j], "bl_rev_object_string", &val); + name = val; + return false; + } + if (!judge(lines[j], status, name)) + return false; + } + return true; +} + +int bs_bom_check(EPM_rule_message_t msg) +{ + int ifail = EPM_go, att_count, line_cnt; + tag_t rootTask, *attachments, win, top, *lines; + char *val; + EPM_ask_root_task(msg.task, &rootTask); + + EPM_ask_attachments(rootTask, EPM_target_attachment, &att_count, &attachments); + TC_argument_list_t * arguments = msg.arguments; + int arg_cnt = TC_number_of_arguments(arguments), status = 0; + vector types; + string name; + map 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; + + } + split(paras["type"].c_str(),",", &types); + printf("check status:%s\n", paras["status"].c_str()); + BOM_create_window(&win); + for (int i = 0; i < att_count; i++) + { + bool pass = false; + for (int j = 0; j < types.size(); j++) + { + if (isTypeOf(attachments[i], types[j].c_str())) + { + pass = true; + break; + } + } + if (!pass) + continue; + printf("begin check \n"); + BOM_set_window_top_line(win, NULLTAG, attachments[i], NULLTAG, &top); + if(!judge(top, paras["status"],name)) + { + ifail = EPM_nogo; + break; + } + printf("end check \n"); + + } + BOM_close_window(win); + if (ifail==EPM_nogo) { + name += paras["prompt"]; + EMH_store_error_s1(EMH_severity_user_error, EMH_PROP_error_base, name.c_str()); + } + return ifail; +} + diff --git a/HEZON_ITK/bs_bom_save_check.cpp b/HEZON_ITK/bs_bom_save_check.cpp new file mode 100644 index 0000000..0a197a9 --- /dev/null +++ b/HEZON_ITK/bs_bom_save_check.cpp @@ -0,0 +1,62 @@ +#include "util.h" + +boolean save_judge(tag_t top,string &check,string &name,vector &type_vec) +{ + int line_cnt; + tag_t *lines; + BOM_line_ask_child_lines(top, &line_cnt, &lines); + char *val; + for (int i = 0; i type_vec(type_val,type_val+type_cnt); + + check = check_val; + BOM_ask_window_top_line(win, &top); + if (!save_judge(top, check, name,type_vec)) { + ifail = 1; + name += "¶ÔÏóΪ¶³½á״̬»òδ·¢²¼£¬²»Äܱ£´æBOM!"; + EMH_store_error_s1(EMH_severity_user_error, EMH_PROP_error_base, name.c_str()); + } + + printf("bs_bom_save_check end11\n"); + + return ifail; +} + diff --git a/HEZON_ITK/bs_sap.cpp b/HEZON_ITK/bs_sap.cpp index 267ee92..4023004 100644 --- a/HEZON_ITK/bs_sap.cpp +++ b/HEZON_ITK/bs_sap.cpp @@ -1,97 +1,4 @@ -#include "epm_handler_common.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "tc/envelope.h" -#include -#include "ae/dataset.h" -#include -#include -#include -#include -#include -#include -#include -#include "ce/ce.h" -#include -#include -#include -#include -#include -#include "string" -#include "sstream" -#include -#include -#include -#include "ctime" -#include "tchar.h" -#using "C:/Users/lyf/source/repos/Testdll/bin/Debug/declib.dll" -using namespace std; -using namespace Testdll; -using namespace System; - -extern "C" int POM_AM__set_application_bypass(logical bypass); -string ConvertToString(System::String^ str) -{ - char* p = (char*)(void*)System::Runtime::InteropServices::Marshal::StringToHGlobalAnsi(str); - return p; -} -System::String ^ convert_to_cstring(const char *p) -{ - return System::Runtime::InteropServices::Marshal::PtrToStringAnsi((System::IntPtr)(char *)p); -} -bool isTypeOf(tag_t objtag, const char * type_name) { - tag_t type = NULLTAG; - TCTYPE_ask_object_type(objtag, &type); - tag_t item_type = NULLTAG; - TCTYPE_find_type(type_name, "", &item_type); - bool is_type = false; - if (item_type != NULLTAG) { - logical isok = FALSE; - TCTYPE_is_type_of(type, item_type, &isok); - if (isok) { - is_type = true; - } - } - return is_type; -} -void split(std::string s, const char* delim, std::vector* ret) -{ - size_t last = 0; - size_t index = s.find(delim, last); - int size = strlen(delim); - while (index != std::string::npos) { - ret->push_back(s.substr(last, index - last)); - last = index + size; - index = s.find(delim, last); - } - if (index - last > 0) { - ret->push_back(s.substr(last, index - last)); - } -} +#include "util.h" int bs_sap_material(EPM_action_message_t msg) { printf("start sap material\n"); @@ -101,12 +8,15 @@ int bs_sap_material(EPM_action_message_t msg) int pref_cnt; char **pref_vals; EPM_ask_root_task(msg.task, &rootTask); + map class_map; EPM_ask_attachments(rootTask, EPM_target_attachment, &att_count, &attachments); TC_argument_list_t * arguments = msg.arguments; int arg_cnt = TC_number_of_arguments(arguments), status = 0; POM_AM__set_application_bypass(true); map paras,rel_map; + map prop_map; + vector rel_vec; for (auto i = 0; i < arg_cnt; i++) { @@ -114,6 +24,20 @@ int bs_sap_material(EPM_action_message_t msg) ITK_ask_argument_named_value(TC_next_argument(arguments), &temp_key, &temp_val); paras[temp_key] = temp_val; } + string d0 = "D00", d1 = "D0"; + for(int i=0;i<67;i++) + { + if(i>8) + { + + class_map[1000+i] = d1 + to_string(i + 1); + }else + { + class_map[1000 + i] = d0 + to_string(i + 1); + + + } + } PREF_ask_char_values("connor_sap", &pref_cnt, &pref_vals); split(pref_vals[4], ",", &rel_vec); for(int i=0;i temp_vec; + split(rel_vec[i], "=", &temp_vec); + if (temp_vec.size() == 2) + { + prop_map[temp_vec[0]] = temp_vec[1]; + } + } GRM_find_relation_type("IMAN_master_form", &relation_type); printf("create class\n"); Testclass ^test = gcnew Testclass(); @@ -132,24 +67,22 @@ int bs_sap_material(EPM_action_message_t msg) String^ url = convert_to_cstring(pref_vals[0]); String^ user = convert_to_cstring(pref_vals[2]); String^ password = convert_to_cstring(pref_vals[3]); - map map; - map["MTART"] = "jd2_wllx"; - map["MATNR"] = "item_id"; - map["MAKTX"] = "jd2_wlms"; - map["MEINS"] = "jd2_jldw"; - map["MATKL"] = "jd2_wlz"; - map["PRDHA"] = "jd2_cppc"; - map["EXTWG"] = "jd2_wbwlz"; - map["MSTAE"] = "release_status_list"; - map["VOLUM"] = "jd2_tj"; - map["VOLEH"] = "jd2_tjdw"; - map["BISMT"] = "jd2_jwlh"; - map["ZEINR"] = "jd2_th"; - map["BRGEW"] = "jd2_mz"; - map["NTGEW"] = "jd2_jz"; - map["GEWEI"] = "jd2_zldw"; - map["CLASS"] = "jd2_wllx"; - + // prop_map["MTART"] = "jd2_wllx"; + // prop_map["MATNR"] = "item_id"; + // prop_map["MAKTX"] = "jd2_wlms"; + // prop_map["MEINS"] = "jd2_dldw"; + // prop_map["MATKL"] = "jd2_wlz"; + // prop_map["PRDHA"] = "jd2_cpcc"; + // prop_map["EXTWG"] = "jd2_wbwlz"; + // prop_map["MSTAE"] = "release_status_list"; + // prop_map["VOLUM"] = "jd2_tj"; + // prop_map["VOLEH"] = "jd2_tjdw"; + // prop_map["BISMT"] = "jd2_jwlh"; + // prop_map["ZEINR"] = "jd2_th"; + // prop_map["BRGEW"] = "jd2_mz"; + // prop_map["NTGEW"] = "jd2_jz"; + // prop_map["GEWEI"] = "jd2_zldw"; + // prop_map["CLASS"] = "jd2_wllx"; vector vec{ "jd2_wllx","item_id","jd2_wlms","jd2_jldw","jd2_wlz","jd2_cppc","jd2_wbwlz","release_status_list","jd2_tj","jd2_tjdw","jd2_jwlh","jd2_th","jd2_mz","jd2_jz","jd2_zldw" }; printf("start111\n"); for (int i = 0; i < att_count; i++) @@ -160,7 +93,7 @@ int bs_sap_material(EPM_action_message_t msg) tag_t *rels; GRM_list_secondary_objects_only(attachments[i], relation_type, &rel_cnt, &rels); System::Collections::Generic::Dictionary ^dic = gcnew System::Collections::Generic::Dictionary(); - for (auto j = map.begin(); j != map.end(); j++) + for (auto j = prop_map.begin(); j != prop_map.end(); j++) { char *val=""; string temp_val; @@ -182,8 +115,26 @@ int bs_sap_material(EPM_action_message_t msg) AOM_UIF_ask_value(rels[0], j->second.c_str(), &val); temp_val = val; } + dic[convert_to_cstring(j->first.c_str())] = convert_to_cstring(temp_val.c_str()); } + tag_t class_obj; + ICS_ask_classification_object(attachments[i], &class_obj); + if (class_obj) + { + char ***vals; + int cnt, *ids,*val_count; + ICS_ico_ask_attributes(class_obj, &cnt, &ids, &val_count, &vals); + for(int j=0;jsend_bom(url, user, password, a_list)); printf("result:%s\n", result.c_str()); diff --git a/HEZON_ITK/bs_sign_cad.cpp b/HEZON_ITK/bs_sign_cad.cpp new file mode 100644 index 0000000..26f756c --- /dev/null +++ b/HEZON_ITK/bs_sign_cad.cpp @@ -0,0 +1,95 @@ +#pragma once +#include "util.h" +static void replace_dataset_named_reference(tag_t dataset_tag, tag_t old_file, + const char *new_file_path, char *ref_name) +{ + IMF_file_data_p_t file_data; + int index = 0; + ITKCALL(IMF_get_file_access(old_file, 0, &file_data)); + + tag_t new_file_tag = NULLTAG; + AOM_lock(old_file); + + ITKCALL(IMF_replace_file_and_get_new_tag(old_file, new_file_path, + FALSE, &new_file_tag)); + + AOM_lock(dataset_tag); + + ITKCALL(AE_replace_dataset_named_ref2(dataset_tag, old_file, ref_name, + AE_PART_OF, new_file_tag)); + ITKCALL(AE_save_myself(dataset_tag)); + AOM_unlock(dataset_tag); + ITKCALL(IMF_release_file_access(&file_data)); + // ITKCALL2(AOM_lock_for_delete(old_file)); + // ITKCALL2(AOM_delete(old_file)); +} + +int bs_sign_cad(EPM_action_message_t msg) +{ + int ifail = ITK_ok, att_count,tag_cnt,form_cnt; + tag_t rootTask, *attachments, *tags,ref,*forms; + TC_argument_list_t * arguments = msg.arguments; + char *name,*val; + int arg_cnt = TC_number_of_arguments(arguments), status = 0; + POM_AM__set_application_bypass(true); + map paras; + string tempdir = getenv("temp"); + for (auto i = 0; i prop_vec; + map prop_map; + split(paras["prop"], ",", &prop_vec); + for(int i=0;i temp_vec; + split(prop_vec[i], "=", &temp_vec); + if (temp_vec.size() == 2) + prop_map[temp_vec[0]] = temp_vec[1]; + } + EPM_ask_root_task(msg.task, &rootTask); + Testclass ^test = gcnew Testclass(); + EPM_ask_attachments(rootTask, EPM_target_attachment, &att_count, &attachments); + AE_reference_type_t ae_ref; + POM_AM__set_application_bypass(true); + for(int i=0;i ^dic = gcnew System::Collections::Generic::Dictionary(); + for(auto k=prop_map.begin();k!=prop_map.end();k++) + { + AOM_UIF_ask_value(forms[0], k->second.c_str(), &val); + dic[convert_to_cstring(k->first.c_str())] = convert_to_cstring(val); + } + bool result= test->signCad(convert_to_cstring(path.str().c_str()), convert_to_cstring(paras["title"].c_str()), dic); + if(result) + { + replace_dataset_named_reference(tags[j], ref, path.str().c_str(), "JD2_dwg"); + } + } + } + } + } + POM_AM__set_application_bypass(false); + + return 0; +} + diff --git a/HEZON_ITK/bs_wl_check.cpp b/HEZON_ITK/bs_wl_check.cpp new file mode 100644 index 0000000..8bc1da6 --- /dev/null +++ b/HEZON_ITK/bs_wl_check.cpp @@ -0,0 +1,98 @@ +#include "util.h" + +int bs_wl_check(EPM_rule_message_t msg) +{ + int ifail = EPM_go, att_count, tag_cnt,form_cnt; + tag_t rootTask, *attachments, win, top, *tags,*forms; + char *val; + EPM_ask_root_task(msg.task, &rootTask); + + EPM_ask_attachments(rootTask, EPM_target_attachment, &att_count, &attachments); + TC_argument_list_t * arguments = msg.arguments; + int arg_cnt = TC_number_of_arguments(arguments), status = 0; + vector wl_types, judge_types,judge_vec; + + string name; + map paras,judge_map; + for (auto i = 0; i temp; + split(judge_vec[i], "=", &temp); + if(temp.size()==2) + { + judge_map[temp[0]] = temp[1]; + } + } + + for (int i = 0; ifirst.c_str(), &val); + if(j->second!=val) + { + pass = true; + break; + } + } + if(!pass) + { + continue; + } + AOM_ask_value_tags(attachments[i], paras["relation"].c_str(), &tag_cnt, &tags); + printf("relation :%s\n, length:%d\n", paras["relation"].c_str(), tag_cnt); + pass = false; + + for(int j=0;j* ret) +{ + size_t last = 0; + size_t index = s.find(delim, last); + int size = strlen(delim); + while (index != std::string::npos) { + ret->push_back(s.substr(last, index - last)); + last = index + size; + index = s.find(delim, last); + } + if (index - last > 0) { + ret->push_back(s.substr(last, index - last)); + } +} + +const char* newGUID() +{ + static char buf[64] = { 0 }; + GUID guid; + if (S_OK == ::CoCreateGuid(&guid)) + { + _snprintf(buf, sizeof(buf) + , "%08X-%04X-%04x-%02X%02X-%02X%02X%02X%02X%02X%02X" + , guid.Data1 + , guid.Data2 + , guid.Data3 + , guid.Data4[0], guid.Data4[1] + , guid.Data4[2], guid.Data4[3], guid.Data4[4], guid.Data4[5] + , guid.Data4[6], guid.Data4[7] + ); + } + return (const char*)buf; + +} \ No newline at end of file diff --git a/HEZON_ITK/util.h b/HEZON_ITK/util.h new file mode 100644 index 0000000..31c36ce --- /dev/null +++ b/HEZON_ITK/util.h @@ -0,0 +1,68 @@ +#pragma once +#include "epm_handler_common.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "tc/envelope.h" +#include +#include "ae/dataset.h" +#include +#include +#include +#include +#include +#include +#include +#include "ce/ce.h" +#include +#include +#include +#include +#include +#include "string" +#include "sstream" +#include +#include +#include +#include "ctime" +#include "tchar.h" +#include "ics/ics.h" +#include "ics/ics2.h" +#using "C:/Users/lyf/source/repos/Testdll/bin/Debug/declib.dll" + +using namespace std; +using namespace Testdll; +using namespace System; +extern "C" int POM_AM__set_application_bypass(logical bypass); + + + +string ConvertToString(System::String^ str); +System::String ^ convert_to_cstring(const char *p); +bool isTypeOf(tag_t objtag, const char * type_name); +void split(std::string s, const char* delim, std::vector* ret); + +const char* newGUID(); \ No newline at end of file