|
|
#include "cn_util.h"
|
|
|
|
|
|
|
|
|
|
|
|
static void GTAC_free(void *what)
|
|
|
{
|
|
|
if (what != NULL)
|
|
|
{
|
|
|
MEM_free(what);
|
|
|
what = NULL;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
void Split( string strArg, string spliter, vector<string> &ans )
|
|
|
{
|
|
|
|
|
|
ans.clear();
|
|
|
|
|
|
size_t index0;
|
|
|
string one_arg;
|
|
|
|
|
|
if ( strArg.find_first_not_of(" ") == string::npos )
|
|
|
strArg = "";
|
|
|
|
|
|
|
|
|
while( strArg.size()>0 )
|
|
|
{
|
|
|
|
|
|
index0 = strArg.find(spliter);
|
|
|
|
|
|
if( index0 != string::npos )
|
|
|
{
|
|
|
|
|
|
one_arg = strArg.substr( 0, index0 );
|
|
|
strArg = strArg.substr( index0 + spliter.size() );
|
|
|
ans.push_back( one_arg );
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
|
|
|
ans.push_back( strArg );
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void add_tag_to_tag_array(tag_t add_tag,int *n_array,tag_t **tag_array)
|
|
|
{
|
|
|
int count = *n_array;
|
|
|
count++;
|
|
|
if(count == 1){
|
|
|
(*tag_array) = (tag_t *)MEM_alloc(sizeof(tag_t));
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
(*tag_array) = (tag_t *)MEM_realloc((*tag_array),count*sizeof(tag_t));
|
|
|
}
|
|
|
(*tag_array)[count - 1] = add_tag;
|
|
|
*n_array = count;
|
|
|
}
|
|
|
/*
|
|
|
|
|
|
*/
|
|
|
|
|
|
void GTAC_create_item(char *item_id,char *item_name,char *item_type,char *rev_id,tag_t *item,tag_t *rev)
|
|
|
{
|
|
|
char *rev_type_name = NULL;
|
|
|
rev_type_name = (char*) MEM_alloc((strlen(item_type) + strlen("Revision")+1)*sizeof(char));
|
|
|
sprintf(rev_type_name,"%sRevision",item_type);
|
|
|
tag_t rev_type_tag =NULLTAG;
|
|
|
TCTYPE_find_type(rev_type_name,NULL,&rev_type_tag);
|
|
|
if(rev_type_name){
|
|
|
MEM_free(rev_type_name);
|
|
|
}
|
|
|
tag_t rev_create_input_tag = NULLTAG;
|
|
|
TCTYPE_construct_create_input(rev_type_tag,&rev_create_input_tag);
|
|
|
AOM_set_value_string(rev_create_input_tag,"item_revision_id",rev_id);
|
|
|
AOM_set_value_string(rev_create_input_tag,"object_name",item_name);
|
|
|
/* Construct a CreateInput object for Item */
|
|
|
tag_t item_type_tag = NULLTAG;
|
|
|
TCTYPE_find_type(item_type,NULL,&item_type_tag);
|
|
|
tag_t item_create_input_tag = NULLTAG;
|
|
|
TCTYPE_construct_create_input(item_type_tag,&item_create_input_tag);
|
|
|
AOM_set_value_string(item_create_input_tag,"item_id",item_id);
|
|
|
AOM_set_value_string(item_create_input_tag,"object_name",item_name);
|
|
|
AOM_set_value_tag(item_create_input_tag,"revision",rev_create_input_tag);
|
|
|
TCTYPE_create_object(item_create_input_tag,item);
|
|
|
/* the deprecated function ITEM_create_item does not save the item
|
|
|
TCTYPE_create_object requires AOM_save or AOM_save_with_extensions
|
|
|
*/
|
|
|
AOM_save_with_extensions(*item);
|
|
|
(AOM_unlock(*item));//20241211
|
|
|
ITEM_ask_latest_rev(*item,rev);
|
|
|
printf("part create success\n");
|
|
|
}
|
|
|
|
|
|
void c_split(char *target,const char *s_str,vector<char*> &vec)
|
|
|
{
|
|
|
char* p=strtok(target,s_str);//<2F><>һ<EFBFBD>ε<EFBFBD><CEB5><EFBFBD>strtok
|
|
|
while(p!=NULL){//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><D6B5>ΪNULLʱ<4C><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѭ<EFBFBD><D1AD>
|
|
|
// printf("%s\n",p);//<2F><><EFBFBD><EFBFBD><EFBFBD>ֽ<EFBFBD><D6BD><EFBFBD><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD>
|
|
|
vec.push_back(p);
|
|
|
p=strtok(NULL,s_str);//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>strtok<6F><6B><EFBFBD>ֽ<EFBFBD>ʣ<EFBFBD>µ<EFBFBD><C2B5>ַ<EFBFBD><D6B7><EFBFBD>
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
void cn_ask_file(tag_t dataset,char *ref_name,char **file_path)
|
|
|
{
|
|
|
*file_path = (char *)MEM_alloc(SS_MAXPATHLEN * sizeof(char));
|
|
|
tag_t last_dataset=NULLTAG,ref_obj=NULLTAG;
|
|
|
AE_reference_type_t ref_type;
|
|
|
ITKCALL(AE_ask_dataset_latest_rev(dataset,&last_dataset)); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݼ<EFBFBD><DDBC><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD>汾
|
|
|
ITKCALL(AE_ask_dataset_named_ref2(last_dataset, ref_name,&ref_type,&ref_obj)); //<2F><>ȡ<EFBFBD><C8A1><EFBFBD>ݼ<EFBFBD><DDBC>е<EFBFBD><D0B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
if(ref_type == AE_PART_OF){
|
|
|
char *pathmne=NULL,*filename=NULL;
|
|
|
ITKCALL(IMF_ask_file_pathname2(ref_obj,SS_WNT_MACHINE,&pathmne));
|
|
|
ITKCALL(IMF_ask_original_file_name2(ref_obj,&filename));
|
|
|
//char *new_file_name = USER_new_file_name("", "word", "docx", 0);
|
|
|
char *temp_dir = getenv("TEMP");
|
|
|
//char temp_file[SS_MAXPATHLEN] = "";
|
|
|
sprintf(*file_path,"%s\\%s",temp_dir,filename);
|
|
|
ITKCALL(IMF_export_file(ref_obj, *file_path)); //<2F><><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD>TEMP
|
|
|
//file_path = temp_file;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|