
#include <tccore/custom.h>
#include <server_exits/user_server_exits.h>
#include <tccore/item_msg.h>
#include <epm/epm.h>
//#include "register_handler_head.h"
#include "register_handler_methods.h"


//供流程调用的
// 标准的注册供流程调用服务handler的入口 TC_save_msg



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;

	int status = ITK_ok;




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


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


	(ifail = EPM_register_action_handler("jy-create-material-code", "", (EPM_action_handler_t)jy_create_material_code));
	if (ifail == 0) {
		printf("Registering action handler jy-create-material-code successful\n");
	}
	else {
		printf("Registering action handler jy-create-material-code failed %d\n", ifail);
	}

	(ifail = EPM_register_action_handler("xy-assign-form-props", "", (EPM_action_handler_t)xy_assign_form_props));
	if (ifail == 0) {
		printf("Registering action handler xy-assign-form-props successful\n");
	}
	else {
		printf("Registering action handler xy-assign-form-props failed %d\n", ifail);
	}

	return ifail;
}


int Connor_open_bypass(void* returnValue)
{
	int ifail = ITK_ok;
	char* propname;
	ITKCALL(ifail = USERARG_get_string_argument(&propname));
	printf("propname=================%s\n", propname);
	if (strcmp(propname, "true") == 0) {
		POM_AM__set_application_bypass(TRUE);
	}
	else {
		POM_AM__set_application_bypass(FALSE);
	}

	return  0;
}

//
//定义JAVA调用的服务
//register service method
int USERSERVICE_custom_register_methods(int* decision, va_list args)
{


	int ifail = ITK_ok;
	int status = ITK_ok,
		numberOfArguments = 0,
		returnValueType = USERARG_STRING_TYPE,
		* argumentList = NULL;
	USER_function_t functionPtr;

	//开旁路

	numberOfArguments = 1;
	functionPtr = Connor_open_bypass;
	argumentList = (int*)MEM_alloc(numberOfArguments * sizeof(int));
	argumentList[0] = USERARG_STRING_TYPE;
	returnValueType = USERARG_VOID_TYPE;

	ITKCALL(status = USERSERVICE_register_method("setbypass", functionPtr, numberOfArguments,
		argumentList, returnValueType));
	MEM_free(argumentList);
	if (status == ITK_ok)
	{
		fprintf(stdout, "\n Registering setbypass finished\n");
	}
	else
	{
		fprintf(stdout, "\n Registering setbypass failed %d\n", status);
	}
	return 0;
}