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.

210 lines
4.9 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)
{
char* log_file = NULL;
printf("创建日志文件\n");
char* TO_SRM = (char*)malloc(sizeof("TO_SRM"));
strcpy(TO_SRM, "TO_SRM");
CreateLogFile(TO_SRM, &log_file);
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) {
WriteLog("Registering action handler Auto-Signoff-Info successful\n");
}
else {
WriteLog("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) {
WriteLog("Registering action handler Check-And-Signoff successful\n");
}
else {
WriteLog("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) {
WriteLog("Registering action handler jy-create-material-code successful\n");
}
else {
WriteLog("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) {
WriteLog("Registering action handler xy-assign-form-props successful\n");
}
else {
WriteLog("Registering action handler xy-assign-form-props 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;
}