#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 "common_itk_util.h" /** * @headerfile standard c & cpp header files */ #include #include #include //#include //#include #include #include #include #include #include #include #include /** * @headerfile user's header files */ #include "handler_common.h" #include "error_handling.h" #include "common_itk_util.h" #include "string_helper.h" using namespace std; typedef struct { string name; string value; }CAD_ATTR_STRUCT; extern "C" int POM_AM__set_application_bypass(logical bypass); int Connor_set_bypass(void* returnValue) { POM_AM__set_application_bypass(true); return 0; } int Connor_close_bypass(void* returnValue) { POM_AM__set_application_bypass(false); return 0; } int create_signinfo_file(char* file_content, char* item_id, char** file_name) { time_t now; struct tm* p; FILE* filePtr = NULL; char* temp_dir = getenv("TEMP"); char local_path[MAX_PATH] = ""; time(&now); p = localtime(&now); if (temp_dir[strlen(temp_dir) - 1] == '\\') { sprintf_s(local_path, "%s%s-%d-%d-%d-%d-%d-%d.dat", temp_dir, item_id, 1900 + p->tm_year, p->tm_mon + 1, p->tm_mday + 1, p->tm_hour, p->tm_min, p->tm_sec); } else { sprintf_s(local_path, "%s\\%s-%d-%d-%d-%d-%d-%d.dat", temp_dir, item_id, 1900 + p->tm_year, p->tm_mon + 1, p->tm_mday + 1, p->tm_hour, p->tm_min, p->tm_sec); } if ((filePtr = fopen(local_path, "wt")) == NULL) { printf("Can not create the temp dat file!\n"); return -1; } *file_name = (char*)MEM_alloc(sizeof(char) * 512); strcpy((*file_name), local_path); fwrite(file_content, sizeof(char), strlen(file_content), filePtr); fclose(filePtr); return ITK_ok; } //导入数据集 static int import_dataset_file(tag_t dataset, char* ref_name, char* ext, char* fullfilename, char* original_name) { int ifail = ITK_ok; tag_t new_file_tag = NULLTAG; IMF_file_t file_descriptor = NULL; AOM_refresh(dataset, FALSE); char* new_file_name = NULL; char new_ds_name[WSO_name_size_c + 1] = ""; char* filename = NULL; new_file_name = USER_new_file_name(new_ds_name, ref_name, ext, 0); filename = strrchr(fullfilename, '\\') + 1; if (filename == NULL) return ITK_ok; ECHO("IMF_import_file\n"); set_bypass(true); IMF_import_file(fullfilename, new_file_name, SS_BINARY, &new_file_tag, &file_descriptor); ECHO("IMF_set_original_file_name\n"); IMF_set_original_file_name2(new_file_tag, original_name); IMF_close_file(file_descriptor); AOM_save(new_file_tag); AOM_unlock(new_file_tag); AOM_refresh(new_file_tag, FALSE); //添加至命名引用 set_bypass(true); ITKCALL(AOM_lock(dataset)); ECHO("AE_remove_dataset_named_ref\n"); AE_remove_dataset_named_ref2(dataset, ref_name); AOM_save(dataset); ECHO("AE_add_dataset_named_ref\n"); set_bypass(true); AE_add_dataset_named_ref2(dataset, ref_name, AE_PART_OF, new_file_tag); AOM_save(dataset); AOM_unlock(dataset); //ITKCALL( AOM_refresh( dataset, FALSE ) ); return ifail; } //static int import_excel(tag_t dataset, char* ref_name, char* ext, char* fullfilename, char* original_name) //{ // int ifail = ITK_ok; // tag_t new_file_tag = NULLTAG; // IMF_file_t file_descriptor = NULL; // AOM_refresh(dataset, FALSE); // char* new_file_name = NULL; // char new_ds_name[WSO_name_size_c + 1] = ""; // char* filename = NULL; // new_file_name = USER_new_file_name(new_ds_name, ref_name, ext, 0); // // // filename = strrchr(fullfilename, '\\') + 1; // if (filename == NULL) // return ITK_ok; // ECHO("IMF_import_file\n"); // set_bypass(true); // IMF_import_file(fullfilename, new_file_name, SS_BINARY, &new_file_tag, &file_descriptor); // ECHO("IMF_set_original_file_name\n"); // IMF_set_original_file_name2(new_file_tag, original_name); // // IMF_close_file(file_descriptor); // AOM_save(new_file_tag); // AOM_unlock(new_file_tag); // AOM_refresh(new_file_tag, FALSE); // // //添加至命名引用 // set_bypass(true); // ITKCALL(AOM_lock(dataset)); // ECHO("AE_remove_dataset_named_ref\n"); // AE_remove_dataset_named_ref2(dataset, ref_name); // AOM_save(dataset); // // ECHO("AE_add_dataset_named_ref\n"); // set_bypass(true); // AE_add_dataset_named_ref2(dataset, ref_name, AE_PART_OF, new_file_tag); // // AOM_save(dataset); // AOM_unlock(dataset); // //ITKCALL( AOM_refresh( dataset, FALSE ) ); // return ifail; //} //int importExcel2(tag_t rev_tag, tag_t rel_tag, const char* pdfFile, char* datasetName, tag_t dataset) { // tag_t* rfTags, datasetTag = NULLTAG, relation = NULLTAG; // int ifail = ITK_ok, rfCount = 0; // char type_class[WSO_object_type_size_c + 1], * pdfDatasetName; // // ITKCALL(ifail = GRM_create_relation(rev_tag, datasetTag, rel_tag, NULLTAG, &relation)); // ITKCALL(GRM_save_relation(relation)); // //set_bypass(false); // if (ifail == ITK_ok) { // printf("挂载到版本下成功\n"); // } // else { // printf("挂载到版本下失败\n"); // return -1; // } // // char* pdfFile2 = new char[255]; // strcpy(pdfFile2, pdfFile); // ITKCALL(ifail = import_excel(datasetTag, "PDF_Reference", "pdf", pdfFile2, pdfName)); // if (ifail != ITK_ok) { // //WriteLog(dwgName, "上传数据集文件失败"); // printf("上传数据集文件失败\n"); // } //} int importPdf2(tag_t rev_tag, tag_t rel_tag, const char* pdfFile, char* datasetName, char* pdfName, tag_t owner_user) { tag_t* rfTags, datasetTag = NULLTAG, relation = NULLTAG; int ifail = ITK_ok, rfCount = 0; char type_class[WSO_object_type_size_c + 1], * pdfDatasetName; if (datasetTag == NULLTAG) { printf("没有找到PDF数据集%s,开始进行创建\n", datasetName); tag_t pdfTypeTag = NULLTAG, tool = NULLTAG; ITKCALL(ifail = AE_find_datasettype2("PDF", &pdfTypeTag)); ITKCALL(ifail = AE_create_dataset_with_id(pdfTypeTag, datasetName, "", "", "A", &datasetTag));//modify 2019 12 31 pdfname->datasetName 2020/10/15描述设置成dwg ITKCALL(ifail = AE_ask_datasettype_def_tool(pdfTypeTag, &tool)); ITKCALL(ifail = AE_set_dataset_tool(datasetTag, tool)); ITKCALL(ifail = POM_set_owning_user(datasetTag, owner_user)); ITKCALL(ifail = AE_set_dataset_format2(datasetTag, "PDF_Reference")); ITKCALL(ifail = AOM_save(datasetTag)); ITKCALL(ifail = POM_set_owning_user(datasetTag, owner_user)); ITKCALL(ifail = AOM_save(datasetTag)); if (datasetTag == NULLTAG) { printf("创建失败\n"); return -1; } else { printf("创建成功\n"); //set_bypass(true) ITKCALL(ifail = GRM_create_relation(rev_tag, datasetTag, rel_tag, NULLTAG, &relation)); ITKCALL(GRM_save_relation(relation)); //set_bypass(false); if (ifail == ITK_ok) { printf("挂载到版本下成功\n"); } else { printf("挂载到版本下失败\n"); return -1; } } } else { printf("找到PDF数据集%s,开始进行更新数据文件\n", pdfName); } char* pdfFile2 = new char[255]; strcpy(pdfFile2, pdfFile); ITKCALL(ifail = import_dataset_file(datasetTag, "PDF_Reference", "pdf", pdfFile2, pdfName)); if (ifail != ITK_ok) { //WriteLog(dwgName, "上传数据集文件失败"); printf("上传数据集文件失败\n"); } return ifail; } int signoff_msword(tag_t item_rev_tag, tag_t dataset, tag_t rel_tag, char* dat_file, char* ext) { tag_t spec_dataset_rev = NULLTAG, ref_object = NULLTAG, owner_user = NULLTAG; AE_reference_type_t reference_type; char* value = NULL; //printf("\n111111111111\n"); AE_ask_dataset_latest_rev(dataset, &spec_dataset_rev); AOM_ask_value_string(dataset, "object_name", &value); AOM_ask_owner(dataset, &owner_user); char ref_name[WSO_name_size_c + 1] = "word"; //printf("\n22222222222\n"); ITKCALL(AE_ask_dataset_named_ref2(spec_dataset_rev, ref_name, &reference_type, &ref_object)); if (ref_object == NULLTAG) { strcpy(ref_name, "Fnd0word"); ITKCALL(AE_ask_dataset_named_ref2(spec_dataset_rev, ref_name, &reference_type, &ref_object)); } if (reference_type == AE_PART_OF) { //printf("\n3333333333333\n"); int ifail = ITK_ok; char* pathname = NULL; IMF_ask_file_pathname2(ref_object, SS_WNT_MACHINE, &pathname); char* origin_file_name = NULL; IMF_ask_original_file_name2(ref_object, &origin_file_name); //printf("\n44444444444444\n"); char new_ds_name[WSO_name_size_c + 1] = ""; char* new_file_name = USER_new_file_name(new_ds_name, ref_name, ext, 0); char* temp_dir = getenv("temp"); /*temp_dir = "E:\\TEMP";*/ //printf("\n555555555555\n"); char temp_file[SS_MAXPATHLEN] = ""; char temp_file2[SS_MAXPATHLEN] = "\0"; strcpy(temp_file, temp_dir); strcat(temp_file, "\\"); strcat(temp_file, value); /*if (strstr(temp_file, ".docx") != NULL) { char temp_file_temp[SS_MAXPATHLEN] = "\0"; strncpy(temp_file_temp, temp_file, strlen(temp_file) - 5); sprintf(temp_file2, "%s.pdf", temp_file_temp); } else if (strstr(temp_file, ".docm") != NULL) { char temp_file_temp[SS_MAXPATHLEN] = "\0"; strncpy(temp_file_temp, temp_file, strlen(temp_file) - 5); sprintf(temp_file2, "%s.pdf", temp_file_temp); } else if (strstr(temp_file, ".doc") != NULL) { char temp_file_temp[SS_MAXPATHLEN] = "\0"; strncpy(temp_file_temp, temp_file, strlen(temp_file) - 4); sprintf(temp_file2, "%s.pdf", temp_file_temp); } else { sprintf(temp_file2, "%s.pdf", temp_file); }*/ IMF_export_file(ref_object, temp_file); //printf("\n66666666666666\n"); int iCnt; char* user_lib_env, pTempStr[500]; char local_path[MAX_PATH] = ""; char cmd[256] = ""; //user_lib_env = getenv("TC_USER_LIB"); //strcpy(local_path, user_lib_env); //iCnt = strlen(user_lib_env); //while( user_lib_env[iCnt] != '\\' ) //{ // iCnt--; //} //strcpy(pTempStr,""); //strcpy(pTempStr,&user_lib_env[iCnt+1]); //if( strcmp(pTempStr,"SubstMacros-MSWord.wsf") != 0 ) //{ // strcat( user_lib_env, "\\SubstMacros-MSWord.wsf" ); //} //strcpy( cmd, user_lib_env ); strcpy(cmd, "C:\\属性映射\\SubstMacros-MSWord.wsf"); strcat(cmd, " \""); strcat(cmd, temp_file); strcat(cmd, "\" \""); strcat(cmd, dat_file); strcat(cmd, "\""); printf("\n%s\n", cmd); system(cmd); //printf("\n777777777777\n"); //strcpy(user_lib_env, local_path); Sleep(1000); //printf("\n8888888888888\n"); tag_t new_file_tag = NULLTAG; IMF_file_t file_descriptor; IMF_import_file(temp_file, new_file_name, SS_BINARY, &new_file_tag, &file_descriptor); IMF_set_original_file_name2(new_file_tag, origin_file_name); IMF_close_file(file_descriptor); AOM_save(new_file_tag); AOM_unlock(new_file_tag); AOM_lock(spec_dataset_rev); AE_remove_dataset_named_ref_by_tag2(spec_dataset_rev, ref_name, ref_object); AE_add_dataset_named_ref2(spec_dataset_rev, ref_name, AE_PART_OF, new_file_tag); AOM_save(spec_dataset_rev); AOM_unlock(spec_dataset_rev); if (remove(temp_file) == 0) { printf("Removed %s.", temp_file); } else { printf("删除失败 %s.", temp_file); } } return ITK_ok; } int signoff_msexcel(tag_t item_rev_tag, tag_t dataset, tag_t rel_tag, char* dat_file, char* ext) { tag_t spec_dataset_rev = NULLTAG, ref_object = NULLTAG, owner_user = NULLTAG; int ifail = ITK_ok; char* value = NULL; AE_reference_type_t reference_type; AE_ask_dataset_latest_rev(dataset, &spec_dataset_rev); AOM_ask_value_string(dataset, "object_name", &value); AOM_ask_owner(dataset, &owner_user); char ref_name[WSO_name_size_c + 1] = "excel"; ITKCALL(AE_ask_dataset_named_ref2(spec_dataset_rev, ref_name, &reference_type, &ref_object)); if (reference_type == AE_PART_OF) { char* pathname = NULL; IMF_ask_file_pathname2(ref_object, SS_WNT_MACHINE, &pathname); char* origin_file_name = NULL; IMF_ask_original_file_name2(ref_object, &origin_file_name); char new_ds_name[WSO_name_size_c + 1] = ""; char* new_file_name = USER_new_file_name(new_ds_name, ref_name, ext, 0); char* temp_dir = getenv("temp"); //temp_dir = "E:\\TEMP"; char temp_file[SS_MAXPATHLEN] = ""; char temp_file2[SS_MAXPATHLEN] = "\0"; strcpy(temp_file, temp_dir); strcat(temp_file, "\\"); strcat(temp_file, value); /*if (strstr(temp_file, ".xlsx") != NULL) { char temp_file_temp[SS_MAXPATHLEN] = "\0"; strncpy(temp_file_temp, temp_file, strlen(temp_file) - 5); sprintf(temp_file2, "%s.pdf", temp_file_temp); } else if (strstr(temp_file, ".xls") != NULL) { char temp_file_temp[SS_MAXPATHLEN] = "\0"; strncpy(temp_file_temp, temp_file, strlen(temp_file) - 4); sprintf(temp_file2, "%s.pdf", temp_file_temp); } else if (strstr(temp_file, ".xlsm") != NULL) { char temp_file_temp[SS_MAXPATHLEN] = "\0"; strncpy(temp_file_temp, temp_file, strlen(temp_file) - 5); sprintf(temp_file2, "%s.pdf", temp_file_temp); } else { sprintf(temp_file2, "%s.pdf", temp_file); }*/ IMF_export_file(ref_object, temp_file); int iCnt; char* user_lib_env, pTempStr[500]; char local_path[MAX_PATH] = ""; char cmd[256] = ""; /*user_lib_env = getenv("TC_USER_LIB"); strcpy(local_path, user_lib_env); iCnt = strlen(user_lib_env); while( user_lib_env[iCnt] != '\\' ) { iCnt--; } strcpy(pTempStr,""); strcpy(pTempStr,&user_lib_env[iCnt+1]); if( strcmp(pTempStr,"SubstMacros-MSExcel.wsf") != 0 ) { strcat( user_lib_env, "\\SubstMacros-MSExcel.wsf" ); }*/ //strcpy( cmd, user_lib_env ); strcpy(cmd, "C:\\属性映射\\SubstMacros-MSExcel.wsf"); strcat(cmd, " \""); strcat(cmd, temp_file); strcat(cmd, "\" \""); strcat(cmd, dat_file); strcat(cmd, "\""); printf("\n%s\n", cmd); system(cmd); //strcpy(user_lib_env, local_path); Sleep(1000); /*strcpy(cmd, "java -jar C:\\电子签名\\exceltopdf.jar"); strcat(cmd, " \""); strcat(cmd, temp_file); strcat(cmd, "\" \""); strcat(cmd, temp_file2); strcat(cmd, "\""); printf("\n%s\n", cmd); system(cmd);*/ //printf("\n8888888888888\n"); tag_t new_file_tag = NULLTAG; IMF_file_t file_descriptor; IMF_import_file(temp_file, new_file_name, SS_BINARY, &new_file_tag, &file_descriptor); IMF_set_original_file_name2(new_file_tag, origin_file_name); IMF_close_file(file_descriptor); AOM_save(new_file_tag); AOM_unlock(new_file_tag); AOM_lock(spec_dataset_rev); AE_remove_dataset_named_ref_by_tag2(spec_dataset_rev, ref_name, ref_object); AE_add_dataset_named_ref2(spec_dataset_rev, ref_name, AE_PART_OF, new_file_tag); AOM_save(spec_dataset_rev); AOM_unlock(spec_dataset_rev); if (remove(temp_file) == 0) { printf("Removed %s.", temp_file); } else { printf("删除失败 %s.", temp_file); } } return ITK_ok; } int BH_Mapping_Att(EPM_action_message_t msg) { int ifail = ITK_ok, rcode = 0; //参数相关 char arg1value[1024] = "", arg2value[1024] = "", arg3value[1024] = "", arg4value[1024] = "", signcounter_info[1024] = "", * value = NULL; char* argflag = NULL, * argvalue = NULL, * arg = NULL; BOOL bypass = FALSE; int arg_cnt = 0; //流程节点相关 tag_t root_task = NULLTAG, * sub_tasks = NULL, current_task = NULLTAG, type_tag = NULLTAG; int sub_task_count = 0; char root_task_name[128] = "", task_name[128] = ""; int occur_of_counts = 0; tag_t* taskAttches = NULLTAG; char tgt_type[WSO_name_size_c + 1] = "", * type_class = NULL; ////循环内部变量 tag_t cur_task = NULLTAG; char task_type[WSO_name_size_c + 1] = ""; //循环变量 int i = 0, j = 0, k = 0, count = 0, n = 0; //节点信息变量 char sign_info[2048] = ""; //节点循环处理变量 tag_t itemrevision = NULLTAG, master_form_rel_type = NULLTAG, item = NULLTAG; char* rev_id = NULL; char* item_id = NULL; char* item_type2 = NULL; int form_count = 0; tag_t* form_list = NULL, master_form = NULLTAG, * release = NULL; char local_path[128] = ""; //编制节点 int s = 0; char* timeinfo2 = ""; EPM_decision_t decision = EPM_nogo; tag_t aUserTag, responsibleParty; char* userName; date_t decision_date; char person_name[SA_name_size_c + 1] = ""; char* prop_name = "last_mod_date"; //会签相关 int n_prop = 0, q = 0, num = 0; char** prop_names = NULL, hq_name[128] = "", hq_time_name[128] = "", * hq_value = NULL; char exclude_type[256] = "", item_type[ITEM_type_size_c + 1] = "", Property[128] = "", Item_type[128] = "", dataset_type[128] = ""; logical is_sign = false; map sign_map; vector prop_vec; current_task = msg.task; //CreateLogFile("PLA8_signoff",&txtfile); ECHO("=========================================================\n"); ECHO("LB_signoff_dataset 开始执行\n"); ECHO("=========================================================\n"); struct tm* p; char date_string[2000]; time_t now; time(&now); p = localtime(&now); sprintf(date_string, "%4d-%d-%-d %d:%d:%d", 1900 + p->tm_year, p->tm_mon + 1, p->tm_mday, p->tm_hour, p->tm_min, p->tm_sec); ECHO("时间:%s\n", date_string); arg_cnt = TC_number_of_arguments(msg.arguments); ECHO("参数个数为:%d\n", arg_cnt); POM_AM__set_application_bypass(true); vector ans, ans1, typelx; if (arg_cnt > 0) { for (i = 0;i < arg_cnt;i++) { arg = TC_next_argument(msg.arguments); ifail = ITK_ask_argument_named_value((const char*)arg, &argflag, &argvalue); if (stricmp(argflag, "Item_type") == 0) { if (argvalue != NULL) { strcpy(Item_type, argvalue); } } else if (strcmp(argflag, "Property") == 0) { if (argvalue != NULL) { strcpy(Property, argvalue); Split(argvalue, ";", ans); } } else if (stricmp(argflag, "dataset_type") == 0) { if (argvalue != NULL) { strcpy(dataset_type, argvalue); Split(argvalue, ";", typelx); } } } MEM_free(argflag); MEM_free(argvalue); } tag_t sx = NULLTAG; PROP_value_type_t a; char* valuetype, * object_name; ECHO("item_type:%s\n", Item_type); //获取属性 ECHO("进来了\n"); ITKCALL(EPM_ask_root_task(msg.task, &root_task)); ITKCALL(EPM_ask_sub_tasks(root_task, &sub_task_count, &sub_tasks)); ITKCALL(EPM_ask_attachments(root_task, EPM_target_attachment, &occur_of_counts, &taskAttches)); ECHO("%d target attachment found", occur_of_counts); for (count = 0; count < occur_of_counts; count++) { ECHO("the %dth work", count); TCTYPE_ask_object_type(taskAttches[count], &type_tag); ifail = TCTYPE_ask_class_name2(type_tag, &type_class); ECHO("type_class : %s", type_class); //过滤掉非版本对象 if (((strstr(type_class, "Revision") != NULL) || (strstr(type_class, "revision") != NULL)) && (strstr(type_class, "Master") == NULL) && (strstr(type_class, "master") == NULL) && (strstr(type_class, "BOM") == NULL) && (strstr(type_class, "bom") == NULL) && (strstr(type_class, "Bom") == NULL)) { itemrevision = taskAttches[count]; ITEM_ask_rev_id2(itemrevision, &rev_id); ITEM_ask_rev_type2(itemrevision, &item_type2); ECHO("item_type====================================%s", item_type); ITEM_ask_item_of_rev(itemrevision, &item); ITEM_ask_id2(item, &item_id); if (strcmp(Item_type, "Item") == 0) { for (int i = 0; i < ans.size(); i++) { ITKCALL(AOM_ask_value_type(item, ans[i].c_str(), &a, &valuetype)); ECHO("PROP_value_type_t2 a=%d\n", a); if (a == 8) { AOM_ask_value_string(item, ans[i].c_str(), &object_name); ans1.push_back(object_name); } } } else if (strcmp(Item_type, "ItemRevision") == 0) { for (int i = 0; i < ans.size(); i++) { ITKCALL(AOM_ask_value_type(itemrevision, ans[i].c_str(), &a, &valuetype)); ECHO("PROP_value_type_t2 a=%d\n", a); if (a == 8) { AOM_ask_value_string(itemrevision, ans[i].c_str(), &object_name); ans1.push_back(object_name); } } } else if (strcmp(Item_type, "ItemRevisionMaster") == 0) { GRM_find_relation_type(TC_master_form_rtype, &master_form_rel_type); GRM_list_secondary_objects_only(itemrevision, master_form_rel_type, &form_count, &form_list); if (form_count == 0) { ECHO("未找到签名form,继续..."); continue; } master_form = form_list[0]; for (int i = 0; i < ans.size(); i++) { ITKCALL(AOM_ask_value_type(master_form, ans[i].c_str(), &a, &valuetype)); ECHO("PROP_value_type_t2 a=%d\n", a); if (a == 8) { AOM_ask_value_string(master_form, ans[i].c_str(), &object_name); ans1.push_back(object_name); } } } string info; for (int j = 0; j < ans1.size(); j++) { info.append(ans[j]); info.append("="); info.append(ans1[j]); info.append("|"); } ECHO("\n info1: %s", info.c_str()); char* data_file1 = NULL; create_signinfo_file((char*)info.c_str(), item_id, &data_file1); if (data_file1 == NULL) { printf("成功"); } ECHO("\n 创建文本文件%s\n", data_file1); //获得数据集 tag_t relation_type = NULLTAG; tag_t relation_type1 = NULLTAG; //tag_t attach_relation_type = NULLTAG; GRM_find_relation_type(TC_specification_rtype, &relation_type); tag_t* secondary_objects = NULLTAG; tag_t* secondary_objects1 = NULLTAG; int ds_count = 0; int ds_count1 = 0; char* dataset_type1 = NULL, * desc_value = NULL, * file_path = NULL, * desc_path; //GRM_list_secondary_objects_only(itemrevision, relation_type, &ds_count, &secondary_objects); ITKCALL(AOM_ask_value_tags(itemrevision, TC_specification_rtype, &ds_count, &secondary_objects)); for (int j = 0; j < ds_count; j++) { printf("进1\n"); AOM_ask_value_string(secondary_objects[j], "object_type", &dataset_type1); int des_count = 0; tag_t* dess = NULL; char* name; if (typelx.size() > 1) { if (!(strcmp(dataset_type1, "MSWord") == 0 || strcmp(dataset_type1, "MSWordX") == 0 || strcmp(dataset_type1, "MSExcel") == 0 || strcmp(dataset_type1, "MSExcelX") == 0)) { if (dataset_type1 != NULL) { MEM_free(dataset_type1); dataset_type1 = NULL; } continue; } AOM_ask_value_tags(secondary_objects[j], "ref_list", &des_count, &dess); if (des_count < 1) { printf("该数据集引用数量错误\n"); continue; } printf("开始判断类型\n"); if (strcmp(dataset_type1, "MSWord") == 0) { AOM_ask_value_string(dess[0], "original_file_name", &name); printf("name=%s\n", name); /*if ((strstr(name, "docx") != NULL) || (strstr(name, "xlsx") != NULL)) { printf("后缀为docx或xlsx退出\n"); continue; }*/ signoff_msword(itemrevision, secondary_objects[j], relation_type, data_file1, "doc"); } else if (strcmp(dataset_type1, "MSWordX") == 0) { AOM_ask_value_string(dess[0], "original_file_name", &name); printf("name=%s\n", name); /*if ((strstr(name, "docx") != NULL) || (strstr(name, "xlsx") != NULL)) { printf("后缀为docx或xlsx退出\n"); continue; }*/ if ((strstr(name, "docx")) != NULL) { signoff_msword(itemrevision, secondary_objects[j], relation_type, data_file1, "docx"); } if ((strstr(name, "docm")) != NULL) { signoff_msword(itemrevision, secondary_objects[j], relation_type, data_file1, "docm"); } }else if (strcmp(dataset_type1, "MSExcel") == 0) { AOM_ask_value_string(dess[0], "original_file_name", &name); printf("name=%s\n", name); /*if ((strstr(name, "docx") != NULL) || (strstr(name, "xlsx") != NULL)) { printf("后缀为docx或xlsx退出\n"); continue; }*/ signoff_msexcel(itemrevision, secondary_objects[j], relation_type, data_file1, "xls"); } else if (strcmp(dataset_type1, "MSExcelX") == 0) { AOM_ask_value_string(dess[0], "original_file_name", &name); printf("name=%s\n", name); /*if ((strstr(name, "docx") != NULL) || (strstr(name, "xlsx") != NULL)) { printf("后缀为docx或xlsx退出\n"); continue; }*/ if ((strstr(name, "xlsx")) != NULL) { signoff_msexcel(itemrevision, secondary_objects[j], relation_type, data_file1, "xlsx"); } if ((strstr(name, "xlsm")) != NULL) { signoff_msexcel(itemrevision, secondary_objects[j], relation_type, data_file1, "xlsm"); } } } else { if (strcmp(dataset_type, "word") == 0) { if (!(strcmp(dataset_type1, "MSWord") == 0 || strcmp(dataset_type1, "MSWordX") == 0)) { if (dataset_type1 != NULL) { MEM_free(dataset_type1); dataset_type1 = NULL; } continue; } AOM_ask_value_tags(secondary_objects[j], "ref_list", &des_count, &dess); if (des_count < 1) { printf("该数据集引用数量错误\n"); continue; } printf("开始判断类型\n"); if (strcmp(dataset_type1, "MSWord") == 0) { AOM_ask_value_string(dess[0], "original_file_name", &name); printf("name=%s\n", name); /*if ((strstr(name, "docx") != NULL) || (strstr(name, "xlsx") != NULL)) { printf("后缀为docx或xlsx退出\n"); continue; }*/ signoff_msword(itemrevision, secondary_objects[j], relation_type, data_file1, "doc"); } else if (strcmp(dataset_type1, "MSWordX") == 0) { AOM_ask_value_string(dess[0], "original_file_name", &name); printf("name=%s\n", name); /*if ((strstr(name, "docx") != NULL) || (strstr(name, "xlsx") != NULL)) { printf("后缀为docx或xlsx退出\n"); continue; }*/ if ((strstr(name, "docx")) != NULL) { signoff_msword(itemrevision, secondary_objects[j], relation_type, data_file1, "docx"); } if ((strstr(name, "docm")) != NULL) { signoff_msword(itemrevision, secondary_objects[j], relation_type, data_file1, "docm"); } } } else if (strcmp(dataset_type, "excel") == 0) { if (!(strcmp(dataset_type1, "MSExcel") == 0 || strcmp(dataset_type1, "MSExcelX") == 0)) { if (dataset_type1 != NULL) { MEM_free(dataset_type1); dataset_type1 = NULL; } continue; } AOM_ask_value_tags(secondary_objects[j], "ref_list", &des_count, &dess); if (des_count < 1) { printf("该数据集引用数量错误\n"); continue; } printf("开始判断类型\n"); if (strcmp(dataset_type1, "MSExcel") == 0) { AOM_ask_value_string(dess[0], "original_file_name", &name); printf("name=%s\n", name); /*if ((strstr(name, "docx") != NULL) || (strstr(name, "xlsx") != NULL)) { printf("后缀为docx或xlsx退出\n"); continue; }*/ signoff_msexcel(itemrevision, secondary_objects[j], relation_type, data_file1, "xls"); } else if (strcmp(dataset_type1, "MSExcelX") == 0) { AOM_ask_value_string(dess[0], "original_file_name", &name); printf("name=%s\n", name); /*if ((strstr(name, "docx") != NULL) || (strstr(name, "xlsx") != NULL)) { printf("后缀为docx或xlsx退出\n"); continue; }*/ if ((strstr(name, "xlsx")) != NULL) { signoff_msexcel(itemrevision, secondary_objects[j], relation_type, data_file1, "xlsx"); } if ((strstr(name, "xlsm")) != NULL) { signoff_msexcel(itemrevision, secondary_objects[j], relation_type, data_file1, "xlsm"); } } } } } } } POM_AM__set_application_bypass(false); DOFREE(taskAttches); ECHO("=========================================================\n"); ECHO("jf_signoff_dataset 执行结束\n"); ECHO("=========================================================\n"); return rcode; } //数据移植 int Connor_Data_Transplant(EPM_action_message_t msg) { ECHO("=========================================================\n"); ECHO("Connor_Data_Transplant 开始执行\n"); ECHO("=========================================================\n"); int ifail = ITK_ok, rcode = 0; tag_t task_tag = NULLTAG; //这个开超级权限是干什么的 printf("开超级权限\n"); POM_AM__set_application_bypass(true); task_tag = msg.task; if (task_tag == NULLTAG) { goto end; } //获取流程目标 tag_t* flowTargets = NULLTAG; int targetNum = 0; ITKCALL(ifail = AOM_ask_value_tags(task_tag, "root_target_attachments", &targetNum, &flowTargets)); //获取流程引用 tag_t* flowReferences = NULLTAG; int referenceNum = 0; ITKCALL(ifail = AOM_ask_value_tags(task_tag, "root_reference_attachments", &referenceNum, &flowReferences)); //获取流程引用对象类型 char* reference_type = NULL; ITKCALL(ifail = AOM_ask_value_string(flowReferences[0], "object_type", &reference_type)); /*将流程目标下的数据剪切到流程引用中*/ //tag_t* uploadDataSets = NULLTAG; //int dataCount = 0; //ITKCALL(ifail = AOM_ask_value_tags(flowTargets[0], "contents", &dataCount, &uploadDataSets));//获取流程目标文件夹下的数据集 if (targetNum > 0) { //获取临时文件夹对象 char* value; char* folderUID; ITKCALL(PREF_ask_char_value("BH_Upload_USER", 0, &value));//获取首选项的第一个值 //截取被|分割的第二个字符串 const char* d = "|"; if (value != NULL) { folderUID = strtok(value, d); folderUID = strtok(NULL, d); } else { printf("请先配置首选项并为其赋值\n"); goto end; } tag_t temp_folder; ITK__convert_uid_to_tag(folderUID, &temp_folder); for (int i = 0; i < targetNum; i++) { //tag_t temp_test; //ITK__convert_uid_to_tag("wJtJGAvXpVL7kA", &temp_test); //转换所有权 tag_t user_tag, group_tag; ITKCALL(ifail = AOM_ask_value_tag(flowReferences[0], "owning_user", &user_tag));//获取流程引用的所有权用户 ITKCALL(ifail = AOM_ask_value_tag(flowReferences[0], "owning_group", &group_tag)); ITKCALL(AOM_lock(flowTargets[i])); if (group_tag == NULLTAG) { ITKCALL(POM_set_owning_user(flowTargets[i], user_tag)); } else { AOM_set_ownership(flowTargets[i], user_tag, group_tag); //AOM_set_ownership(temp_test, user_tag, group_tag); /*ITKCALL(POM_set_owning_user(flowTargets[i], user_tag)); ITKCALL(POM_set_owning_group(flowTargets[i], group_tag));*/ //ITKCALL(POM_set_owners(1, &flowTargets[i], user_tag, group_tag)); //ITKCALL(POM_set_owners(1, &temp_test, user_tag, group_tag)); } AOM_save(flowTargets[i]); ITKCALL(AOM_unlock(flowTargets[i])); ITKCALL(ifail = AOM_refresh(flowTargets[i], FALSE)); //解除上传的数据集与临时文件夹的关系,从临时文件夹中移除 FL_remove(temp_folder, flowTargets[i]); AOM_save(temp_folder); //将数据集的描述值清空 AOM_set_value_string(flowTargets[i], "object_desc", ""); //判断流程引用的对象类型 tag_t typeTag = NULLTAG, relationTag = NULLTAG; if (strstr(reference_type, "Folder") != NULL) { //ITKCALL(GRM_find_relation_type("contents", &typeTag)); printf("在流程引用下的对象为文件夹\n"); FL_insert(flowReferences[0], flowTargets[i], 999); AOM_save(flowReferences[0]); //AOM_refresh(flowReferences[0],0); } else { ITKCALL(GRM_find_relation_type("IMAN_specification", &typeTag)); printf("在流程引用下的对象为版本\n"); ITKCALL(GRM_create_relation(flowReferences[0], flowTargets[i], typeTag, NULLTAG, &relationTag));//建立关系 ITKCALL(GRM_save_relation(relationTag));//保存关系 } } //刷新流程引用对象和临时文件夹对象 ITKCALL(ifail = AOM_refresh(temp_folder, FALSE)); ITKCALL(ifail = AOM_refresh(flowReferences[0], FALSE)); } DOFREE(flowTargets); DOFREE(flowReferences); printf("执行完成"); printf("关超级权限\n"); POM_AM__set_application_bypass(false); end: ECHO("=========================================================\n"); ECHO("Connor_Data_Transplant 执行结束\n"); ECHO("=========================================================\n"); return rcode; }