#include "epm_handler_common.h" #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 "tc/envelope.h" #include #include "ae/dataset.h" #include #include #include #include #include #include #include #include "ce/ce.h" #include #include #include #include #include #include "string" #include "sstream" #include #include #include #include "ctime" #include "tchar.h" #include "jni.h" using namespace std; extern "C" int POM_AM__set_application_bypass(logical bypass); 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; } string GBKToUTF8(const char* strGBK) { int len = MultiByteToWideChar(CP_ACP, 0, strGBK, -1, NULL, 0); wchar_t* wstr = new wchar_t[len+1]; memset(wstr, 0, len+1); MultiByteToWideChar(CP_ACP, 0, strGBK, -1, wstr, len); len = WideCharToMultiByte(CP_UTF8, 0, wstr, -1, NULL, 0, NULL, NULL); char* str = new char[len+1]; memset(str, 0, len+1); WideCharToMultiByte(CP_UTF8, 0, wstr, -1, str, len, NULL, NULL); string strTemp = str; if(wstr) delete[] wstr; if(str) delete[] str; return strTemp; } int sap(EPM_action_message_t msg) { printf("start sap\n"); int ifail = ITK_ok, att_count; tag_t rootTask, *attachments, user_tag,relation_type; char *action_string, *user_name, *task_name; EPM_ask_root_task(msg.task, &rootTask); EPM_ask_attachments(rootTask,EPM_target_attachment, &att_count, &attachments); TC_argument_list_t * arguments = msg.arguments; int arg_cnt = TC_number_of_arguments(arguments), status = 0; map paras; for (auto i = 0; iFindClass("zplm_interface/SAPTest"); jmethodID methodId_main = env->GetStaticMethodID(class_Test, "sap", "([Ljava/lang/String;Ljava/lang/String;[Ljava/lang/String;)Z"); jobjectArray info = env->NewObjectArray(2, env->FindClass("Ljava/lang/String;"), NULL); int index=0; PREF_ask_char_values("Origin_SAP_URL",&pref_cnt,&pref_vals); jstring url=env->NewStringUTF(pref_vals[0]); PREF_ask_char_values("Origin_SAP_PassWord",&pref_cnt,&pref_vals); env->SetObjectArrayElement(info, 0, env->NewStringUTF(pref_vals[0])); env->SetObjectArrayElement(info, 1, env->NewStringUTF(pref_vals[1])); vector vec; vec.push_back("cdc_Partnum"); vec.push_back("CustName"); vec.push_back("DCM_specification"); vec.push_back("cdc_Specsize1"); vec.push_back("DCM_Weight"); vec.push_back("DCM_SurfState"); vec.push_back("cdc_WetherTSTM"); vec.push_back("cdc_InWPTDT"); vec.push_back("cdc_WithWPTSTM"); printf("start\n"); GRM_find_relation_type(IMAN_master_form_rtype, &relation_type); printf("type:%s\n",paras["itemRev_type"].c_str()); for(int i=0;iNewObjectArray(vec.size(), env->FindClass("Ljava/lang/String;"), NULL); for(auto j=0;j3){ temp=temp.substr(3); } printf("args:%s\n",temp.c_str()); temp=GBKToUTF8(temp.c_str()); env->SetObjectArrayElement(strs, j, env->NewStringUTF(temp.c_str())); } printf("pass11"); jboolean result= env->CallStaticBooleanMethod(class_Test, methodId_main, strs, url,info); printf("result:%d\n",result==JNI_TRUE); if(result==JNI_FALSE){ printf("error\n"); EMH_store_error_s1(EMH_severity_error, EMH_ATTR_error_base, "SAP服务异常,请与SAP系统管理员联系"); return 1; } } } jvm->DestroyJavaVM(); FreeLibrary(hModule); return 0; }