|
|
|
|
|
|
|
|
#include "epm_handler_common.h"
|
|
|
#include <ae/ae.h>
|
|
|
#include <tccore\item.h>
|
|
|
#include <stdio.h>
|
|
|
#include <tc\emh.h>
|
|
|
#include <tc\preferences.h>
|
|
|
#include <epm\epm_toolkit_tc_utils.h>
|
|
|
#include <tccore\item.h>
|
|
|
#include <tccore\grm.h>
|
|
|
#include <tccore\imantype.h>
|
|
|
#include <tccore\iman_grmtype.h>
|
|
|
#include <tccore\aom.h>
|
|
|
#include <property\prop_errors.h>
|
|
|
#include <qry\qry.h>
|
|
|
#include <epm\cr.h>
|
|
|
#include <bom/bom.h>
|
|
|
#include <stdio.h>
|
|
|
#include <string>
|
|
|
#include <iterator>
|
|
|
#include <vector>
|
|
|
#include <iostream>
|
|
|
#pragma warning(disable : 4996)
|
|
|
#include <tccore\aom_prop.h>
|
|
|
//日志输出
|
|
|
#include "common_itk_util.h"
|
|
|
|
|
|
extern "C" int POM_AM__set_application_bypass(logical bypass);
|
|
|
using namespace std;
|
|
|
|
|
|
int setTarget2(tag_t tag_task, tag_t tag_a) {
|
|
|
int ifail = ITK_ok;
|
|
|
int master_count = 0, count = 0;
|
|
|
int attachment_types = 0;
|
|
|
|
|
|
if (tag_a != NULL) {
|
|
|
//AOM_unlock(tag_a);
|
|
|
attachment_types = EPM_target_attachment;
|
|
|
//attachment_types = EPM_reference_attachment;
|
|
|
|
|
|
printf("开始将版本放入目标\n");
|
|
|
EPM_add_attachments(tag_task, 1, &(tag_a), &attachment_types);
|
|
|
printf("结束将版本放入目标\n");
|
|
|
//AOM_lock(tag_a);
|
|
|
return ITK_ok;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
//分割字符串函数
|
|
|
void split_img(char* src, const char* separator, char** dest, int* num) {
|
|
|
/*
|
|
|
src 源字符串的首地址(buf的地址)
|
|
|
separator 指定的分割字符
|
|
|
dest 接收子字符串的数组
|
|
|
num 分割后子字符串的个数
|
|
|
*/
|
|
|
char* pNext;
|
|
|
int count = 0;
|
|
|
if (src == NULL || strlen(src) == 0) //如果传入的地址为空或长度为0,直接终止
|
|
|
return;
|
|
|
if (separator == NULL || strlen(separator) == 0) //如未指定分割的字符串,直接终止
|
|
|
return;
|
|
|
pNext = (char*)strtok(src, separator); //必须使用(char *)进行强制类型转换(虽然不写有的编译器中不会出现指针错误)
|
|
|
while (pNext != NULL) {
|
|
|
*dest++ = pNext;
|
|
|
++count;
|
|
|
pNext = (char*)strtok(NULL, separator); //必须使用(char *)进行强制类型转换
|
|
|
}
|
|
|
*num = count;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
*传入数据集,就下载数据集,调用JAVA程序插入图片(pdf)
|
|
|
*
|
|
|
*/
|
|
|
int insert_pdf(tag_t dataset, char *ext,char *second_tag_type, tag_t rootTask_tag)
|
|
|
{
|
|
|
int ifail = ITK_ok;
|
|
|
printf("insert_pdf \r\n");
|
|
|
tag_t spec_dataset_rev = NULLTAG,
|
|
|
ref_object = NULLTAG;
|
|
|
|
|
|
AE_reference_type_t reference_type;
|
|
|
ITKCALL(ifail = AE_ask_dataset_latest_rev(dataset, &spec_dataset_rev));
|
|
|
|
|
|
char ref_name[WSO_name_size_c + 1] = "";
|
|
|
if (strcmp(second_tag_type, "PDF") == 0) {
|
|
|
strcpy(ref_name,"PDF_Reference");
|
|
|
ITKCALL(ifail = AE_ask_dataset_named_ref(spec_dataset_rev, ref_name, &reference_type, &ref_object));
|
|
|
}
|
|
|
else {
|
|
|
strcpy(ref_name, "CAEAnalysisData");
|
|
|
ITKCALL(ifail = AE_ask_dataset_named_ref(spec_dataset_rev, ref_name, &reference_type, &ref_object));
|
|
|
|
|
|
}
|
|
|
|
|
|
if (reference_type == AE_PART_OF)
|
|
|
{
|
|
|
char pathname[SS_MAXPATHLEN] = "";
|
|
|
//返回磁盘上与给定TcFile关联的物理文件的完整路径名。路径名的格式将取决于机器类型的值
|
|
|
ITKCALL(ifail = IMF_ask_file_pathname(ref_object, SS_WNT_MACHINE, pathname));
|
|
|
char origin_file_name[IMF_filename_size_c + 1] = "";
|
|
|
ITKCALL(ifail = IMF_ask_original_file_name(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 *new_file_name = USER_new_file_name(new_ds_name, ref_name, "pdf", 0);
|
|
|
char *temp_dir = getenv("temp"); //C:\Windows\temp
|
|
|
char * tc_root_dir = getenv("tc_root"); //C:\Siemens\Teamcenter11
|
|
|
char img_file[SS_MAXPATHLEN] = "";
|
|
|
char temp_file[SS_MAXPATHLEN] = "";
|
|
|
char temp_file2[SS_MAXPATHLEN] = "";
|
|
|
char jar_file[SS_MAXPATHLEN] = "";
|
|
|
//-----------------------------
|
|
|
strcpy(temp_file, temp_dir);
|
|
|
strcat(temp_file, "\\");
|
|
|
strcat(temp_file, new_file_name); //C:\Windows\temp\\new_ds_name.pdf 输入路径
|
|
|
//printf("输入的pdf路径名字: %s\n",temp_file);
|
|
|
//--------------------------
|
|
|
strcpy(temp_file2, temp_dir);
|
|
|
strcat(temp_file2, "\\");
|
|
|
strcat(temp_file2, new_file_name);
|
|
|
strcat(temp_file2, ".pdf"); //C:\Windows\temp\\new_ds_name.pdf.pdf 输出路径
|
|
|
//printf("输出的pdf路径名字: %s\n", temp_file);
|
|
|
//-----------------------------4
|
|
|
strcpy(img_file, tc_root_dir);
|
|
|
//strcat(img_file, "\\bin\\");
|
|
|
strcat(img_file, "\\");
|
|
|
strcat(img_file, "sign.jpg"); //C:\Siemens\Teamcenter11\\bin
|
|
|
//-----------------------------
|
|
|
strcpy(jar_file, tc_root_dir);
|
|
|
strcat(jar_file, "\\bin\\");
|
|
|
strcat(jar_file, "insert_pdf.jar");
|
|
|
|
|
|
//将TcFile放入操作系统中的输入路径名。路径名可以相对于当前工作目录。(file_tag,pathname)
|
|
|
ITKCALL(ifail = IMF_export_file(ref_object, temp_file));
|
|
|
ITKCALL(ifail = IMF_export_file(ref_object, temp_file2));
|
|
|
int iCnt;
|
|
|
char *user_lib_env, pTempStr[500];
|
|
|
char local_path[MAX_PATH] = "";
|
|
|
char cmd[256] = "";
|
|
|
strcpy(cmd, "java -jar \"");
|
|
|
strcat(cmd, jar_file);
|
|
|
strcat(cmd, "\" \"");
|
|
|
strcat(cmd, temp_file2);
|
|
|
strcat(cmd, "\" \"");
|
|
|
strcat(cmd, temp_file);
|
|
|
strcat(cmd, "\"");
|
|
|
printf("\n%s\n", cmd);
|
|
|
system(cmd);
|
|
|
|
|
|
tag_t new_file_tag = NULLTAG;
|
|
|
IMF_file_t file_descriptor;
|
|
|
|
|
|
ITKCALL(ifail = IMF_import_file(temp_file, new_file_name, SS_BINARY, &new_file_tag, &file_descriptor));
|
|
|
AOM_lock(new_file_tag);
|
|
|
ITKCALL(ifail = IMF_set_original_file_name(new_file_tag, origin_file_name));
|
|
|
ITKCALL(ifail = IMF_close_file(file_descriptor));
|
|
|
ITKCALL(ifail = AOM_save(new_file_tag));
|
|
|
AOM_unlock(new_file_tag);
|
|
|
AOM_refresh(new_file_tag,TRUE);
|
|
|
AOM_lock(spec_dataset_rev);
|
|
|
AE_remove_dataset_named_ref_by_tag(spec_dataset_rev, ref_name, ref_object);
|
|
|
AE_add_dataset_named_ref(spec_dataset_rev, ref_name, AE_PART_OF, new_file_tag);
|
|
|
AOM_save(spec_dataset_rev);
|
|
|
AOM_unlock(spec_dataset_rev);
|
|
|
AOM_refresh(spec_dataset_rev,TRUE);
|
|
|
}
|
|
|
|
|
|
return ITK_ok;
|
|
|
}
|
|
|
/**
|
|
|
给word添加水印
|
|
|
*/
|
|
|
int insert_word(tag_t dataset, char* ext,char *type,tag_t rev,tag_t rootTask_tag,char* folder_name)
|
|
|
{
|
|
|
printf("word添加水印开始转换pdf开始 \r\n");
|
|
|
tag_t spec_dataset_rev = NULLTAG,
|
|
|
ref_object = NULLTAG,
|
|
|
ref_object2 = NULLTAG;
|
|
|
char* object_name = NULL;
|
|
|
AE_reference_type_t reference_type;
|
|
|
AE_reference_type_t reference_type2;
|
|
|
//ITKCALL(AE_ask_dataset_latest_rev(dataset, &spec_dataset_rev));
|
|
|
AE_ask_dataset_latest_rev(dataset, &spec_dataset_rev);
|
|
|
char ref_name[WSO_name_size_c + 1] = "word";
|
|
|
char ref_name2[WSO_name_size_c + 1] = "PDF_Reference";
|
|
|
//ITKCALL(AE_ask_dataset_named_ref(spec_dataset_rev, ref_name, &reference_type, &ref_object));
|
|
|
AE_ask_dataset_named_ref(spec_dataset_rev, ref_name, &reference_type, &ref_object);
|
|
|
|
|
|
AOM_ask_value_string(dataset,"object_name",&object_name); //原来word数据集的object_name
|
|
|
printf("word的原来名称为:%s",object_name);
|
|
|
//如果存在名字相同的pdf,不继续执行
|
|
|
tag_t relation_type , *second_tags;
|
|
|
int second_tags_count = 0;
|
|
|
char *other_name = NULL,*other_type = NULL ,self_name[WSO_name_size_c + 1] = "",self_new_name[WSO_name_size_c + 1] = "";//去掉后缀之后的word名称
|
|
|
int self_num = 0;
|
|
|
char* revbuf_test[8] = { }; //存放分割后的子字符串
|
|
|
strcpy(self_name,object_name);
|
|
|
|
|
|
printf("word的原来名称为:%s\n",self_name);
|
|
|
if(strstr(self_name,".") > 0){
|
|
|
split_img(self_name,".", revbuf_test, &self_num);
|
|
|
for(int i=0;i<self_num;i++){
|
|
|
strcat(self_new_name,revbuf_test[i]);
|
|
|
}
|
|
|
}
|
|
|
else{
|
|
|
strcat(self_new_name,self_name);
|
|
|
}
|
|
|
printf("word的名称为:%s\n",self_new_name);
|
|
|
boolean if_continue = false;
|
|
|
//word在伪文件夹
|
|
|
if(strlen(folder_name)==0){
|
|
|
GRM_find_relation_type(folder_name, &relation_type);
|
|
|
|
|
|
}
|
|
|
//word在版本下面
|
|
|
else{
|
|
|
GRM_find_relation_type(TC_specification_rtype, &relation_type);
|
|
|
}
|
|
|
GRM_list_secondary_objects_only(rev, relation_type, &second_tags_count, &second_tags);
|
|
|
printf("数据集的数量 %d\n",second_tags_count);
|
|
|
for (int i = 0; i < second_tags_count; i++)
|
|
|
{
|
|
|
AOM_ask_value_string(second_tags[i],"object_name",&other_name);
|
|
|
AOM_ask_value_string(second_tags[i],"object_type",&other_type);
|
|
|
printf("名称为:%s, 类型为:%s\n",other_name,other_type);
|
|
|
if(strstr(other_type,"PDF") != NULL && strstr(other_name,self_new_name) != NULL){
|
|
|
printf("三个数据分别为:名称,类型,word名称 %s,%s,%s\n",other_name,other_type,self_new_name);
|
|
|
if_continue = true;
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
//释放内存
|
|
|
MEM_free(other_name);
|
|
|
other_name = NULL;
|
|
|
MEM_free(other_type);
|
|
|
other_type = NULL;
|
|
|
//MEM_free(second_tags);
|
|
|
//second_tags = NULL;
|
|
|
if(if_continue){
|
|
|
printf("不继续\n");
|
|
|
return ITK_ok;
|
|
|
}
|
|
|
|
|
|
if (reference_type == AE_PART_OF)
|
|
|
{
|
|
|
char pathname[SS_MAXPATHLEN] = "";
|
|
|
//返回磁盘上与给定TcFile关联的物理文件的完整路径名。路径名的格式将取决于机器类型的值
|
|
|
IMF_ask_file_pathname(ref_object, SS_WNT_MACHINE, pathname);
|
|
|
char origin_file_name[IMF_filename_size_c + 1] = "";
|
|
|
IMF_ask_original_file_name(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 *new_file_name = USER_new_file_name(new_ds_name, ref_name, "pdf", 0);
|
|
|
char* temp_dir = getenv("temp"); //C:\Windows\temp
|
|
|
char* tc_root_dir = getenv("tc_root"); //C:\Siemens\Teamcenter11
|
|
|
char img_file[SS_MAXPATHLEN] = "";
|
|
|
char temp_file[SS_MAXPATHLEN] = "";
|
|
|
char temp_file2[SS_MAXPATHLEN] = "";
|
|
|
char temp_file3[SS_MAXPATHLEN] = ""; //pdf添加水印之后生成的文件的路径
|
|
|
char jar_file[SS_MAXPATHLEN] = ""; //水印jar包的路径
|
|
|
char jar_file2[SS_MAXPATHLEN] = ""; //转换成pdf jar包的路径
|
|
|
//-----------------------------
|
|
|
char new_file_name2[WSO_name_size_c + 1] = "";
|
|
|
strcpy(new_file_name2, new_file_name);
|
|
|
strcat(new_file_name2, ".pdf"); //new_file_name.pdf 转换成pdf文件的名字
|
|
|
|
|
|
char new_file_name3[WSO_name_size_c + 1] = "";
|
|
|
strcpy(new_file_name3, new_file_name);
|
|
|
strcat(new_file_name3, "new.pdf"); //new_file_namenew.pdf 添加水印后pdf文件的名字
|
|
|
|
|
|
|
|
|
strcpy(temp_file, temp_dir);
|
|
|
strcat(temp_file, "\\");
|
|
|
strcat(temp_file, new_file_name); //C:\Windows\temp\\new_ds_name.doc||docx 输入路径
|
|
|
strcat(temp_file,type); //printf("输入的pdf路径名字: %s\n",temp_file);
|
|
|
|
|
|
strcpy(temp_file2, temp_dir);
|
|
|
strcat(temp_file2, "\\");
|
|
|
strcat(temp_file2, new_file_name2); //C:\Windows\temp\\new_ds_name.pdf 输出路径
|
|
|
|
|
|
|
|
|
strcpy(temp_file3, temp_dir);
|
|
|
strcat(temp_file3, "\\");
|
|
|
strcat(temp_file3, new_file_name3);
|
|
|
|
|
|
strcpy(img_file, tc_root_dir);
|
|
|
//strcat(img_file, "\\bin\\");
|
|
|
strcat(img_file, "\\");
|
|
|
strcat(img_file, "sign.jpg"); //C:\Siemens\Teamcenter11\\bin
|
|
|
|
|
|
strcpy(jar_file, tc_root_dir);
|
|
|
strcat(jar_file, "\\bin\\");
|
|
|
strcat(jar_file, "insert_pdf.jar");
|
|
|
|
|
|
strcpy(jar_file2, tc_root_dir);
|
|
|
strcat(jar_file2, "\\bin\\");
|
|
|
strcat(jar_file2, "change.jar");
|
|
|
|
|
|
//将TcFile放入操作系统中的输入路径名。路径名可以相对于当前工作目录。(file_tag,pathname)
|
|
|
IMF_export_file(ref_object, temp_file);
|
|
|
int iCnt;
|
|
|
char* user_lib_env, pTempStr[500];
|
|
|
char local_path[MAX_PATH] = "";
|
|
|
char cmd[256] = "";
|
|
|
char cmd2[256] ="";
|
|
|
strcpy(cmd, "java -jar \"");
|
|
|
strcat(cmd, jar_file2);
|
|
|
strcat(cmd, "\" \"");
|
|
|
strcat(cmd, temp_file);
|
|
|
strcat(cmd, "\" \"");
|
|
|
strcat(cmd, temp_file2);
|
|
|
strcat(cmd, "\""); //cmd = Java -jar input(\) output(\) 转换pdf的cmd
|
|
|
printf("\n%s\n", cmd);
|
|
|
|
|
|
strcpy(cmd2, "java -jar \"");
|
|
|
strcat(cmd2, jar_file);
|
|
|
strcat(cmd2, "\" \"");
|
|
|
strcat(cmd2, temp_file2);
|
|
|
strcat(cmd2, "\" \"");
|
|
|
strcat(cmd2, temp_file3);
|
|
|
strcat(cmd2, "\"");
|
|
|
printf("\n%s\n", cmd2); //添加水印的cmd
|
|
|
|
|
|
//把work转换成pdf //pdf路径在temp_file3
|
|
|
system(cmd);
|
|
|
|
|
|
int num = 0, tc_num = 0;
|
|
|
char* revbuf[8] = { }; //存放分割后的子字符串
|
|
|
char* revbuf2[8] = { };
|
|
|
split_img(origin_file_name, ".", revbuf2, &num); //调用函数进行分割 得到名字和后缀名
|
|
|
|
|
|
char realName[256] = "";
|
|
|
char realName2[256] = "";
|
|
|
if(strstr(object_name,".") > 0){
|
|
|
split_img(object_name, ".", revbuf, &tc_num);
|
|
|
for(int m=0;m<tc_num-1;m++){
|
|
|
strcat(realName,revbuf[m]);
|
|
|
if(m<tc_num-1){
|
|
|
strcat(realName,".");
|
|
|
}
|
|
|
}
|
|
|
strcat(realName,"pdf");
|
|
|
}
|
|
|
else{
|
|
|
strcat(realName,object_name);
|
|
|
strcat(realName,".pdf");
|
|
|
}
|
|
|
|
|
|
|
|
|
for(int m=0;m<num-1;m++){
|
|
|
strcat(realName2,revbuf2[m]);
|
|
|
if(m<num-1){
|
|
|
strcat(realName2,".");
|
|
|
}
|
|
|
}
|
|
|
strcat(realName2,"pdf");
|
|
|
|
|
|
//新建pdf数据集
|
|
|
tag_t item=NULLTAG;
|
|
|
ITEM_ask_item_of_rev(rev,&item);
|
|
|
const char name[AE_datasettype_name_size_c + 1] = "PDF";
|
|
|
//cout << name << endl;
|
|
|
tag_t datasetType = NULLTAG,tool = NULLTAG;
|
|
|
tag_t newDatasetTag = NULLTAG; //新数据集的tag
|
|
|
tag_t relation = NULLTAG;
|
|
|
AE_find_datasettype(name, &datasetType);
|
|
|
|
|
|
AE_ask_datasettype_def_tool(datasetType,&tool);
|
|
|
|
|
|
AE_create_dataset(datasetType, realName,"", &newDatasetTag);
|
|
|
|
|
|
AOM_lock(newDatasetTag);
|
|
|
AE_set_dataset_tool(newDatasetTag,tool);
|
|
|
|
|
|
AE_set_dataset_format(newDatasetTag, name);
|
|
|
|
|
|
|
|
|
AOM_save(newDatasetTag);
|
|
|
AOM_unlock(newDatasetTag);
|
|
|
AOM_refresh(newDatasetTag,TRUE);
|
|
|
tag_t relation_type3=NULLTAG;
|
|
|
if(strlen(folder_name)==0){
|
|
|
ITEM_attach_rev_object(rev, newDatasetTag, ITEM_specification_atth);
|
|
|
}
|
|
|
else{
|
|
|
GRM_find_relation_type(folder_name, &relation_type3);
|
|
|
|
|
|
ITEM_attach_object_tag(rev, newDatasetTag, relation_type3);
|
|
|
}
|
|
|
|
|
|
|
|
|
//给转换之后的pdf添加水印
|
|
|
system(cmd2);
|
|
|
|
|
|
tag_t new_file_tag = NULLTAG;
|
|
|
IMF_file_t file_descriptor;
|
|
|
IMF_import_file(temp_file3, new_file_name3, SS_BINARY, &new_file_tag, &file_descriptor);
|
|
|
AOM_lock(new_file_tag);
|
|
|
IMF_set_original_file_name(new_file_tag, realName2);
|
|
|
IMF_close_file(file_descriptor);
|
|
|
AOM_save(new_file_tag);
|
|
|
AOM_unlock(new_file_tag);
|
|
|
AOM_lock(newDatasetTag);
|
|
|
AE_add_dataset_named_ref(newDatasetTag, ref_name2, AE_PART_OF, new_file_tag);
|
|
|
|
|
|
AOM_save(newDatasetTag);
|
|
|
AOM_unlock(newDatasetTag);
|
|
|
AOM_refresh(newDatasetTag,0);
|
|
|
int attachment_types = EPM_target_attachment;
|
|
|
//AOM_unlock(rootTask_tag);
|
|
|
AOM_refresh(rootTask_tag, TRUE);
|
|
|
EPM_add_attachments(rootTask_tag, 1, &(newDatasetTag), &attachment_types);
|
|
|
AOM_save(rootTask_tag);
|
|
|
}
|
|
|
|
|
|
return ITK_ok;
|
|
|
}
|
|
|
/**
|
|
|
给excel添加水印
|
|
|
*/
|
|
|
int insert_excel2(tag_t dataset, char* ext,char* type ,tag_t rev)
|
|
|
{
|
|
|
printf("excel添加水印开始 \r\n");
|
|
|
int ifail = ITK_ok;
|
|
|
tag_t spec_dataset_rev = NULLTAG,
|
|
|
ref_object = NULLTAG;
|
|
|
AE_reference_type_t reference_type;
|
|
|
|
|
|
ITKCALL(ifail = AE_ask_dataset_latest_rev(dataset, &spec_dataset_rev));
|
|
|
char ref_name[WSO_name_size_c + 1] = "excel";
|
|
|
AE_ask_dataset_named_ref(spec_dataset_rev, ref_name, &reference_type, &ref_object);
|
|
|
if (reference_type == AE_PART_OF)
|
|
|
{
|
|
|
char pathname[SS_MAXPATHLEN] = "";
|
|
|
//返回磁盘上与给定TcFile关联的物理文件的完整路径名。路径名的格式将取决于机器类型的值
|
|
|
ITKCALL(ifail = IMF_ask_file_pathname(ref_object, SS_WNT_MACHINE, pathname));
|
|
|
char origin_file_name[IMF_filename_size_c + 1] = "";
|
|
|
ITKCALL(ifail = IMF_ask_original_file_name(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 *new_file_name = USER_new_file_name(new_ds_name, ref_name, "pdf", 0);
|
|
|
char* temp_dir = getenv("temp"); //C:\Windows\temp
|
|
|
char* tc_root_dir = getenv("tc_root"); //C:\Siemens\Teamcenter11
|
|
|
char img_file[SS_MAXPATHLEN] = "";
|
|
|
char temp_file[SS_MAXPATHLEN] = "";
|
|
|
char temp_file2[SS_MAXPATHLEN] = "";
|
|
|
char jar_file[SS_MAXPATHLEN] = "";
|
|
|
//-----------------------------
|
|
|
|
|
|
strcpy(temp_file, temp_dir);
|
|
|
strcat(temp_file, "\\");
|
|
|
strcat(temp_file, new_file_name); //C:\Windows\temp\\new_ds_name.pdf 输入路径
|
|
|
//printf("输入的pdf路径名字: %s\n",temp_file);
|
|
|
//--------------------------
|
|
|
strcpy(temp_file2, temp_dir);
|
|
|
strcat(temp_file2, "\\");
|
|
|
strcat(temp_file2, new_file_name);
|
|
|
strcat(temp_file2, type); //printf("输出的pdf路径名字: %s\n", temp_file);
|
|
|
//-----------------------------4
|
|
|
strcpy(img_file, tc_root_dir);
|
|
|
strcat(img_file, "\\");
|
|
|
strcat(img_file, "sign.jpg"); //C:\Siemens\Teamcenter11\\bin
|
|
|
//-----------------------------
|
|
|
strcpy(jar_file, tc_root_dir);
|
|
|
strcat(jar_file, "\\bin\\");
|
|
|
strcat(jar_file, "insert_pdf.jar");
|
|
|
|
|
|
//将TcFile放入操作系统中的输入路径名。路径名可以相对于当前工作目录。(file_tag,pathname)
|
|
|
ITKCALL(ifail = IMF_export_file(ref_object, temp_file));
|
|
|
ITKCALL(ifail = IMF_export_file(ref_object, temp_file2));
|
|
|
int iCnt;
|
|
|
char* user_lib_env, pTempStr[500];
|
|
|
char local_path[MAX_PATH] = "";
|
|
|
char cmd[256] = "";
|
|
|
strcpy(cmd, "java -jar \"");
|
|
|
strcat(cmd, jar_file);
|
|
|
strcat(cmd, "\" \"");
|
|
|
strcat(cmd, temp_file2);
|
|
|
strcat(cmd, "\" \"");
|
|
|
strcat(cmd, temp_file);
|
|
|
|
|
|
strcat(cmd, "\"");
|
|
|
printf("\n%s\n", cmd);
|
|
|
system(cmd);
|
|
|
|
|
|
tag_t new_file_tag = NULLTAG;
|
|
|
IMF_file_t file_descriptor;
|
|
|
|
|
|
ITKCALL(ifail = IMF_import_file(temp_file, new_file_name, SS_BINARY, &new_file_tag, &file_descriptor));
|
|
|
ITKCALL(ifail = IMF_set_original_file_name(new_file_tag, origin_file_name));
|
|
|
ITKCALL(ifail = IMF_close_file(file_descriptor));
|
|
|
ITKCALL(ifail = AOM_save(new_file_tag));
|
|
|
AOM_unlock(new_file_tag);
|
|
|
ITKCALL(ifail = AOM_lock(spec_dataset_rev));
|
|
|
ITKCALL(ifail = AE_remove_dataset_named_ref_by_tag(spec_dataset_rev, ref_name, ref_object));
|
|
|
ITKCALL(ifail = AE_add_dataset_named_ref(spec_dataset_rev, ref_name, AE_PART_OF, new_file_tag));
|
|
|
ITKCALL(ifail = AOM_save(spec_dataset_rev));
|
|
|
AOM_unlock(spec_dataset_rev);
|
|
|
|
|
|
}
|
|
|
|
|
|
return ifail;
|
|
|
}
|
|
|
/**
|
|
|
把excel转换成pdf之后添加水印
|
|
|
*/
|
|
|
int insert_excel(tag_t dataset, char* ext, char* type, tag_t rev, tag_t rootTask_tag,char* folder_name){
|
|
|
printf("excel添加水印开始转换pdf开始 \r\n");
|
|
|
int ifail = ITK_ok;
|
|
|
tag_t spec_dataset_rev = NULLTAG,
|
|
|
ref_object = NULLTAG;
|
|
|
|
|
|
char* object_name = NULL;
|
|
|
AE_reference_type_t reference_type;
|
|
|
ITKCALL(ifail = AE_ask_dataset_latest_rev(dataset, &spec_dataset_rev));
|
|
|
char ref_name[WSO_name_size_c + 1] = "excel";
|
|
|
char ref_name2[WSO_name_size_c + 1] = "PDF_Reference";
|
|
|
//ITKCALL(AE_ask_dataset_named_ref(spec_dataset_rev, ref_name, &reference_type, &ref_object));
|
|
|
ITKCALL(ifail = AE_ask_dataset_named_ref(spec_dataset_rev, ref_name, &reference_type, &ref_object));
|
|
|
|
|
|
ITKCALL(ifail = AOM_ask_value_string(dataset, "object_name", &object_name)); //原来excel数据集的object_name
|
|
|
printf("word的原来名称为:%s",object_name);
|
|
|
//如果存在名字相同的pdf,不继续执行
|
|
|
tag_t relation_type , *second_tags;
|
|
|
int second_tags_count = 0;
|
|
|
char *other_name = NULL,*other_type = NULL ,self_name[WSO_name_size_c + 1] = "",self_new_name[WSO_name_size_c + 1] = "";//去掉后缀之后的word名称
|
|
|
int self_num = 0;
|
|
|
char* revbuf_test[8] = { }; //存放分割后的子字符串
|
|
|
strcpy(self_name,object_name);
|
|
|
|
|
|
printf("word的原来名称为:%s\n",self_name);
|
|
|
if(strstr(self_name,".") > 0){
|
|
|
split_img(self_name,".", revbuf_test, &self_num);
|
|
|
for(int i=0;i<self_num;i++){
|
|
|
strcat(self_new_name,revbuf_test[i]);
|
|
|
}
|
|
|
}
|
|
|
else{
|
|
|
strcat(self_new_name,self_name);
|
|
|
}
|
|
|
printf("word的名称为:%s\n",self_new_name);
|
|
|
boolean if_continue = false;
|
|
|
//word在伪文件夹
|
|
|
if(strlen(folder_name)==0){
|
|
|
ITKCALL(ifail = GRM_find_relation_type(folder_name, &relation_type));
|
|
|
|
|
|
}
|
|
|
//word在版本下面
|
|
|
else{
|
|
|
ITKCALL(ifail = GRM_find_relation_type(TC_specification_rtype, &relation_type));
|
|
|
}
|
|
|
ITKCALL(ifail = GRM_list_secondary_objects_only(rev, relation_type, &second_tags_count, &second_tags));
|
|
|
printf("数据集的数量 %d\n",second_tags_count);
|
|
|
for (int i = 0; i < second_tags_count; i++)
|
|
|
{
|
|
|
ITKCALL(ifail = AOM_ask_value_string(second_tags[i],"object_name",&other_name));
|
|
|
ITKCALL(ifail = AOM_ask_value_string(second_tags[i],"object_type",&other_type));
|
|
|
printf("名称为:%s, 类型为:%s\n",other_name,other_type);
|
|
|
if(strstr(other_type,"PDF") != NULL && strstr(other_name,self_new_name) != NULL){
|
|
|
printf("三个数据分别为:名称,类型,excel名称 %s,%s,%s\n",other_name,other_type,self_new_name);
|
|
|
if_continue = true;
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
//释放内存
|
|
|
MEM_free(other_name);
|
|
|
other_name = NULL;
|
|
|
MEM_free(other_type);
|
|
|
other_type = NULL;
|
|
|
//MEM_free(second_tags);
|
|
|
//second_tags = NULL;
|
|
|
if(if_continue){
|
|
|
printf("不继续\n");
|
|
|
return ITK_ok;
|
|
|
}
|
|
|
|
|
|
if (reference_type == AE_PART_OF)
|
|
|
{
|
|
|
char pathname[SS_MAXPATHLEN] = "";
|
|
|
//返回磁盘上与给定TcFile关联的物理文件的完整路径名。路径名的格式将取决于机器类型的值
|
|
|
ITKCALL(ifail = IMF_ask_file_pathname(ref_object, SS_WNT_MACHINE, pathname));
|
|
|
char origin_file_name[IMF_filename_size_c + 1] = "";
|
|
|
//ITKCALL(IMF_ask_original_file_name(ref_object, origin_file_name));
|
|
|
ITKCALL(ifail = IMF_ask_original_file_name(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 *new_file_name = USER_new_file_name(new_ds_name, ref_name, "pdf", 0);
|
|
|
char* temp_dir = getenv("temp"); //C:\Windows\temp
|
|
|
char* tc_root_dir = getenv("tc_root"); //C:\Siemens\Teamcenter11
|
|
|
char img_file[SS_MAXPATHLEN] = "";
|
|
|
char temp_file[SS_MAXPATHLEN] = "";
|
|
|
char temp_file2[SS_MAXPATHLEN] = "";
|
|
|
char temp_file3[SS_MAXPATHLEN] = ""; //pdf添加水印之后生成的文件的路径
|
|
|
char jar_file[SS_MAXPATHLEN] = ""; //水印jar包的路径
|
|
|
char jar_file2[SS_MAXPATHLEN] = ""; //转换成pdf jar包的路径
|
|
|
//-----------------------------
|
|
|
char new_file_name2[WSO_name_size_c + 1] = "";
|
|
|
strcpy(new_file_name2, new_file_name);
|
|
|
strcat(new_file_name2, ".pdf"); //new_file_name.pdf 转换成pdf文件的名字
|
|
|
|
|
|
char new_file_name3[WSO_name_size_c + 1] = "";
|
|
|
strcpy(new_file_name3, new_file_name);
|
|
|
strcat(new_file_name3, "new.pdf"); //new_file_namenew.pdf 添加水印后pdf文件的名字
|
|
|
|
|
|
|
|
|
strcpy(temp_file, temp_dir);
|
|
|
strcat(temp_file, "\\");
|
|
|
strcat(temp_file, new_file_name); //C:\Windows\temp\\new_ds_name.doc||docx 输入路径
|
|
|
strcat(temp_file, type); //printf("输入的pdf路径名字: %s\n",temp_file);
|
|
|
|
|
|
strcpy(temp_file2, temp_dir);
|
|
|
strcat(temp_file2, "\\");
|
|
|
strcat(temp_file2, new_file_name2); //C:\Windows\temp\\new_ds_name.pdf 输出路径
|
|
|
|
|
|
|
|
|
strcpy(temp_file3, temp_dir);
|
|
|
strcat(temp_file3, "\\");
|
|
|
strcat(temp_file3, new_file_name3);
|
|
|
|
|
|
strcpy(img_file, tc_root_dir);
|
|
|
strcat(img_file, "\\");
|
|
|
strcat(img_file, "sign.jpg"); //C:\Siemens\Teamcenter11\\bin
|
|
|
|
|
|
strcpy(jar_file, tc_root_dir);
|
|
|
strcat(jar_file, "\\bin\\");
|
|
|
strcat(jar_file, "insert_pdf.jar");
|
|
|
|
|
|
strcpy(jar_file2, tc_root_dir);
|
|
|
strcat(jar_file2, "\\bin\\");
|
|
|
strcat(jar_file2, "change.jar");
|
|
|
|
|
|
//将TcFile放入操作系统中的输入路径名。路径名可以相对于当前工作目录。(file_tag,pathname)
|
|
|
ITKCALL(ifail = IMF_export_file(ref_object, temp_file));
|
|
|
int iCnt;
|
|
|
char* user_lib_env, pTempStr[500];
|
|
|
char local_path[MAX_PATH] = "";
|
|
|
char cmd[256] = "";
|
|
|
char cmd2[256] = "";
|
|
|
strcpy(cmd, "java -jar \"");
|
|
|
strcat(cmd, jar_file2);
|
|
|
strcat(cmd, "\" \"");
|
|
|
strcat(cmd, temp_file);
|
|
|
strcat(cmd, "\" \"");
|
|
|
strcat(cmd, temp_file2);
|
|
|
strcat(cmd, "\""); //cmd = Java -jar input(\) output(\) 转换pdf的cmd
|
|
|
printf("\n%s\n", cmd);
|
|
|
|
|
|
strcpy(cmd2, "java -jar \"");
|
|
|
strcat(cmd2, jar_file);
|
|
|
strcat(cmd2, "\" \"");
|
|
|
strcat(cmd2, temp_file2);
|
|
|
strcat(cmd2, "\" \"");
|
|
|
strcat(cmd2, temp_file3);
|
|
|
//strcat(cmd2, "\" \"");
|
|
|
//strcat(cmd2, img_file);
|
|
|
strcat(cmd2, "\"");
|
|
|
printf("\n%s\n", cmd2); //添加水印的cmd
|
|
|
|
|
|
//把work转换成pdf //pdf路径在temp_file3
|
|
|
system(cmd);
|
|
|
|
|
|
|
|
|
//得到pdf的下载名字,得到tc中转换的pdf的名字
|
|
|
int num = 0, tc_num = 0;
|
|
|
char* revbuf[8] = { }; //存放分割后的子字符串
|
|
|
char* revbuf2[8] = { };
|
|
|
split_img(origin_file_name, ".", revbuf2, &num); //调用函数进行分割 得到名字和后缀名
|
|
|
|
|
|
char realName[256] = "";
|
|
|
char realName2[256] = "";
|
|
|
if(strstr(object_name,".") > 0){
|
|
|
split_img(object_name, ".", revbuf, &tc_num);
|
|
|
for(int m=0;m<tc_num-1;m++){
|
|
|
strcat(realName,revbuf[m]);
|
|
|
if(m<tc_num-1){
|
|
|
strcat(realName,".");
|
|
|
}
|
|
|
}
|
|
|
strcat(realName,"pdf");
|
|
|
}
|
|
|
else{
|
|
|
strcat(realName,object_name);
|
|
|
strcat(realName,".pdf");
|
|
|
}
|
|
|
|
|
|
|
|
|
for(int m=0;m<num-1;m++){
|
|
|
strcat(realName2,revbuf2[m]);
|
|
|
if(m<num-1){
|
|
|
strcat(realName2,".");
|
|
|
}
|
|
|
}
|
|
|
strcat(realName2,"pdf");
|
|
|
|
|
|
//新建pdf数据集
|
|
|
tag_t item = NULLTAG;
|
|
|
ITKCALL(ifail = ITEM_ask_item_of_rev(rev, &item));
|
|
|
const char name[AE_datasettype_name_size_c + 1] = "PDF";
|
|
|
//cout << name << endl;
|
|
|
tag_t datasetType = NULLTAG, tool = NULLTAG;
|
|
|
tag_t newDatasetTag = NULLTAG; //新数据集的tag
|
|
|
tag_t relation = NULLTAG;
|
|
|
ITKCALL(ifail = AE_find_datasettype(name, &datasetType));
|
|
|
|
|
|
ITKCALL(ifail = AE_ask_datasettype_def_tool(datasetType, &tool));
|
|
|
|
|
|
ITKCALL(ifail = AE_create_dataset(datasetType, realName, "", &newDatasetTag));
|
|
|
ITKCALL(ifail = AOM_lock(newDatasetTag));
|
|
|
ITKCALL(ifail = AE_set_dataset_tool(newDatasetTag, tool));
|
|
|
|
|
|
ITKCALL(ifail = AE_set_dataset_format(newDatasetTag, name));
|
|
|
|
|
|
ITKCALL(ifail = AOM_save(newDatasetTag));
|
|
|
AOM_unlock(newDatasetTag);
|
|
|
ITKCALL(ifail = AOM_refresh(newDatasetTag,TRUE));
|
|
|
|
|
|
tag_t relation_type =NULLTAG;
|
|
|
if(strlen(folder_name)==0){
|
|
|
ITKCALL(ifail = ITEM_attach_rev_object(rev, newDatasetTag, ITEM_specification_atth));
|
|
|
}
|
|
|
else{
|
|
|
ITKCALL(ifail = GRM_find_relation_type(folder_name, &relation_type));
|
|
|
|
|
|
ITKCALL(ifail = ITEM_attach_object_tag(rev, newDatasetTag, relation_type));
|
|
|
}
|
|
|
|
|
|
//给转换之后的pdf添加水印
|
|
|
system(cmd2);
|
|
|
|
|
|
tag_t new_file_tag = NULLTAG;
|
|
|
IMF_file_t file_descriptor;
|
|
|
|
|
|
cout<<temp_file3<<endl;
|
|
|
cout<<new_file_name3<<endl;
|
|
|
ITKCALL(ifail = IMF_import_file(temp_file3, new_file_name3, SS_BINARY, &new_file_tag, &file_descriptor));
|
|
|
ITKCALL(ifail = AOM_lock(new_file_tag));
|
|
|
ITKCALL(ifail = IMF_set_original_file_name(new_file_tag, realName2));
|
|
|
ITKCALL(ifail = IMF_close_file(file_descriptor));
|
|
|
ITKCALL(ifail = AOM_save(new_file_tag));
|
|
|
AOM_unlock(new_file_tag);
|
|
|
ITKCALL(ifail = AOM_refresh(new_file_tag,TRUE));
|
|
|
ITKCALL(ifail = AOM_lock(newDatasetTag));
|
|
|
ITKCALL(ifail = AE_add_dataset_named_ref(newDatasetTag, ref_name2, AE_PART_OF, new_file_tag));
|
|
|
ITKCALL(ifail = AOM_save(newDatasetTag));
|
|
|
AOM_unlock(newDatasetTag);
|
|
|
ITKCALL(ifail = AOM_refresh(newDatasetTag,TRUE));
|
|
|
int attachment_types = EPM_target_attachment;
|
|
|
ITKCALL(ifail = AOM_refresh(rootTask_tag, TRUE));
|
|
|
ITKCALL(ifail = EPM_add_attachments(rootTask_tag, 1, &(newDatasetTag), &attachment_types));
|
|
|
ITKCALL(ifail = AOM_save(rootTask_tag));
|
|
|
//free(new_file_name);
|
|
|
//free(temp_dir);
|
|
|
}
|
|
|
|
|
|
return ifail;
|
|
|
|
|
|
}
|
|
|
|
|
|
//添加水印和转pdf添加水印
|
|
|
void changePdf(tag_t rev,tag_t rootTask_tag,tag_t second_tags,char* folder_name){
|
|
|
int ifail = ITK_ok;
|
|
|
char * second_tag_type = NULL;
|
|
|
ITKCALL(ifail = AOM_ask_value_string(second_tags, "object_type", &second_tag_type));
|
|
|
printf(" second_tag_type => %s \r\n", second_tag_type);// second_tag_type => MSWordX
|
|
|
if(second_tag_type == NULL){
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
if (strcmp(second_tag_type, "PDF") == 0 || strcmp(second_tag_type, "CAEAnalysisDS") == 0) {
|
|
|
insert_pdf(second_tags, "pdf",second_tag_type, rootTask_tag);
|
|
|
printf("%s\n", "pdf水印添加成功");
|
|
|
//setTarget2(rootTask_tag, tag_tags[m]);//将版本带入目标
|
|
|
}
|
|
|
else if (strcmp(second_tag_type, "MSWordX") == 0)
|
|
|
{
|
|
|
insert_word(second_tags, "word",".docx", rev, rootTask_tag,folder_name);
|
|
|
printf("word水印添加成功\n");
|
|
|
}
|
|
|
else if (strcmp(second_tag_type, "MSWord") == 0)
|
|
|
{
|
|
|
insert_word(second_tags, "word", ".doc", rev, rootTask_tag,folder_name);
|
|
|
printf("word水印添加成功\n");
|
|
|
}
|
|
|
else if (strcmp(second_tag_type, "MSExcelX") == 0 ) {
|
|
|
|
|
|
insert_excel(second_tags, "excel",".xlsx", rev, rootTask_tag,folder_name);
|
|
|
printf("excel水印添加成功\n");
|
|
|
}
|
|
|
else if (strcmp(second_tag_type, "MSExcel") == 0)
|
|
|
{
|
|
|
insert_excel(second_tags, "excel", ".xls", rev, rootTask_tag,folder_name);
|
|
|
printf("excel水印添加成功\n");
|
|
|
}
|
|
|
|
|
|
if (second_tag_type != NULL) {
|
|
|
MEM_free(second_tag_type);
|
|
|
second_tag_type = NULL;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
*在PDF中插入图片handler
|
|
|
*
|
|
|
*/
|
|
|
int jl_insert_img_pdf(EPM_action_message_t msg)
|
|
|
{
|
|
|
char* log_file = NULL;
|
|
|
char log_path[128] = "C:\\Temp\\jl_insert_img_pdf_LOG.txt";
|
|
|
CreateLogFile(log_path, &log_file);
|
|
|
|
|
|
//printf("%s\n","pdf插入图片开始");
|
|
|
WriteLog("》》》pdf插入图片开始");
|
|
|
//变量定义
|
|
|
POM_AM__set_application_bypass(true);
|
|
|
int ifail = ITK_ok, att_cnt = 0, i = 0;
|
|
|
tag_t task_tag = NULLTAG,
|
|
|
rootTask_tag = NULLTAG,
|
|
|
*attachments = NULL,
|
|
|
relation_type = NULLTAG,
|
|
|
relation_type1 = NULLTAG,
|
|
|
relation_type2 = NULLTAG,
|
|
|
relation_type3 = NULLTAG,
|
|
|
relation_type4 = NULLTAG,
|
|
|
relation_type5 = NULLTAG,
|
|
|
type_tag = NULLTAG;
|
|
|
char tgt_type[WSO_name_size_c + 1] = "",
|
|
|
type_class[TCTYPE_class_name_size_c + 1] = "",
|
|
|
rev_type[ITEM_type_size_c + 1] = "";
|
|
|
map<tag_t, string> rev_map;
|
|
|
//获取流程
|
|
|
task_tag = msg.task;
|
|
|
WriteLog("》》》开始获取根流程");
|
|
|
//获取根流程
|
|
|
ITKCALL(ifail = EPM_ask_root_task(task_tag, &rootTask_tag));
|
|
|
//获取流程目标对象
|
|
|
WriteLog("》》》开始遍历流程目标下的对象");
|
|
|
ITKCALL(ifail = EPM_ask_attachments(rootTask_tag, EPM_target_attachment, &att_cnt, &attachments));
|
|
|
for (i = 0; i < att_cnt; i++)
|
|
|
{
|
|
|
WriteLog("》》》获取对象类型");
|
|
|
ITKCALL(ifail = TCTYPE_ask_object_type(attachments[i], &type_tag));
|
|
|
ITKCALL(ifail = TCTYPE_ask_class_name(type_tag, type_class));
|
|
|
printf("type_class : %s \r\n", type_class);
|
|
|
|
|
|
//过滤掉非版本对象
|
|
|
WriteLog("》》》开始过滤掉非版本对象");
|
|
|
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))
|
|
|
{
|
|
|
printf("coming");
|
|
|
//将版本对象写入到缓存
|
|
|
WriteLog("》》》将过滤后的版本对象写入到缓存");
|
|
|
rev_map.insert(pair<tag_t, string>(attachments[i], ""));
|
|
|
}
|
|
|
}
|
|
|
|
|
|
WriteLog("》》》开始检索给定关系类型");
|
|
|
ITKCALL(ifail = GRM_find_relation_type(TC_attaches_rtype, &relation_type));
|
|
|
ITKCALL(ifail = GRM_find_relation_type(TC_specification_rtype, &relation_type1));
|
|
|
ITKCALL(ifail = GRM_find_relation_type("catia_auxiliaryLink", &relation_type2));
|
|
|
|
|
|
ITKCALL(ifail = GRM_find_relation_type("Gd6_CPYQ1", &relation_type3));
|
|
|
ITKCALL(ifail = GRM_find_relation_type("Gd6_KHSR", &relation_type4));
|
|
|
|
|
|
//开始遍历缓存中的版本对象
|
|
|
WriteLog("》》》开始遍历缓存中的版本对象");
|
|
|
map<tag_t, string>::iterator rev_it;
|
|
|
for (rev_it = rev_map.begin(); rev_it != rev_map.end(); rev_it++)
|
|
|
{
|
|
|
WriteLog("》》》遍历缓存中的版本对象beginning···\n");
|
|
|
//ITKCALL(ITEM_ask_rev_type(rev_it->first, rev_type));
|
|
|
ITEM_ask_rev_type(rev_it->first, rev_type);
|
|
|
tag_t * second_tagsAll = (tag_t *)MEM_alloc(sizeof(tag_t));
|
|
|
|
|
|
tag_t * second_tags = NULLTAG;
|
|
|
tag_t * second_tags1 = NULLTAG;
|
|
|
tag_t * second_tags2 = NULLTAG;
|
|
|
tag_t* second_tags3 = NULLTAG;
|
|
|
tag_t* second_tags4 = NULLTAG;
|
|
|
int second_tags_countAll = 0;
|
|
|
int second_tags_count = 0;
|
|
|
int second_tags_count1 = 0;
|
|
|
int second_tags_count2 = 0;
|
|
|
int second_tags_count3 = 0;
|
|
|
int second_tags_count4 = 0;
|
|
|
//添加数据集下载逻辑
|
|
|
ITKCALL(ifail = GRM_list_secondary_objects_only(rev_it->first, relation_type, &second_tags_count, &second_tags));
|
|
|
ITKCALL(ifail = GRM_list_secondary_objects_only(rev_it->first, relation_type1, &second_tags_count1, &second_tags1));
|
|
|
ITKCALL(ifail = GRM_list_secondary_objects_only(rev_it->first, relation_type2, &second_tags_count2, &second_tags2));
|
|
|
|
|
|
second_tags_countAll = second_tags_count + second_tags_count1 + second_tags_count2;
|
|
|
|
|
|
|
|
|
printf("%s\n", "111111111");
|
|
|
WriteLog("》》》开始添加数据到second_tagsAll \n");
|
|
|
for (int i = 0; i < second_tags_count; i++)
|
|
|
{
|
|
|
WriteLog("》》》second_tagsAll[i] = second_tagsAll[%d]",i);
|
|
|
second_tagsAll[i] = second_tags[i];
|
|
|
}
|
|
|
for (int i = 0; i < second_tags_count1; i++)
|
|
|
{
|
|
|
WriteLog("》》》second_tagsAll[i+second_tags_count] = second_tagsAll[%d]", i+second_tags_count);
|
|
|
second_tagsAll[i+second_tags_count] = second_tags1[i];
|
|
|
}
|
|
|
for (int i = 0; i < second_tags_count2; i++)
|
|
|
{
|
|
|
WriteLog("》》》second_tagsAll[i+second_tags_count+second_tags_count1] = second_tagsAll[%d]", i+second_tags_count+second_tags_count1);
|
|
|
second_tagsAll[i+second_tags_count+second_tags_count1] = second_tags2[i];
|
|
|
}
|
|
|
|
|
|
printf("%s\n", "111111111");
|
|
|
|
|
|
printf("second_tags_countAll的数量为:%d\n", second_tags_countAll);
|
|
|
WriteLog("》》》second_tags_countAll的数量为:%d\n", second_tags_countAll);
|
|
|
char * carModel = NULL;
|
|
|
ITKCALL(ifail = AOM_ask_value_string(rev_it->first, "item_id", &carModel));
|
|
|
printf("item_id=%s \n", carModel);
|
|
|
MEM_free(carModel);
|
|
|
for (i = 0; i < second_tags_countAll; i++) {
|
|
|
char * second_tag_type = NULL;
|
|
|
ITKCALL(ifail = AOM_ask_value_string(second_tagsAll[i], "object_type", &second_tag_type));
|
|
|
printf(" second_tag_type 类型 => %s \r\n", second_tag_type);// second_tag_type => MSWordX
|
|
|
WriteLog("》》》second_tag_type 类型 => %s \r\n", second_tag_type);
|
|
|
MEM_free(second_tag_type);
|
|
|
}
|
|
|
|
|
|
for (i = 0; i < second_tags_countAll; i++) {
|
|
|
if(second_tagsAll[i]!=0&&second_tagsAll[i]!=NULL){
|
|
|
changePdf(rev_it->first,rootTask_tag,second_tagsAll[i],"");
|
|
|
}
|
|
|
|
|
|
}
|
|
|
if(strcmp(rev_type,"Gd6_CPYQRevision")==0){
|
|
|
WriteLog("》》》类型rev_type==Gd6_CPYQRevision \n 产品要求开始》》》\n");
|
|
|
cout<<"产品要求开始"<<endl;
|
|
|
cout<< relation_type3 <<endl;
|
|
|
ITKCALL(ifail = GRM_list_secondary_objects_only(rev_it->first, relation_type3, &second_tags_count3, &second_tags3));
|
|
|
for (int i = 0; i < second_tags_count3; i++)
|
|
|
{
|
|
|
changePdf(rev_it->first,rootTask_tag,second_tags3[i],"Gd6_CPYQ1");
|
|
|
WriteLog("》》》Gd6_CPYQ1》》》\n");
|
|
|
}
|
|
|
WriteLog("》》》类型rev_type==Gd6_CPYQRevision \n 客户输入开始》》》\n");
|
|
|
cout<<"客户输入开始"<<endl;
|
|
|
cout<< relation_type4 <<endl;
|
|
|
ITKCALL(ifail = GRM_list_secondary_objects_only(rev_it->first, relation_type4, &second_tags_count4, &second_tags4));
|
|
|
|
|
|
for (int i = 0; i < second_tags_count4; i++)
|
|
|
{
|
|
|
WriteLog("》》》Gd6_KHSR》》》\n");
|
|
|
changePdf(rev_it->first,rootTask_tag,second_tags4[i],"Gd6_KHSR");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
printf("kkk\n");
|
|
|
WriteLog("》》》执行结束前释放对象\n");
|
|
|
if (second_tags) {
|
|
|
WriteLog("》》》释放second_tags\n");
|
|
|
MEM_free(second_tags);
|
|
|
second_tags = NULL;
|
|
|
}
|
|
|
if (second_tags1) {
|
|
|
WriteLog("》》》释放second_tags1\n");
|
|
|
MEM_free(second_tags1);
|
|
|
second_tags1 = NULL;
|
|
|
}
|
|
|
if (second_tags2) {
|
|
|
WriteLog("》》》释放second_tags2\n");
|
|
|
MEM_free(second_tags2);
|
|
|
second_tags2 = NULL;
|
|
|
}
|
|
|
if (second_tags3) {
|
|
|
WriteLog("》》》释放second_tags3\n");
|
|
|
MEM_free(second_tags3);
|
|
|
second_tags3 = NULL;
|
|
|
}
|
|
|
if (second_tags4) {
|
|
|
WriteLog("》》》释放second_tags4\n");
|
|
|
MEM_free(second_tags4);
|
|
|
second_tags4 = NULL;
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
printf("ksaskk\n");
|
|
|
if (attachments != NULL) {
|
|
|
WriteLog("》》》释放attachments\n");
|
|
|
MEM_free(attachments);
|
|
|
attachments = NULL;
|
|
|
}
|
|
|
POM_AM__set_application_bypass(false);
|
|
|
printf("水映结束\n");
|
|
|
WriteLog("》》》执行结束\n");
|
|
|
CloseLog();
|
|
|
return ifail;
|
|
|
}
|
|
|
|
|
|
|