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.

191 lines
4.2 KiB

/*===================================================================================================
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 "mdbks_register.h"
#include "connor_itk_util.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;
int status = ITK_ok;
//checkSRM
(ifail = EPM_register_rule_handler("JK_check_has_material_and_ecn", "JK_check_has_material_and_ecn", (EPM_rule_handler_t)JK_check_has_material_and_ecn));//汇总表
if (ifail == 0) {
printf("Registering rule handler JK_check_has_material_and_ecn successful\n");
}
else {
printf("Registering rule handler JK_check_has_material_and_ecn failed %d\n", ifail);
}
//SRM下发
ifail = EPM_register_action_handler("JK_Send_SRM", "JK_Send_SRM",
(EPM_action_handler_t)JK_Send_SRM);
if (ifail == ITK_ok)
{
fprintf(stdout, "Registering action handler JK_Send_SRM completed!\n");
}
else
{
fprintf(stdout, "Registering action handler JK_Send_SRM failed %d!\n", ifail);
}
//CloseLog();
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
extern DLLAPI 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;
}