#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, TRUE, &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); } string result= ConvertToString(test->signCad(convert_to_cstring(path.str().c_str()), convert_to_cstring(paras["title"].c_str()), dic)); if(result.length()) { replace_dataset_named_reference(tags[j], ref, result.c_str(), "JD2_dwg"); } } } } } POM_AM__set_application_bypass(false); return 0; }