/*===================================================================================================
                    Copyright(c) 2011 Siemens PLM Software Corp. All rights reserved.
                             Unpublished - All rights reserved
====================================================================================================
File description:
    
    Filename : epm_register_handler.c

    This file registers functions which are called when Teamcenter is being initialized

====================================================================================================
Date               Name                  Description of Change
2011-8-21			Ray               creation

$HISTORY$
==================================================================================================*/

#pragma warning (disable: 4819) 

/**
* @headerfile			tcua 头文件
*/
#include <server_exits/user_server_exits.h>
#include <tccore/custom.h>
#include <tccore/item_msg.h>
#include <epm/epm.h>

/**
* @headerfile			standard c & cpp header files
*/
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>
#include <time.h>
#include <tc/tc.h>
#include <tccore/method.h>


/**
* @headerfile			user's header files
*/
#include "epm_register_handler.h"
#include "epm_handler_common.h"
#include "erp_send_item.h"
#include "hz_custom.h"
#include "hx_custom.h"
#include "jk_custom.h"
#include "jk_custom_erp.h"

#define LIMITDAY 2016

int checkvalue(char* str)
{
    
    int i;
    for (i=0;i<strlen(str);i++)
    {
        if (isdigit(str[i]) == 0)
			return 0;
    }
    return 1;
}

char* decrypt(char *lic_file)
{
	char* p = NULL, buf[512], *str;
	int i = 0;

	FILE *fp1=NULL;
	if((fp1 = fopen(lic_file,"r")) == NULL)
	{
		printf("can not open the license file\n");
		return "";
	}
	fgets(buf, 9, fp1);
	//printf("buf=%s\n",buf);
	p = buf;
	while(*p != '\0')
	*p++ ^= i++;
	p = buf;
	while(*p != '\0')
	*p++ ^= i++;
	p = buf;
	while(*p != '\0')
	*p++ ^= i++;
	return buf;
}
char* encrypt(char* str)
{
 char* p = str;
 int i = 0;
 while(*p != '\0')
  *p++ ^= i++;
 return str;
}

