@ -30,7 +30,6 @@
# include <sa/tcfile_cache.h>
# include <ics\ics2.h>
# include "sstream"
# include "libxl.h"
# include "atlstr.h"
# include <tc\tc_macros.h>
@ -96,6 +95,8 @@
# include <string>
# define MAX_PATH_LEN 256
# define GUID_LEN 64
# ifdef WIN32
# define ACCESS(fileName,accessMode) _access(fileName,accessMode)
# define MKDIR(path) _mkdir(path)
@ -103,9 +104,12 @@
# define ACCESS(fileName,accessMode) access(fileName,accessMode)
# define MKDIR(path) mkdir(path,S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH)
# endif
# define LOCALJARPATH "D:\\Siemens\\Teamcenter11\\bin\\tc_extra_jar\\"
# define REMOTEJARPATH "D:\\app\\Siemens\\Teamcenter12\\bin\\tc_extra_jar\\"
//#include <iostream>
using namespace std ;
using namespace libxl ;
# ifdef __cplusplus
extern " C " int POM_AM__set_application_bypass ( logical bypass ) ;
extern " C " {
@ -232,8 +236,7 @@ extern "C" {
std : : cout < < " Added " < < urlPath < < " to the classpath. " < < std : : endl ;
}
int JD_Revise_clear ( METHOD_message_t * msg , va_list args ) {
int JD_clear ( METHOD_message_t * msg , va_list args , tag_t new_rev ) {
printf ( " 升版执行 \n " ) ;
//获取数据集
char * temp_path , * attach_type ;
@ -257,20 +260,21 @@ extern "C" {
printf ( " dir:%s \n " , dir . str ( ) . c_str ( ) ) ;
//获取时间
//time_t t;
//time(&t);
//tm* time = localtime(&t);
stringstream date ;
//date << time->tm_year + 1900 << "-";
//date << time->tm_mon + 1 << "-";
//date << time->tm_mday << "-";
//date << time->tm_hour << "-";
//date << time->tm_min << "-";
//date << time->tm_sec;
date < < " 2 " ;
printf ( " datetime:%s \n " , date . str ( ) . c_str ( ) ) ;
//获取guid
char buffer [ GUID_LEN ] = { 0 } ;
GUID guid ;
if ( CoCreateGuid ( & guid ) ) {
fprintf ( stderr , " create guid error \n " ) ;
return - 1 ;
}
_snprintf ( buffer , sizeof ( buffer ) ,
" %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 ] ) ;
printf ( " guid: %s \n " , buffer ) ;
POM_AM__set_application_bypass ( true ) ;
@ -278,7 +282,7 @@ extern "C" {
wstringstream wss ;
wss < < getenv ( " JRE_HOME " ) < < " \\ bin \\ server \\ jvm.dll " ;
printf ( " wxs:%s \n " , wss . str ( ) . c_str ( ) ) ;
printf ( " wxs:%s \n " , wss . str ( ) . c_str ( ) ) ;
JavaVMInitArgs vmArgs ;
const int OPTION_COUNT = 1 ;
@ -321,135 +325,165 @@ extern "C" {
}
printf ( " after load jvm \n " ) ;
add_path ( env , " D: \\ Siemens \\ Teamcenter11 \\ bin \\ tc_extra_jar \\ sign2fileRunnable.jar " ) ;
//add_path(env, "D:\\app\\Siemens\\Teamcenter12\\bin\\tc_extra_jar\\sign2fileRunnable.jar");
stringstream s ;
if ( ACCESS ( LOCALJARPATH , 0 ) ! = 0 ) {
s < < REMOTEJARPATH ;
s < < " sign2fileRunnable.jar " ;
add_path ( env , s . str ( ) . c_str ( ) ) ;
} else {
s < < LOCALJARPATH ;
s < < " sign2fileRunnable.jar " ;
add_path ( env , s . str ( ) . c_str ( ) ) ;
}
printf ( " add path \n " ) ;
jclass class_Test ;
int file_type = - 1 ;
int ifail = ITK_ok , objects_count ;
tag_t new_rev = va_arg ( args , tag_t ) , * objects ;
char * operation = va_arg ( args , char * ) ;
tag_t * objects ;
ITKCALL ( AOM_ask_value_tags ( new_rev , " IMAN_master_form_rev " , & objects_count , & objects ) ) ;
//表单签名
for ( auto iii = 0 ; iii < objects_count ; iii + + ) {
AOM_lock ( objects [ iii ] ) ;
AOM_set_value_string ( objects [ iii ] , " jd2_bz " , " " ) ;
AOM_set_value_string ( objects [ iii ] , " jd2_bzrq " , " " ) ;
AOM_set_value_string ( objects [ iii ] , " jd2_jd " , " " ) ;
AOM_set_value_string ( objects [ iii ] , " jd2_jdrq " , " " ) ;
AOM_set_value_string ( objects [ iii ] , " jd2_sh " , " " ) ;
AOM_set_value_string ( objects [ iii ] , " jd2_shrq " , " " ) ;
AOM_set_value_string ( objects [ iii ] , " jd2_hq " , " " ) ;
AOM_set_value_string ( objects [ iii ] , " jd2_hqrq " , " " ) ;
AOM_set_value_string ( objects [ iii ] , " jd2_pz " , " " ) ;
AOM_set_value_string ( objects [ iii ] , " jd2_pzrq " , " " ) ;
ITKCALL ( AOM_save ( objects [ iii ] ) ) ;
AOM_unlock ( objects [ iii ] ) ;
}
MEM_free ( objects ) ;
printf ( " startSign \n " ) ;
ITKCALL ( AOM_ask_value_tags ( new_rev , " IMAN_specification " , & n_attachs , & dataset ) ) ;
for ( int i = 0 ; i < n_attachs ; i + + ) {
stringstream ss ;
ss < < dir . str ( ) . c_str ( ) ;
printf ( ss . str ( ) . c_str ( ) ) ;
ITKCALL ( TCTYPE_ask_object_type ( dataset [ i ] , & type_tag ) ) ;
if ( type_tag = = wordx_tag | | type_tag = = word_tag ) {
ITKCALL ( AE_ask_dataset_named_ref2 ( dataset [ i ] , " word " , & ae_ref , & word_ref ) ) ;
char * file_name ;
ITKCALL ( AOM_UIF_ask_value ( word_ref , " file_name " , & file_name ) ) ;
ss < < buffer ;
ss < < " _ " ;
ss < < file_name ;
printf ( " path:%s \n " , ss . str ( ) . c_str ( ) ) ;
ITKCALL ( AE_export_named_ref ( dataset [ i ] , " word " , ss . str ( ) . c_str ( ) ) ) ;
file_type = 0 ;
} else if ( type_tag = = excel_tag | | type_tag = = excelx_tag ) {
ITKCALL ( AE_ask_dataset_named_ref2 ( dataset [ i ] , " excel " , & ae_ref , & excel_ref ) ) ;
char * file_name ;
ITKCALL ( AOM_UIF_ask_value ( excel_ref , " file_name " , & file_name ) ) ;
ss < < buffer ;
ss < < " _ " ;
ss < < file_name ;
printf ( " path:%s \n " , ss . str ( ) . c_str ( ) ) ;
ITKCALL ( AE_export_named_ref ( dataset [ i ] , " excel " , ss . str ( ) . c_str ( ) ) ) ;
file_type = 1 ;
}
if ( strcmp ( operation , " Revise " ) = = 0 | | strcmp ( operation , " SaveAs " ) = = 0 ) {
//todo怎么判断需要操作的类型?
if ( isTypeOf ( new_rev , " ItemRevision " ) ) {
ITKCALL ( AOM_ask_value_tags ( new_rev , " IMAN_master_form_rev " , & objects_count , & objects ) ) ;
//表单签名
for ( auto iii = 0 ; iii < objects_count ; iii + + ) {
AOM_lock ( objects [ iii ] ) ;
AOM_set_value_string ( objects [ iii ] , " jd2_bz " , " " ) ;
AOM_set_value_string ( objects [ iii ] , " jd2_bzrq " , " " ) ;
AOM_set_value_string ( objects [ iii ] , " jd2_jd " , " " ) ;
AOM_set_value_string ( objects [ iii ] , " jd2_jdrq " , " " ) ;
AOM_set_value_string ( objects [ iii ] , " jd2_sh " , " " ) ;
AOM_set_value_string ( objects [ iii ] , " jd2_shrq " , " " ) ;
AOM_set_value_string ( objects [ iii ] , " jd2_hq " , " " ) ;
AOM_set_value_string ( objects [ iii ] , " jd2_hqrq " , " " ) ;
AOM_set_value_string ( objects [ iii ] , " jd2_pz " , " " ) ;
AOM_set_value_string ( objects [ iii ] , " jd2_pzrq " , " " ) ;
ITKCALL ( AOM_save ( objects [ iii ] ) ) ;
AOM_unlock ( objects [ iii ] ) ;
printf ( " file_type:%d \n " , file_type ) ;
if ( file_type = = 0 ) {
class_Test = env - > FindClass ( " sign2file/SignToWord " ) ;
int res = sign ( env , class_Test , ss . str ( ) . c_str ( ) , " " , 54 ) ;
if ( res ) {
replace_dataset_named_reference ( dataset [ i ] , word_ref , ss . str ( ) . c_str ( ) , " word " ) ;
}
MEM_free ( objects ) ;
printf ( " startSign \n " ) ;
ITKCALL ( AOM_ask_value_tags ( new_rev , " IMAN_specification " , & n_attachs , & dataset ) ) ;
for ( int i = 0 ; i < n_attachs ; i + + ) {
stringstream ss ;
ss < < dir . str ( ) . c_str ( ) ;
printf ( ss . str ( ) . c_str ( ) ) ;
ITKCALL ( TCTYPE_ask_object_type ( dataset [ i ] , & type_tag ) ) ;
if ( type_tag = = wordx_tag | | type_tag = = word_tag ) {
ITKCALL ( AE_ask_dataset_named_ref2 ( dataset [ i ] , " word " , & ae_ref , & word_ref ) ) ;
char * file_name ;
ITKCALL ( AOM_UIF_ask_value ( word_ref , " file_name " , & file_name ) ) ;
ss < < date . str ( ) . c_str ( ) ;
ss < < " _ " ;
ss < < file_name ;
printf ( " path:%s \n " , ss . str ( ) . c_str ( ) ) ;
ITKCALL ( AE_export_named_ref ( dataset [ i ] , " word " , ss . str ( ) . c_str ( ) ) ) ;
file_type = 0 ;
} else if ( type_tag = = excel_tag | | type_tag = = excelx_tag ) {
ITKCALL ( AE_ask_dataset_named_ref2 ( dataset [ i ] , " excel " , & ae_ref , & excel_ref ) ) ;
char * file_name ;
ITKCALL ( AOM_UIF_ask_value ( excel_ref , " file_name " , & file_name ) ) ;
ss < < date . str ( ) . c_str ( ) ;
ss < < " _ " ;
ss < < file_name ;
printf ( " path:%s \n " , ss . str ( ) . c_str ( ) ) ;
ITKCALL ( AE_export_named_ref ( dataset [ i ] , " excel " , ss . str ( ) . c_str ( ) ) ) ;
file_type = 1 ;
}
} else if ( file_type = = 1 ) {
class_Test = env - > FindClass ( " sign2file/SignToExcel " ) ;
int res = sign ( env , class_Test , ss . str ( ) . c_str ( ) , " " , 54 ) ;
if ( res ) {
replace_dataset_named_reference ( dataset [ i ] , excel_ref , ss . str ( ) . c_str ( ) , " excel " ) ;
}
}
file_type = - 1 ;
}
MEM_free ( dataset ) ;
AOM_ask_value_tags ( new_rev , " TC_Attaches " , & n_attachs , & dataset ) ;
for ( int i = 0 ; i < n_attachs ; i + + ) {
stringstream ss ;
ss < < dir . str ( ) . c_str ( ) ;
ITKCALL ( TCTYPE_ask_object_type ( dataset [ i ] , & type_tag ) ) ;
if ( type_tag = = wordx_tag | | type_tag = = word_tag ) {
ITKCALL ( AE_ask_dataset_named_ref2 ( dataset [ i ] , " word " , & ae_ref , & word_ref ) ) ;
char * file_name ;
ITKCALL ( AOM_UIF_ask_value ( word_ref , " file_name " , & file_name ) ) ;
ss < < buffer ;
ss < < " _ " ;
ss < < file_name ;
printf ( " path:%s \n " , ss . str ( ) . c_str ( ) ) ;
ITKCALL ( AE_export_named_ref ( dataset [ i ] , " word " , ss . str ( ) . c_str ( ) ) ) ;
file_type = 0 ;
} else if ( type_tag = = excel_tag | | type_tag = = excelx_tag ) {
ITKCALL ( AE_ask_dataset_named_ref2 ( dataset [ i ] , " excel " , & ae_ref , & excel_ref ) ) ;
char * file_name ;
ITKCALL ( AOM_UIF_ask_value ( excel_ref , " file_name " , & file_name ) ) ;
ss < < buffer ;
ss < < " _ " ;
ss < < file_name ;
printf ( " path:%s \n " , ss . str ( ) . c_str ( ) ) ;
ITKCALL ( AE_export_named_ref ( dataset [ i ] , " excel " , ss . str ( ) . c_str ( ) ) ) ;
file_type = 1 ;
}
printf ( " file_type:%d \n " , file_type ) ;
if ( file_type = = 0 ) {
class_Test = env - > FindClass ( " sign2file/SignToWord " ) ;
int res = sign ( env , class_Test , ss . str ( ) . c_str ( ) , " " , 54 ) ;
if ( res ) {
replace_dataset_named_reference ( dataset [ i ] , word_ref , ss . str ( ) . c_str ( ) , " word " ) ;
}
} else if ( file_type = = 1 ) {
class_Test = env - > FindClass ( " sign2file/SignToExcel " ) ;
int res = sign ( env , class_Test , ss . str ( ) . c_str ( ) , " " , 54 ) ;
if ( res ) {
replace_dataset_named_reference ( dataset [ i ] , excel_ref , ss . str ( ) . c_str ( ) , " excel " ) ;
}
}
file_type = - 1 ;
printf ( " file_type:%d \n " , file_type ) ;
if ( file_type = = 0 ) {
class_Test = env - > FindClass ( " sign2file/SignToWord " ) ;
int res = sign ( env , class_Test , ss . str ( ) . c_str ( ) , " " , 54 ) ;
if ( res ) {
replace_dataset_named_reference ( dataset [ i ] , word_ref , ss . str ( ) . c_str ( ) , " word " ) ;
}
MEM_free ( dataset ) ;
AOM_ask_value_tags ( new_rev , " TC_Attaches " , & n_attachs , & dataset ) ;
for ( int i = 0 ; i < n_attachs ; i + + ) {
stringstream ss ;
ss < < dir . str ( ) . c_str ( ) ;
ITKCALL ( TCTYPE_ask_object_type ( dataset [ i ] , & type_tag ) ) ;
if ( type_tag = = wordx_tag | | type_tag = = word_tag ) {
ITKCALL ( AE_ask_dataset_named_ref2 ( dataset [ i ] , " word " , & ae_ref , & word_ref ) ) ;
char * file_name ;
ITKCALL ( AOM_UIF_ask_value ( word_ref , " file_name " , & file_name ) ) ;
ss < < date . str ( ) . c_str ( ) ;
ss < < " _ " ;
ss < < file_name ;
printf ( " path:%s \n " , ss . str ( ) . c_str ( ) ) ;
ITKCALL ( AE_export_named_ref ( dataset [ i ] , " word " , ss . str ( ) . c_str ( ) ) ) ;
file_type = 0 ;
} else if ( type_tag = = excel_tag | | type_tag = = excelx_tag ) {
ITKCALL ( AE_ask_dataset_named_ref2 ( dataset [ i ] , " excel " , & ae_ref , & excel_ref ) ) ;
char * file_name ;
ITKCALL ( AOM_UIF_ask_value ( excel_ref , " file_name " , & file_name ) ) ;
ss < < date . str ( ) . c_str ( ) ;
ss < < " _ " ;
ss < < file_name ;
printf ( " path:%s \n " , ss . str ( ) . c_str ( ) ) ;
ITKCALL ( AE_export_named_ref ( dataset [ i ] , " excel " , ss . str ( ) . c_str ( ) ) ) ;
file_type = 1 ;
}
} else if ( file_type = = 1 ) {
class_Test = env - > FindClass ( " sign2file/SignToExcel " ) ;
int res = sign ( env , class_Test , ss . str ( ) . c_str ( ) , " " , 54 ) ;
if ( res ) {
replace_dataset_named_reference ( dataset [ i ] , excel_ref , ss . str ( ) . c_str ( ) , " excel " ) ;
}
}
file_type = - 1 ;
}
MEM_free ( dataset ) ;
printf ( " endSign \n " ) ;
FreeLibrary ( hModule ) ;
POM_AM__set_application_bypass ( false ) ;
return ITK_ok ;
}
int JD_Revise_clear ( METHOD_message_t * msg , va_list args ) {
tag_t new_rev = va_arg ( args , tag_t ) ;
char * operation = va_arg ( args , char * ) , * * pref_values , * type ;
int ifail = ITK_ok , pref_count ;
AOM_ask_value_string ( new_rev , " object_type " , & type ) ;
printf ( " file_type:%d \n " , file_type ) ;
if ( file_type = = 0 ) {
class_Test = env - > FindClass ( " sign2file/SignToWord " ) ;
int res = sign ( env , class_Test , ss . str ( ) . c_str ( ) , " " , 54 ) ;
if ( res ) {
replace_dataset_named_reference ( dataset [ i ] , word_ref , ss . str ( ) . c_str ( ) , " word " ) ;
}
} else if ( file_type = = 1 ) {
class_Test = env - > FindClass ( " sign2file/SignToExcel " ) ;
int res = sign ( env , class_Test , ss . str ( ) . c_str ( ) , " " , 54 ) ;
if ( res ) {
replace_dataset_named_reference ( dataset [ i ] , excel_ref , ss . str ( ) . c_str ( ) , " excel " ) ;
}
if ( strcmp ( operation , " Revise " ) = = 0 | | strcmp ( operation , " SaveAs " ) = = 0 ) {
if ( isTypeOf ( new_rev , " ItemRevision " ) ) {
//获取首选项
PREF_ask_char_values ( " jd_revise_clear_revisions " , & pref_count , & pref_values ) ;
for ( int i = 0 ; i < pref_count ; i + + ) {
if ( strcmp ( pref_values [ i ] , type ) = = 0 ) {
JD_clear ( msg , args , new_rev ) ;
break ;
}
file_type = - 1 ;
}
MEM_free ( dataset ) ;
printf ( " endSign \n " ) ;
}
}
FreeLibrary ( hModule ) ;
POM_AM__set_application_bypass ( false ) ;
return ifail ;
}
@ -457,13 +491,13 @@ extern "C" {
int status = ITK_ok ;
char * err_string , * err_function ;
int err_line = - 1 ;
printf ( " JD_Revise_clear函数 \n " ) ;
printf ( " JD_Revise_clear函数 开始注册 \n " ) ;
METHOD_id_t mth_tag ;
ITKCALL ( status = METHOD_find_method ( " ItemRevision " , ITEM_deep_copy_msg , & mth_tag ) ) ;
if ( mth_tag . id ! = 0 ) {
ITKCALL ( METHOD_add_action ( mth_tag , METHOD_post_action_type , JD_Revise_clear , NULL ) ) ;
printf ( " JD_Revise_clear注册成功 " ) ;
printf ( " JD_Revise_clear注册成功 \n " ) ;
}
return status ;
}