You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

275 lines
7.5 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

/*===================================================================================================
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 <tccore/method.h>
#include <tccore/tc_msg.h>
/**
* @headerfile user's header files
*/
#include "epm_register_handler.h"
#include "connor_util.h"
#include "Supor_register.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;
int status = ITK_ok;
//指派人员
(ifail = EPM_register_action_handler("Connor_ChangeTask_AssignUser", "Connor_ChangeTask_AssignUser", (EPM_action_handler_t)Connor_ChangeTask_AssignUser));
if (ifail == 0)
{
printf("Registering action handler Connor_ChangeTask_AssignUser success\n");
}
else
{
printf("Registering action handler Connor_ChangeTask_AssignUser failed\n");
}
(ifail = EPM_register_action_handler("Connor_ChangeTask_SetComments", "Connor_ChangeTask_SetComments", (EPM_action_handler_t)Connor_ChangeTask_SetComments));
if (ifail == 0)
{
printf("Registering action handler Connor_ChangeTask_SetComments success\n");
}
else
{
printf("Registering action handler Connor_ChangeTask_SetComments failed\n");
}
(ifail = EPM_register_action_handler("Connor_ChangeTask_CheckValue", "Connor_ChangeTask_CheckValue", (EPM_action_handler_t)Connor_ChangeTask_CheckValue));
if (ifail == 0)
{
printf("Registering action handler Connor_ChangeTask_CheckValue success\n");
}
else
{
printf("Registering action handler Connor_ChangeTask_CheckValue failed\n");
}
(ifail = EPM_register_action_handler("Connor_signoff_dataset", "对数据集进行电子签名", (EPM_action_handler_t)Connor_signoff_dataset));
if(ifail==0)
{
printf("Registering action handler Connor_signoff_dataset success\n");
}else
{
printf("Registering action handler Supor_signoff_dataset failed\n");
}
(ifail = EPM_register_action_handler("Connor_signoff_form", "将审签信息记录到表单上", (EPM_action_handler_t)Connor_signoff_form));
if (ifail == 0)
{
printf("Registering action handler Connor_signoff_form success\n");
}
else
{
printf("Registering action handler Connor_signoff_form failed\n");
}
(ifail = EPM_register_action_handler("Connor_ChangeTask_SetValue", "Connor_ChangeTask_SetValue", (EPM_action_handler_t)Connor_ChangeTask_SetValue));
if (ifail == 0)
{
printf("Registering action handler Connor_ChangeTask_SetValue success\n");
}
else
{
printf("Registering action handler Connor_ChangeTask_SetValue failed\n");
}
//创建后操
(ifail = METHOD_find_method("Item", ITEM_create_msg, &mth_tag));//参数1类型支持原生和客制化的参数2操作类型
if (mth_tag.id != 0) {
(ifail = METHOD_add_action(mth_tag, METHOD_post_action_type, Connor_CreateItemPost, NULL));//参数2执行操作的时刻支持前操作和后操作
fprintf(stdout, "regist Connor_CreateItemPost post_action successfully !\n");
}
else {
fprintf(stdout, "regist Connor_CreateItemPost post_action fiald !\n");
}
return ifail;
}
//定义JAVA调用的服务
//register service method
extern DLLAPI int USERSERVICE_custom_register_methods(int *decision, va_list args)
{
int ifail = ITK_ok;
METHOD_id_t mth_tag;
int
status = ITK_ok,
numberOfArguments = 0,
returnValueType = USERARG_STRING_TYPE,
*argumentList = NULL;
USER_function_t functionPtr;
numberOfArguments = 2;
//需要调用的函数地址函数地址
functionPtr = Supor_add_release_status;
//定义java需要传递的参数
argumentList = (int*)MEM_alloc(numberOfArguments * sizeof(int) );
argumentList[0] = USERARG_STRING_TYPE;
argumentList[1] = USERARG_STRING_TYPE;
//定义返回值的类型
returnValueType = USERARG_STRING_TYPE;
ITKCALL(status = USERSERVICE_register_method("Supor_add_release_status", functionPtr, numberOfArguments,
argumentList, returnValueType ));
MEM_free(argumentList);
if(status == ITK_ok)
{
fprintf( stdout, "RegisteringSupor_add_release_status\n" );
}
else
{
fprintf( stdout, "Registering[%d]Supor_add_release_status\n" , status );
}
numberOfArguments = 1;
functionPtr = ITK_server_bypass;
argumentList = (int*)MEM_alloc(numberOfArguments * sizeof(int) );
argumentList[0] = USERARG_STRING_TYPE;
returnValueType = USERARG_VOID_TYPE;
ITKCALL(status = USERSERVICE_register_method("ITK_server_bypass", functionPtr, numberOfArguments,
argumentList, returnValueType ));
MEM_free(argumentList);
if(status == ITK_ok)
{
fprintf( stdout, "\n Registering ITK_server_bypass finished\n" );
}
else
{
fprintf( stdout, "\n Registering ITK_server_bypass failed %d\n" , status );
}
numberOfArguments = 1;
functionPtr = Supor_open_bypass;
argumentList = (int*)MEM_alloc(numberOfArguments * sizeof(int));
argumentList[0] = USERARG_STRING_TYPE;
returnValueType = USERARG_VOID_TYPE;
ITKCALL(status = USERSERVICE_register_method("Supor_open_bypass", functionPtr, numberOfArguments,
argumentList, returnValueType));
MEM_free(argumentList);
if (status == ITK_ok)
{
fprintf(stdout, "RegisteringSupor_open_bypass\n");
}
else
{
fprintf(stdout, "Registering[%d]Supor_open_bypass\n", status);
}
numberOfArguments = 1;
functionPtr = Supor_close_bypass;
argumentList = (int*)MEM_alloc(numberOfArguments * sizeof(int));
argumentList[0] = USERARG_STRING_TYPE;
returnValueType = USERARG_VOID_TYPE;
ITKCALL(status = USERSERVICE_register_method("Supor_close_bypass", functionPtr, numberOfArguments,
argumentList, returnValueType));
MEM_free(argumentList);
if (status == ITK_ok)
{
fprintf(stdout, "RegisteringSupor_close_bypass\n");
}
else
{
fprintf(stdout, "Registering[%d]Supor_close_bypass\n", status);
}
return ITK_ok;
}