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_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