@ -1,97 +1,4 @@
# include "epm_handler_common.h"
# include "util.h"
# include <tc\tc_macros.h>
# include <tc\emh.h>
# include <tc\preferences.h>
# include <property\propdesc.h>
# include <epm\epm.h>
# include <epm\epm_toolkit_tc_utils.h>
# include <tccore\item.h>
# include <tccore\grmtype.h>
# include <tccore\grm.h>
# include <tccore\imantype.h>
# include <sa\am.h>
# include <sa\sa.h>
# include <tccore\aom.h>
# include <tccore\aom_prop.h>
# include <property\prop_errors.h>
# include <tccore\workspaceobject.h>
# include <qry\qry.h>
# include <bom\bom_attr.h>
# include <bom\bom.h>
# include <epm\signoff.h>
# include <pom\pom\pom.h>
# include <pom\pom\pom_errors.h>
# include <fclasses\tc_date.h>
# include <epm\cr.h>
# include <cfm\cfm.h>
# include <sa\am.h>
# include "tc/envelope.h"
# include <stdio.h>
# include "ae/dataset.h"
# include <ctype.h>
# include <string.h>
# include <string>
# include <iostream>
# include <iterator>
# include <map>
# include <vector>
# include "ce/ce.h"
# include <time.h>
# include <windows.h>
# include <iostream>
# include <sql.h>
# include <sqlext.h>
# include "string"
# include "sstream"
# include <sa/tcfile.h>
# include <tccore/aom.h>
# include <sa/tcfile_cache.h>
# include "ctime"
# include "tchar.h"
# using "C: / Users / lyf / source / repos / Testdll / bin / Debug / declib.dll"
using namespace std ;
using namespace Testdll ;
using namespace System ;
extern " C " int POM_AM__set_application_bypass ( logical bypass ) ;
string ConvertToString ( System : : String ^ str )
{
char * p = ( char * ) ( void * ) System : : Runtime : : InteropServices : : Marshal : : StringToHGlobalAnsi ( str ) ;
return p ;
}
System : : String ^ convert_to_cstring ( const char * p )
{
return System : : Runtime : : InteropServices : : Marshal : : PtrToStringAnsi ( ( System : : IntPtr ) ( char * ) p ) ;
}
bool isTypeOf ( tag_t objtag , const char * type_name ) {
tag_t type = NULLTAG ;
TCTYPE_ask_object_type ( objtag , & type ) ;
tag_t item_type = NULLTAG ;
TCTYPE_find_type ( type_name , " " , & item_type ) ;
bool is_type = false ;
if ( item_type ! = NULLTAG ) {
logical isok = FALSE ;
TCTYPE_is_type_of ( type , item_type , & isok ) ;
if ( isok ) {
is_type = true ;
}
}
return is_type ;
}
void split ( std : : string s , const char * delim , std : : vector < std : : string > * ret )
{
size_t last = 0 ;
size_t index = s . find ( delim , last ) ;
int size = strlen ( delim ) ;
while ( index ! = std : : string : : npos ) {
ret - > push_back ( s . substr ( last , index - last ) ) ;
last = index + size ;
index = s . find ( delim , last ) ;
}
if ( index - last > 0 ) {
ret - > push_back ( s . substr ( last , index - last ) ) ;
}
}
int bs_sap_material ( EPM_action_message_t msg )
int bs_sap_material ( EPM_action_message_t msg )
{
{
printf ( " start sap material \n " ) ;
printf ( " start sap material \n " ) ;
@ -101,12 +8,15 @@ int bs_sap_material(EPM_action_message_t msg)
int pref_cnt ;
int pref_cnt ;
char * * pref_vals ;
char * * pref_vals ;
EPM_ask_root_task ( msg . task , & rootTask ) ;
EPM_ask_root_task ( msg . task , & rootTask ) ;
map < int , string > class_map ;
EPM_ask_attachments ( rootTask , EPM_target_attachment , & att_count , & attachments ) ;
EPM_ask_attachments ( rootTask , EPM_target_attachment , & att_count , & attachments ) ;
TC_argument_list_t * arguments = msg . arguments ;
TC_argument_list_t * arguments = msg . arguments ;
int arg_cnt = TC_number_of_arguments ( arguments ) , status = 0 ;
int arg_cnt = TC_number_of_arguments ( arguments ) , status = 0 ;
POM_AM__set_application_bypass ( true ) ;
POM_AM__set_application_bypass ( true ) ;
map < string , string > paras , rel_map ;
map < string , string > paras , rel_map ;
map < string , string > prop_map ;
vector < string > rel_vec ;
vector < string > rel_vec ;
for ( auto i = 0 ; i < arg_cnt ; i + + )
for ( auto i = 0 ; i < arg_cnt ; i + + )
{
{
@ -114,6 +24,20 @@ int bs_sap_material(EPM_action_message_t msg)
ITK_ask_argument_named_value ( TC_next_argument ( arguments ) , & temp_key , & temp_val ) ;
ITK_ask_argument_named_value ( TC_next_argument ( arguments ) , & temp_key , & temp_val ) ;
paras [ temp_key ] = temp_val ;
paras [ temp_key ] = temp_val ;
}
}
string d0 = " D00 " , d1 = " D0 " ;
for ( int i = 0 ; i < 67 ; i + + )
{
if ( i > 8 )
{
class_map [ 1000 + i ] = d1 + to_string ( i + 1 ) ;
} else
{
class_map [ 1000 + i ] = d0 + to_string ( i + 1 ) ;
}
}
PREF_ask_char_values ( " connor_sap " , & pref_cnt , & pref_vals ) ;
PREF_ask_char_values ( " connor_sap " , & pref_cnt , & pref_vals ) ;
split ( pref_vals [ 4 ] , " , " , & rel_vec ) ;
split ( pref_vals [ 4 ] , " , " , & rel_vec ) ;
for ( int i = 0 ; i < rel_vec . size ( ) ; i + + )
for ( int i = 0 ; i < rel_vec . size ( ) ; i + + )
@ -125,6 +49,17 @@ int bs_sap_material(EPM_action_message_t msg)
rel_map [ temp_vec [ 0 ] ] = temp_vec [ 1 ] ;
rel_map [ temp_vec [ 0 ] ] = temp_vec [ 1 ] ;
}
}
}
}
split ( pref_vals [ 5 ] , " , " , & rel_vec ) ;
for ( int i = 0 ; i < rel_vec . size ( ) ; i + + )
{
vector < string > temp_vec ;
split ( rel_vec [ i ] , " = " , & temp_vec ) ;
if ( temp_vec . size ( ) = = 2 )
{
prop_map [ temp_vec [ 0 ] ] = temp_vec [ 1 ] ;
}
}
GRM_find_relation_type ( " IMAN_master_form " , & relation_type ) ;
GRM_find_relation_type ( " IMAN_master_form " , & relation_type ) ;
printf ( " create class \n " ) ;
printf ( " create class \n " ) ;
Testclass ^ test = gcnew Testclass ( ) ;
Testclass ^ test = gcnew Testclass ( ) ;
@ -132,24 +67,22 @@ int bs_sap_material(EPM_action_message_t msg)
String ^ url = convert_to_cstring ( pref_vals [ 0 ] ) ;
String ^ url = convert_to_cstring ( pref_vals [ 0 ] ) ;
String ^ user = convert_to_cstring ( pref_vals [ 2 ] ) ;
String ^ user = convert_to_cstring ( pref_vals [ 2 ] ) ;
String ^ password = convert_to_cstring ( pref_vals [ 3 ] ) ;
String ^ password = convert_to_cstring ( pref_vals [ 3 ] ) ;
map < string , string > map ;
// prop_map["MTART"] = "jd2_wllx";
map [ " MTART " ] = " jd2_wllx " ;
// prop_map["MATNR"] = "item_id";
map [ " MATNR " ] = " item_id " ;
// prop_map["MAKTX"] = "jd2_wlms";
map [ " MAKTX " ] = " jd2_wlms " ;
// prop_map["MEINS"] = "jd2_dldw";
map [ " MEINS " ] = " jd2_jldw " ;
// prop_map["MATKL"] = "jd2_wlz";
map [ " MATKL " ] = " jd2_wlz " ;
// prop_map["PRDHA"] = "jd2_cpcc";
map [ " PRDHA " ] = " jd2_cppc " ;
// prop_map["EXTWG"] = "jd2_wbwlz";
map [ " EXTWG " ] = " jd2_wbwlz " ;
// prop_map["MSTAE"] = "release_status_list";
map [ " MSTAE " ] = " release_status_list " ;
// prop_map["VOLUM"] = "jd2_tj";
map [ " VOLUM " ] = " jd2_tj " ;
// prop_map["VOLEH"] = "jd2_tjdw";
map [ " VOLEH " ] = " jd2_tjdw " ;
// prop_map["BISMT"] = "jd2_jwlh";
map [ " BISMT " ] = " jd2_jwlh " ;
// prop_map["ZEINR"] = "jd2_th";
map [ " ZEINR " ] = " jd2_th " ;
// prop_map["BRGEW"] = "jd2_mz";
map [ " BRGEW " ] = " jd2_mz " ;
// prop_map["NTGEW"] = "jd2_jz";
map [ " NTGEW " ] = " jd2_jz " ;
// prop_map["GEWEI"] = "jd2_zldw";
map [ " GEWEI " ] = " jd2_zldw " ;
// prop_map["CLASS"] = "jd2_wllx";
map [ " CLASS " ] = " jd2_wllx " ;
vector < string > vec { " jd2_wllx " , " item_id " , " jd2_wlms " , " jd2_jldw " , " jd2_wlz " , " jd2_cppc " , " jd2_wbwlz " , " release_status_list " , " jd2_tj " , " jd2_tjdw " , " jd2_jwlh " , " jd2_th " , " jd2_mz " , " jd2_jz " , " jd2_zldw " } ;
vector < string > vec { " jd2_wllx " , " item_id " , " jd2_wlms " , " jd2_jldw " , " jd2_wlz " , " jd2_cppc " , " jd2_wbwlz " , " release_status_list " , " jd2_tj " , " jd2_tjdw " , " jd2_jwlh " , " jd2_th " , " jd2_mz " , " jd2_jz " , " jd2_zldw " } ;
printf ( " start111 \n " ) ;
printf ( " start111 \n " ) ;
for ( int i = 0 ; i < att_count ; i + + )
for ( int i = 0 ; i < att_count ; i + + )
@ -160,7 +93,7 @@ int bs_sap_material(EPM_action_message_t msg)
tag_t * rels ;
tag_t * rels ;
GRM_list_secondary_objects_only ( attachments [ i ] , relation_type , & rel_cnt , & rels ) ;
GRM_list_secondary_objects_only ( attachments [ i ] , relation_type , & rel_cnt , & rels ) ;
System : : Collections : : Generic : : Dictionary < String ^ , String ^ > ^ dic = gcnew System : : Collections : : Generic : : Dictionary < String ^ , String ^ > ( ) ;
System : : Collections : : Generic : : Dictionary < String ^ , String ^ > ^ dic = gcnew System : : Collections : : Generic : : Dictionary < String ^ , String ^ > ( ) ;
for ( auto j = map. begin ( ) ; j ! = map. end ( ) ; j + + )
for ( auto j = prop_ map. begin ( ) ; j ! = prop_ map. end ( ) ; j + + )
{
{
char * val = " " ;
char * val = " " ;
string temp_val ;
string temp_val ;
@ -182,8 +115,26 @@ int bs_sap_material(EPM_action_message_t msg)
AOM_UIF_ask_value ( rels [ 0 ] , j - > second . c_str ( ) , & val ) ;
AOM_UIF_ask_value ( rels [ 0 ] , j - > second . c_str ( ) , & val ) ;
temp_val = val ;
temp_val = val ;
}
}
dic [ convert_to_cstring ( j - > first . c_str ( ) ) ] = convert_to_cstring ( temp_val . c_str ( ) ) ;
dic [ convert_to_cstring ( j - > first . c_str ( ) ) ] = convert_to_cstring ( temp_val . c_str ( ) ) ;
}
}
tag_t class_obj ;
ICS_ask_classification_object ( attachments [ i ] , & class_obj ) ;
if ( class_obj )
{
char * * * vals ;
int cnt , * ids , * val_count ;
ICS_ico_ask_attributes ( class_obj , & cnt , & ids , & val_count , & vals ) ;
for ( int j = 0 ; j < cnt ; j + + )
{
printf ( " id:%d \n " , ids [ j ] ) ;
if ( class_map . find ( ids [ j ] ) ! = class_map . end ( ) )
{
if ( val_count [ j ] )
dic [ convert_to_cstring ( class_map [ ids [ j ] ] . c_str ( ) ) ] = convert_to_cstring ( vals [ j ] [ 0 ] ) ;
}
}
}
dic [ " MBRSH " ] = " M " ;
dic [ " MBRSH " ] = " M " ;
dic [ " SPART " ] = " 00 " ;
dic [ " SPART " ] = " 00 " ;
dic [ " KLART " ] = " 001 " ;
dic [ " KLART " ] = " 001 " ;
@ -279,6 +230,7 @@ int bs_sap_bom(EPM_action_message_t msg)
AOM_ask_value_string ( rels [ 0 ] , " jd2_BOMyt " , & stlan ) ;
AOM_ask_value_string ( rels [ 0 ] , " jd2_BOMyt " , & stlan ) ;
if ( tc_strlen ( werks ) = = 0 | | tc_strlen ( stlan ) = = 0 )
if ( tc_strlen ( werks ) = = 0 | | tc_strlen ( stlan ) = = 0 )
continue ;
continue ;
get_bom ( a_list , top_line , werks , stlan ) ;
get_bom ( a_list , top_line , werks , stlan ) ;
string result = ConvertToString ( test - > send_bom ( url , user , password , a_list ) ) ;
string result = ConvertToString ( test - > send_bom ( url , user , password , a_list ) ) ;
printf ( " result:%s \n " , result . c_str ( ) ) ;
printf ( " result:%s \n " , result . c_str ( ) ) ;