//供流程调用的
// 标准的注册供流程调用服务handler的入口 TC_save_msg
extern DLLAPI int USERSERVICE_custom_register_handlers(int *decision, va_list args)
{
	int ifail = ITK_ok, n=0;
	char date_buf[80],*expire_date, env[512], temp1[512], temp2[512];
	time_t now;
	struct   tm   *p;

	*decision = ALL_CUSTOMIZATIONS;
	//宏协
	METHOD_id_t mth_tag;
 /*   ITKCALL(ifail = METHOD_find_method("Item",ITEM_create_msg,&mth_tag));
    if (mth_tag.id != 0){
		ITKCALL(ifail = METHOD_add_action2(mth_tag, METHOD_post_action_type, HX3_create_item_post, NULL,true));

        fprintf(stdout,"regist Item_create pre_action successfully  !\n");
	}else{
		fprintf(stdout,"regist Item_create pre_action fiald  !\n");
	}*/

	//保存对象后操作
/*	ITKCALL(ifail = METHOD_find_method("BOMWindow",BOMWindow_save_msg,&mth_tag));
    if (mth_tag.id != 0){
		ITKCALL(ifail = METHOD_add_action(mth_tag, METHOD_pre_action_type, HX3_bom_save, NULL));
        fprintf(stdout,"regist  BOMWindow  BOMWindow_save_msg pre_action successfully  !\n");
	}else{
		char  *errMsg = NULL;
		fprintf(stdout,"regist  BOMWindow  BOMWindow_save_msg post_action fiald  !\n");
		EMH_ask_error_text(ifail, &errMsg);
		
		printf("ERROR:登陆错误 : \"%d\", \"%s\"\n", ifail, errMsg);
		if(errMsg!=NULL){
			errMsg =NULL;
			MEM_free(errMsg);
		}

	}
*/
	//
	//保存对象后操作
	


	*decision = ALL_CUSTOMIZATIONS;

	//int status  = ITK_ok;
	//    //EBP SP-EXT-FUN-04. 修改项目状态后自动设置项目结束日期并通知SAP --zhanggl
	//{
	//           ITKCALL( METHOD_find_prop_method ( "HX3_GYTRevision", "HX3_MUJT", PROP_set_value_tags_msg, &mth_tag ) );
	//           if ( mth_tag.id != NULLTAG )
	//           {
	//			printf("find HX3_GYTRevision HX3_MUJT \n ");
	//               ITKCALL(status = METHOD_add_action( mth_tag, METHOD_post_action_type,( METHOD_function_t ) HX3_post_prop_set, NULL ) );
	//			if(status == ITK_ok){
	//				printf("success HX3_MUJT \n ");
	//			}else{
	//				printf("faild HX3_MUJT \n ");
	//			}
	//		}else{
	//			printf("not find HX3_GYTRevision HX3_MUJT \n ");
	//		}
	//}  

	//标准的注册action_handler的入口
	
	ifail = EPM_register_action_handler("JK-signoff-form", "JK-signoff-form", 
	(EPM_action_handler_t)jf_sign_ir_master); 
	if(ifail == ITK_ok) 
	{ 
		fprintf(stdout,"Registering action handler JK-signoff-form completed!\n"); 
	} 
	else
	{
		fprintf(stdout , "Registering action handler JK-signoff-form failed %d!\n",ifail);
	}

	ifail = EPM_register_action_handler("TX-signoff-form", "TX-signoff-form", 
	(EPM_action_handler_t)tx_sign_ir_master); 
	if(ifail == ITK_ok) 
	{ 
		fprintf(stdout,"Registering action handler TX-signoff-form completed!\n"); 
	} 
	else
	{
		fprintf(stdout , "Registering action handler TX-signoff-form failed %d!\n",ifail);
	}
	ifail = EPM_register_action_handler("tx_AutoSign_Handler", "tx_AutoSign_Handler", 
	(EPM_action_handler_t)tx_AutoSign_Handler); 
	if(ifail == ITK_ok) 
	{ 
		fprintf(stdout,"Registering action handler tx_AutoSign_Handler completed!\n"); 
	} 
	else
	{
		fprintf(stdout , "Registering action handler tx_AutoSign_Handler failed %d!\n",ifail);
	}
	ifail = EPM_register_action_handler("jk_AutoSign_Handler", "jk_AutoSign_Handler", 
	(EPM_action_handler_t)jk_AutoSign_Handler); 
	if(ifail == ITK_ok) 
	{ 
		fprintf(stdout,"Registering action handler jk_AutoSign_Handler completed!\n"); 
	} 
	else
	{
		fprintf(stdout , "Registering action handler jk_AutoSign_Handler failed %d!\n",ifail);
	}
	//DWG签名 
	ifail = EPM_register_action_handler("JK-signoff-dataset", "JK-signoff-dataset", 
	(EPM_action_handler_t)jf_signoff_dataset); 
	if(ifail == ITK_ok) 
	{ 
		fprintf(stdout,"Registering action handler JK-signoff-dataset completed!\n"); 
	}
	else
	{
		fprintf(stdout,"Registering action handler JK-signoff-dataset failed %d!\n",ifail);
	}

	//新建物料传递ERP
/*	ifail = EPM_register_action_handler("tm-erp-send-items", "tm-erp-send-items", 
	(EPM_action_handler_t)jf_erp_send_items); 
	if(ifail == ITK_ok) 
	{ 
		fprintf(stdout,"Registering action handler tm-erp-send-items completed!\n"); 
	}
	else
	{
		fprintf(stdout,"Registering action handler tm-erp-send-items failed %d!\n",ifail);
	}
	//新建BOM传递ERP
	ifail = EPM_register_action_handler("tm-erp-send-boms", "tm-erp-send-boms", 
	(EPM_action_handler_t)jf_erp_send_boms); 
	if(ifail == ITK_ok) 
	{ 
		fprintf(stdout,"Registering action handler tm-erp-send-boms completed!\n"); 
	}
	else
	{
		fprintf(stdout,"Registering action handler tm-erp-send-boms failed %d!\n",ifail);
	}

	//新建物料传递HL
	ifail = EPM_register_action_handler("tm-hl-send-items", "tm-hl-send-items", 
	(EPM_action_handler_t)jf_hl_send_items); 
	if(ifail == ITK_ok) 
	{ 
		fprintf(stdout,"Registering action handler tm-hl-send-items completed!\n"); 
	}
	else
	{
		fprintf(stdout,"Registering action handler tm-hl-send-items failed %d!\n",ifail);
	}
	//新建BOM传递混料
	ifail = EPM_register_action_handler("tm-hl-send-boms", "tm-hl-send-boms", 
	(EPM_action_handler_t)jf_hl_send_boms); 
	if(ifail == ITK_ok) 
	{ 
		fprintf(stdout,"Registering action handler tm-hl-send-boms completed!\n"); 
	}
	else
	{
		fprintf(stdout,"Registering action handler tm-hl-send-boms failed %d!\n",ifail);
	}
	//PDF插入图片
	ifail = EPM_register_action_handler("tm_insert_img_pdf", "tm_insert_img_pdf", 
	(EPM_action_handler_t)jf_insert_img_pdf); 
	if(ifail == ITK_ok) 
	{ 
		fprintf(stdout,"Registering action handler tm_insert_img_pdf completed!\n"); 
	}
	else
	{
		fprintf(stdout,"Registering action handler tm_insert_img_pdf failed %d!\n",ifail);
	}

	//检查文件夹是否为空（rule_handler）
	ifail = EPM_register_rule_handler("tm_check_folder_null", "tm_check_folder_null", 
	(EPM_rule_handler_t)check_target_null); 
	if(ifail == ITK_ok) 
	{ 
		fprintf(stdout,"Registering rule handler tm_check_folder_null completed!\n"); 
	}
	else
	{
		fprintf(stdout,"Registering rule handler tm_check_folder_null failed %d!\n",ifail);
	}

	//通知节点属性签名
	ifail = EPM_register_action_handler("tm_sign_tongzhi", "tm_sign_tongzhi", 
	(EPM_action_handler_t)tm_sign_tongzhi); 
	if(ifail == ITK_ok) 
	{ 
		fprintf(stdout,"Registering action handler tm_sign_tongzhi completed!\n"); 
	}
	else
	{
		fprintf(stdout,"Registering action handler tm_sign_tongzhi failed %d!\n",ifail);
	}
	*/
	//显示时间表名称
	ifail = EPM_register_action_handler("CN_show_schedule_name", "CN_show_schedule_name", 
	(EPM_action_handler_t)tm_show_object_name); 
	if(ifail == ITK_ok) 
	{ 
		fprintf(stdout,"Registering action handler CN_show_schedule_name completed!\n"); 
	}else
	{
		fprintf(stdout,"Registering action handler CN_show_schedule_name failed %d!\n",ifail);
	}
	//传递控制计划 jf_control_plan_send
/*	
	ifail = EPM_register_action_handler("tm_control_plan_send", "tm_control_plan_send", 
	(EPM_action_handler_t)jf_control_plan_send); 
	if(ifail == ITK_ok) 
	{ 
		fprintf(stdout,"Registering action handler tm_control_plan_send completed!\n"); 
	}
	else
	{
		fprintf(stdout,"Registering action handler tm_control_plan_send failed %d!\n",ifail);
	}
*/
	( ifail = EPM_register_rule_handler("JK_summary_form", "JK_summary_form",(EPM_rule_handler_t) JK_summary_form));
	if(ifail==0) {
		printf("Registering rule handler JK_summary_form successful\n");
	} else {
		printf("Registering rule handler JK_summary_form failed %d\n", ifail);
	}
	( ifail = EPM_register_rule_handler("jk_water_summary", "jk_water_summary",(EPM_rule_handler_t) jk_water_summary));
	if(ifail==0) {
		printf("Registering rule handler jk_water_summary successful\n");
	} else {
		printf("Registering rule handler jk_water_summary failed %d\n", ifail);
	}
	( ifail = EPM_register_rule_handler("jk_decide_time", "jk_decide_time",(EPM_rule_handler_t) jk_decide_time));
	if(ifail==0) {
		printf("Registering rule handler jk_decide_time successful\n");
	} else {
		printf("Registering rule handler jk_decide_time failed %d\n", ifail);
	}

	( ifail = EPM_register_rule_handler("check_target_null", "check_target_null",(EPM_rule_handler_t) check_target_null));
	if(ifail==0) {
		printf("Registering rule handler check_target_null successful\n");
	} else {
		printf("Registering rule handler check_target_null failed %d\n", ifail);
	}
	( ifail = EPM_register_rule_handler("jk_check_virtual", "jk_check_virtual",(EPM_rule_handler_t) jk_check_virtual));
	if(ifail==0) {
		printf("Registering rule handler jk_check_virtual successful\n");
	} else {
		printf("Registering rule handler jk_check_virtual failed %d\n", ifail);
	}	
	( ifail = EPM_register_rule_handler("JK_check_workflow", "JK_check_workflow",(EPM_rule_handler_t) JK_check_workflow));
	if(ifail==0) {
		printf("Registering rule handler JK_check_workflow successful\n");
	} else {
		printf("Registering rule handler JK_check_workflow failed %d\n", ifail);
	}
	( ifail = EPM_register_action_handler("jk_add_actual", "jk_add_actual",(EPM_action_handler_t) jk_add_actual));
	if(ifail==0) {
		printf("Registering rule handler jk_add_actual successful\n");
	} else {
		printf("Registering rule handler jk_add_actual failed %d\n", ifail);
	}
	( ifail = EPM_register_action_handler("jk_exportExcel", "jk_exportExcel",(EPM_action_handler_t) jk_exportExcel));
	if(ifail==0) {
		printf("Registering rule handler jk_exportExcel successful\n");
	} else {
		printf("Registering rule handler jk_exportExcel failed %d\n", ifail);
	}
	( ifail = EPM_register_action_handler("jk_auto_create_process", "jk_auto_create_process",(EPM_action_handler_t) jk_auto_create_process));
	if(ifail==0) {
		printf("Registering rule handler jk_auto_create_process successful\n");
	} else {
		printf("Registering rule handler jk_auto_create_process failed %d\n", ifail);
	}
	( ifail = EPM_register_action_handler("jk_remove_allStatus", "删除版本状态",(EPM_action_handler_t) jk_remove_allStatus));
	if(ifail==0) {
		printf("Registering rule handler jk_remove_allStatus successful\n");
	} else {
		printf("Registering rule handler jk_remove_allStatus failed %d\n", ifail);
	}
	( ifail = EPM_register_action_handler("JK_send_email", "JK_send_email",(EPM_action_handler_t) JK_send_email));
	if(ifail==0) {
		printf("Registering rule handler JK_send_email successful\n");
	} else {
		printf("Registering rule handler JK_send_email failed %d\n", ifail);
	}
	
	( ifail = EPM_register_action_handler("JK_send_email_2", "JK_send_email_2",(EPM_action_handler_t) JK_send_email_2));
	if(ifail==0) {
		printf("Registering rule handler JK_send_email_2 successful\n");
	} else {
		printf("Registering rule handler JK_send_email_2 failed %d\n", ifail);
	}

	//JK_matereial_summary_fee   JK_change_qx
	( ifail = EPM_register_action_handler("JK_matereial_summary_fee", "JK_matereial_summary_fee",(EPM_action_handler_t) JK_matereial_summary_fee));
	if(ifail==0) {
		printf("Registering rule handler JK_matereial_summary_fee successful\n");
	} else {
		printf("Registering rule handler JK_matereial_summary_fee failed %d\n", ifail);
	}

	( ifail = EPM_register_action_handler("JK_change_qx", "JK_change_qx",(EPM_action_handler_t) JK_change_qx));
	if(ifail==0) {
		printf("Registering rule handler JK_change_qx successful\n");
	} else {
		printf("Registering rule handler JK_change_qx failed %d\n", ifail);
	}
	( ifail = EPM_register_action_handler("jk_add_attatchments", "jk_add_attatchments",(EPM_action_handler_t) jk_add_attatchments));
	if(ifail==0) {
		printf("Registering rule handler jk_add_attatchments successful\n");
	} else {
		printf("Registering rule handler jk_add_attatchments failed %d\n", ifail);
	}



	( ifail = EPM_register_action_handler("JK_send_material", "JK_send_material",(EPM_action_handler_t) JK_send_material));
	if(ifail==0) {
		printf("Registering rule handler JK_send_material successful\n");
	} else {
		printf("Registering rule handler JK_send_material failed %d\n", ifail);
	}
	( ifail = EPM_register_action_handler("jk_test_ask_icoAttribute", "jk_test_ask_icoAttribute",(EPM_action_handler_t) jk_test_ask_icoAttribute));
	if(ifail==0) {
		printf("Registering rule handler jk_test_ask_icoAttribute successful\n");
	} else {
		printf("Registering rule handler jk_test_ask_icoAttribute failed %d\n", ifail);
	}

	( ifail = EPM_register_action_handler("JK_send_bom", "JK_send_bom",(EPM_action_handler_t) JK_send_bom));
	if(ifail==0) {
		printf("Registering rule handler JK_send_bom successful\n");
	} else {
		printf("Registering rule handler JK_send_bom failed %d\n", ifail);
	}

	( ifail = EPM_register_action_handler("JK_bypass", "JK_bypass",(EPM_action_handler_t) JK_bypass));
	if(ifail==0) {
		printf("Registering action handler JK_bypass successful\n");
	} else {
		printf("Registering action handler JK_bypass failed %d\n", ifail);
	}

	( ifail = EPM_register_rule_handler("JK_class_null", "JK_class_null",(EPM_rule_handler_t) JK_class_null));
	if(ifail==0) {
		printf("Registering rule handler JK_class_null successful\n");
	} else {
		printf("Registering rule handler JK_class_null failed %d\n", ifail);
	}

	( ifail = EPM_register_rule_handler("JK_summary_pcb_form", "JK_summary_pcb_form",(EPM_rule_handler_t) JK_summary_pcb_form));
	if(ifail==0) {
		printf("Registering rule handler JK_summary_pcb_form successful\n");
	} else {
		printf("Registering rule handler JK_summary_pcb_form failed %d\n", ifail);
	}

	( ifail = EPM_register_rule_handler("JK_Bom_is_release", "JK_Bom_is_release",(EPM_rule_handler_t) JK_Bom_is_release));
	if(ifail==0) {
		printf("Registering rule handler JK_Bom_is_release successful\n");
	} else {
		printf("Registering rule handler JK_Bom_is_release failed %d\n", ifail);
	}

	//检查能否发起物料停用流程
		( ifail = EPM_register_rule_handler("MaterialDiscontinuation", "检查能否发起物料停用流程",(EPM_rule_handler_t) MaterialDiscontinuation));
	if(ifail==0) {
		printf("Registering rule handler MaterialDiscontinuation successful\n");
	} else {
		printf("Registering rule handler MaterialDiscontinuation failed %d\n", ifail);
	}
	//检查能否发起物料停用流程
		( ifail = EPM_register_rule_handler("tx_checkMaterialReleased", "天信检查能否发起物料停用流程",(EPM_rule_handler_t) tx_checkMaterialReleased));
	if(ifail==0) {
		printf("Registering rule handler tx_checkMaterialReleased successful\n");
	} else {
		printf("Registering rule handler tx_checkMaterialReleased failed %d\n", ifail);
	}

	//检查能否发起物料启用流程MaterialOpenning
			( ifail = EPM_register_rule_handler("MaterialOpenning", "检查能否发起物料启用流程",(EPM_rule_handler_t) MaterialOpenning));
	if(ifail==0) {
		printf("Registering rule handler MaterialOpenning successful\n");
	} else {
		printf("Registering rule handler MaterialOpenning failed %d\n", ifail);
	}
	//检查能否发起物料启用流程MaterialOpenning
			( ifail = EPM_register_rule_handler("tx_checkMaterialDisabled", "天信检查能否发起物料启用流程",(EPM_rule_handler_t) tx_checkMaterialDisabled));
	if(ifail==0) {
		printf("Registering rule handler tx_checkMaterialDisabled successful\n");
	} else {
		printf("Registering rule handler tx_checkMaterialDisabled failed %d\n", ifail);
	}
	//检查BOM子阶物料审核流程
	( ifail = EPM_register_rule_handler("BOMDiscontinuation", "BOM子阶物料审核流程",(EPM_rule_handler_t) BOMDiscontinuation));
	if(ifail==0) {
		printf("Registering rule handler BOMDiscontinuation successful\n");
	} else {
		printf("Registering rule handler BOMDiscontinuation failed %d\n", ifail);
	}
	//添加失效状态并传递中间表
	( ifail = EPM_register_action_handler("addDisabled", "添加失效状态",(EPM_action_handler_t) addDisabled));
	if(ifail==0) {
		printf("Registering action handler addDisabled successful\n");
	} else {
		printf("Registering action handler addDisabled failed %d\n", ifail);
	}
	//添加失效状态并传递中间表
	( ifail = EPM_register_action_handler("tx_addDisabled", "天信添加失效状态",(EPM_action_handler_t) tx_addDisabled));
	if(ifail==0) {
		printf("Registering action handler tx_addDisabled successful\n");
	} else {
		printf("Registering action handler tx_addDisabled failed %d\n", ifail);
	}
	//给历史物料添加状态，状态可以自定义
	( ifail = EPM_register_action_handler("historicalDataAddMark", "历史物料添加状态",(EPM_action_handler_t) historicalDataAddMark));
	if(ifail==0) {
		printf("Registering action handler historicalDataAddMark successful\n");
	} else {
		printf("Registering action handler historicalDataAddMark failed %d\n", ifail);
	}	
	//天信erp集成
	( ifail = EPM_register_action_handler("tx_erp_bom", "天信erp集成传递BOM",(EPM_action_handler_t) tx_erp_bom));
	if(ifail==0) {
		printf("Registering action handler tx_erp_bom successful\n");
	} else {
		printf("Registering action handler tx_erp_bom failed %d\n", ifail);
	}
	//天信erp集成
	( ifail = EPM_register_action_handler("tx_erp", "天信erp集成传递物料",(EPM_action_handler_t) tx_erp));
	if(ifail==0) {
		printf("Registering action handler tx_erp successful\n");
	} else {
		printf("Registering action handler tx_erp failed %d\n", ifail);
	}
	//删除失效状态
	( ifail = EPM_register_action_handler("removeDisabled", "添加失效状态",(EPM_action_handler_t) removeDisabled));
	if(ifail==0) {
		printf("Registering action handler removeDisabled successful\n");
	} else {
		printf("Registering action handler removeDisabled failed %d\n", ifail);
	}
	//删除失效状态
	( ifail = EPM_register_action_handler("tx_removeDisabled", "天信添加失效状态",(EPM_action_handler_t) tx_removeDisabled));
	if(ifail==0) {
		printf("Registering action handler tx_removeDisabled successful\n");
	} else {
		printf("Registering action handler tx_removeDisabled failed %d\n", ifail);
	}
	//EBOM变更驱动MBOM变更
	( ifail = EPM_register_action_handler("jk_upgrade_version", "EBOM变更驱动MBOM变更",(EPM_action_handler_t) jk_upgrade_version));
	if(ifail==0) {
		printf("Registering action handler jk_upgrade_version successful\n");
	} else {
		printf("Registering action handler jk_upgrade_version failed %d\n", ifail);
	}
//	ifail = EPM_register_action_handler("sendMaterialInfomationAddDisabled", "发送失效状态",(EPM_action_handler_t) sendMaterialInfomationAddDisabled);
//	if(ifail==0) {
//		printf("Registering action handler sendMaterialInfomationAddDisabled successful\n");
//	} else {
//		printf("Registering action handler sendMaterialInfomationAddDisabled failed %d\n", ifail);
//	}
	//合众
	/*( ifail = EPM_register_action_handler("HZ_attach_assembly", "HZ_attach_assembly",(EPM_action_handler_t) HZ_attach_assembly));
	if(ifail==0) {
		printf("Registering action handler HZ_attach_assembly successful\n");
	} else {
		printf("Registering action handler HZ_attach_assembly failed %d\n", ifail);
	}

	( ifail = EPM_register_rule_handler("HZ_Check_BOM_Condition", "HZ_Check_BOM_Condition",(EPM_rule_handler_t) HZ_Check_BOM_Condition));
	if(ifail==0) {
		printf("Registering rule handler HZ_Check_BOM_Condition successful\n");
	} else {
		printf("Registering rule handler HZ_Check_BOM_Condition failed %d\n", ifail);
	}

	( ifail = EPM_register_action_handler("HZ_Doc_Released", "HZ_Doc_Released",(EPM_action_handler_t) hz_auto_revison_to_folder));
	if(ifail==0) {
		printf("Registering action handler HZ_Doc_Released successful\n");
	} else {
		printf("Registering action handler HZ_Doc_Released failed %d\n", ifail);
	}
	//检查状态
	( ifail = EPM_register_rule_handler("HZ-check-related-objects", "HZ-check-related-objects",(EPM_rule_handler_t) hz_status_check));
	if(ifail==0) {
		printf("Registering action handler HZ-check-related-objects successful\n");
	} else {
		printf("Registering action handler HZ-check-related-objects failed %d\n", ifail);
	}
	*/
	//ifail = EPM_register_action_handler("QTM2_attach_components","attach components",
	//	(EPM_action_handler_t)qtm2_attach_components);
	//if(ifail == ITK_ok)
	//{
	//	fprintf(stdout,"Registering QTM2_attach_components\n");
	//}
	return ifail;
}
//
//定义JAVA调用的服务
//register service method
extern DLLAPI int USERSERVICE_custom_register_methods(int *decision, va_list args)
{
	int 
		status = ITK_ok,
		numberOfArguments = 0,
		returnValueType = USERARG_STRING_TYPE,
		*argumentList = NULL;
	USER_function_t functionPtr;

	//QTM_ebom_to_pbom
	//规定java需要传递过来的个数
	numberOfArguments = 1;
	//需要调用的函数地址函数地址
	functionPtr = ORIGIN_set_bypass;
	//定义java需要传递的参数
	argumentList = (int*)MEM_alloc(numberOfArguments * sizeof(int) );
	argumentList[0] = USERARG_STRING_TYPE;
	//argumentList[1] = USERARG_DATE_TYPE;
	//argumentList[2] = USERARG_STRING_TYPE +USERARG_ARRAY_TYPE;
	//argumentList[1] = USERARG_STRING_TYPE + USERARG_ARRAY_TYPE;
	//returnValueType = USERARG_STRING_TYPE;
	//定义返回值的类型
	returnValueType = USERARG_VOID_TYPE;
	ITKCALL(status = USERSERVICE_register_method("Connor_set_bypass", functionPtr, numberOfArguments,
		argumentList, returnValueType ));
	MEM_free(argumentList);
	if(status == ITK_ok)
	{
		fprintf( stdout, "\n Registering Connor_set_bypass finished\n" );
	}
	else
	{
		fprintf( stdout, "\n Registering Connor_set_bypass failed %d\n" , status );
	}



	//===========================================


	numberOfArguments = 1;
	//需要调用的函数地址函数地址
	functionPtr = remove_class;
	//定义java需要传递的参数
	argumentList = (int*)MEM_alloc(numberOfArguments * sizeof(int) );
	argumentList[0] = USERARG_STRING_TYPE;
	
	returnValueType = USERARG_VOID_TYPE; 
	ITKCALL(status = USERSERVICE_register_method("IcoRemove", functionPtr, numberOfArguments,
		argumentList, returnValueType ));
	MEM_free(argumentList);
	if(status == ITK_ok)
	{
		fprintf( stdout, "\n Registering ORIGIN_set_bypass finished\n" );
	}
	else
	{
		fprintf( stdout, "\n Registering ORIGIN_set_bypass failed %d\n" , status );
	}



	//===========================================

	numberOfArguments = 1;
	//需要调用的函数地址函数地址
	functionPtr = ORIGIN_set_bypass;
	//定义java需要传递的参数
	argumentList = (int*)MEM_alloc(numberOfArguments * sizeof(int) );
	argumentList[0] = USERARG_STRING_TYPE;
	//argumentList[1] = USERARG_DATE_TYPE;
	//argumentList[2] = USERARG_STRING_TYPE +USERARG_ARRAY_TYPE;
	//argumentList[1] = USERARG_STRING_TYPE + USERARG_ARRAY_TYPE;
	//returnValueType = USERARG_STRING_TYPE;
	//定义返回值的类型
	returnValueType = USERARG_VOID_TYPE;
	ITKCALL(status = USERSERVICE_register_method("ORIGIN_set_bypass", functionPtr, numberOfArguments,
		argumentList, returnValueType ));
	MEM_free(argumentList);
	if(status == ITK_ok)
	{
		fprintf( stdout, "\n Registering ORIGIN_set_bypass finished\n" );
	}
	else
	{
		fprintf( stdout, "\n Registering ORIGIN_set_bypass failed %d\n" , status );
	}


	//===========================================

	numberOfArguments = 1;
	functionPtr = ORIGIN_close_bypass;
	argumentList = (int*)MEM_alloc(numberOfArguments * sizeof(int) );
	argumentList[0] = USERARG_STRING_TYPE;
	//argumentList[1] = USERARG_STRING_TYPE + USERARG_ARRAY_TYPE;
	//returnValueType = USERARG_STRING_TYPE;
	returnValueType = USERARG_VOID_TYPE;
	ITKCALL(status = USERSERVICE_register_method("Connor_close_bypass", functionPtr, numberOfArguments,
		argumentList, returnValueType ));
	MEM_free(argumentList);
	if(status == ITK_ok)
	{
		fprintf( stdout, "\n Registering Connor_close_bypass finished\n" );
	}
	else
	{
		fprintf( stdout, "\n Registering Connor_close_bypass failed %d\n" , status );
	}
	//=============================================
	numberOfArguments = 1;
	functionPtr = ORIGIN_close_bypass;
	argumentList = (int*)MEM_alloc(numberOfArguments * sizeof(int) );
	argumentList[0] = USERARG_STRING_TYPE;
	//argumentList[1] = USERARG_STRING_TYPE + USERARG_ARRAY_TYPE;
	//returnValueType = USERARG_STRING_TYPE;
	returnValueType = USERARG_VOID_TYPE;
	ITKCALL(status = USERSERVICE_register_method("ORIGIN_close_bypass", functionPtr, numberOfArguments,
		argumentList, returnValueType ));
	MEM_free(argumentList);
	if(status == ITK_ok)
	{
		fprintf( stdout, "\n Registering ORIGIN_close_bypass finished\n" );
	}
	else
	{
		fprintf( stdout, "\n Registering ORIGIN_close_bypass failed %d\n" , status );
	}
	//=================================================================
	numberOfArguments = 1;
	functionPtr = getDbMsg;
	argumentList = (int*)MEM_alloc(numberOfArguments * sizeof(int) );
	argumentList[0] = USERARG_STRING_TYPE;
	//argumentList[1] = USERARG_STRING_TYPE + USERARG_ARRAY_TYPE;
	//returnValueType = USERARG_STRING_TYPE;
	returnValueType = USERARG_VOID_TYPE;
	ITKCALL(status = USERSERVICE_register_method("HX_GetProjMsg", functionPtr, numberOfArguments,
		argumentList, returnValueType ));
	MEM_free(argumentList);
	if(status == ITK_ok)
	{
		fprintf( stdout, "\n Registering HX_GetProjMsg finished\n" );
	}
	else
	{
		fprintf( stdout, "\n Registering HX_GetProjMsg failed %d\n" , status );
	}

	//=============================================

	numberOfArguments = 2;
	functionPtr = connor_set_release_status;
	argumentList = (int*)MEM_alloc(numberOfArguments * sizeof(int) );
	argumentList[0] =USERARG_TAG_TYPE ;
	argumentList[1] =USERARG_STRING_TYPE ;
	returnValueType = USERARG_VOID_TYPE;
	ITKCALL(status = USERSERVICE_register_method("connor_set_release_status", functionPtr, numberOfArguments,
		argumentList, returnValueType ));
	MEM_free(argumentList);
	if(status == ITK_ok)
	{
		fprintf( stdout, "\n Registering connor_set_release_status finished\n" );
	}
	else
	{
		fprintf( stdout, "\n Registering connor_set_release_status failed %d\n" , status );
	}

	//=======================
	numberOfArguments = 1;
	functionPtr = USERSEVICE_TEST;
	argumentList = (int*)MEM_alloc(numberOfArguments * sizeof(int) );
	argumentList[0] =USERARG_TAG_TYPE ;
	returnValueType = USERARG_VOID_TYPE;
	ITKCALL(status = USERSERVICE_register_method("SendItem", functionPtr, numberOfArguments,
		argumentList, returnValueType ));
	MEM_free(argumentList);
	if(status == ITK_ok)
	{
		fprintf( stdout, "\n Registering SendItem finished\n" );
	}
	else
	{
		fprintf( stdout, "\n Registering SendItem failed %d\n" , status );
	}

	//=======================

	*decision = ALL_CUSTOMIZATIONS;
	METHOD_id_t mth_tag;
	//int status  = ITK_ok;
	    
	/*
	{
		
            ITKCALL( METHOD_find_prop_method ( "HX3_GYTRevision", "HX3_MUJT", PROP_set_value_tags_msg, &mth_tag ) );
            if ( mth_tag.id != NULLTAG )
            {
				printf("find HX3_GYTRevision HX3_MUJT \n ");
                ITKCALL(status = METHOD_add_action( mth_tag, METHOD_post_action_type,( METHOD_function_t ) HX3_post_prop_set_MJ, NULL ) );
				if(status == ITK_ok){
					printf("success HX3_MUJT \n ");
				}else{
					printf("faild HX3_MUJT \n ");
				}
			}else{
				printf("not find HX3_GYTRevision HX3_MUJT \n ");
			}
	}  

	{
        ITKCALL( METHOD_find_prop_method ( "JK8MaterialRevisionMaster", "jk8SpecModel", PROP_set_value_string_msg, &mth_tag ) );
        if ( mth_tag.id != NULLTAG )
        {
			printf("find HX3_GYTRevision JK8Material \n ");
            ITKCALL(status = METHOD_add_action( mth_tag, METHOD_pre_action_type,( METHOD_function_t ) LP_set_prop, NULL ) );
			if(status == ITK_ok){
				printf("success JK8Material \n ");
			}else{
				printf("faild JK8Material \n ");
			}
		}else{
			printf("not find JK8Material HX3_JIANJT \n ");
		}
	} 

	{
        ITKCALL( METHOD_find_prop_method ( "HX3_ZPTRevision", "last_mod_date", PROP_set_value_date_msg, &mth_tag ) );
        if ( mth_tag.id != NULLTAG )
        {
			printf("find HX3_ZPTRevision last_mod_date \n ");
            ITKCALL(status = METHOD_add_action( mth_tag, METHOD_post_action_type,( METHOD_function_t ) HX3_mod_date, NULL ) );
			if(status == ITK_ok){
				printf("success last_mod_date \n ");
			}else{
				printf("faild last_mod_date \n ");
			}
		}else{
			printf("not find HX3_ZPTRevision last_mod_date \n ");
		}
	} 
	*/

	return(status);
}

extern DLLAPI int USERSERVICE_custom_register_runtime_methods(int *decision, va_list args)
{
	int status = ITK_ok;
	METHOD_id_t method;
	
	ITKCALL(status = METHOD_register_prop_method ("JCI6_ProgramInfo", "", PROP_ask_value_string_msg,
								(METHOD_function_t) HX3_regist_runtime_prop,0, &method));
	if(status != ITK_ok){
		printf("进行Runtime属性注册的时候失败\n");
	}

	if (method.id == 0){

	}

	return(status);

}
