commit
f48201c70a
@ -0,0 +1,3 @@
|
|||||||
|
.git.zip
|
||||||
|
jf_itk.sdf
|
||||||
|
JK_itk.sdf
|
||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -0,0 +1,290 @@
|
|||||||
|
/**
|
||||||
|
* @file common_itk_util.cpp
|
||||||
|
* @brief itk warpper utility function
|
||||||
|
* @author James
|
||||||
|
* @history
|
||||||
|
* ===================================================================================
|
||||||
|
* Date Name Description of Change
|
||||||
|
* 18-July-2008 James
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma warning (disable: 4996)
|
||||||
|
#pragma warning (disable: 4819)
|
||||||
|
|
||||||
|
#include <epm/epm.h>
|
||||||
|
#include <epm/epm_toolkit_tc_utils.h>
|
||||||
|
#include <ict/ict_userservice.h>
|
||||||
|
#include <tccore/item.h>
|
||||||
|
#include <ae/ae.h>
|
||||||
|
#include <tc/folder.h>
|
||||||
|
#include <tccore/aom.h>
|
||||||
|
#include <sa/sa.h>
|
||||||
|
#include <tccore/aom_prop.h>
|
||||||
|
#include <property/prop_errors.h>
|
||||||
|
#include <tccore/workspaceobject.h>
|
||||||
|
#include <tc/preferences.h>
|
||||||
|
#include <tccore/imantype.h>
|
||||||
|
#include <tccore//grm.h>
|
||||||
|
#include <tccore/grmtype.h>
|
||||||
|
#include <sa/am.h>
|
||||||
|
#include <cfm/cfm.h>
|
||||||
|
#include <bom/bom.h>
|
||||||
|
#include <tccore/uom.h>
|
||||||
|
#include <ps/ps.h>
|
||||||
|
#include <epm/signoff.h>
|
||||||
|
#include <fclasses/tc_date.h>
|
||||||
|
//#include <tccore/imantype.h>
|
||||||
|
//#include <textsrv/textserver.h>
|
||||||
|
//#include <user_exits/epm_toolkit_utils.h>
|
||||||
|
//#include <ss/ss_errors.h>
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
//#include <io.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <time.h>
|
||||||
|
//#include <direct.h>
|
||||||
|
//#include <unistd.h>
|
||||||
|
#include "error_handling.h"
|
||||||
|
#include "common_itk_util.h"
|
||||||
|
|
||||||
|
#ifdef WIN32
|
||||||
|
#include <io.h>
|
||||||
|
#include <direct.h>
|
||||||
|
#else
|
||||||
|
#include <unistd.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#define ARGS_LENGTH 200
|
||||||
|
#define ARGS_NAME_DEBUG "-debug"
|
||||||
|
#define DEBUG "-debug="
|
||||||
|
#define MAX_PRINTLINE_LENGTH 2000
|
||||||
|
#define MAX_PATH_LENGTH 2000
|
||||||
|
#define MAX_ARGUMENT_LENGTH 400
|
||||||
|
#define MAX_PARAMNAME_LENGTH 50
|
||||||
|
#define MAX_FILE_EXT_LENGTH 10
|
||||||
|
#define TRUE_FLAG 1
|
||||||
|
#define FALSE_FLAG 0
|
||||||
|
#define DETAILLOG 1
|
||||||
|
|
||||||
|
extern "C" int AM__set_application_bypass(logical bypass);
|
||||||
|
|
||||||
|
void ECHO(char *format, ...)
|
||||||
|
{
|
||||||
|
//if( !YFJC_OPT_DEBUG )
|
||||||
|
// return;
|
||||||
|
|
||||||
|
char msg[1024];
|
||||||
|
va_list args;
|
||||||
|
|
||||||
|
va_start( args, format );
|
||||||
|
vsprintf( msg, format, args );
|
||||||
|
va_end( args );
|
||||||
|
|
||||||
|
printf( msg );
|
||||||
|
TC_write_syslog( msg );
|
||||||
|
}
|
||||||
|
|
||||||
|
FILE* logFile = NULL;
|
||||||
|
|
||||||
|
void set_bypass(logical bypass)
|
||||||
|
{
|
||||||
|
AM__set_application_bypass(bypass);
|
||||||
|
}
|
||||||
|
/*=============================================================================*
|
||||||
|
* FUNCTION: current_time
|
||||||
|
* PURPOSE : get the current datetime
|
||||||
|
* INPUT:
|
||||||
|
* date_t* date_tag // current date time tag
|
||||||
|
*
|
||||||
|
* RETURN:
|
||||||
|
* void
|
||||||
|
*============================================================================*/
|
||||||
|
void current_time( date_t * date_tag )
|
||||||
|
{
|
||||||
|
time_t ltime;
|
||||||
|
struct tm *today ;
|
||||||
|
|
||||||
|
// Set time zone from TZ environment variable. If TZ is not set,
|
||||||
|
// the operating system is queried to obtain the default value
|
||||||
|
// for the variable.
|
||||||
|
//
|
||||||
|
//_tzset();
|
||||||
|
|
||||||
|
// Get UNIX-style time and display as number and string.
|
||||||
|
time( <ime );
|
||||||
|
|
||||||
|
today = localtime( <ime );
|
||||||
|
date_tag->year = today->tm_year + 1900 ;
|
||||||
|
date_tag->month = today->tm_mon ;
|
||||||
|
date_tag->day = today->tm_mday ;
|
||||||
|
date_tag->hour = today->tm_hour ;
|
||||||
|
date_tag->minute = today->tm_min ;
|
||||||
|
date_tag->second = today->tm_sec ;
|
||||||
|
}
|
||||||
|
/*=============================================================================*
|
||||||
|
* FUNCTION: CreateLogFile
|
||||||
|
* PURPOSE : create log file
|
||||||
|
* INPUT:
|
||||||
|
* char* FunctionName // the funtion which need to create log file
|
||||||
|
* FILE** logFile // out: the log file pointer
|
||||||
|
*
|
||||||
|
* RETURN:
|
||||||
|
* void
|
||||||
|
*============================================================================*/
|
||||||
|
void CreateLogFile(char* FunctionName, char **fullname)
|
||||||
|
{
|
||||||
|
int i=0, ifail = ITK_ok;
|
||||||
|
//date_t status_now;
|
||||||
|
//char* date_string = NULL;
|
||||||
|
char date_string[MAX_PATH_LENGTH];
|
||||||
|
char logFileDir[MAX_PATH_LENGTH];
|
||||||
|
char logFileName[MAX_PATH_LENGTH];
|
||||||
|
|
||||||
|
char* session_uid = NULL;
|
||||||
|
tag_t session_tag = NULLTAG;
|
||||||
|
time_t now;
|
||||||
|
struct tm *p;
|
||||||
|
|
||||||
|
time(&now);
|
||||||
|
|
||||||
|
logFile = NULL;
|
||||||
|
//current_time(&status_now);
|
||||||
|
p=localtime(&now);
|
||||||
|
|
||||||
|
memset(date_string, 0, sizeof(date_string));
|
||||||
|
sprintf(date_string,"%4d%02d%02d%02d%02d%02d",1900+p->tm_year,p->tm_mon+1 ,p->tm_mday ,p->tm_hour,p->tm_min ,p->tm_sec );
|
||||||
|
//if( DATE_date_to_string( status_now, "%Y%m%d%H%M%S", &date_string) != ITK_ok )
|
||||||
|
//ifail = ITK_date_to_string (status_now, &date_string );
|
||||||
|
//if (ifail)
|
||||||
|
//{
|
||||||
|
// printf("!*ERROR*!: Failed to get current date time\n");
|
||||||
|
// goto CLEANUP;
|
||||||
|
//}
|
||||||
|
|
||||||
|
memset(logFileDir, 0, sizeof(logFileDir));
|
||||||
|
memset(logFileName, 0, sizeof(logFileName));
|
||||||
|
//get log dir
|
||||||
|
sprintf(logFileDir, "%s", getenv("TEMP"));
|
||||||
|
printf("\n log file dir: %s\n", logFileDir);
|
||||||
|
//try to change dir to TC_USER_LOG_DIR
|
||||||
|
if(chdir(logFileDir)!=ITK_ok)
|
||||||
|
{
|
||||||
|
//not set TC_USER_LOG_DIR
|
||||||
|
//log in to default TC_LOG
|
||||||
|
memset(logFileDir, 0, sizeof(logFileDir));
|
||||||
|
sprintf(logFileDir, "%s", getenv("TC_LOG"));
|
||||||
|
printf("\n TC_USER_LOG_DIR invalide, log file dir: %s\n", logFileDir);
|
||||||
|
if(chdir(logFileDir)!=ITK_ok)
|
||||||
|
{
|
||||||
|
//still can not change to log dir
|
||||||
|
printf("!*ERROR*!: Failed to change dir to TC_USER_LOG_DIR\n");
|
||||||
|
goto CLEANUP;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//get session_uid to make sure the log file name unique
|
||||||
|
POM_ask_session(&session_tag);
|
||||||
|
ITK__convert_tag_to_uid(session_tag, &session_uid);
|
||||||
|
|
||||||
|
|
||||||
|
//get logFileName
|
||||||
|
sprintf(logFileName, "%s_%s_%s.log", FunctionName, session_uid, date_string);
|
||||||
|
printf("log file name: %s\n", logFileName);
|
||||||
|
|
||||||
|
*fullname = (char *)MEM_alloc(sizeof(char)*512);
|
||||||
|
sprintf(*fullname,"%s\\%s",logFileDir,logFileName);
|
||||||
|
|
||||||
|
//for(i = 0; _access((char *)logFileName, 4) == 0; i++)
|
||||||
|
/*{
|
||||||
|
memset(logFileName, 0, sizeof(logFileName));
|
||||||
|
sprintf(logFileName, "%s_%s_%s_%d.log", FunctionName, session_uid, date_string, i);
|
||||||
|
}
|
||||||
|
printf("final log file name: %s\n", logFileName);*/
|
||||||
|
|
||||||
|
//create log file
|
||||||
|
logFile = fopen(logFileName, "w");
|
||||||
|
|
||||||
|
CLEANUP:
|
||||||
|
//DOFREE(date_string);
|
||||||
|
DOFREE(session_uid);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*=============================================================================*
|
||||||
|
* FUNCTION: WriteLog
|
||||||
|
* PURPOSE : write log, if debug log File not null, write log message to log File
|
||||||
|
* INPUT:
|
||||||
|
* const char* format // debug message string
|
||||||
|
*
|
||||||
|
* RETURN:
|
||||||
|
* void
|
||||||
|
*============================================================================*/
|
||||||
|
void WriteLog(const char* format, ...)
|
||||||
|
{
|
||||||
|
va_list arg;
|
||||||
|
char tmp[MAX_PRINTLINE_LENGTH];
|
||||||
|
|
||||||
|
if(logFile)
|
||||||
|
{
|
||||||
|
//get the message
|
||||||
|
memset(tmp, 0, sizeof(tmp));
|
||||||
|
va_start(arg, format);
|
||||||
|
vsprintf(tmp, format, arg);
|
||||||
|
va_end(arg);
|
||||||
|
|
||||||
|
//----------print to command window for trace--------//
|
||||||
|
printf("%s\n", tmp);
|
||||||
|
|
||||||
|
//print message to log file
|
||||||
|
fprintf(logFile, "%s\n", tmp);
|
||||||
|
fflush(logFile);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
printf("*!Error!*: Log File Not Exist\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void CloseLog(void)
|
||||||
|
{
|
||||||
|
if(logFile)
|
||||||
|
{
|
||||||
|
fclose(logFile);
|
||||||
|
logFile = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//void getTypeinfo(char *type)
|
||||||
|
//{
|
||||||
|
// int ulen = 0,i=0,tempcount=0,asd=0;
|
||||||
|
//
|
||||||
|
// char temp[128]="";
|
||||||
|
// ulen = strlen(type);
|
||||||
|
// asd = ulen-1;
|
||||||
|
// for(i=0;i < ulen;i++)
|
||||||
|
// {
|
||||||
|
// if(type[i] == ';')
|
||||||
|
// {
|
||||||
|
// temp[tempcount] = '\0';
|
||||||
|
// strcpy(excludetypes[typecount].type,temp);
|
||||||
|
// strcpy(temp,"");
|
||||||
|
// tempcount = 0;
|
||||||
|
// typecount = typecount + 1;
|
||||||
|
// }
|
||||||
|
// else
|
||||||
|
// {
|
||||||
|
//
|
||||||
|
// temp[tempcount] = type[i];
|
||||||
|
// tempcount = tempcount + 1;
|
||||||
|
// if(i==asd)
|
||||||
|
// {
|
||||||
|
// temp[tempcount] = '\0';
|
||||||
|
// strcpy(excludetypes[typecount].type,temp);
|
||||||
|
// typecount = typecount + 1;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
//}
|
||||||
@ -0,0 +1,42 @@
|
|||||||
|
/**
|
||||||
|
* @file common_itk_util.h
|
||||||
|
* @brief itk warpper utility function
|
||||||
|
* @author James
|
||||||
|
* @history
|
||||||
|
* ===================================================================================
|
||||||
|
* Date Name Description of Change
|
||||||
|
* 09-July-2008 James
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef COMMON_ITK_UTIL
|
||||||
|
#define COMMON_ITK_UTIL
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
|
||||||
|
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define DOFREE(obj) \
|
||||||
|
{ \
|
||||||
|
if(obj) \
|
||||||
|
{ \
|
||||||
|
MEM_free(obj); \
|
||||||
|
obj = NULL; \
|
||||||
|
} \
|
||||||
|
}
|
||||||
|
void ECHO(char *format, ...);
|
||||||
|
void CreateLogFile(char* FunctionName, char **fullname);
|
||||||
|
void WriteLog(const char* format, ...);
|
||||||
|
void CloseLog(void);
|
||||||
|
void set_bypass(logical bypass);
|
||||||
|
//int FindDatasetReferenceExt( tag_t datasettype, const char *datasettype_ref, char ext[10] );
|
||||||
|
//int CompareDate( date_t date1, date_t date2 );
|
||||||
|
//int GetRandomTempFile( char tempFile[256] );
|
||||||
|
//logical IsItemRevisionType( char object_type[WSO_name_size_c + 1] );
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
||||||
@ -0,0 +1,160 @@
|
|||||||
|
/*!
|
||||||
|
* @addtogroup common
|
||||||
|
* \file error_handling.h
|
||||||
|
* \brief 错误处理函数
|
||||||
|
* \date 2008/6/10
|
||||||
|
* \author Ray Li
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef SIMPLE_ERR_H_INCLUDED
|
||||||
|
#define SIMPLE_ERR_H_INCLUDED
|
||||||
|
|
||||||
|
|
||||||
|
#include <itk/mem.h>
|
||||||
|
#include <tc/iman.h>
|
||||||
|
#include <tc/emh.h>
|
||||||
|
#include <pom/pom/pom_errors.h>
|
||||||
|
#include <tc/emh_const.h>
|
||||||
|
#include <tc/tc.h>
|
||||||
|
#include <pom/pom/pom.h>
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <time.h>
|
||||||
|
|
||||||
|
#define BUFSIZE 512
|
||||||
|
|
||||||
|
|
||||||
|
//
|
||||||
|
//#define HANDLER_ARGUMENT_ERROR EMH_USER_error_base + 1
|
||||||
|
//#define WORKFLOW_NODE_IS_NOT_VALID EMH_USER_error_base + 2
|
||||||
|
//#define HANDLER_PLACED_INVALID EMH_USER_error_base + 3
|
||||||
|
//
|
||||||
|
////user errors define
|
||||||
|
////<error id="100">在站点文件中缺少 %1$ 配置,或该配置中无数据项</error>
|
||||||
|
//#define ERROR_PREFERENCE_NOT_FOUND (EMH_USER_error_base + 100)
|
||||||
|
|
||||||
|
|
||||||
|
#define DOFREE(obj) \
|
||||||
|
{ \
|
||||||
|
if(obj) \
|
||||||
|
{ \
|
||||||
|
MEM_free(obj); \
|
||||||
|
obj = NULL; \
|
||||||
|
} \
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//#define ECHO(X) printf X;
|
||||||
|
#define SYS_LOG(X) IMAN_write_syslog X;
|
||||||
|
#define LOG_ECHO(X) printf X; IMAN_write_syslog X;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \def CALL(x)
|
||||||
|
* 打印错误信息
|
||||||
|
*/
|
||||||
|
#define CALL(x) { \
|
||||||
|
int stat; \
|
||||||
|
char *err_string; \
|
||||||
|
if( (stat = (x)) != ITK_ok) \
|
||||||
|
{ \
|
||||||
|
EMH_ask_error_text (stat, &err_string); \
|
||||||
|
LOG_ECHO( ("ERROR: %d ERROR MSG: %s.\n",stat, err_string) ) \
|
||||||
|
LOG_ECHO( ("Function: %s FILE: %s LINE: %d\n", #x, __FILE__, __LINE__ ) ) \
|
||||||
|
MEM_free (err_string); \
|
||||||
|
return (stat); \
|
||||||
|
} \
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \def DO(x)
|
||||||
|
* 打印错误信息
|
||||||
|
*/
|
||||||
|
#define DO(x) { \
|
||||||
|
int stat; \
|
||||||
|
char *err_string; \
|
||||||
|
if( (stat = (x)) != POM_ok) \
|
||||||
|
{ \
|
||||||
|
EMH_ask_error_text (stat, &err_string); \
|
||||||
|
printf ("ERROR: %d ERROR MSG: %s.\n", stat, err_string); \
|
||||||
|
printf ("Function: %s FILE: %s LINE: %d\n",#x, __FILE__, __LINE__); \
|
||||||
|
MEM_free (err_string); \
|
||||||
|
} \
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \def CALLRNULL(x)
|
||||||
|
* 打印错误信息
|
||||||
|
*/
|
||||||
|
#define CALLRNULL(x) { \
|
||||||
|
int stat; \
|
||||||
|
char *err_string; \
|
||||||
|
if( (stat = (x)) != ITK_ok) \
|
||||||
|
{ \
|
||||||
|
EMH_ask_error_text (stat, &err_string); \
|
||||||
|
printf ("ERROR: %d ERROR MSG: %s.\n", stat, err_string); \
|
||||||
|
printf ("Function: %s FILE: %s LINE: %d\n",#x, __FILE__, __LINE__); \
|
||||||
|
MEM_free (err_string); \
|
||||||
|
return ((char *)NULL); \
|
||||||
|
} \
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \def CALL2(x)
|
||||||
|
* 打印错误信息
|
||||||
|
*/
|
||||||
|
#define CALL2(x) { \
|
||||||
|
int stat, n_ifails, *serverities, *ifails, err_count; \
|
||||||
|
char *err_string, **texts; \
|
||||||
|
if( (stat = (x)) != ITK_ok) \
|
||||||
|
{ \
|
||||||
|
printf ("Function: %s FILE: %s LINE: %d\n",#x, __FILE__, __LINE__); \
|
||||||
|
EMH_ask_errors( &n_ifails, (const int**)(&serverities), (const int**)(&ifails), (const char***)(&texts) );\
|
||||||
|
for( err_count=0; err_count<n_ifails; err_count++ ) \
|
||||||
|
{ \
|
||||||
|
printf( "ERROR: %d ERROR MSG: %s.\n", ifails[i], texts[i] ); \
|
||||||
|
} \
|
||||||
|
MEM_free( serverities ); \
|
||||||
|
MEM_free( ifails ); \
|
||||||
|
MEM_free( texts ); \
|
||||||
|
return (stat); \
|
||||||
|
} \
|
||||||
|
} \
|
||||||
|
|
||||||
|
#define CHECK_FILE(x,ret) { \
|
||||||
|
FILE *stream = NULL; \
|
||||||
|
if( (stream = fopen(x,"rb")) == NULL ) { \
|
||||||
|
printf( "%s doesn't exists, please check!\n", x ); \
|
||||||
|
IMAN_write_syslog( "%s doesn't exists, please check!\n", x) ; \
|
||||||
|
ret = -1; \
|
||||||
|
} \
|
||||||
|
else { \
|
||||||
|
fclose(stream); \
|
||||||
|
stream = NULL; \
|
||||||
|
ret = 0; \
|
||||||
|
} \
|
||||||
|
} \
|
||||||
|
|
||||||
|
|
||||||
|
#define CHECK_FILE_NOT_EXISTS(x,ret) { \
|
||||||
|
FILE *stream = NULL; \
|
||||||
|
if( (stream = fopen(x,"rb")) != NULL ) { \
|
||||||
|
fclose(stream); \
|
||||||
|
stream = NULL; \
|
||||||
|
printf( "%s exists, please check!\n", x ); \
|
||||||
|
IMAN_write_syslog( "%s exists, please check!\n", x) ; \
|
||||||
|
ret = -1; \
|
||||||
|
} \
|
||||||
|
else { \
|
||||||
|
ret = 0; \
|
||||||
|
} \
|
||||||
|
} \
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
||||||
@ -0,0 +1 @@
|
|||||||
|
# include "jf3_main.h"
|
||||||
@ -0,0 +1,57 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<ItemGroup>
|
||||||
|
<Filter Include="源文件">
|
||||||
|
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
|
||||||
|
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
|
||||||
|
</Filter>
|
||||||
|
<Filter Include="头文件">
|
||||||
|
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
|
||||||
|
<Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
|
||||||
|
</Filter>
|
||||||
|
<Filter Include="资源文件">
|
||||||
|
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
|
||||||
|
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
|
||||||
|
</Filter>
|
||||||
|
<Filter Include="common">
|
||||||
|
<UniqueIdentifier>{65de63f5-1c56-4dd5-8613-cf9edb74ee2c}</UniqueIdentifier>
|
||||||
|
</Filter>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClCompile Include="jf3_main.cpp">
|
||||||
|
<Filter>源文件</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="common_itk_util.c">
|
||||||
|
<Filter>common</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="ocilib.cxx">
|
||||||
|
<Filter>common</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="string_helper.cpp">
|
||||||
|
<Filter>common</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="string_utils.cxx">
|
||||||
|
<Filter>common</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClInclude Include="jf3_main.h">
|
||||||
|
<Filter>头文件</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="common_itk_util.h">
|
||||||
|
<Filter>common</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="ocilib.h">
|
||||||
|
<Filter>common</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="string_helper.h">
|
||||||
|
<Filter>common</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="string_utils.h">
|
||||||
|
<Filter>common</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="error_handling.h">
|
||||||
|
<Filter>common</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
</ItemGroup>
|
||||||
|
</Project>
|
||||||
@ -0,0 +1,98 @@
|
|||||||
|
/*=====================================================================================================================
|
||||||
|
Copyright(c) 2012 ORIGIN.
|
||||||
|
Unpublished - All rights reserved
|
||||||
|
=======================================================================================================================
|
||||||
|
File description:
|
||||||
|
|
||||||
|
Filename: ocilib.h
|
||||||
|
Module : OCI
|
||||||
|
|
||||||
|
This Header file of OCI library Package.
|
||||||
|
|
||||||
|
=======================================================================================================================
|
||||||
|
Date Name Description of Change
|
||||||
|
1-Feb-2015 Ray Initialize creation
|
||||||
|
$HISTORY$
|
||||||
|
=====================================================================================================================*/
|
||||||
|
#include <oci.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <memory.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <malloc.h>
|
||||||
|
//#include <limits.h>
|
||||||
|
|
||||||
|
#define OCI_FAIL 1
|
||||||
|
#define OCI_OK 0
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C"
|
||||||
|
{
|
||||||
|
#endif
|
||||||
|
/**
|
||||||
|
* 连接数据库.
|
||||||
|
* @param username - <I> 用户名
|
||||||
|
* @param password - <I> 密码
|
||||||
|
* @param dbname - <I> 数据库SID
|
||||||
|
* @return - OCI_OK or error code
|
||||||
|
*
|
||||||
|
* ORACLE 数据库的连接与封装函数
|
||||||
|
*/
|
||||||
|
extern int ConnServer(char *username,char *password,char *dbname);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 不带输入参数的执行SQL语句.
|
||||||
|
* @param SQL - <I> SQL语句
|
||||||
|
* @return - OCI_OK or error code
|
||||||
|
*
|
||||||
|
* ORACLE 数据库的连接与封装函数
|
||||||
|
*/
|
||||||
|
extern int ExecuteSQLNoInputParam(char *SQL);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 带输入参数的执行SQL语句.
|
||||||
|
* @param SQL - <I> SQL语句
|
||||||
|
* @param inputValueCount - <I> 输入参数数量
|
||||||
|
* @param inputValue - <I> 输入参数值
|
||||||
|
* @return - OCI_OK or error code
|
||||||
|
*
|
||||||
|
* ORACLE 数据库的连接与封装函数
|
||||||
|
*/
|
||||||
|
extern int ExecuteSQL(char *SQL,int inputValueCount,char **inputValue);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 不带输入参数的查询SQL语句.
|
||||||
|
* @param SQL - <I> SQL语句
|
||||||
|
* @param outputColumn - <O> 输出表的列的数量
|
||||||
|
* @param outputValueCount - <O> 输出表的行的数量
|
||||||
|
* @param outputValue - <O> 输出表内容
|
||||||
|
* @return - OCI_OK or error code
|
||||||
|
*
|
||||||
|
* ORACLE 数据库的连接与封装函数
|
||||||
|
*/
|
||||||
|
extern int QuerySQLNoInputParam(char *SQL, int * outputColumn, int * outputValueCount, char **** outputValue);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 带输入参数的查询SQL语句.
|
||||||
|
* @param SQL - <I> SQL语句
|
||||||
|
* @param inputValueCount - <I> 输入参数数量
|
||||||
|
* @param inputValue - <I> 输入参数值
|
||||||
|
* @param outputColumn - <O> 输出表的列的数量
|
||||||
|
* @param outputValueCount - <O> 输出表的行的数量
|
||||||
|
* @param outputValue - <O> 输出表内容
|
||||||
|
* @return - OCI_OK or error code
|
||||||
|
*
|
||||||
|
* ORACLE 数据库的连接与封装函数
|
||||||
|
*/
|
||||||
|
extern int QuerySQL(char *SQL, int inputValueCount, char ** inputValue, int * outputColumn, int * outputValueCount, char **** outputValue);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 断开数据库连接.
|
||||||
|
*
|
||||||
|
* ORACLE 数据库的连接与封装函数
|
||||||
|
*/
|
||||||
|
extern void DisConnServer();
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
@ -0,0 +1,146 @@
|
|||||||
|
/**
|
||||||
|
* @file string_helper.cpp
|
||||||
|
* @brief string utility functions' implemention
|
||||||
|
* @author James
|
||||||
|
* @history
|
||||||
|
* ===================================================================================
|
||||||
|
* Date Name Description of Change
|
||||||
|
* 09-July-2008 James
|
||||||
|
* 14-Jau-2009 James modify Split functions, add trim blank characters
|
||||||
|
*/
|
||||||
|
#pragma warning(disable:4996)
|
||||||
|
//
|
||||||
|
//#include <stdio.h>
|
||||||
|
//#include <iostream>
|
||||||
|
//#include <windows.h>
|
||||||
|
#include "string_helper.h"
|
||||||
|
|
||||||
|
string TrimString( string strArg )
|
||||||
|
{
|
||||||
|
size_t index1 = 0;
|
||||||
|
index1 = strArg.find_first_not_of( ' ');
|
||||||
|
if( index1 != string::npos )
|
||||||
|
strArg.erase( strArg.begin(), strArg.begin()+index1 );
|
||||||
|
index1 = strArg.find_last_not_of( ' ');
|
||||||
|
if( index1 != string::npos )
|
||||||
|
strArg.erase( strArg.begin() + index1 + 1 );
|
||||||
|
return strArg;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Split( string strArg, char spliter, vector<string> &ans )
|
||||||
|
{
|
||||||
|
ans.clear();
|
||||||
|
size_t index0 = 0;
|
||||||
|
string one_arg;
|
||||||
|
if ( strArg.find_first_not_of(' ') == string::npos )
|
||||||
|
strArg = "";
|
||||||
|
while( strArg.size()>0 )
|
||||||
|
{
|
||||||
|
index0 = strArg.find_first_of( spliter );
|
||||||
|
if( index0 != string::npos )
|
||||||
|
{
|
||||||
|
one_arg = strArg.substr( 0,index0 );
|
||||||
|
strArg = strArg.substr( index0 + 1 );
|
||||||
|
ans.push_back( one_arg );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ans.push_back( strArg );
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Split( string strArg, string spliter, vector<string> &ans )
|
||||||
|
{
|
||||||
|
|
||||||
|
ans.clear();
|
||||||
|
|
||||||
|
size_t index0;
|
||||||
|
string one_arg;
|
||||||
|
|
||||||
|
if ( strArg.find_first_not_of(" ") == string::npos )
|
||||||
|
strArg = "";
|
||||||
|
|
||||||
|
|
||||||
|
while( strArg.size()>0 )
|
||||||
|
{
|
||||||
|
|
||||||
|
index0 = strArg.find(spliter);
|
||||||
|
|
||||||
|
if( index0 != string::npos )
|
||||||
|
{
|
||||||
|
|
||||||
|
one_arg = strArg.substr( 0, index0 );
|
||||||
|
strArg = strArg.substr( index0 + spliter.size() );
|
||||||
|
|
||||||
|
ans.push_back( one_arg );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
|
||||||
|
ans.push_back( strArg );
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void RemoveLiner( string &in, string &out )
|
||||||
|
{
|
||||||
|
char buf[BUFSIZ] = "";
|
||||||
|
for( int i=0; i<(int)in.size(); i++ )
|
||||||
|
{
|
||||||
|
if( in[i] == '\n')
|
||||||
|
continue;
|
||||||
|
else
|
||||||
|
sprintf( buf,"%s%c", buf, in[i] );
|
||||||
|
}
|
||||||
|
out.assign(buf);
|
||||||
|
}
|
||||||
|
|
||||||
|
////Converting a WChar string to a Ansi string
|
||||||
|
//std::string WChar2Ansi(LPCWSTR pwszSrc)
|
||||||
|
//{
|
||||||
|
// int nLen = WideCharToMultiByte(CP_ACP, 0, pwszSrc, -1, NULL, 0, NULL, NULL);
|
||||||
|
//
|
||||||
|
// if (nLen<= 0) return std::string("");
|
||||||
|
//
|
||||||
|
// char* pszDst = new char[nLen];
|
||||||
|
// if (NULL == pszDst) return std::string("");
|
||||||
|
//
|
||||||
|
// WideCharToMultiByte(CP_ACP, 0, pwszSrc, -1, pszDst, nLen, NULL, NULL);
|
||||||
|
// pszDst[nLen -1] = 0;
|
||||||
|
//
|
||||||
|
// std::string strTemp(pszDst);
|
||||||
|
// delete [] pszDst;
|
||||||
|
//
|
||||||
|
// return strTemp;
|
||||||
|
//}
|
||||||
|
//
|
||||||
|
//string ws2s(wstring& inputws){ return WChar2Ansi(inputws.c_str()); }
|
||||||
|
//
|
||||||
|
////Converting a Ansi string to WChar string
|
||||||
|
//std::wstring Ansi2WChar(LPCSTR pszSrc, int nLen)
|
||||||
|
//{
|
||||||
|
// int nSize = MultiByteToWideChar(CP_ACP, 0, (LPCSTR)pszSrc, nLen, 0, 0);
|
||||||
|
// if(nSize <= 0) return NULL;
|
||||||
|
//
|
||||||
|
// WCHAR *pwszDst = new WCHAR[nSize+1];
|
||||||
|
// if( NULL == pwszDst) return NULL;
|
||||||
|
//
|
||||||
|
// MultiByteToWideChar(CP_ACP, 0,(LPCSTR)pszSrc, nLen, pwszDst, nSize);
|
||||||
|
// pwszDst[nSize] = 0;
|
||||||
|
//
|
||||||
|
// if( pwszDst[0] == 0xFEFF) // skip Oxfeff
|
||||||
|
// for(int i = 0; i < nSize; i ++)
|
||||||
|
// pwszDst[i] = pwszDst[i+1];
|
||||||
|
//
|
||||||
|
// wstring wcharString(pwszDst);
|
||||||
|
// delete pwszDst;
|
||||||
|
//
|
||||||
|
// return wcharString;
|
||||||
|
//}
|
||||||
|
//
|
||||||
|
//std::wstring s2ws(const string& s){ return Ansi2WChar(s.c_str(),s.size());}
|
||||||
|
|
||||||
@ -0,0 +1,25 @@
|
|||||||
|
/**
|
||||||
|
* @file string_helper.h
|
||||||
|
* @brief string utilities to help dealing with string
|
||||||
|
* @author James
|
||||||
|
* @history
|
||||||
|
* ===================================================================================
|
||||||
|
* Date Name Description of Change
|
||||||
|
* 09-July-2008 James
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef STRING_HELPER
|
||||||
|
#define STRING_HELPER
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
string TrimString( string strArg );
|
||||||
|
void Split( string strArg, char spliter, vector<string> &ans );
|
||||||
|
void Split( string strArg, string spliter, vector<string> &ans );
|
||||||
|
void RemoveLiner( string &in, string &out );
|
||||||
|
//string ws2s(wstring& inputws);
|
||||||
|
//wstring s2ws(const string& s);
|
||||||
|
|
||||||
|
#endif
|
||||||
@ -0,0 +1,253 @@
|
|||||||
|
/*==================================================================================================================
|
||||||
|
Copyright(c) 2012 ORIGIN.
|
||||||
|
Unpublished - All rights reserved
|
||||||
|
====================================================================================================================
|
||||||
|
File description:
|
||||||
|
Filename: string_utils.c
|
||||||
|
Module : Common module.
|
||||||
|
|
||||||
|
This file includes some operations of the string.
|
||||||
|
|
||||||
|
====================================================================================================================
|
||||||
|
Date Name Description of Change
|
||||||
|
3-Feb-2015 Ray li Initialize creation
|
||||||
|
$HISTORY$
|
||||||
|
===================================================================================================================*/
|
||||||
|
#ifndef _cplusplus
|
||||||
|
#ifndef _CRT_SECURE_NO_DEPRECATE
|
||||||
|
#define _CRT_SECURE_NO_DEPRECATE
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <fclasses/tc_string.h>
|
||||||
|
#include <tc/tc_util.h>
|
||||||
|
#include <itk/mem.h>
|
||||||
|
#include <tccore/workspaceobject.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <ctype.h>
|
||||||
|
|
||||||
|
#include "string_utils.h"
|
||||||
|
|
||||||
|
//void Split( string strArg, string spliter, vector<string> &ans )
|
||||||
|
//{
|
||||||
|
// ans.clear();
|
||||||
|
// size_t index0;
|
||||||
|
// string one_arg;
|
||||||
|
// if ( strArg.find_first_not_of(' ') == string::npos )
|
||||||
|
// strArg = "";
|
||||||
|
// while( strArg.size()>0 )
|
||||||
|
// {
|
||||||
|
// index0 = strArg.find(spliter);
|
||||||
|
// if( index0 != string::npos )
|
||||||
|
// {
|
||||||
|
// one_arg = strArg.substr( 0, index0 );
|
||||||
|
// strArg = strArg.substr( index0 + spliter.size() );
|
||||||
|
// ans.push_back( one_arg );
|
||||||
|
// }
|
||||||
|
// else
|
||||||
|
// {
|
||||||
|
// ans.push_back( strArg );
|
||||||
|
// break;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//}
|
||||||
|
char* GSTR_clone( char **dst, const char *src )
|
||||||
|
{
|
||||||
|
char *retVal = NULL;
|
||||||
|
int srcLen = 0;
|
||||||
|
|
||||||
|
*dst = NULL;
|
||||||
|
if (src == NULL)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
srcLen = (int)tc_strlen( src ) + 1;
|
||||||
|
*dst = (char*)MEM_alloc( srcLen * sizeof(char) );
|
||||||
|
retVal = tc_strncpy( *dst, src, srcLen );
|
||||||
|
(*dst)[srcLen - 1] = '\0';
|
||||||
|
|
||||||
|
return retVal;
|
||||||
|
}
|
||||||
|
|
||||||
|
char* GSTR_copy( char *dst, const char *src, int dstSize )
|
||||||
|
{
|
||||||
|
char *retVal = tc_strncpy( dst, src, dstSize );
|
||||||
|
dst[dstSize - 1] = '\0';
|
||||||
|
return retVal;
|
||||||
|
}
|
||||||
|
|
||||||
|
char* GSTR_int_to_string( char **dst, int value )
|
||||||
|
{
|
||||||
|
char strVal[128 + 1];
|
||||||
|
|
||||||
|
*dst = NULL;
|
||||||
|
memset( strVal, 0, sizeof(strVal)/sizeof(char) );
|
||||||
|
sprintf( strVal, "%d", value );
|
||||||
|
|
||||||
|
return GSTR_clone( dst, strVal );
|
||||||
|
}
|
||||||
|
|
||||||
|
void GSTR_format_int_to_string( char *dst, int digitNum, int value )
|
||||||
|
{
|
||||||
|
char sNum[WSO_desc_size_c + 1];
|
||||||
|
sprintf( sNum, "%%0%dd", digitNum );
|
||||||
|
sprintf( dst, sNum, value );
|
||||||
|
}
|
||||||
|
|
||||||
|
void GSTR_format_string( const char *dst, int m, const char *fill_char, char **out )
|
||||||
|
{
|
||||||
|
char sNum[WSO_name_size_c + 1] = {0};
|
||||||
|
char sNew[WSO_name_size_c + 1] = {0};
|
||||||
|
sprintf( sNum, "%%%d.%ds", m, m );
|
||||||
|
sprintf( sNew, sNum, dst );
|
||||||
|
STRNG_replace_str( sNew, " ", fill_char, out );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
char* GSTR_string_append( const char *s1, const char *s2 )
|
||||||
|
{
|
||||||
|
char *s = NULL;
|
||||||
|
if (s1 == NULL || s2 == NULL)
|
||||||
|
{
|
||||||
|
GSTR_clone(&s, s1 == NULL ? (s2 == NULL ? "" : s2) : s1 );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
int size = (int)tc_strlen(s1) + (int)tc_strlen(s2) + 1;
|
||||||
|
s = (char *)MEM_alloc( size );
|
||||||
|
tc_strcpy( s, s1 );
|
||||||
|
tc_strcat( s, s2 );
|
||||||
|
s[size - 1] = '\0';
|
||||||
|
}
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
|
||||||
|
logical GSTR_is_float(const char *str)
|
||||||
|
{
|
||||||
|
logical isfloat = true;
|
||||||
|
char *pStr = (char *)str;
|
||||||
|
logical hasPositive = false;
|
||||||
|
logical hasMinus = false;
|
||||||
|
logical hasDot = false;
|
||||||
|
|
||||||
|
if (str == NULL)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
while (*pStr != '\0' && isfloat == true)
|
||||||
|
{
|
||||||
|
if ( (*pStr >= '0' && *pStr <= '9'))
|
||||||
|
{
|
||||||
|
//continue;
|
||||||
|
}
|
||||||
|
else if ( *pStr == '+' )
|
||||||
|
{
|
||||||
|
isfloat = (hasPositive ? false : (hasPositive = true));
|
||||||
|
}
|
||||||
|
else if ( *pStr == '-' )
|
||||||
|
{
|
||||||
|
isfloat = (hasMinus ? false : (hasMinus = true));
|
||||||
|
}
|
||||||
|
else if ( *pStr == '.' )
|
||||||
|
{
|
||||||
|
isfloat = (hasDot ? false : (hasDot = true));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
isfloat = false;
|
||||||
|
|
||||||
|
pStr ++;
|
||||||
|
}
|
||||||
|
return isfloat;
|
||||||
|
}
|
||||||
|
|
||||||
|
logical GSTR_is_number(const char *str)
|
||||||
|
{
|
||||||
|
logical is_number = true;
|
||||||
|
char *pStr = (char *)str;
|
||||||
|
if (str == NULL)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
while (*pStr != '\0')
|
||||||
|
{
|
||||||
|
if ( !( (*pStr >= '0' && *pStr <= '9') || *pStr == '-' ) )
|
||||||
|
{
|
||||||
|
is_number = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
pStr ++;
|
||||||
|
}
|
||||||
|
return is_number;
|
||||||
|
}
|
||||||
|
|
||||||
|
logical GSTR_is_ascii(char ch)
|
||||||
|
{
|
||||||
|
return ((unsigned int)ch) < 128;
|
||||||
|
}
|
||||||
|
|
||||||
|
int GSTR_trim_l( char *str, char s )
|
||||||
|
{
|
||||||
|
int count = 0;
|
||||||
|
char *pointer = str, *poffset = NULL;
|
||||||
|
if (str == NULL || str[0] == '\0')
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
while ( *pointer != '\0' )
|
||||||
|
{
|
||||||
|
if ( *pointer != s )
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
count++;
|
||||||
|
pointer++;
|
||||||
|
}
|
||||||
|
if (count == 0)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
poffset = str + count;
|
||||||
|
pointer = str;
|
||||||
|
while ( *poffset != '\0' )
|
||||||
|
{
|
||||||
|
*pointer = *poffset;
|
||||||
|
pointer ++;
|
||||||
|
poffset ++;
|
||||||
|
}
|
||||||
|
*pointer = '\0';
|
||||||
|
|
||||||
|
return count;
|
||||||
|
}
|
||||||
|
|
||||||
|
int GSTR_trim_r( char *str, char s )
|
||||||
|
{
|
||||||
|
int count = 0;
|
||||||
|
char *pointer = NULL;
|
||||||
|
if (str == NULL || str[0] == '\0')
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
pointer = str + ((int) strlen(str) - 1);
|
||||||
|
|
||||||
|
while ( pointer != str )
|
||||||
|
{
|
||||||
|
if ( *pointer != s )
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
*pointer = '\0';
|
||||||
|
|
||||||
|
count++;
|
||||||
|
pointer--;
|
||||||
|
}
|
||||||
|
|
||||||
|
return count;
|
||||||
|
}
|
||||||
|
|
||||||
|
void GSTR_trim_float( char *floatValue )
|
||||||
|
{
|
||||||
|
if ( !IS_EMPTY(floatValue) && tc_strstr(floatValue, ".") != NULL )
|
||||||
|
{
|
||||||
|
int len = 0;
|
||||||
|
GSTR_trim_r(floatValue, '0');
|
||||||
|
len = (int)tc_strlen(floatValue);
|
||||||
|
if (floatValue[ len - 1 ] == '.')
|
||||||
|
floatValue[ len - 1 ] = '\0';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@ -0,0 +1,125 @@
|
|||||||
|
/*=====================================================================================================================
|
||||||
|
Copyright(c) 2005 ORIGIN PLM Software Corp. All rights reserved.
|
||||||
|
Unpublished - All rights reserved
|
||||||
|
=======================================================================================================================
|
||||||
|
File description:
|
||||||
|
Filename: string_utils.h
|
||||||
|
Module : Common module.
|
||||||
|
|
||||||
|
This file includes some operations of the string.
|
||||||
|
|
||||||
|
=======================================================================================================================
|
||||||
|
Date Name Description of Change
|
||||||
|
14-Jul-2009 Ray Li Initialize creation
|
||||||
|
$HISTORY$
|
||||||
|
=====================================================================================================================*/
|
||||||
|
#ifndef STRING_UTILS_H
|
||||||
|
#define STRING_UTILS_H
|
||||||
|
#include <string>
|
||||||
|
#include <map>
|
||||||
|
#include <vector>
|
||||||
|
using namespace std;
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C"
|
||||||
|
{
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// @{{ String assister
|
||||||
|
#define IS_NULL(S) ((S)==NULL)
|
||||||
|
#define IS_EMPTY(S) (((S)==NULL) || !(*(S)))
|
||||||
|
// @}}
|
||||||
|
void Split( string strArg, string spliter, vector<string> &ans );
|
||||||
|
/**
|
||||||
|
* Clones the string.
|
||||||
|
* @param dst - <OF> the output string.
|
||||||
|
* @param src - <I> the string to be cloned.
|
||||||
|
* @return - the destinatin string pointer.
|
||||||
|
*/
|
||||||
|
extern char* GSTR_clone( char **dst, const char *src );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Copy safely the string with null end.
|
||||||
|
* @param dst - <O> the output string.
|
||||||
|
* @param src - <I> the string to be cloned.
|
||||||
|
* @param dstSize - <I> the size of output string.
|
||||||
|
* @return - the destinatin string pointer.
|
||||||
|
*/
|
||||||
|
extern char *GSTR_copy( char *dst, const char *src, int dstSize );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Converts int to string.
|
||||||
|
* @param dst - <OF> the output string.
|
||||||
|
* @param value - <I> the int to be cloned.
|
||||||
|
* @return - the destinatin string pointer.
|
||||||
|
*/
|
||||||
|
extern char* GSTR_int_to_string( char **dst, int value );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Formats the int/string value as string.
|
||||||
|
* @param dst - <O> the destination string.
|
||||||
|
* @param digitNum - <I> the digit number of the value.
|
||||||
|
* @param value - <I> the value to be converted.
|
||||||
|
* @return - N/A.
|
||||||
|
*/
|
||||||
|
extern void GSTR_format_int_to_string( char *dst, int digitNum, int value );
|
||||||
|
extern void GSTR_format_string( const char *dst, int m, const char *fill_char, char **out );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Appends the strings( never null returned )
|
||||||
|
* @param s1 - <I> string 1
|
||||||
|
* @param s2 - <I> string 2
|
||||||
|
* @return - <OF> new string
|
||||||
|
*/
|
||||||
|
extern char* GSTR_string_append( const char *s1, const char *s2 );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether the string is float type
|
||||||
|
* @param str - <I> The string
|
||||||
|
*
|
||||||
|
* NOTE: it's only check whether each word is in "+-.0123456789", not care the float with "E" or the float rule,
|
||||||
|
* like "00-1.+01", it will return true.
|
||||||
|
* @return - return true if it is one.
|
||||||
|
*/
|
||||||
|
extern logical GSTR_is_float(const char *str);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether all char of the string are number
|
||||||
|
* @param str - <I> The string
|
||||||
|
*
|
||||||
|
* NOTE: it's only check whether each word is in "0123456789"
|
||||||
|
* @return - return true if it is one.
|
||||||
|
*/
|
||||||
|
extern logical GSTR_is_number(const char *str);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Is ascii char
|
||||||
|
* @param ch - <I> ascii char
|
||||||
|
* @return - return true if it is.
|
||||||
|
*/
|
||||||
|
extern logical GSTR_is_ascii(char ch);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Trims the string's prefix.
|
||||||
|
* @param str - <I> The string
|
||||||
|
* @param s - <I> The char
|
||||||
|
*
|
||||||
|
* @return - count.
|
||||||
|
*/
|
||||||
|
extern int GSTR_trim_l( char *str, char s );
|
||||||
|
extern int GSTR_trim_r( char *str, char s );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove the zero.
|
||||||
|
* For Example:
|
||||||
|
* floatValue="50.00" -> = "50"
|
||||||
|
* floatValue="50.0100" -> = "50.01"
|
||||||
|
* @return - count.
|
||||||
|
*/
|
||||||
|
extern void GSTR_trim_float( char *floatValue );
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#endif //STRING_UTILS_H
|
||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -0,0 +1,10 @@
|
|||||||
|
<?xml version='1.0' encoding='UTF-8' standalone='yes'?>
|
||||||
|
<assembly xmlns='urn:schemas-microsoft-com:asm.v1' manifestVersion='1.0'>
|
||||||
|
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
|
||||||
|
<security>
|
||||||
|
<requestedPrivileges>
|
||||||
|
<requestedExecutionLevel level='asInvoker' uiAccess='false' />
|
||||||
|
</requestedPrivileges>
|
||||||
|
</security>
|
||||||
|
</trustInfo>
|
||||||
|
</assembly>
|
||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -0,0 +1,291 @@
|
|||||||
|
/**
|
||||||
|
* @file common_itk_util.cpp
|
||||||
|
* @brief itk warpper utility function
|
||||||
|
* @author James
|
||||||
|
* @history
|
||||||
|
* ===================================================================================
|
||||||
|
* Date Name Description of Change
|
||||||
|
* 18-July-2008 James
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma warning (disable: 4996)
|
||||||
|
#pragma warning (disable: 4819)
|
||||||
|
|
||||||
|
#include <epm/epm.h>
|
||||||
|
#include <epm/epm_toolkit_tc_utils.h>
|
||||||
|
#include <ict/ict_userservice.h>
|
||||||
|
#include <tccore/item.h>
|
||||||
|
#include <ae/ae.h>
|
||||||
|
#include <tc/folder.h>
|
||||||
|
#include <tccore/aom.h>
|
||||||
|
#include <sa/sa.h>
|
||||||
|
#include <tccore/aom_prop.h>
|
||||||
|
#include <property/prop_errors.h>
|
||||||
|
#include <tccore/workspaceobject.h>
|
||||||
|
#include <tc/preferences.h>
|
||||||
|
#include <tccore/imantype.h>
|
||||||
|
#include <tccore//grm.h>
|
||||||
|
#include <tccore/grmtype.h>
|
||||||
|
#include <sa/am.h>
|
||||||
|
#include <cfm/cfm.h>
|
||||||
|
#include <bom/bom.h>
|
||||||
|
#include <tccore/uom.h>
|
||||||
|
#include <ps/ps.h>
|
||||||
|
#include <epm/signoff.h>
|
||||||
|
#include <fclasses/tc_date.h>
|
||||||
|
//#include <tccore/imantype.h>
|
||||||
|
//#include <textsrv/textserver.h>
|
||||||
|
//#include <user_exits/epm_toolkit_utils.h>
|
||||||
|
//#include <ss/ss_errors.h>
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
//#include <io.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <time.h>
|
||||||
|
//#include <direct.h>
|
||||||
|
//#include <unistd.h>
|
||||||
|
#include "error_handling.h"
|
||||||
|
#include "common_itk_util.h"
|
||||||
|
|
||||||
|
#ifdef WIN32
|
||||||
|
#include <io.h>
|
||||||
|
#include <direct.h>
|
||||||
|
#else
|
||||||
|
#include <unistd.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#define ARGS_LENGTH 200
|
||||||
|
#define ARGS_NAME_DEBUG "-debug"
|
||||||
|
#define DEBUG "-debug="
|
||||||
|
#define MAX_PRINTLINE_LENGTH 2000
|
||||||
|
#define MAX_PATH_LENGTH 2000
|
||||||
|
#define MAX_ARGUMENT_LENGTH 400
|
||||||
|
#define MAX_PARAMNAME_LENGTH 50
|
||||||
|
#define MAX_FILE_EXT_LENGTH 10
|
||||||
|
#define TRUE_FLAG 1
|
||||||
|
#define FALSE_FLAG 0
|
||||||
|
#define DETAILLOG 1
|
||||||
|
|
||||||
|
int AM__set_application_bypass(logical bypass);
|
||||||
|
|
||||||
|
void ECHO(char *format, ...)
|
||||||
|
{
|
||||||
|
//if( !YFJC_OPT_DEBUG )
|
||||||
|
// return;
|
||||||
|
|
||||||
|
char msg[1024];
|
||||||
|
va_list args;
|
||||||
|
|
||||||
|
va_start( args, format );
|
||||||
|
vsprintf( msg, format, args );
|
||||||
|
va_end( args );
|
||||||
|
|
||||||
|
printf( msg );
|
||||||
|
TC_write_syslog( msg );
|
||||||
|
}
|
||||||
|
|
||||||
|
FILE* logFile = NULL;
|
||||||
|
|
||||||
|
void set_bypass(logical bypass)
|
||||||
|
{
|
||||||
|
AM__set_application_bypass(bypass);
|
||||||
|
}
|
||||||
|
/*=============================================================================*
|
||||||
|
* FUNCTION: current_time
|
||||||
|
* PURPOSE : get the current datetime
|
||||||
|
* INPUT:
|
||||||
|
* date_t* date_tag // current date time tag
|
||||||
|
*
|
||||||
|
* RETURN:
|
||||||
|
* void
|
||||||
|
*============================================================================*/
|
||||||
|
void current_time( date_t * date_tag )
|
||||||
|
{
|
||||||
|
time_t ltime;
|
||||||
|
struct tm *today ;
|
||||||
|
|
||||||
|
// Set time zone from TZ environment variable. If TZ is not set,
|
||||||
|
// the operating system is queried to obtain the default value
|
||||||
|
// for the variable.
|
||||||
|
//
|
||||||
|
//_tzset();
|
||||||
|
|
||||||
|
// Get UNIX-style time and display as number and string.
|
||||||
|
time( <ime );
|
||||||
|
|
||||||
|
today = localtime( <ime );
|
||||||
|
date_tag->year = today->tm_year + 1900 ;
|
||||||
|
date_tag->month = today->tm_mon ;
|
||||||
|
date_tag->day = today->tm_mday ;
|
||||||
|
date_tag->hour = today->tm_hour ;
|
||||||
|
date_tag->minute = today->tm_min ;
|
||||||
|
date_tag->second = today->tm_sec ;
|
||||||
|
}
|
||||||
|
/*=============================================================================*
|
||||||
|
* FUNCTION: CreateLogFile
|
||||||
|
* PURPOSE : create log file
|
||||||
|
* INPUT:
|
||||||
|
* char* FunctionName // the funtion which need to create log file
|
||||||
|
* FILE** logFile // out: the log file pointer
|
||||||
|
*
|
||||||
|
* RETURN:
|
||||||
|
* void
|
||||||
|
*============================================================================*/
|
||||||
|
void CreateLogFile(char* FunctionName, char **fullname)
|
||||||
|
{
|
||||||
|
int i=0, ifail = ITK_ok;
|
||||||
|
//date_t status_now;
|
||||||
|
//char* date_string = NULL;
|
||||||
|
char date_string[MAX_PATH_LENGTH];
|
||||||
|
char logFileDir[MAX_PATH_LENGTH];
|
||||||
|
char logFileName[MAX_PATH_LENGTH];
|
||||||
|
|
||||||
|
char* session_uid = NULL;
|
||||||
|
tag_t session_tag = NULLTAG;
|
||||||
|
time_t now;
|
||||||
|
struct tm *p;
|
||||||
|
|
||||||
|
time(&now);
|
||||||
|
|
||||||
|
logFile = NULL;
|
||||||
|
//current_time(&status_now);
|
||||||
|
p=localtime(&now);
|
||||||
|
|
||||||
|
memset(date_string, 0, sizeof(date_string));
|
||||||
|
sprintf(date_string,"%4d%02d%02d%02d%02d%02d",1900+p->tm_year,p->tm_mon+1 ,p->tm_mday ,p->tm_hour,p->tm_min ,p->tm_sec );
|
||||||
|
//if( DATE_date_to_string( status_now, "%Y%m%d%H%M%S", &date_string) != ITK_ok )
|
||||||
|
//ifail = ITK_date_to_string (status_now, &date_string );
|
||||||
|
//if (ifail)
|
||||||
|
//{
|
||||||
|
// printf("!*ERROR*!: Failed to get current date time\n");
|
||||||
|
// goto CLEANUP;
|
||||||
|
//}
|
||||||
|
|
||||||
|
memset(logFileDir, 0, sizeof(logFileDir));
|
||||||
|
memset(logFileName, 0, sizeof(logFileName));
|
||||||
|
//get log dir
|
||||||
|
sprintf(logFileDir, "%s", getenv("TEMP"));
|
||||||
|
printf("\n log file dir: %s\n", logFileDir);
|
||||||
|
//try to change dir to TC_USER_LOG_DIR
|
||||||
|
if(chdir(logFileDir)!=ITK_ok)
|
||||||
|
{
|
||||||
|
//not set TC_USER_LOG_DIR
|
||||||
|
//log in to default TC_LOG
|
||||||
|
memset(logFileDir, 0, sizeof(logFileDir));
|
||||||
|
sprintf(logFileDir, "%s", getenv("TC_LOG"));
|
||||||
|
printf("\n TC_USER_LOG_DIR invalide, log file dir: %s\n", logFileDir);
|
||||||
|
if(chdir(logFileDir)!=ITK_ok)
|
||||||
|
{
|
||||||
|
//still can not change to log dir
|
||||||
|
printf("!*ERROR*!: Failed to change dir to TC_USER_LOG_DIR\n");
|
||||||
|
goto CLEANUP;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//get session_uid to make sure the log file name unique
|
||||||
|
POM_ask_session(&session_tag);
|
||||||
|
ITK__convert_tag_to_uid(session_tag, &session_uid);
|
||||||
|
|
||||||
|
|
||||||
|
//get logFileName
|
||||||
|
sprintf(logFileName, "%s_%s_%s.log", FunctionName, session_uid, date_string);
|
||||||
|
printf("log file name: %s\n", logFileName);
|
||||||
|
|
||||||
|
*fullname = (char *)MEM_alloc(sizeof(char)*512);
|
||||||
|
sprintf(*fullname,"%s\\%s",logFileDir,logFileName);
|
||||||
|
|
||||||
|
//for(i = 0; _access((char *)logFileName, 4) == 0; i++)
|
||||||
|
/*{
|
||||||
|
memset(logFileName, 0, sizeof(logFileName));
|
||||||
|
sprintf(logFileName, "%s_%s_%s_%d.log", FunctionName, session_uid, date_string, i);
|
||||||
|
}
|
||||||
|
printf("final log file name: %s\n", logFileName);*/
|
||||||
|
|
||||||
|
//create log file
|
||||||
|
logFile = fopen(logFileName, "w");
|
||||||
|
|
||||||
|
CLEANUP:
|
||||||
|
//DOFREE(date_string);
|
||||||
|
DOFREE(session_uid);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*=============================================================================*
|
||||||
|
* FUNCTION: WriteLog
|
||||||
|
* PURPOSE : write log, if debug log File not null, write log message to log File
|
||||||
|
* INPUT:
|
||||||
|
* const char* format // debug message string
|
||||||
|
*
|
||||||
|
* RETURN:
|
||||||
|
* void
|
||||||
|
*============================================================================*/
|
||||||
|
void WriteLog(const char* format, ...)
|
||||||
|
{
|
||||||
|
va_list arg;
|
||||||
|
char tmp[MAX_PRINTLINE_LENGTH];
|
||||||
|
|
||||||
|
if(logFile)
|
||||||
|
{
|
||||||
|
//get the message
|
||||||
|
memset(tmp, 0, sizeof(tmp));
|
||||||
|
va_start(arg, format);
|
||||||
|
vsprintf(tmp, format, arg);
|
||||||
|
va_end(arg);
|
||||||
|
|
||||||
|
//----------print to command window for trace--------//
|
||||||
|
printf("%s\n", tmp);
|
||||||
|
|
||||||
|
//print message to log file
|
||||||
|
fprintf(logFile, "%s\n", tmp);
|
||||||
|
fflush(logFile);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
printf("*!Error!*: Log File Not Exist\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void CloseLog(void)
|
||||||
|
{
|
||||||
|
if(logFile)
|
||||||
|
{
|
||||||
|
fclose(logFile);
|
||||||
|
logFile = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//void getTypeinfo(char *type)
|
||||||
|
//{
|
||||||
|
// int ulen = 0,i=0,tempcount=0,asd=0;
|
||||||
|
//
|
||||||
|
// char temp[128]="";
|
||||||
|
// ulen = strlen(type);
|
||||||
|
// asd = ulen-1;
|
||||||
|
// for(i=0;i < ulen;i++)
|
||||||
|
// {
|
||||||
|
// if(type[i] == ';')
|
||||||
|
// {
|
||||||
|
// temp[tempcount] = '\0';
|
||||||
|
// strcpy(excludetypes[typecount].type,temp);
|
||||||
|
// strcpy(temp,"");
|
||||||
|
// tempcount = 0;
|
||||||
|
// typecount = typecount + 1;
|
||||||
|
// }
|
||||||
|
// else
|
||||||
|
// {
|
||||||
|
//
|
||||||
|
// temp[tempcount] = type[i];
|
||||||
|
// tempcount = tempcount + 1;
|
||||||
|
// if(i==asd)
|
||||||
|
// {
|
||||||
|
// temp[tempcount] = '\0';
|
||||||
|
// strcpy(excludetypes[typecount].type,temp);
|
||||||
|
// typecount = typecount + 1;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
//}
|
||||||
@ -0,0 +1,40 @@
|
|||||||
|
/**
|
||||||
|
* @file common_itk_util.h
|
||||||
|
* @brief itk warpper utility function
|
||||||
|
* @author James
|
||||||
|
* @history
|
||||||
|
* ===================================================================================
|
||||||
|
* Date Name Description of Change
|
||||||
|
* 09-July-2008 James
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef COMMON_ITK_UTIL
|
||||||
|
#define COMMON_ITK_UTIL
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define DOFREE(obj) \
|
||||||
|
{ \
|
||||||
|
if(obj) \
|
||||||
|
{ \
|
||||||
|
MEM_free(obj); \
|
||||||
|
obj = NULL; \
|
||||||
|
} \
|
||||||
|
}
|
||||||
|
void ECHO(char *format, ...);
|
||||||
|
void CreateLogFile(char* FunctionName, char **fullname);
|
||||||
|
void WriteLog(const char* format, ...);
|
||||||
|
void CloseLog(void);
|
||||||
|
void set_bypass(logical bypass);
|
||||||
|
//int FindDatasetReferenceExt( tag_t datasettype, const char *datasettype_ref, char ext[10] );
|
||||||
|
//int CompareDate( date_t date1, date_t date2 );
|
||||||
|
//int GetRandomTempFile( char tempFile[256] );
|
||||||
|
//logical IsItemRevisionType( char object_type[WSO_name_size_c + 1] );
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
||||||
@ -0,0 +1,160 @@
|
|||||||
|
/*!
|
||||||
|
* @addtogroup common
|
||||||
|
* \file error_handling.h
|
||||||
|
* \brief 错误处理函数
|
||||||
|
* \date 2008/6/10
|
||||||
|
* \author Ray Li
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef SIMPLE_ERR_H_INCLUDED
|
||||||
|
#define SIMPLE_ERR_H_INCLUDED
|
||||||
|
|
||||||
|
|
||||||
|
#include <itk/mem.h>
|
||||||
|
#include <tc/iman.h>
|
||||||
|
#include <tc/emh.h>
|
||||||
|
#include <pom/pom/pom_errors.h>
|
||||||
|
#include <tc/emh_const.h>
|
||||||
|
#include <tc/tc.h>
|
||||||
|
#include <pom/pom/pom.h>
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <time.h>
|
||||||
|
|
||||||
|
#define BUFSIZE 512
|
||||||
|
|
||||||
|
|
||||||
|
//
|
||||||
|
//#define HANDLER_ARGUMENT_ERROR EMH_USER_error_base + 1
|
||||||
|
//#define WORKFLOW_NODE_IS_NOT_VALID EMH_USER_error_base + 2
|
||||||
|
//#define HANDLER_PLACED_INVALID EMH_USER_error_base + 3
|
||||||
|
//
|
||||||
|
////user errors define
|
||||||
|
////<error id="100">在站点文件中缺少 %1$ 配置,或该配置中无数据项</error>
|
||||||
|
//#define ERROR_PREFERENCE_NOT_FOUND (EMH_USER_error_base + 100)
|
||||||
|
|
||||||
|
|
||||||
|
#define DOFREE(obj) \
|
||||||
|
{ \
|
||||||
|
if(obj) \
|
||||||
|
{ \
|
||||||
|
MEM_free(obj); \
|
||||||
|
obj = NULL; \
|
||||||
|
} \
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//#define ECHO(X) printf X;
|
||||||
|
#define SYS_LOG(X) IMAN_write_syslog X;
|
||||||
|
#define LOG_ECHO(X) printf X; IMAN_write_syslog X;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \def CALL(x)
|
||||||
|
* 打印错误信息
|
||||||
|
*/
|
||||||
|
#define CALL(x) { \
|
||||||
|
int stat; \
|
||||||
|
char *err_string; \
|
||||||
|
if( (stat = (x)) != ITK_ok) \
|
||||||
|
{ \
|
||||||
|
EMH_ask_error_text (stat, &err_string); \
|
||||||
|
LOG_ECHO( ("ERROR: %d ERROR MSG: %s.\n",stat, err_string) ) \
|
||||||
|
LOG_ECHO( ("Function: %s FILE: %s LINE: %d\n", #x, __FILE__, __LINE__ ) ) \
|
||||||
|
MEM_free (err_string); \
|
||||||
|
return (stat); \
|
||||||
|
} \
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \def DO(x)
|
||||||
|
* 打印错误信息
|
||||||
|
*/
|
||||||
|
#define DO(x) { \
|
||||||
|
int stat; \
|
||||||
|
char *err_string; \
|
||||||
|
if( (stat = (x)) != POM_ok) \
|
||||||
|
{ \
|
||||||
|
EMH_ask_error_text (stat, &err_string); \
|
||||||
|
printf ("ERROR: %d ERROR MSG: %s.\n", stat, err_string); \
|
||||||
|
printf ("Function: %s FILE: %s LINE: %d\n",#x, __FILE__, __LINE__); \
|
||||||
|
MEM_free (err_string); \
|
||||||
|
} \
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \def CALLRNULL(x)
|
||||||
|
* 打印错误信息
|
||||||
|
*/
|
||||||
|
#define CALLRNULL(x) { \
|
||||||
|
int stat; \
|
||||||
|
char *err_string; \
|
||||||
|
if( (stat = (x)) != ITK_ok) \
|
||||||
|
{ \
|
||||||
|
EMH_ask_error_text (stat, &err_string); \
|
||||||
|
printf ("ERROR: %d ERROR MSG: %s.\n", stat, err_string); \
|
||||||
|
printf ("Function: %s FILE: %s LINE: %d\n",#x, __FILE__, __LINE__); \
|
||||||
|
MEM_free (err_string); \
|
||||||
|
return ((char *)NULL); \
|
||||||
|
} \
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \def CALL2(x)
|
||||||
|
* 打印错误信息
|
||||||
|
*/
|
||||||
|
#define CALL2(x) { \
|
||||||
|
int stat, n_ifails, *serverities, *ifails, err_count; \
|
||||||
|
char *err_string, **texts; \
|
||||||
|
if( (stat = (x)) != ITK_ok) \
|
||||||
|
{ \
|
||||||
|
printf ("Function: %s FILE: %s LINE: %d\n",#x, __FILE__, __LINE__); \
|
||||||
|
EMH_ask_errors( &n_ifails, (const int**)(&serverities), (const int**)(&ifails), (const char***)(&texts) );\
|
||||||
|
for( err_count=0; err_count<n_ifails; err_count++ ) \
|
||||||
|
{ \
|
||||||
|
printf( "ERROR: %d ERROR MSG: %s.\n", ifails[i], texts[i] ); \
|
||||||
|
} \
|
||||||
|
MEM_free( serverities ); \
|
||||||
|
MEM_free( ifails ); \
|
||||||
|
MEM_free( texts ); \
|
||||||
|
return (stat); \
|
||||||
|
} \
|
||||||
|
} \
|
||||||
|
|
||||||
|
#define CHECK_FILE(x,ret) { \
|
||||||
|
FILE *stream = NULL; \
|
||||||
|
if( (stream = fopen(x,"rb")) == NULL ) { \
|
||||||
|
printf( "%s doesn't exists, please check!\n", x ); \
|
||||||
|
IMAN_write_syslog( "%s doesn't exists, please check!\n", x) ; \
|
||||||
|
ret = -1; \
|
||||||
|
} \
|
||||||
|
else { \
|
||||||
|
fclose(stream); \
|
||||||
|
stream = NULL; \
|
||||||
|
ret = 0; \
|
||||||
|
} \
|
||||||
|
} \
|
||||||
|
|
||||||
|
|
||||||
|
#define CHECK_FILE_NOT_EXISTS(x,ret) { \
|
||||||
|
FILE *stream = NULL; \
|
||||||
|
if( (stream = fopen(x,"rb")) != NULL ) { \
|
||||||
|
fclose(stream); \
|
||||||
|
stream = NULL; \
|
||||||
|
printf( "%s exists, please check!\n", x ); \
|
||||||
|
IMAN_write_syslog( "%s exists, please check!\n", x) ; \
|
||||||
|
ret = -1; \
|
||||||
|
} \
|
||||||
|
else { \
|
||||||
|
ret = 0; \
|
||||||
|
} \
|
||||||
|
} \
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
||||||
@ -0,0 +1,12 @@
|
|||||||
|
# include "common_itk_util.h"
|
||||||
|
# include "error_handling.h"
|
||||||
|
# include "ocilib.h"
|
||||||
|
# include "string_helper.h"
|
||||||
|
# include "string_utils.h"
|
||||||
|
|
||||||
|
|
||||||
|
int ITK_user_main(int argc, char* argv[])
|
||||||
|
{
|
||||||
|
printf("1111\n");
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,57 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<ItemGroup>
|
||||||
|
<Filter Include="源文件">
|
||||||
|
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
|
||||||
|
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
|
||||||
|
</Filter>
|
||||||
|
<Filter Include="头文件">
|
||||||
|
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
|
||||||
|
<Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
|
||||||
|
</Filter>
|
||||||
|
<Filter Include="资源文件">
|
||||||
|
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
|
||||||
|
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
|
||||||
|
</Filter>
|
||||||
|
<Filter Include="common">
|
||||||
|
<UniqueIdentifier>{695e5212-e914-4315-a83f-087109122c06}</UniqueIdentifier>
|
||||||
|
</Filter>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClCompile Include="common_itk_util.c">
|
||||||
|
<Filter>common</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="string_helper.cpp">
|
||||||
|
<Filter>common</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="ocilib.cxx">
|
||||||
|
<Filter>common</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="string_utils.cxx">
|
||||||
|
<Filter>common</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="jf_erp_project.cpp">
|
||||||
|
<Filter>源文件</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClInclude Include="common_itk_util.h">
|
||||||
|
<Filter>common</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="error_handling.h">
|
||||||
|
<Filter>common</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="ocilib.h">
|
||||||
|
<Filter>common</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="string_helper.h">
|
||||||
|
<Filter>common</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="string_utils.h">
|
||||||
|
<Filter>common</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="jf_erp_project.h">
|
||||||
|
<Filter>头文件</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
</ItemGroup>
|
||||||
|
</Project>
|
||||||
@ -0,0 +1,98 @@
|
|||||||
|
/*=====================================================================================================================
|
||||||
|
Copyright(c) 2012 ORIGIN.
|
||||||
|
Unpublished - All rights reserved
|
||||||
|
=======================================================================================================================
|
||||||
|
File description:
|
||||||
|
|
||||||
|
Filename: ocilib.h
|
||||||
|
Module : OCI
|
||||||
|
|
||||||
|
This Header file of OCI library Package.
|
||||||
|
|
||||||
|
=======================================================================================================================
|
||||||
|
Date Name Description of Change
|
||||||
|
1-Feb-2015 Ray Initialize creation
|
||||||
|
$HISTORY$
|
||||||
|
=====================================================================================================================*/
|
||||||
|
#include <oci.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <memory.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <malloc.h>
|
||||||
|
//#include <limits.h>
|
||||||
|
|
||||||
|
#define OCI_FAIL 1
|
||||||
|
#define OCI_OK 0
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C"
|
||||||
|
{
|
||||||
|
#endif
|
||||||
|
/**
|
||||||
|
* 连接数据库.
|
||||||
|
* @param username - <I> 用户名
|
||||||
|
* @param password - <I> 密码
|
||||||
|
* @param dbname - <I> 数据库SID
|
||||||
|
* @return - OCI_OK or error code
|
||||||
|
*
|
||||||
|
* ORACLE 数据库的连接与封装函数
|
||||||
|
*/
|
||||||
|
extern int ConnServer(char *username,char *password,char *dbname);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 不带输入参数的执行SQL语句.
|
||||||
|
* @param SQL - <I> SQL语句
|
||||||
|
* @return - OCI_OK or error code
|
||||||
|
*
|
||||||
|
* ORACLE 数据库的连接与封装函数
|
||||||
|
*/
|
||||||
|
extern int ExecuteSQLNoInputParam(char *SQL);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 带输入参数的执行SQL语句.
|
||||||
|
* @param SQL - <I> SQL语句
|
||||||
|
* @param inputValueCount - <I> 输入参数数量
|
||||||
|
* @param inputValue - <I> 输入参数值
|
||||||
|
* @return - OCI_OK or error code
|
||||||
|
*
|
||||||
|
* ORACLE 数据库的连接与封装函数
|
||||||
|
*/
|
||||||
|
extern int ExecuteSQL(char *SQL,int inputValueCount,char **inputValue);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 不带输入参数的查询SQL语句.
|
||||||
|
* @param SQL - <I> SQL语句
|
||||||
|
* @param outputColumn - <O> 输出表的列的数量
|
||||||
|
* @param outputValueCount - <O> 输出表的行的数量
|
||||||
|
* @param outputValue - <O> 输出表内容
|
||||||
|
* @return - OCI_OK or error code
|
||||||
|
*
|
||||||
|
* ORACLE 数据库的连接与封装函数
|
||||||
|
*/
|
||||||
|
extern int QuerySQLNoInputParam(char *SQL, int * outputColumn, int * outputValueCount, char **** outputValue);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 带输入参数的查询SQL语句.
|
||||||
|
* @param SQL - <I> SQL语句
|
||||||
|
* @param inputValueCount - <I> 输入参数数量
|
||||||
|
* @param inputValue - <I> 输入参数值
|
||||||
|
* @param outputColumn - <O> 输出表的列的数量
|
||||||
|
* @param outputValueCount - <O> 输出表的行的数量
|
||||||
|
* @param outputValue - <O> 输出表内容
|
||||||
|
* @return - OCI_OK or error code
|
||||||
|
*
|
||||||
|
* ORACLE 数据库的连接与封装函数
|
||||||
|
*/
|
||||||
|
extern int QuerySQL(char *SQL, int inputValueCount, char ** inputValue, int * outputColumn, int * outputValueCount, char **** outputValue);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 断开数据库连接.
|
||||||
|
*
|
||||||
|
* ORACLE 数据库的连接与封装函数
|
||||||
|
*/
|
||||||
|
extern void DisConnServer();
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
@ -0,0 +1,146 @@
|
|||||||
|
/**
|
||||||
|
* @file string_helper.cpp
|
||||||
|
* @brief string utility functions' implemention
|
||||||
|
* @author James
|
||||||
|
* @history
|
||||||
|
* ===================================================================================
|
||||||
|
* Date Name Description of Change
|
||||||
|
* 09-July-2008 James
|
||||||
|
* 14-Jau-2009 James modify Split functions, add trim blank characters
|
||||||
|
*/
|
||||||
|
#pragma warning(disable:4996)
|
||||||
|
//
|
||||||
|
//#include <stdio.h>
|
||||||
|
//#include <iostream>
|
||||||
|
//#include <windows.h>
|
||||||
|
#include "string_helper.h"
|
||||||
|
|
||||||
|
string TrimString( string strArg )
|
||||||
|
{
|
||||||
|
size_t index1 = 0;
|
||||||
|
index1 = strArg.find_first_not_of( ' ');
|
||||||
|
if( index1 != string::npos )
|
||||||
|
strArg.erase( strArg.begin(), strArg.begin()+index1 );
|
||||||
|
index1 = strArg.find_last_not_of( ' ');
|
||||||
|
if( index1 != string::npos )
|
||||||
|
strArg.erase( strArg.begin() + index1 + 1 );
|
||||||
|
return strArg;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Split( string strArg, char spliter, vector<string> &ans )
|
||||||
|
{
|
||||||
|
ans.clear();
|
||||||
|
size_t index0 = 0;
|
||||||
|
string one_arg;
|
||||||
|
if ( strArg.find_first_not_of(' ') == string::npos )
|
||||||
|
strArg = "";
|
||||||
|
while( strArg.size()>0 )
|
||||||
|
{
|
||||||
|
index0 = strArg.find_first_of( spliter );
|
||||||
|
if( index0 != string::npos )
|
||||||
|
{
|
||||||
|
one_arg = strArg.substr( 0,index0 );
|
||||||
|
strArg = strArg.substr( index0 + 1 );
|
||||||
|
ans.push_back( one_arg );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ans.push_back( strArg );
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Split( string strArg, string spliter, vector<string> &ans )
|
||||||
|
{
|
||||||
|
|
||||||
|
ans.clear();
|
||||||
|
|
||||||
|
size_t index0;
|
||||||
|
string one_arg;
|
||||||
|
|
||||||
|
if ( strArg.find_first_not_of(" ") == string::npos )
|
||||||
|
strArg = "";
|
||||||
|
|
||||||
|
|
||||||
|
while( strArg.size()>0 )
|
||||||
|
{
|
||||||
|
|
||||||
|
index0 = strArg.find(spliter);
|
||||||
|
|
||||||
|
if( index0 != string::npos )
|
||||||
|
{
|
||||||
|
|
||||||
|
one_arg = strArg.substr( 0, index0 );
|
||||||
|
strArg = strArg.substr( index0 + spliter.size() );
|
||||||
|
|
||||||
|
ans.push_back( one_arg );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
|
||||||
|
ans.push_back( strArg );
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void RemoveLiner( string &in, string &out )
|
||||||
|
{
|
||||||
|
char buf[BUFSIZ] = "";
|
||||||
|
for( int i=0; i<(int)in.size(); i++ )
|
||||||
|
{
|
||||||
|
if( in[i] == '\n')
|
||||||
|
continue;
|
||||||
|
else
|
||||||
|
sprintf( buf,"%s%c", buf, in[i] );
|
||||||
|
}
|
||||||
|
out.assign(buf);
|
||||||
|
}
|
||||||
|
|
||||||
|
////Converting a WChar string to a Ansi string
|
||||||
|
//std::string WChar2Ansi(LPCWSTR pwszSrc)
|
||||||
|
//{
|
||||||
|
// int nLen = WideCharToMultiByte(CP_ACP, 0, pwszSrc, -1, NULL, 0, NULL, NULL);
|
||||||
|
//
|
||||||
|
// if (nLen<= 0) return std::string("");
|
||||||
|
//
|
||||||
|
// char* pszDst = new char[nLen];
|
||||||
|
// if (NULL == pszDst) return std::string("");
|
||||||
|
//
|
||||||
|
// WideCharToMultiByte(CP_ACP, 0, pwszSrc, -1, pszDst, nLen, NULL, NULL);
|
||||||
|
// pszDst[nLen -1] = 0;
|
||||||
|
//
|
||||||
|
// std::string strTemp(pszDst);
|
||||||
|
// delete [] pszDst;
|
||||||
|
//
|
||||||
|
// return strTemp;
|
||||||
|
//}
|
||||||
|
//
|
||||||
|
//string ws2s(wstring& inputws){ return WChar2Ansi(inputws.c_str()); }
|
||||||
|
//
|
||||||
|
////Converting a Ansi string to WChar string
|
||||||
|
//std::wstring Ansi2WChar(LPCSTR pszSrc, int nLen)
|
||||||
|
//{
|
||||||
|
// int nSize = MultiByteToWideChar(CP_ACP, 0, (LPCSTR)pszSrc, nLen, 0, 0);
|
||||||
|
// if(nSize <= 0) return NULL;
|
||||||
|
//
|
||||||
|
// WCHAR *pwszDst = new WCHAR[nSize+1];
|
||||||
|
// if( NULL == pwszDst) return NULL;
|
||||||
|
//
|
||||||
|
// MultiByteToWideChar(CP_ACP, 0,(LPCSTR)pszSrc, nLen, pwszDst, nSize);
|
||||||
|
// pwszDst[nSize] = 0;
|
||||||
|
//
|
||||||
|
// if( pwszDst[0] == 0xFEFF) // skip Oxfeff
|
||||||
|
// for(int i = 0; i < nSize; i ++)
|
||||||
|
// pwszDst[i] = pwszDst[i+1];
|
||||||
|
//
|
||||||
|
// wstring wcharString(pwszDst);
|
||||||
|
// delete pwszDst;
|
||||||
|
//
|
||||||
|
// return wcharString;
|
||||||
|
//}
|
||||||
|
//
|
||||||
|
//std::wstring s2ws(const string& s){ return Ansi2WChar(s.c_str(),s.size());}
|
||||||
|
|
||||||
@ -0,0 +1,25 @@
|
|||||||
|
/**
|
||||||
|
* @file string_helper.h
|
||||||
|
* @brief string utilities to help dealing with string
|
||||||
|
* @author James
|
||||||
|
* @history
|
||||||
|
* ===================================================================================
|
||||||
|
* Date Name Description of Change
|
||||||
|
* 09-July-2008 James
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef STRING_HELPER
|
||||||
|
#define STRING_HELPER
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
string TrimString( string strArg );
|
||||||
|
void Split( string strArg, char spliter, vector<string> &ans );
|
||||||
|
void Split( string strArg, string spliter, vector<string> &ans );
|
||||||
|
void RemoveLiner( string &in, string &out );
|
||||||
|
//string ws2s(wstring& inputws);
|
||||||
|
//wstring s2ws(const string& s);
|
||||||
|
|
||||||
|
#endif
|
||||||
@ -0,0 +1,253 @@
|
|||||||
|
/*==================================================================================================================
|
||||||
|
Copyright(c) 2012 ORIGIN.
|
||||||
|
Unpublished - All rights reserved
|
||||||
|
====================================================================================================================
|
||||||
|
File description:
|
||||||
|
Filename: string_utils.c
|
||||||
|
Module : Common module.
|
||||||
|
|
||||||
|
This file includes some operations of the string.
|
||||||
|
|
||||||
|
====================================================================================================================
|
||||||
|
Date Name Description of Change
|
||||||
|
3-Feb-2015 Ray li Initialize creation
|
||||||
|
$HISTORY$
|
||||||
|
===================================================================================================================*/
|
||||||
|
#ifndef _cplusplus
|
||||||
|
#ifndef _CRT_SECURE_NO_DEPRECATE
|
||||||
|
#define _CRT_SECURE_NO_DEPRECATE
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <fclasses/tc_string.h>
|
||||||
|
#include <tc/tc_util.h>
|
||||||
|
#include <itk/mem.h>
|
||||||
|
#include <tccore/workspaceobject.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <ctype.h>
|
||||||
|
|
||||||
|
#include "string_utils.h"
|
||||||
|
|
||||||
|
//void Split( string strArg, string spliter, vector<string> &ans )
|
||||||
|
//{
|
||||||
|
// ans.clear();
|
||||||
|
// size_t index0;
|
||||||
|
// string one_arg;
|
||||||
|
// if ( strArg.find_first_not_of(' ') == string::npos )
|
||||||
|
// strArg = "";
|
||||||
|
// while( strArg.size()>0 )
|
||||||
|
// {
|
||||||
|
// index0 = strArg.find(spliter);
|
||||||
|
// if( index0 != string::npos )
|
||||||
|
// {
|
||||||
|
// one_arg = strArg.substr( 0, index0 );
|
||||||
|
// strArg = strArg.substr( index0 + spliter.size() );
|
||||||
|
// ans.push_back( one_arg );
|
||||||
|
// }
|
||||||
|
// else
|
||||||
|
// {
|
||||||
|
// ans.push_back( strArg );
|
||||||
|
// break;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//}
|
||||||
|
char* GSTR_clone( char **dst, const char *src )
|
||||||
|
{
|
||||||
|
char *retVal = NULL;
|
||||||
|
int srcLen = 0;
|
||||||
|
|
||||||
|
*dst = NULL;
|
||||||
|
if (src == NULL)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
srcLen = (int)tc_strlen( src ) + 1;
|
||||||
|
*dst = (char*)MEM_alloc( srcLen * sizeof(char) );
|
||||||
|
retVal = tc_strncpy( *dst, src, srcLen );
|
||||||
|
(*dst)[srcLen - 1] = '\0';
|
||||||
|
|
||||||
|
return retVal;
|
||||||
|
}
|
||||||
|
|
||||||
|
char* GSTR_copy( char *dst, const char *src, int dstSize )
|
||||||
|
{
|
||||||
|
char *retVal = tc_strncpy( dst, src, dstSize );
|
||||||
|
dst[dstSize - 1] = '\0';
|
||||||
|
return retVal;
|
||||||
|
}
|
||||||
|
|
||||||
|
char* GSTR_int_to_string( char **dst, int value )
|
||||||
|
{
|
||||||
|
char strVal[128 + 1];
|
||||||
|
|
||||||
|
*dst = NULL;
|
||||||
|
memset( strVal, 0, sizeof(strVal)/sizeof(char) );
|
||||||
|
sprintf( strVal, "%d", value );
|
||||||
|
|
||||||
|
return GSTR_clone( dst, strVal );
|
||||||
|
}
|
||||||
|
|
||||||
|
void GSTR_format_int_to_string( char *dst, int digitNum, int value )
|
||||||
|
{
|
||||||
|
char sNum[WSO_desc_size_c + 1];
|
||||||
|
sprintf( sNum, "%%0%dd", digitNum );
|
||||||
|
sprintf( dst, sNum, value );
|
||||||
|
}
|
||||||
|
|
||||||
|
void GSTR_format_string( const char *dst, int m, const char *fill_char, char **out )
|
||||||
|
{
|
||||||
|
char sNum[WSO_name_size_c + 1] = {0};
|
||||||
|
char sNew[WSO_name_size_c + 1] = {0};
|
||||||
|
sprintf( sNum, "%%%d.%ds", m, m );
|
||||||
|
sprintf( sNew, sNum, dst );
|
||||||
|
STRNG_replace_str( sNew, " ", fill_char, out );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
char* GSTR_string_append( const char *s1, const char *s2 )
|
||||||
|
{
|
||||||
|
char *s = NULL;
|
||||||
|
if (s1 == NULL || s2 == NULL)
|
||||||
|
{
|
||||||
|
GSTR_clone(&s, s1 == NULL ? (s2 == NULL ? "" : s2) : s1 );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
int size = (int)tc_strlen(s1) + (int)tc_strlen(s2) + 1;
|
||||||
|
s = (char *)MEM_alloc( size );
|
||||||
|
tc_strcpy( s, s1 );
|
||||||
|
tc_strcat( s, s2 );
|
||||||
|
s[size - 1] = '\0';
|
||||||
|
}
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
|
||||||
|
logical GSTR_is_float(const char *str)
|
||||||
|
{
|
||||||
|
logical isfloat = true;
|
||||||
|
char *pStr = (char *)str;
|
||||||
|
logical hasPositive = false;
|
||||||
|
logical hasMinus = false;
|
||||||
|
logical hasDot = false;
|
||||||
|
|
||||||
|
if (str == NULL)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
while (*pStr != '\0' && isfloat == true)
|
||||||
|
{
|
||||||
|
if ( (*pStr >= '0' && *pStr <= '9'))
|
||||||
|
{
|
||||||
|
//continue;
|
||||||
|
}
|
||||||
|
else if ( *pStr == '+' )
|
||||||
|
{
|
||||||
|
isfloat = (hasPositive ? false : (hasPositive = true));
|
||||||
|
}
|
||||||
|
else if ( *pStr == '-' )
|
||||||
|
{
|
||||||
|
isfloat = (hasMinus ? false : (hasMinus = true));
|
||||||
|
}
|
||||||
|
else if ( *pStr == '.' )
|
||||||
|
{
|
||||||
|
isfloat = (hasDot ? false : (hasDot = true));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
isfloat = false;
|
||||||
|
|
||||||
|
pStr ++;
|
||||||
|
}
|
||||||
|
return isfloat;
|
||||||
|
}
|
||||||
|
|
||||||
|
logical GSTR_is_number(const char *str)
|
||||||
|
{
|
||||||
|
logical is_number = true;
|
||||||
|
char *pStr = (char *)str;
|
||||||
|
if (str == NULL)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
while (*pStr != '\0')
|
||||||
|
{
|
||||||
|
if ( !( (*pStr >= '0' && *pStr <= '9') || *pStr == '-' ) )
|
||||||
|
{
|
||||||
|
is_number = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
pStr ++;
|
||||||
|
}
|
||||||
|
return is_number;
|
||||||
|
}
|
||||||
|
|
||||||
|
logical GSTR_is_ascii(char ch)
|
||||||
|
{
|
||||||
|
return ((unsigned int)ch) < 128;
|
||||||
|
}
|
||||||
|
|
||||||
|
int GSTR_trim_l( char *str, char s )
|
||||||
|
{
|
||||||
|
int count = 0;
|
||||||
|
char *pointer = str, *poffset = NULL;
|
||||||
|
if (str == NULL || str[0] == '\0')
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
while ( *pointer != '\0' )
|
||||||
|
{
|
||||||
|
if ( *pointer != s )
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
count++;
|
||||||
|
pointer++;
|
||||||
|
}
|
||||||
|
if (count == 0)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
poffset = str + count;
|
||||||
|
pointer = str;
|
||||||
|
while ( *poffset != '\0' )
|
||||||
|
{
|
||||||
|
*pointer = *poffset;
|
||||||
|
pointer ++;
|
||||||
|
poffset ++;
|
||||||
|
}
|
||||||
|
*pointer = '\0';
|
||||||
|
|
||||||
|
return count;
|
||||||
|
}
|
||||||
|
|
||||||
|
int GSTR_trim_r( char *str, char s )
|
||||||
|
{
|
||||||
|
int count = 0;
|
||||||
|
char *pointer = NULL;
|
||||||
|
if (str == NULL || str[0] == '\0')
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
pointer = str + ((int) strlen(str) - 1);
|
||||||
|
|
||||||
|
while ( pointer != str )
|
||||||
|
{
|
||||||
|
if ( *pointer != s )
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
*pointer = '\0';
|
||||||
|
|
||||||
|
count++;
|
||||||
|
pointer--;
|
||||||
|
}
|
||||||
|
|
||||||
|
return count;
|
||||||
|
}
|
||||||
|
|
||||||
|
void GSTR_trim_float( char *floatValue )
|
||||||
|
{
|
||||||
|
if ( !IS_EMPTY(floatValue) && tc_strstr(floatValue, ".") != NULL )
|
||||||
|
{
|
||||||
|
int len = 0;
|
||||||
|
GSTR_trim_r(floatValue, '0');
|
||||||
|
len = (int)tc_strlen(floatValue);
|
||||||
|
if (floatValue[ len - 1 ] == '.')
|
||||||
|
floatValue[ len - 1 ] = '\0';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@ -0,0 +1,125 @@
|
|||||||
|
/*=====================================================================================================================
|
||||||
|
Copyright(c) 2005 ORIGIN PLM Software Corp. All rights reserved.
|
||||||
|
Unpublished - All rights reserved
|
||||||
|
=======================================================================================================================
|
||||||
|
File description:
|
||||||
|
Filename: string_utils.h
|
||||||
|
Module : Common module.
|
||||||
|
|
||||||
|
This file includes some operations of the string.
|
||||||
|
|
||||||
|
=======================================================================================================================
|
||||||
|
Date Name Description of Change
|
||||||
|
14-Jul-2009 Ray Li Initialize creation
|
||||||
|
$HISTORY$
|
||||||
|
=====================================================================================================================*/
|
||||||
|
#ifndef STRING_UTILS_H
|
||||||
|
#define STRING_UTILS_H
|
||||||
|
#include <string>
|
||||||
|
#include <map>
|
||||||
|
#include <vector>
|
||||||
|
using namespace std;
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C"
|
||||||
|
{
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// @{{ String assister
|
||||||
|
#define IS_NULL(S) ((S)==NULL)
|
||||||
|
#define IS_EMPTY(S) (((S)==NULL) || !(*(S)))
|
||||||
|
// @}}
|
||||||
|
void Split( string strArg, string spliter, vector<string> &ans );
|
||||||
|
/**
|
||||||
|
* Clones the string.
|
||||||
|
* @param dst - <OF> the output string.
|
||||||
|
* @param src - <I> the string to be cloned.
|
||||||
|
* @return - the destinatin string pointer.
|
||||||
|
*/
|
||||||
|
extern char* GSTR_clone( char **dst, const char *src );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Copy safely the string with null end.
|
||||||
|
* @param dst - <O> the output string.
|
||||||
|
* @param src - <I> the string to be cloned.
|
||||||
|
* @param dstSize - <I> the size of output string.
|
||||||
|
* @return - the destinatin string pointer.
|
||||||
|
*/
|
||||||
|
extern char *GSTR_copy( char *dst, const char *src, int dstSize );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Converts int to string.
|
||||||
|
* @param dst - <OF> the output string.
|
||||||
|
* @param value - <I> the int to be cloned.
|
||||||
|
* @return - the destinatin string pointer.
|
||||||
|
*/
|
||||||
|
extern char* GSTR_int_to_string( char **dst, int value );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Formats the int/string value as string.
|
||||||
|
* @param dst - <O> the destination string.
|
||||||
|
* @param digitNum - <I> the digit number of the value.
|
||||||
|
* @param value - <I> the value to be converted.
|
||||||
|
* @return - N/A.
|
||||||
|
*/
|
||||||
|
extern void GSTR_format_int_to_string( char *dst, int digitNum, int value );
|
||||||
|
extern void GSTR_format_string( const char *dst, int m, const char *fill_char, char **out );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Appends the strings( never null returned )
|
||||||
|
* @param s1 - <I> string 1
|
||||||
|
* @param s2 - <I> string 2
|
||||||
|
* @return - <OF> new string
|
||||||
|
*/
|
||||||
|
extern char* GSTR_string_append( const char *s1, const char *s2 );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether the string is float type
|
||||||
|
* @param str - <I> The string
|
||||||
|
*
|
||||||
|
* NOTE: it's only check whether each word is in "+-.0123456789", not care the float with "E" or the float rule,
|
||||||
|
* like "00-1.+01", it will return true.
|
||||||
|
* @return - return true if it is one.
|
||||||
|
*/
|
||||||
|
extern logical GSTR_is_float(const char *str);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether all char of the string are number
|
||||||
|
* @param str - <I> The string
|
||||||
|
*
|
||||||
|
* NOTE: it's only check whether each word is in "0123456789"
|
||||||
|
* @return - return true if it is one.
|
||||||
|
*/
|
||||||
|
extern logical GSTR_is_number(const char *str);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Is ascii char
|
||||||
|
* @param ch - <I> ascii char
|
||||||
|
* @return - return true if it is.
|
||||||
|
*/
|
||||||
|
extern logical GSTR_is_ascii(char ch);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Trims the string's prefix.
|
||||||
|
* @param str - <I> The string
|
||||||
|
* @param s - <I> The char
|
||||||
|
*
|
||||||
|
* @return - count.
|
||||||
|
*/
|
||||||
|
extern int GSTR_trim_l( char *str, char s );
|
||||||
|
extern int GSTR_trim_r( char *str, char s );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove the zero.
|
||||||
|
* For Example:
|
||||||
|
* floatValue="50.00" -> = "50"
|
||||||
|
* floatValue="50.0100" -> = "50.01"
|
||||||
|
* @return - count.
|
||||||
|
*/
|
||||||
|
extern void GSTR_trim_float( char *floatValue );
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#endif //STRING_UTILS_H
|
||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -0,0 +1,39 @@
|
|||||||
|
Shoulder 2017/05/11 09:52:49
|
||||||
|
lx = form.getTCProperty("jk8ProductType").getStringArrayValue();//产品类型
|
||||||
|
cpxh = form.getTCProperty("jk8ProductModNO").getStringArrayValue();// 产品型号
|
||||||
|
sbh = form.getTCProperty("jk8ProductIdentifyNO").getStringArrayValue();// 识别号
|
||||||
|
cpmc = form.getTCProperty("jk8ProductName").getStringArrayValue();// 产品名称
|
||||||
|
jbcj = form.getTCProperty("jk8BaseMeterManufactor").getStringArrayValue();// 基表厂家
|
||||||
|
ickxh = form.getTCProperty("jk8ICCardType").getStringArrayValue();// IC卡型号
|
||||||
|
xlbxh = form.getTCProperty("jk8CircBoardModNO").getStringArrayValue();// 线路板型号
|
||||||
|
cxtz = form.getTCProperty("jk8ProgramFeatures").getStringArrayValue();// 程序特征
|
||||||
|
tdxh = form.getTCProperty("jk8InsteadType").getStringArrayValue();// 替代型号
|
||||||
|
gngs = form.getTCProperty("jk8FunctionOverview").getStringArrayValue();// 功能概述
|
||||||
|
khtsyq = form.getTCProperty("jk8CustSpecRequirements").getStringArrayValue();// 客户特殊要求
|
||||||
|
u8mmh = form.getTCProperty("jk8U8NO").getStringArrayValue();// U8编码号
|
||||||
|
fm = form.getTCProperty("jk8Valve").getStringArrayValue();// 阀门
|
||||||
|
jmlx = form.getTCProperty("jk8EncryptType").getStringArrayValue();// 加密类型
|
||||||
|
sqr = form.getTCProperty("jk8Applicant").getStringArrayValue();// 申请人
|
||||||
|
djrq = form.getTCProperty("jk8RecordDate").getStringArrayValue();// 登记日期
|
||||||
|
sysc = form.getTCProperty("jk8ApplyMarket").getStringArrayValue();// 适用市场
|
||||||
|
ptjbcj = form.getTCProperty("jk8BMManfMatched").getStringArrayValue();// 配套基表厂家
|
||||||
|
|
||||||
|
|
||||||
|
jk8ProductType//产品类型
|
||||||
|
jk8ProductModNO// 产品型号
|
||||||
|
jk8ProductIdentifyNO// 识别号
|
||||||
|
jk8ProductName// 产品名称
|
||||||
|
jk8BaseMeterManufactor// 基表厂家
|
||||||
|
jk8ICCardType// IC卡型号
|
||||||
|
jk8CircBoardModNO// 线路板型号
|
||||||
|
jk8ProgramFeatures// 程序特征
|
||||||
|
jk8InsteadType// 替代型号
|
||||||
|
jk8FunctionOverview// 功能概述
|
||||||
|
jk8CustSpecRequirements// 客户特殊要求
|
||||||
|
jk8U8NO// U8编码号 (去掉)
|
||||||
|
jk8Valve// 阀门
|
||||||
|
jk8EncryptType// 加密类型
|
||||||
|
jk8Applicant// 申请人
|
||||||
|
jk8RecordDate// 登记日期
|
||||||
|
jk8ApplyMarket// 适用市场
|
||||||
|
jk8BMManfMatched// 配套基表厂家
|
||||||
@ -0,0 +1,289 @@
|
|||||||
|
/**
|
||||||
|
* @file common_itk_util.cpp
|
||||||
|
* @brief itk warpper utility function
|
||||||
|
* @author James
|
||||||
|
* @history
|
||||||
|
* ===================================================================================
|
||||||
|
* Date Name Description of Change
|
||||||
|
* 18-July-2008 James
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma warning (disable: 4996)
|
||||||
|
#pragma warning (disable: 4819)
|
||||||
|
|
||||||
|
#include <epm/epm.h>
|
||||||
|
#include <epm/epm_toolkit_tc_utils.h>
|
||||||
|
#include <ict/ict_userservice.h>
|
||||||
|
#include <tccore/item.h>
|
||||||
|
#include <ae/ae.h>
|
||||||
|
#include <tc/folder.h>
|
||||||
|
#include <tccore/aom.h>
|
||||||
|
#include <sa/sa.h>
|
||||||
|
#include <tccore/aom_prop.h>
|
||||||
|
#include <property/prop_errors.h>
|
||||||
|
#include <tccore/workspaceobject.h>
|
||||||
|
#include <tc/preferences.h>
|
||||||
|
#include <tccore/imantype.h>
|
||||||
|
#include <tccore//grm.h>
|
||||||
|
#include <tccore/grmtype.h>
|
||||||
|
#include <sa/am.h>
|
||||||
|
#include <cfm/cfm.h>
|
||||||
|
#include <bom/bom.h>
|
||||||
|
#include <tccore/uom.h>
|
||||||
|
#include <ps/ps.h>
|
||||||
|
#include <epm/signoff.h>
|
||||||
|
#include <fclasses/tc_date.h>
|
||||||
|
//#include <tccore/imantype.h>
|
||||||
|
//#include <textsrv/textserver.h>
|
||||||
|
//#include <user_exits/epm_toolkit_utils.h>
|
||||||
|
//#include <ss/ss_errors.h>
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
//#include <io.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <time.h>
|
||||||
|
//#include <direct.h>
|
||||||
|
//#include <unistd.h>
|
||||||
|
#include "error_handling.h"
|
||||||
|
#include "common_itk_util.h"
|
||||||
|
|
||||||
|
#ifdef WIN32
|
||||||
|
#include <io.h>
|
||||||
|
#include <direct.h>
|
||||||
|
#else
|
||||||
|
#include <unistd.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#define ARGS_LENGTH 200
|
||||||
|
#define ARGS_NAME_DEBUG "-debug"
|
||||||
|
#define DEBUG "-debug="
|
||||||
|
#define MAX_PRINTLINE_LENGTH 2000
|
||||||
|
#define MAX_PATH_LENGTH 2000
|
||||||
|
#define MAX_ARGUMENT_LENGTH 400
|
||||||
|
#define MAX_PARAMNAME_LENGTH 50
|
||||||
|
#define MAX_FILE_EXT_LENGTH 10
|
||||||
|
#define TRUE_FLAG 1
|
||||||
|
#define FALSE_FLAG 0
|
||||||
|
#define DETAILLOG 1
|
||||||
|
|
||||||
|
|
||||||
|
void ECHO(char *format, ...)
|
||||||
|
{
|
||||||
|
//if( !YFJC_OPT_DEBUG )
|
||||||
|
// return;
|
||||||
|
|
||||||
|
char msg[20480];
|
||||||
|
va_list args;
|
||||||
|
|
||||||
|
va_start( args, format );
|
||||||
|
vsprintf( msg, format, args );
|
||||||
|
va_end( args );
|
||||||
|
|
||||||
|
printf( msg );
|
||||||
|
TC_write_syslog( msg );
|
||||||
|
}
|
||||||
|
|
||||||
|
FILE* logFile = NULL;
|
||||||
|
|
||||||
|
void set_bypass(logical bypass)
|
||||||
|
{
|
||||||
|
AM__set_application_bypass(bypass);
|
||||||
|
}
|
||||||
|
/*=============================================================================*
|
||||||
|
* FUNCTION: current_time
|
||||||
|
* PURPOSE : get the current datetime
|
||||||
|
* INPUT:
|
||||||
|
* date_t* date_tag // current date time tag
|
||||||
|
*
|
||||||
|
* RETURN:
|
||||||
|
* void
|
||||||
|
*============================================================================*/
|
||||||
|
void current_time( date_t * date_tag )
|
||||||
|
{
|
||||||
|
time_t ltime;
|
||||||
|
struct tm *today ;
|
||||||
|
|
||||||
|
// Set time zone from TZ environment variable. If TZ is not set,
|
||||||
|
// the operating system is queried to obtain the default value
|
||||||
|
// for the variable.
|
||||||
|
//
|
||||||
|
//_tzset();
|
||||||
|
|
||||||
|
// Get UNIX-style time and display as number and string.
|
||||||
|
time( <ime );
|
||||||
|
|
||||||
|
today = localtime( <ime );
|
||||||
|
date_tag->year = today->tm_year + 1900 ;
|
||||||
|
date_tag->month = today->tm_mon ;
|
||||||
|
date_tag->day = today->tm_mday ;
|
||||||
|
date_tag->hour = today->tm_hour ;
|
||||||
|
date_tag->minute = today->tm_min ;
|
||||||
|
date_tag->second = today->tm_sec ;
|
||||||
|
}
|
||||||
|
/*=============================================================================*
|
||||||
|
* FUNCTION: CreateLogFile
|
||||||
|
* PURPOSE : create log file
|
||||||
|
* INPUT:
|
||||||
|
* char* FunctionName // the funtion which need to create log file
|
||||||
|
* FILE** logFile // out: the log file pointer
|
||||||
|
*
|
||||||
|
* RETURN:
|
||||||
|
* void
|
||||||
|
*============================================================================*/
|
||||||
|
void CreateLogFile(char* FunctionName, char **fullname)
|
||||||
|
{
|
||||||
|
int i=0, ifail = ITK_ok;
|
||||||
|
//date_t status_now;
|
||||||
|
//char* date_string = NULL;
|
||||||
|
char date_string[MAX_PATH_LENGTH];
|
||||||
|
char logFileDir[MAX_PATH_LENGTH];
|
||||||
|
char logFileName[MAX_PATH_LENGTH];
|
||||||
|
|
||||||
|
char* session_uid = NULL;
|
||||||
|
tag_t session_tag = NULLTAG;
|
||||||
|
time_t now;
|
||||||
|
struct tm *p;
|
||||||
|
|
||||||
|
time(&now);
|
||||||
|
|
||||||
|
logFile = NULL;
|
||||||
|
//current_time(&status_now);
|
||||||
|
p=localtime(&now);
|
||||||
|
|
||||||
|
memset(date_string, 0, sizeof(date_string));
|
||||||
|
sprintf(date_string,"%4d%02d%02d%02d%02d%02d",1900+p->tm_year,p->tm_mon+1 ,p->tm_mday ,p->tm_hour,p->tm_min ,p->tm_sec );
|
||||||
|
//if( DATE_date_to_string( status_now, "%Y%m%d%H%M%S", &date_string) != ITK_ok )
|
||||||
|
//ifail = ITK_date_to_string (status_now, &date_string );
|
||||||
|
//if (ifail)
|
||||||
|
//{
|
||||||
|
// printf("!*ERROR*!: Failed to get current date time\n");
|
||||||
|
// goto CLEANUP;
|
||||||
|
//}
|
||||||
|
|
||||||
|
memset(logFileDir, 0, sizeof(logFileDir));
|
||||||
|
memset(logFileName, 0, sizeof(logFileName));
|
||||||
|
//get log dir
|
||||||
|
sprintf(logFileDir, "%s", getenv("TEMP"));
|
||||||
|
printf("\n log file dir: %s\n", logFileDir);
|
||||||
|
//try to change dir to TC_USER_LOG_DIR
|
||||||
|
if(chdir(logFileDir)!=ITK_ok)
|
||||||
|
{
|
||||||
|
//not set TC_USER_LOG_DIR
|
||||||
|
//log in to default TC_LOG
|
||||||
|
memset(logFileDir, 0, sizeof(logFileDir));
|
||||||
|
sprintf(logFileDir, "%s", getenv("TC_LOG"));
|
||||||
|
printf("\n TC_USER_LOG_DIR invalide, log file dir: %s\n", logFileDir);
|
||||||
|
if(chdir(logFileDir)!=ITK_ok)
|
||||||
|
{
|
||||||
|
//still can not change to log dir
|
||||||
|
printf("!*ERROR*!: Failed to change dir to TC_USER_LOG_DIR\n");
|
||||||
|
goto CLEANUP;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//get session_uid to make sure the log file name unique
|
||||||
|
POM_ask_session(&session_tag);
|
||||||
|
ITK__convert_tag_to_uid(session_tag, &session_uid);
|
||||||
|
|
||||||
|
|
||||||
|
//get logFileName
|
||||||
|
sprintf(logFileName, "%s_%s_%s.log", FunctionName, session_uid, date_string);
|
||||||
|
printf("log file name: %s\n", logFileName);
|
||||||
|
|
||||||
|
*fullname = (char *)MEM_alloc(sizeof(char)*512);
|
||||||
|
sprintf(*fullname,"%s\\%s",logFileDir,logFileName);
|
||||||
|
|
||||||
|
//for(i = 0; _access((char *)logFileName, 4) == 0; i++)
|
||||||
|
/*{
|
||||||
|
memset(logFileName, 0, sizeof(logFileName));
|
||||||
|
sprintf(logFileName, "%s_%s_%s_%d.log", FunctionName, session_uid, date_string, i);
|
||||||
|
}
|
||||||
|
printf("final log file name: %s\n", logFileName);*/
|
||||||
|
|
||||||
|
//create log file
|
||||||
|
logFile = fopen(logFileName, "w");
|
||||||
|
|
||||||
|
CLEANUP:
|
||||||
|
//DOFREE(date_string);
|
||||||
|
DOFREE(session_uid);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*=============================================================================*
|
||||||
|
* FUNCTION: WriteLog
|
||||||
|
* PURPOSE : write log, if debug log File not null, write log message to log File
|
||||||
|
* INPUT:
|
||||||
|
* const char* format // debug message string
|
||||||
|
*
|
||||||
|
* RETURN:
|
||||||
|
* void
|
||||||
|
*============================================================================*/
|
||||||
|
void WriteLog(const char* format, ...)
|
||||||
|
{
|
||||||
|
va_list arg;
|
||||||
|
char tmp[MAX_PRINTLINE_LENGTH];
|
||||||
|
|
||||||
|
if(logFile)
|
||||||
|
{
|
||||||
|
//get the message
|
||||||
|
memset(tmp, 0, sizeof(tmp));
|
||||||
|
va_start(arg, format);
|
||||||
|
vsprintf(tmp, format, arg);
|
||||||
|
va_end(arg);
|
||||||
|
|
||||||
|
//----------print to command window for trace--------//
|
||||||
|
printf("%s\n", tmp);
|
||||||
|
|
||||||
|
//print message to log file
|
||||||
|
fprintf(logFile, "%s\n", tmp);
|
||||||
|
fflush(logFile);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
printf("*!Error!*: Log File Not Exist\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void CloseLog(void)
|
||||||
|
{
|
||||||
|
if(logFile)
|
||||||
|
{
|
||||||
|
fclose(logFile);
|
||||||
|
logFile = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//void getTypeinfo(char *type)
|
||||||
|
//{
|
||||||
|
// int ulen = 0,i=0,tempcount=0,asd=0;
|
||||||
|
//
|
||||||
|
// char temp[128]="";
|
||||||
|
// ulen = strlen(type);
|
||||||
|
// asd = ulen-1;
|
||||||
|
// for(i=0;i < ulen;i++)
|
||||||
|
// {
|
||||||
|
// if(type[i] == ';')
|
||||||
|
// {
|
||||||
|
// temp[tempcount] = '\0';
|
||||||
|
// strcpy(excludetypes[typecount].type,temp);
|
||||||
|
// strcpy(temp,"");
|
||||||
|
// tempcount = 0;
|
||||||
|
// typecount = typecount + 1;
|
||||||
|
// }
|
||||||
|
// else
|
||||||
|
// {
|
||||||
|
//
|
||||||
|
// temp[tempcount] = type[i];
|
||||||
|
// tempcount = tempcount + 1;
|
||||||
|
// if(i==asd)
|
||||||
|
// {
|
||||||
|
// temp[tempcount] = '\0';
|
||||||
|
// strcpy(excludetypes[typecount].type,temp);
|
||||||
|
// typecount = typecount + 1;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
//}
|
||||||
@ -0,0 +1,41 @@
|
|||||||
|
/**
|
||||||
|
* @file common_itk_util.h
|
||||||
|
* @brief itk warpper utility function
|
||||||
|
* @author James
|
||||||
|
* @history
|
||||||
|
* ===================================================================================
|
||||||
|
* Date Name Description of Change
|
||||||
|
* 09-July-2008 James
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef COMMON_ITK_UTIL
|
||||||
|
#define COMMON_ITK_UTIL
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define DOFREE(obj) \
|
||||||
|
{ \
|
||||||
|
if(obj) \
|
||||||
|
{ \
|
||||||
|
MEM_free(obj); \
|
||||||
|
obj = NULL; \
|
||||||
|
} \
|
||||||
|
}
|
||||||
|
void ECHO(char *format, ...);
|
||||||
|
void CreateLogFile(char* FunctionName, char **fullname);
|
||||||
|
void WriteLog(const char* format, ...);
|
||||||
|
void CloseLog(void);
|
||||||
|
void set_bypass(logical bypass);
|
||||||
|
void current_time( date_t * date_tag );
|
||||||
|
//int FindDatasetReferenceExt( tag_t datasettype, const char *datasettype_ref, char ext[10] );
|
||||||
|
//int CompareDate( date_t date1, date_t date2 );
|
||||||
|
//int GetRandomTempFile( char tempFile[256] );
|
||||||
|
//logical IsItemRevisionType( char object_type[WSO_name_size_c + 1] );
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
||||||
@ -0,0 +1,52 @@
|
|||||||
|
#include "connor_util.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
*判断某个对象是否是类或者子类
|
||||||
|
*objtag 要判断的对象
|
||||||
|
*type_name 类型的名称
|
||||||
|
*/
|
||||||
|
int checkIsTypeOrSubtype(tag_t objtag,char * type_name){
|
||||||
|
printf("判断是否是%s及其子类\n",type_name);
|
||||||
|
tag_t type = NULLTAG;
|
||||||
|
ITKCALL(TCTYPE_ask_object_type(objtag,&type));
|
||||||
|
tag_t item_type = NULLTAG;
|
||||||
|
ITKCALL(TCTYPE_find_type(type_name,"",&item_type));
|
||||||
|
int is_type = 0;
|
||||||
|
if(item_type != NULLTAG){
|
||||||
|
printf("找到%s类\n",type_name);
|
||||||
|
//printf(" find Folder type ok !!!! \n");
|
||||||
|
logical isok = FALSE;
|
||||||
|
ITKCALL(TCTYPE_is_type_of(type,item_type,&isok));
|
||||||
|
if(isok){
|
||||||
|
printf("是%s类及其子类\n",type_name);
|
||||||
|
is_type= 1;
|
||||||
|
}else{
|
||||||
|
printf("不是%s类及其子类\n",type_name);
|
||||||
|
is_type= 0;
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
printf("没有找到%s类\n",type_name);
|
||||||
|
}
|
||||||
|
return is_type;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取首选项
|
||||||
|
*/
|
||||||
|
int getPrefStrings( const char *preference, TC_preference_search_scope_t scope, vector<string> &pref_vec )
|
||||||
|
{
|
||||||
|
int ifail = ITK_ok , i = 0, j = 0, k =0, num = 0;
|
||||||
|
char **values;
|
||||||
|
TC_preference_search_scope_t old_scope;
|
||||||
|
ITKCALL( ifail = PREF_ask_search_scope( &old_scope) );
|
||||||
|
ITKCALL( ifail = PREF_set_search_scope( scope ) );
|
||||||
|
ITKCALL( ifail = PREF_ask_char_values( preference, &num, &values ) );
|
||||||
|
//WriteLog("num=%d",num);
|
||||||
|
for(i = 0; i < num; i++)
|
||||||
|
{
|
||||||
|
pref_vec.push_back(values[i]);
|
||||||
|
}
|
||||||
|
DOFREE(values);
|
||||||
|
ITKCALL( ifail = PREF_set_search_scope( old_scope ) );
|
||||||
|
return ifail;
|
||||||
|
}
|
||||||
@ -0,0 +1,54 @@
|
|||||||
|
#include <ict/ict_userservice.h>
|
||||||
|
#include <tccore/item.h>
|
||||||
|
#include <ae/ae.h>
|
||||||
|
#include <tc/folder.h>
|
||||||
|
#include <tccore/aom.h>
|
||||||
|
#include <pom/pom/pom.h>
|
||||||
|
#include <sa/sa.h>
|
||||||
|
#include <tccore/aom_prop.h>
|
||||||
|
#include <property/prop_errors.h>
|
||||||
|
#include <tccore/workspaceobject.h>
|
||||||
|
#include <tc/preferences.h>
|
||||||
|
#include <tccore/imantype.h>
|
||||||
|
#include <tccore//grm.h>
|
||||||
|
#include <tccore/grmtype.h>
|
||||||
|
#include <sa/am.h>
|
||||||
|
#include <cfm/cfm.h>
|
||||||
|
#include <bom/bom.h>
|
||||||
|
#include <tccore/uom.h>
|
||||||
|
#include <ps/ps.h>
|
||||||
|
#include <epm/signoff.h>
|
||||||
|
#include <epm/epm_task_template_itk.h>
|
||||||
|
#include <fclasses/tc_date.h>
|
||||||
|
#include <tcinit/tcinit.h>
|
||||||
|
#include <ics/ics.h>
|
||||||
|
#include <ics/ics2.h>
|
||||||
|
#include <pom/enq/enq.h>
|
||||||
|
#include <rdv/arch.h>
|
||||||
|
#include <tc/envelope.h>
|
||||||
|
#include <epm/distributionlist.h>
|
||||||
|
#include <sa/user.h>
|
||||||
|
#include <time.h>
|
||||||
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
|
#include <map>
|
||||||
|
#include <fstream>
|
||||||
|
#include <iostream>
|
||||||
|
#include <algorithm>
|
||||||
|
#include <io.h>
|
||||||
|
#include <direct.h>
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
#define DOFREE(obj) \
|
||||||
|
{ \
|
||||||
|
if(obj) \
|
||||||
|
{ \
|
||||||
|
MEM_free(obj); \
|
||||||
|
obj = NULL; \
|
||||||
|
} \
|
||||||
|
}
|
||||||
|
|
||||||
|
int checkIsTypeOrSubtype(tag_t objtag,char * type_name);
|
||||||
|
int getPrefStrings( const char *preference, TC_preference_search_scope_t scope, vector<string> &pref_vec);
|
||||||
|
|
||||||
|
|
||||||
@ -0,0 +1,321 @@
|
|||||||
|
#pragma warning (disable: 4996)
|
||||||
|
#pragma warning (disable: 4819)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @headerfile tcua 头文件
|
||||||
|
*/
|
||||||
|
#include <tc\tc_macros.h>
|
||||||
|
#include <tc\emh.h>
|
||||||
|
#include <tc\preferences.h>
|
||||||
|
#include <property\propdesc.h>
|
||||||
|
#include <epm\epm.h>
|
||||||
|
#include <epm\epm_toolkit_tc_utils.h>
|
||||||
|
#include <tccore\item.h>
|
||||||
|
#include <tccore\grmtype.h>
|
||||||
|
#include <tccore\grm.h>
|
||||||
|
#include <tccore\imantype.h>
|
||||||
|
#include <sa\am.h>
|
||||||
|
#include <sa\sa.h>
|
||||||
|
#include <tccore\aom.h>
|
||||||
|
#include <tccore\aom_prop.h>
|
||||||
|
#include <property\prop_errors.h>
|
||||||
|
#include <tccore\workspaceobject.h>
|
||||||
|
#include <qry\qry.h>
|
||||||
|
#include <bom\bom_attr.h>
|
||||||
|
#include <bom\bom.h>
|
||||||
|
#include <epm\signoff.h>
|
||||||
|
#include <pom\pom\pom.h>
|
||||||
|
#include <pom\pom\pom_errors.h>
|
||||||
|
#include <fclasses\tc_date.h>
|
||||||
|
#include <epm\cr.h>
|
||||||
|
#include <cfm\cfm.h>
|
||||||
|
#include <sa\am.h>
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <ctype.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
#include <iostream>
|
||||||
|
#include <iterator>
|
||||||
|
#include <map>
|
||||||
|
#include <vector>
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @headerfile user's header files
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "epm_handler_common.h"
|
||||||
|
#include "error_handling.h"
|
||||||
|
|
||||||
|
#define BOM_VIEWTYPE "view"
|
||||||
|
void ECHO(char *format, ...);
|
||||||
|
extern "C" int POM_AM__set_application_bypass(logical bypass);
|
||||||
|
extern "C" int AM__set_application_bypass(logical bypass);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
int getBomView(tag_t rev_tag, char* viewtype, tag_t *bomView, tag_t *bomBVR, int debug);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
int CycleBOM1( tag_t bomline, char *userid,char *status, vector<tag_t> &attach_vec, map< string,int > &errMap, logical debug)
|
||||||
|
{
|
||||||
|
tag_t child_item_tag = NULLTAG, child_rev_tag = NULLTAG, ebom_view = NULLTAG, ebom_bvr = NULLTAG,
|
||||||
|
*child_lines = NULL, *status_tag_list = NULL, last_rev = NULLTAG, owning_user = NULLTAG;
|
||||||
|
int ifail = ITK_ok ,j = 0, itemrev_attr_id = 0, zuhao_attr_id = 0, child_cnt = 0, viewtype_attr_id = 0,
|
||||||
|
status_attr_id = 0, status_count = 0;
|
||||||
|
char child_item_id[ITEM_id_size_c + 1]="", *viewtype_value = NULL, *status_list = NULL,
|
||||||
|
child_rev_id[8]="", user_id[33]="";
|
||||||
|
|
||||||
|
ITKCALL(ifail = BOM_line_look_up_attribute(bomAttr_itemRevStatus, &status_attr_id));
|
||||||
|
ITKCALL( ifail = BOM_line_look_up_attribute(bomAttr_lineItemRevTag, &itemrev_attr_id));
|
||||||
|
ITKCALL(ifail = BOM_line_ask_child_lines(bomline, &child_cnt, &child_lines));
|
||||||
|
for( int i = 0; i < child_cnt; i++ )
|
||||||
|
{
|
||||||
|
//ITKCALL(ifail = BOM_line_ask_attribute_string(child_lines[k], status_attr_id, &status_list));
|
||||||
|
|
||||||
|
ITKCALL( ifail = BOM_line_ask_attribute_tag(child_lines[i], itemrev_attr_id, &child_rev_tag));
|
||||||
|
ITKCALL(AOM_ask_owner( child_rev_tag, &owning_user));
|
||||||
|
ITKCALL (SA_ask_user_identifier(owning_user, user_id));
|
||||||
|
if( debug )
|
||||||
|
ECHO("process user_id is %s, object owner is %s\n", userid, user_id);
|
||||||
|
if( strcmp( userid, user_id ) ==0 )
|
||||||
|
{
|
||||||
|
ITKCALL(WSOM_ask_release_status_list(child_rev_tag,&status_count,&status_tag_list));
|
||||||
|
logical isInculde = false;
|
||||||
|
if( status_count > 0 )
|
||||||
|
{
|
||||||
|
for (int j = 0;j < status_count;j++)
|
||||||
|
{
|
||||||
|
char status_type[WSO_name_size_c+1] = "";
|
||||||
|
ITKCALL(CR_ask_release_status_type(status_tag_list[j],status_type));
|
||||||
|
if( debug )
|
||||||
|
ECHO("指定状态:%s, 对象发布状态:%s\n",status,status_type);
|
||||||
|
if( stricmp(status_type, status) == 0 )
|
||||||
|
{
|
||||||
|
int last_status_count = 0;
|
||||||
|
tag_t *last_status_tag_list = NULL,new_child_rev = NULLTAG;
|
||||||
|
ITKCALL(ITEM_ask_item_of_rev( child_rev_tag, &child_item_tag ));
|
||||||
|
ITKCALL(ITEM_ask_latest_rev( child_item_tag, &last_rev ));
|
||||||
|
ITKCALL(WSOM_ask_release_status_list(last_rev,&last_status_count,&last_status_tag_list));
|
||||||
|
if( last_status_count == 0 )
|
||||||
|
{
|
||||||
|
attach_vec.push_back(last_rev);
|
||||||
|
if( debug )
|
||||||
|
ECHO("add last_rev");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
POM_AM__set_application_bypass(true);
|
||||||
|
//ITKCALL( ITEM_create_rev(child_item_tag, NULL, &new_child_rev ));
|
||||||
|
ITKCALL( ITEM_copy_rev( last_rev,NULL, &new_child_rev ));
|
||||||
|
ITKCALL(AOM_save(new_child_rev));
|
||||||
|
ITKCALL(AOM_unlock(new_child_rev));
|
||||||
|
attach_vec.push_back(new_child_rev);
|
||||||
|
if( debug )
|
||||||
|
ECHO("add new_child_rev");
|
||||||
|
}
|
||||||
|
DOFREE(last_status_tag_list);
|
||||||
|
}
|
||||||
|
} //for
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
attach_vec.push_back(child_rev_tag);
|
||||||
|
if( debug )
|
||||||
|
ECHO("add self");
|
||||||
|
}
|
||||||
|
DOFREE(status_tag_list);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
for( int i = 0; i < child_cnt; i++ )
|
||||||
|
{
|
||||||
|
ifail = CycleBOM1(child_lines[i], userid, status, attach_vec, errMap, debug);
|
||||||
|
}
|
||||||
|
return ifail;
|
||||||
|
}
|
||||||
|
|
||||||
|
int HZ_attach_assembly(EPM_action_message_t msg)
|
||||||
|
{
|
||||||
|
|
||||||
|
int ifail = ITK_ok, arg_cnt = 0, att_cnt = 0, i, j, k, m,p,q, pref_count = 0, bvr_cnt = 0, child_cnt = 0,
|
||||||
|
status_attr_id = 0, rev_attr_id = 0, form_count =0, value_count = 0,n_instances = 0,
|
||||||
|
factory_count = 0, num = 0, bvr_count = 0;
|
||||||
|
tag_t task_tag = NULLTAG, rootTask_tag = NULLTAG, type_tag = NULLTAG, rev_rule_tag = NULLTAG;
|
||||||
|
tag_t *attachments = NULL, *bvrs = NULL, *child_lines = NULL, child_rev_tag = NULLTAG, item_tag = NULLTAG,
|
||||||
|
rev_tag = NULLTAG;
|
||||||
|
char *arg = NULL, *flag = NULL, *value = NULL, **values = NULL, type_class[WSO_object_type_size_c+1],
|
||||||
|
item_id[ITEM_id_size_c+1], rev_id[ITEM_id_size_c+1], *argflag =NULL,*argvalue=NULL ,
|
||||||
|
arg_rev_rule[128] = "",arg_status[128] = "",arg3value[128]="",arg_debug[10]="", userid[33]="";
|
||||||
|
|
||||||
|
int attachment_types = 0;
|
||||||
|
logical is_bypass= false;
|
||||||
|
logical debug = true;
|
||||||
|
tag_t bomWindow = NULLTAG, bom_top_line = NULLTAG, bom_config_rule = NULLTAG;
|
||||||
|
map<string,int> errMap;
|
||||||
|
vector<tag_t> attach_vec;
|
||||||
|
EPM_decision_t decision = EPM_go;
|
||||||
|
|
||||||
|
ECHO("*************************************************************\n");
|
||||||
|
ECHO("* HZ_attach_assembly is comming ! *\n");
|
||||||
|
ECHO("*************************************************************\n");
|
||||||
|
|
||||||
|
POM_AM__set_application_bypass(true);
|
||||||
|
ECHO("POM_AM__set_application_bypass\n");
|
||||||
|
|
||||||
|
task_tag = msg.task;
|
||||||
|
if(task_tag == NULLTAG)
|
||||||
|
{
|
||||||
|
ifail = ITK_ok;
|
||||||
|
//goto end_handler;
|
||||||
|
return ifail;
|
||||||
|
}
|
||||||
|
tag_t rootTask = NULLTAG;
|
||||||
|
|
||||||
|
|
||||||
|
//获得参数
|
||||||
|
arg_cnt = TC_number_of_arguments(msg.arguments);
|
||||||
|
if (debug)
|
||||||
|
ECHO("\n arg_cnt=%d\n",arg_cnt);
|
||||||
|
ITKCALL(ifail = EPM_setup_parser(task_tag));
|
||||||
|
for (i=0;i<arg_cnt;i++)
|
||||||
|
{
|
||||||
|
arg = TC_next_argument(msg.arguments);
|
||||||
|
ITKCALL(ifail = ITK_ask_argument_named_value((const char*)arg, &argflag, &argvalue));
|
||||||
|
if (stricmp(argflag, "rev_rule") == 0)
|
||||||
|
{
|
||||||
|
if(argvalue != NULL)
|
||||||
|
{
|
||||||
|
strcpy(arg_rev_rule,argvalue);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if(stricmp(argflag, "status") == 0)
|
||||||
|
{
|
||||||
|
if(argvalue != NULL)
|
||||||
|
{
|
||||||
|
strcpy(arg_status,argvalue);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if(stricmp(argflag,"debug") == 0)
|
||||||
|
{
|
||||||
|
if( argvalue!= NULL)
|
||||||
|
{
|
||||||
|
strcpy(arg_debug,argvalue);
|
||||||
|
if( strcmp( arg_debug, "true") == 0)
|
||||||
|
{
|
||||||
|
debug = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
debug = false;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//tag_t group_member = NULLTAG;
|
||||||
|
tag_t user = NULLTAG;
|
||||||
|
|
||||||
|
ifail = CFM_find(arg_rev_rule, &rev_rule_tag );
|
||||||
|
|
||||||
|
ITKCALL(ifail = EPM_ask_root_task(task_tag, &rootTask_tag));
|
||||||
|
|
||||||
|
ITKCALL(AOM_ask_owner(rootTask_tag, &user));
|
||||||
|
|
||||||
|
ITKCALL(SA_ask_user_identifier( user , userid));
|
||||||
|
ECHO("userid:%s\n",userid);
|
||||||
|
if( strlen(arg_status)< 2 )
|
||||||
|
{
|
||||||
|
|
||||||
|
EPM_set_decision(msg.task, user, CR_no_decision, "", false );
|
||||||
|
|
||||||
|
EMH_store_error_s1(EMH_severity_information, HANDLER_ARGUMENT_ERROR, "缺少status参数");
|
||||||
|
ifail = CR_error_in_handler;
|
||||||
|
return ifail;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//if( strlen(arg_rev_rule)< 2 )
|
||||||
|
//{
|
||||||
|
|
||||||
|
// EPM_set_decision(msg.task, user, CR_no_decision, "", false );
|
||||||
|
|
||||||
|
// EMH_store_error_s1(EMH_severity_information, HANDLER_ARGUMENT_ERROR, "缺少rev_rule参数");
|
||||||
|
// ifail = CR_error_in_handler;
|
||||||
|
// return ifail;
|
||||||
|
|
||||||
|
//}
|
||||||
|
ITKCALL(ifail = EPM_ask_attachments(rootTask_tag, EPM_target_attachment, &att_cnt, &attachments));
|
||||||
|
if( debug )
|
||||||
|
ECHO("DEBUG: find %d target\n", att_cnt);
|
||||||
|
for( i = 0; i < att_cnt; i++ )
|
||||||
|
{
|
||||||
|
ITKCALL( WSOM_ask_object_type(attachments[i], type_class));
|
||||||
|
if (((strstr(type_class,"Revision") != NULL) || (strstr(type_class,"revision") != NULL))
|
||||||
|
&&(strstr(type_class,"Master") == NULL) &&(strstr(type_class,"master") == NULL)
|
||||||
|
&& (strstr(type_class,"BOM") ==NULL) && (strstr(type_class,"bom") ==NULL) && (strstr(type_class,"Bom") == NULL))
|
||||||
|
{
|
||||||
|
rev_tag = attachments[i];
|
||||||
|
ITKCALL(ITEM_ask_item_of_rev(rev_tag, &item_tag));
|
||||||
|
ITKCALL(ITEM_ask_id(item_tag, item_id));
|
||||||
|
tag_t ebom_view = NULLTAG, ebom_bvr = NULLTAG, ebom_window = NULLTAG, ebom_line = NULLTAG,
|
||||||
|
dbom_view = NULLTAG,dbom_bvr = NULLTAG;
|
||||||
|
ifail = getBomView(rev_tag, BOM_VIEWTYPE, &ebom_view, &ebom_bvr, 1);
|
||||||
|
|
||||||
|
if( ebom_view != NULLTAG )
|
||||||
|
{
|
||||||
|
ITKCALL( BOM_create_window( &ebom_window ) );
|
||||||
|
if( rev_rule_tag != NULLTAG)
|
||||||
|
ITKCALL( BOM_set_window_config_rule(ebom_window, rev_rule_tag));
|
||||||
|
ITKCALL( BOM_set_window_top_line_bvr( ebom_window, ebom_bvr, &ebom_line ) );
|
||||||
|
CycleBOM1(ebom_line,userid ,arg_status,attach_vec,errMap,debug);
|
||||||
|
ITKCALL(BOM_close_window(ebom_window));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
DOFREE(attachments);
|
||||||
|
if (debug)
|
||||||
|
ECHO("\nDEBUG: attach_vec.size=%d\n",attach_vec.size());
|
||||||
|
attachment_types = EPM_target_attachment;
|
||||||
|
POM_AM__set_application_bypass(true);
|
||||||
|
for( i = 0; i < attach_vec.size(); i ++ )
|
||||||
|
{
|
||||||
|
ITKCALL(EPM_add_attachments(rootTask_tag, 1,&(attach_vec[i]),&attachment_types));
|
||||||
|
}
|
||||||
|
if( debug )
|
||||||
|
ECHO("DEBUG: errMap.size is %d\n", errMap.size());
|
||||||
|
|
||||||
|
//释放
|
||||||
|
attach_vec.clear();
|
||||||
|
//关闭bypass
|
||||||
|
//POM_AM__ask_application_bypass( &is_bypass );
|
||||||
|
//if( is_bypass );
|
||||||
|
POM_AM__set_application_bypass( false );
|
||||||
|
//if( errMap.size() > 0 )
|
||||||
|
//{
|
||||||
|
// EPM_set_decision(msg.task, user, CR_no_decision, "", false );
|
||||||
|
// map<string,int>::iterator err_it;
|
||||||
|
// for( err_it = errMap.begin(); err_it != errMap.end(); err_it++ )
|
||||||
|
// {
|
||||||
|
// ECHO("DEBUG: err_it is %s\n", err_it->first.c_str());
|
||||||
|
// EMH_store_error_s1(EMH_severity_information,err_it->second, err_it->first.c_str());
|
||||||
|
// }
|
||||||
|
// ifail = CR_error_in_handler;
|
||||||
|
// return ifail;
|
||||||
|
//}
|
||||||
|
|
||||||
|
|
||||||
|
errMap.clear();
|
||||||
|
ECHO("\n************************************************************\n");
|
||||||
|
ECHO("* HZ_attach_assembly is end! *\n");
|
||||||
|
ECHO("*************************************************************\n");
|
||||||
|
return ITK_ok;
|
||||||
|
}
|
||||||
@ -0,0 +1,69 @@
|
|||||||
|
/**
|
||||||
|
* @addtogroup handler
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @file epm_handler_common.h
|
||||||
|
* @brief handler functions declation
|
||||||
|
* @date 2011/4/12
|
||||||
|
* @author Ray
|
||||||
|
* @history
|
||||||
|
* ===================================================================================
|
||||||
|
* Date Name Description
|
||||||
|
* 12-Apr-2011 Ray created
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef EPM_HANDLER_COMMON
|
||||||
|
#define EPM_HANDLER_COMMON
|
||||||
|
|
||||||
|
#include <epm/epm.h>
|
||||||
|
#include <string>
|
||||||
|
#include <map>
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
|
||||||
|
#define TC_specification "IMAN_specification"
|
||||||
|
//#define NX_3W_DATASET_TYPE "UGMASTER"
|
||||||
|
//#define NX_2W_DATASET_TYPE "UGPART"
|
||||||
|
//#define DATASET_REF_TYPE "UGPART"
|
||||||
|
int ORIGIN_set_bypass(void *returnValue);
|
||||||
|
int USERSEVICE_TEST(void * returnValue);
|
||||||
|
int remove_class(void *returnValue);
|
||||||
|
int connor_set_release_status(void * returnValue);
|
||||||
|
int ORIGIN_close_bypass(void *returnValue);
|
||||||
|
int getDbMsg(void *returnValue);
|
||||||
|
int jf_sign_ir_master(EPM_action_message_t msg);
|
||||||
|
int tx_sign_ir_master(EPM_action_message_t msg);
|
||||||
|
int tx_AutoSign_Handler(EPM_action_message_t msg);
|
||||||
|
int jk_AutoSign_Handler(EPM_action_message_t msg);
|
||||||
|
int jf_signoff_dataset( EPM_action_message_t msg );
|
||||||
|
int check_target_null( EPM_rule_message_t msg );
|
||||||
|
int jk_check_virtual( EPM_rule_message_t msg );
|
||||||
|
int JK_check_workflow( EPM_rule_message_t msg );
|
||||||
|
int tm_sign_tongzhi(EPM_action_message_t msg);
|
||||||
|
int tm_show_object_name(EPM_action_message_t msg);
|
||||||
|
int JK_bypass(EPM_action_message_t msg);
|
||||||
|
int JK_class_null(EPM_rule_message_t msg);
|
||||||
|
|
||||||
|
int HZ_Check_BOM_Condition(EPM_rule_message_t msg);
|
||||||
|
int HZ_attach_assembly(EPM_action_message_t msg);
|
||||||
|
//user service end
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
@ -0,0 +1,39 @@
|
|||||||
|
|
||||||
|
/*=================================================================================
|
||||||
|
* @file epm_register_handler.h
|
||||||
|
* @brief itk user exits function declation, to register custom handlers
|
||||||
|
* @date 2009/2/13
|
||||||
|
* @author Ray Li
|
||||||
|
* @history
|
||||||
|
* ===================================================================================
|
||||||
|
* Date Name Description
|
||||||
|
* 13-Feb-2009 Ray created
|
||||||
|
*===================================================================================*/
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef EPM_REGISTER_HANDLER_CUSTOM
|
||||||
|
#define EPM_REGISTER_HANDLER_CUSTOM
|
||||||
|
|
||||||
|
#include <epm/epm.h>
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
extern DLLAPI int USERSERVICE_custom_register_handlers(int *, va_list);
|
||||||
|
extern DLLAPI int USERSERVICE_custom_register_methods(int *decision, va_list args);
|
||||||
|
extern DLLAPI int USERSERVICE_custom_register_runtime_methods(int *decision, va_list args);
|
||||||
|
extern int Register_revise_msg( void );
|
||||||
|
extern int Run_Time_register_properties( void );
|
||||||
|
// int Q7_ebom_to_pbom (void * returnValueType);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,10 @@
|
|||||||
|
|
||||||
|
#include <rdv/arch.h>
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
void SplitUserInfo(char *userinfo);
|
||||||
|
void txSplitUserInfo(char *userinfo);
|
||||||
|
void SplitTimeInfo(char *userinfo);
|
||||||
|
void txSplitTimeInfo(char *userinfo);
|
||||||
|
int ORIGIN_ask_sign_info(tag_t task_node, char *output_str,char *task_name,char *arg3value);
|
||||||
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,14 @@
|
|||||||
|
#include "erp_utils.h"
|
||||||
|
#include "ocilib.h"
|
||||||
|
#include "common_itk_util.h"
|
||||||
|
#include "string_utils.h"
|
||||||
|
#include <vector>
|
||||||
|
#include <map>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
int jf_erp_send_items(EPM_action_message_t msg);
|
||||||
|
int jf_erp_send_boms(EPM_action_message_t msg);
|
||||||
|
int jf_insert_img_pdf(EPM_action_message_t msg);
|
||||||
|
int jf_hl_send_items(EPM_action_message_t msg);
|
||||||
|
int jf_hl_send_boms(EPM_action_message_t msg);
|
||||||
|
int jf_control_plan_send(EPM_action_message_t msg);
|
||||||
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,28 @@
|
|||||||
|
|
||||||
|
#pragma warning (disable: 4996)
|
||||||
|
#pragma warning (disable: 4819)
|
||||||
|
|
||||||
|
|
||||||
|
#include "erp_utils.h"
|
||||||
|
#include "ocilib.h"
|
||||||
|
#include "common_itk_util.h"
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
|
||||||
|
int getPrefStrings( const char *preference, TC_preference_search_scope_t scope, vector<string> &pref_vec )
|
||||||
|
{
|
||||||
|
int ifail = ITK_ok , i = 0, j = 0, k =0, num = 0;
|
||||||
|
char **values;
|
||||||
|
TC_preference_search_scope_t old_scope;
|
||||||
|
ITKCALL( ifail = PREF_ask_search_scope( &old_scope) );
|
||||||
|
ITKCALL( ifail = PREF_set_search_scope( scope ) );
|
||||||
|
ITKCALL( ifail = PREF_ask_char_values( preference, &num, &values ) );
|
||||||
|
WriteLog("num=%d",num);
|
||||||
|
for(i = 0; i < num; i++)
|
||||||
|
{
|
||||||
|
pref_vec.push_back(values[i]);
|
||||||
|
}
|
||||||
|
DOFREE(values);
|
||||||
|
ITKCALL( ifail = PREF_set_search_scope( old_scope ) );
|
||||||
|
return ifail;
|
||||||
|
}
|
||||||
@ -0,0 +1,102 @@
|
|||||||
|
/**
|
||||||
|
* @addtogroup batch service
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @file erp_utils.h
|
||||||
|
*
|
||||||
|
* @brief import item from middle table
|
||||||
|
*
|
||||||
|
* @author Ray Li
|
||||||
|
*
|
||||||
|
* @history
|
||||||
|
* ===================================================================================
|
||||||
|
* Date Name Description of Change
|
||||||
|
* 3-Feb-2015 Ray created
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @headerfile tcua 头文件
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <ict/ict_userservice.h>
|
||||||
|
#include <tccore/item.h>
|
||||||
|
#include <ae/ae.h>
|
||||||
|
#include <tc/folder.h>
|
||||||
|
#include <tccore/aom.h>
|
||||||
|
#include <pom/pom/pom.h>
|
||||||
|
#include <sa/sa.h>
|
||||||
|
#include <tccore/aom_prop.h>
|
||||||
|
#include <property/prop_errors.h>
|
||||||
|
#include <tccore/workspaceobject.h>
|
||||||
|
#include <tc/preferences.h>
|
||||||
|
#include <tccore/imantype.h>
|
||||||
|
#include <tccore//grm.h>
|
||||||
|
#include <tccore/grmtype.h>
|
||||||
|
#include <sa/am.h>
|
||||||
|
#include <cfm/cfm.h>
|
||||||
|
#include <bom/bom.h>
|
||||||
|
#include <tccore/uom.h>
|
||||||
|
#include <ps/ps.h>
|
||||||
|
#include <epm/epm.h>
|
||||||
|
#include <epm/signoff.h>
|
||||||
|
#include <epm/epm_task_template_itk.h>
|
||||||
|
#include <epm/epm_toolkit_tc_utils.h>
|
||||||
|
#include <fclasses/tc_date.h>
|
||||||
|
#include <tcinit/tcinit.h>
|
||||||
|
#include <ics/ics.h>
|
||||||
|
#include <ics/ics2.h>
|
||||||
|
#include <pom/enq/enq.h>
|
||||||
|
/**
|
||||||
|
* @headerfile standard c & cpp header files
|
||||||
|
*/
|
||||||
|
#include <time.h>
|
||||||
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
|
#include <map>
|
||||||
|
#include <fstream>
|
||||||
|
#include <iostream>
|
||||||
|
#include <algorithm>
|
||||||
|
#include <io.h>
|
||||||
|
#include <direct.h>
|
||||||
|
#include <tccore/method.h>
|
||||||
|
#include <tccore/tc_msg.h>
|
||||||
|
#include <tccore/iman_msg.h>
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
//erp table name
|
||||||
|
#define PART_INFO_TABLE "ERP_PART_INFO_TABLE"
|
||||||
|
|
||||||
|
#define PREF_JF3_ERP_DB_Login_Info "TM2_ERP_DB_Login_Info"
|
||||||
|
|
||||||
|
#define CUST_CP_NAME_PROPS "Cust_ERP_PLM_CP_Name_Props"//成品名称规则
|
||||||
|
#define CUST_CP_GG_PROPS "Cust_ERP_PLM_CP_GG_Props"//成品规格规则
|
||||||
|
#define CUST_BCP_NAME_PROPS "Cust_ERP_PLM_BCP_Name_Props"//半成品名称规格
|
||||||
|
#define CUST_BCP_GG_PROPS "Cust_ERP_PLM_BCP_GG_Props"//半成品规格规则
|
||||||
|
#define CUST_YCL_NAME_PROPS "Cust_ERP_PLM_YCL_NAME_Props"//原材料名称规则
|
||||||
|
#define CUST_WL_PROPS "Cust_ERP_PLM_WL_Props"//物料JAVA取属性规则
|
||||||
|
|
||||||
|
//error
|
||||||
|
#define ERROR_PREFERENCE_ERROR (EMH_USER_error_base + 1)
|
||||||
|
#define ERROR_ERP_LOGIN_FAIL (EMH_USER_error_base + 2)
|
||||||
|
|
||||||
|
//ERP
|
||||||
|
#define ERROR_OCI_FAIL (EMH_USER_error_base + 11)
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C"
|
||||||
|
{
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
int getPrefStrings( const char *preference, TC_preference_search_scope_t scope, vector<string> &pref_vec );
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
@ -0,0 +1,162 @@
|
|||||||
|
/*!
|
||||||
|
* @addtogroup common
|
||||||
|
* \file error_handling.h
|
||||||
|
* \brief 错误处理函数
|
||||||
|
* \date 2008/6/10
|
||||||
|
* \author Ray Li
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef SIMPLE_ERR_H_INCLUDED
|
||||||
|
#define SIMPLE_ERR_H_INCLUDED
|
||||||
|
|
||||||
|
|
||||||
|
#include <itk/mem.h>
|
||||||
|
#include <tc/iman.h>
|
||||||
|
#include <tc/emh.h>
|
||||||
|
#include <pom/pom/pom_errors.h>
|
||||||
|
#include <tc/emh_const.h>
|
||||||
|
#include <tc/tc.h>
|
||||||
|
#include <pom/pom/pom.h>
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <time.h>
|
||||||
|
|
||||||
|
#define BUFSIZE 512
|
||||||
|
|
||||||
|
|
||||||
|
//
|
||||||
|
#define HANDLER_ARGUMENT_ERROR EMH_USER_error_base + 1
|
||||||
|
//#define WORKFLOW_NODE_IS_NOT_VALID EMH_USER_error_base + 2
|
||||||
|
|
||||||
|
#define ERROR_STATUS_ERROR EMH_USER_error_base + 2
|
||||||
|
//#define HANDLER_PLACED_INVALID EMH_USER_error_base + 3
|
||||||
|
//
|
||||||
|
////user errors define
|
||||||
|
////<error id="100">在站点文件中缺少 %1$ 配置,或该配置中无数据项</error>
|
||||||
|
//#define ERROR_PREFERENCE_NOT_FOUND (EMH_USER_error_base + 100)
|
||||||
|
|
||||||
|
|
||||||
|
#define DOFREE(obj) \
|
||||||
|
{ \
|
||||||
|
if(obj) \
|
||||||
|
{ \
|
||||||
|
MEM_free(obj); \
|
||||||
|
obj = NULL; \
|
||||||
|
} \
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//#define ECHO(X) printf X;
|
||||||
|
#define SYS_LOG(X) IMAN_write_syslog X;
|
||||||
|
#define LOG_ECHO(X) printf X; IMAN_write_syslog X;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \def CALL(x)
|
||||||
|
* 打印错误信息
|
||||||
|
*/
|
||||||
|
#define CALL(x) { \
|
||||||
|
int stat; \
|
||||||
|
char *err_string; \
|
||||||
|
if( (stat = (x)) != ITK_ok) \
|
||||||
|
{ \
|
||||||
|
EMH_ask_error_text (stat, &err_string); \
|
||||||
|
LOG_ECHO( ("ERROR: %d ERROR MSG: %s.\n",stat, err_string) ) \
|
||||||
|
LOG_ECHO( ("Function: %s FILE: %s LINE: %d\n", #x, __FILE__, __LINE__ ) ) \
|
||||||
|
MEM_free (err_string); \
|
||||||
|
return (stat); \
|
||||||
|
} \
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \def DO(x)
|
||||||
|
* 打印错误信息
|
||||||
|
*/
|
||||||
|
#define DO(x) { \
|
||||||
|
int stat; \
|
||||||
|
char *err_string; \
|
||||||
|
if( (stat = (x)) != POM_ok) \
|
||||||
|
{ \
|
||||||
|
EMH_ask_error_text (stat, &err_string); \
|
||||||
|
printf ("ERROR: %d ERROR MSG: %s.\n", stat, err_string); \
|
||||||
|
printf ("Function: %s FILE: %s LINE: %d\n",#x, __FILE__, __LINE__); \
|
||||||
|
MEM_free (err_string); \
|
||||||
|
} \
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \def CALLRNULL(x)
|
||||||
|
* 打印错误信息
|
||||||
|
*/
|
||||||
|
#define CALLRNULL(x) { \
|
||||||
|
int stat; \
|
||||||
|
char *err_string; \
|
||||||
|
if( (stat = (x)) != ITK_ok) \
|
||||||
|
{ \
|
||||||
|
EMH_ask_error_text (stat, &err_string); \
|
||||||
|
printf ("ERROR: %d ERROR MSG: %s.\n", stat, err_string); \
|
||||||
|
printf ("Function: %s FILE: %s LINE: %d\n",#x, __FILE__, __LINE__); \
|
||||||
|
MEM_free (err_string); \
|
||||||
|
return ((char *)NULL); \
|
||||||
|
} \
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \def CALL2(x)
|
||||||
|
* 打印错误信息
|
||||||
|
*/
|
||||||
|
#define CALL2(x) { \
|
||||||
|
int stat, n_ifails, *serverities, *ifails, err_count; \
|
||||||
|
char *err_string, **texts; \
|
||||||
|
if( (stat = (x)) != ITK_ok) \
|
||||||
|
{ \
|
||||||
|
printf ("Function: %s FILE: %s LINE: %d\n",#x, __FILE__, __LINE__); \
|
||||||
|
EMH_ask_errors( &n_ifails, (const int**)(&serverities), (const int**)(&ifails), (const char***)(&texts) );\
|
||||||
|
for( err_count=0; err_count<n_ifails; err_count++ ) \
|
||||||
|
{ \
|
||||||
|
printf( "ERROR: %d ERROR MSG: %s.\n", ifails[i], texts[i] ); \
|
||||||
|
} \
|
||||||
|
MEM_free( serverities ); \
|
||||||
|
MEM_free( ifails ); \
|
||||||
|
MEM_free( texts ); \
|
||||||
|
return (stat); \
|
||||||
|
} \
|
||||||
|
} \
|
||||||
|
|
||||||
|
#define CHECK_FILE(x,ret) { \
|
||||||
|
FILE *stream = NULL; \
|
||||||
|
if( (stream = fopen(x,"rb")) == NULL ) { \
|
||||||
|
printf( "%s doesn't exists, please check!\n", x ); \
|
||||||
|
IMAN_write_syslog( "%s doesn't exists, please check!\n", x) ; \
|
||||||
|
ret = -1; \
|
||||||
|
} \
|
||||||
|
else { \
|
||||||
|
fclose(stream); \
|
||||||
|
stream = NULL; \
|
||||||
|
ret = 0; \
|
||||||
|
} \
|
||||||
|
} \
|
||||||
|
|
||||||
|
|
||||||
|
#define CHECK_FILE_NOT_EXISTS(x,ret) { \
|
||||||
|
FILE *stream = NULL; \
|
||||||
|
if( (stream = fopen(x,"rb")) != NULL ) { \
|
||||||
|
fclose(stream); \
|
||||||
|
stream = NULL; \
|
||||||
|
printf( "%s exists, please check!\n", x ); \
|
||||||
|
IMAN_write_syslog( "%s exists, please check!\n", x) ; \
|
||||||
|
ret = -1; \
|
||||||
|
} \
|
||||||
|
else { \
|
||||||
|
ret = 0; \
|
||||||
|
} \
|
||||||
|
} \
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
||||||
@ -0,0 +1,55 @@
|
|||||||
|
#include "erp_utils.h"
|
||||||
|
#include "ocilib.h"
|
||||||
|
#include "common_itk_util.h"
|
||||||
|
#include "string_utils.h"
|
||||||
|
#include "string_helper.h"
|
||||||
|
#include "error_handling.h"
|
||||||
|
#include "connor_util.h"
|
||||||
|
#include <vector>
|
||||||
|
#include <map>
|
||||||
|
#include <string>
|
||||||
|
#include <tccore/item_errors.h>
|
||||||
|
#include <ics/ics_enquiry.h>
|
||||||
|
#include <ict/ict_userservice.h>
|
||||||
|
#include <bom/bom_msg.h>
|
||||||
|
#include <tccore/tc_msg.h>
|
||||||
|
#include <ics/ics.h>
|
||||||
|
#include <property/prop_msg.h>
|
||||||
|
#include <bom/bom_msg.h>
|
||||||
|
#include <tccore/item_msg.h>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#define ERROR_QRY_NOT_FOUND (EMH_USER_error_base + 120)
|
||||||
|
extern "C" int POM_AM__set_application_bypass(logical bypass);
|
||||||
|
int HX3_create_item_post(METHOD_message_t* msg , va_list va);
|
||||||
|
int HX3_post_prop_set_MJ( METHOD_message_t *msg, va_list args );
|
||||||
|
int HX3_post_prop_set_JJ( METHOD_message_t *msg, va_list args );
|
||||||
|
int HX3_regist_runtime_prop(METHOD_message_t* msg, va_list args);
|
||||||
|
int HX3_bom_save(METHOD_message_t* msg, va_list args);
|
||||||
|
int HX3_mod_date(METHOD_message_t* msg, va_list args);
|
||||||
|
int HX3_check_prop_is_not_empty(EPM_rule_message_t msg);
|
||||||
|
int Test_set_string( METHOD_message_t *msg, va_list args );
|
||||||
|
int LP_set_prop( METHOD_message_t *msg, va_list args );
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
|
||||||
|
string p_attr_id;
|
||||||
|
string c_class_name;
|
||||||
|
string c_class_id;
|
||||||
|
string c_attr_id;
|
||||||
|
|
||||||
|
} ATTR_NODE;
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
|
||||||
|
string id;
|
||||||
|
string class_dis_name;
|
||||||
|
string class_rel_name;
|
||||||
|
string id_dis_anme;
|
||||||
|
vector<ATTR_NODE> attr_node_vec;
|
||||||
|
|
||||||
|
} CLASS_DEFINE_STRUCT;
|
||||||
@ -0,0 +1,14 @@
|
|||||||
|
#include "erp_utils.h"
|
||||||
|
#include "ocilib.h"
|
||||||
|
#include "common_itk_util.h"
|
||||||
|
#include "string_utils.h"
|
||||||
|
#include "string_helper.h"
|
||||||
|
#include "error_handling.h"
|
||||||
|
#include <vector>
|
||||||
|
#include <map>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
extern "C" int POM_AM__set_application_bypass(logical bypass);
|
||||||
|
int hz_auto_revison_to_folder(EPM_action_message_t msg);
|
||||||
|
int hz_status_check(EPM_rule_message_t msg);
|
||||||
|
logical isInVec(char *type, vector<string> &type_vec);
|
||||||
@ -0,0 +1,238 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<ItemGroup>
|
||||||
|
<Filter Include="源文件">
|
||||||
|
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
|
||||||
|
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
|
||||||
|
</Filter>
|
||||||
|
<Filter Include="头文件">
|
||||||
|
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
|
||||||
|
<Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
|
||||||
|
</Filter>
|
||||||
|
<Filter Include="资源文件">
|
||||||
|
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
|
||||||
|
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
|
||||||
|
</Filter>
|
||||||
|
<Filter Include="common">
|
||||||
|
<UniqueIdentifier>{70889105-2766-48cd-955a-f8fa1cab7cc6}</UniqueIdentifier>
|
||||||
|
</Filter>
|
||||||
|
<Filter Include="epm-handler">
|
||||||
|
<UniqueIdentifier>{2028f5f0-6bdd-4da5-8bc2-e680c333bf79}</UniqueIdentifier>
|
||||||
|
</Filter>
|
||||||
|
<Filter Include="userservice">
|
||||||
|
<UniqueIdentifier>{4e155a8b-5ae9-449f-bb95-aa3a2b2dd9f6}</UniqueIdentifier>
|
||||||
|
</Filter>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClCompile Include="libjf_custom_main.cpp">
|
||||||
|
<Filter>common</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="epm_register_handler.cpp">
|
||||||
|
<Filter>epm-handler</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="string_helper.cpp">
|
||||||
|
<Filter>common</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="common_itk_util.c">
|
||||||
|
<Filter>common</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="epm_sign_rev.cxx">
|
||||||
|
<Filter>epm-handler</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="epm_signoff_dataset.cxx">
|
||||||
|
<Filter>epm-handler</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="ocilib.cxx">
|
||||||
|
<Filter>common</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="string_utils.cxx">
|
||||||
|
<Filter>common</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="erp_send_items.cxx">
|
||||||
|
<Filter>epm-handler</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="erp_utils.cxx">
|
||||||
|
<Filter>epm-handler</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="hz_custom.cpp">
|
||||||
|
<Filter>epm-handler</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="epm_attach_objects.cxx">
|
||||||
|
<Filter>epm-handler</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="epm_check_status.cxx">
|
||||||
|
<Filter>epm-handler</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="hx_custom.cpp">
|
||||||
|
<Filter>epm-handler</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="connor_util.cpp">
|
||||||
|
<Filter>epm-handler</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="jk_custom_erp.cpp">
|
||||||
|
<Filter>epm-handler</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="w2_Clear_Form_PropValue.cpp">
|
||||||
|
<Filter>epm-handler</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="jk_custom.cpp">
|
||||||
|
<Filter>epm-handler</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="MaterialDiscontinuation.cpp">
|
||||||
|
<Filter>epm-handler</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="MaterialOpening.cpp">
|
||||||
|
<Filter>epm-handler</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="BOMDiscontinuation.cpp">
|
||||||
|
<Filter>epm-handler</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="addDisabled.cpp">
|
||||||
|
<Filter>epm-handler</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="removeDisabled.cpp">
|
||||||
|
<Filter>epm-handler</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="sendMaterialInfomationAddDisabled.cpp">
|
||||||
|
<Filter>epm-handler</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="tc_log.cxx">
|
||||||
|
<Filter>common</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="historicalDataAddMark.cpp">
|
||||||
|
<Filter>epm-handler</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="jk_check_virtual.cpp">
|
||||||
|
<Filter>epm-handler</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="jk_add_actual.cpp">
|
||||||
|
<Filter>epm-handler</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="jk_exportExcel.cpp">
|
||||||
|
<Filter>epm-handler</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="jk_remove_allStatus.cpp">
|
||||||
|
<Filter>epm-handler</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="JK_check_workflow.cpp">
|
||||||
|
<Filter>epm-handler</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="jk_auto_create_process.cpp">
|
||||||
|
<Filter>epm-handler</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="jk_upgrade_version.cpp">
|
||||||
|
<Filter>epm-handler</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="jk_upgrade_version2.cpp">
|
||||||
|
<Filter>epm-handler</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="jk_test_ask_icoAttribute.cpp">
|
||||||
|
<Filter>epm-handler</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="jk_decide_time.cpp">
|
||||||
|
<Filter>epm-handler</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="jk_add_attatchments.cpp">
|
||||||
|
<Filter>epm-handler</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="jk_water_summary.cpp">
|
||||||
|
<Filter>epm-handler</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="tx_sign_ir_master.cpp">
|
||||||
|
<Filter>epm-handler</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="tx_autoSign.cpp">
|
||||||
|
<Filter>epm-handler</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="tx_checkMaterialReleased.cpp">
|
||||||
|
<Filter>epm-handler</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="tx_checkMaterialDisabled.cpp">
|
||||||
|
<Filter>epm-handler</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="tx_addDisabled.cpp">
|
||||||
|
<Filter>epm-handler</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="tx_removeDisabled.cpp">
|
||||||
|
<Filter>epm-handler</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="tx_erp_bom.cpp">
|
||||||
|
<Filter>epm-handler</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="jk_AutoSign.cpp">
|
||||||
|
<Filter>epm-handler</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClInclude Include="epm_handler_common.h">
|
||||||
|
<Filter>epm-handler</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="epm_register_handler.h">
|
||||||
|
<Filter>epm-handler</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="string_helper.h">
|
||||||
|
<Filter>common</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="common_itk_util.h">
|
||||||
|
<Filter>common</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="ocilib.h">
|
||||||
|
<Filter>common</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="string_utils.h">
|
||||||
|
<Filter>common</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="erp_utils.h">
|
||||||
|
<Filter>epm-handler</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="error_handling.h">
|
||||||
|
<Filter>common</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="erp_send_item.h">
|
||||||
|
<Filter>epm-handler</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="hz_custom.h">
|
||||||
|
<Filter>epm-handler</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="hx_custom.h">
|
||||||
|
<Filter>epm-handler</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="connor_util.h">
|
||||||
|
<Filter>epm-handler</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="jk_custom.h">
|
||||||
|
<Filter>epm-handler</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="jk_custom_erp.h">
|
||||||
|
<Filter>epm-handler</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="jk_custom_erp_struct.h">
|
||||||
|
<Filter>epm-handler</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="w2_Clear_Form_PropValue.h">
|
||||||
|
<Filter>epm-handler</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="jk_custom_erp_struct1.h">
|
||||||
|
<Filter>epm-handler</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="tc_log.h">
|
||||||
|
<Filter>common</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="epm_sign_rev.h">
|
||||||
|
<Filter>epm-handler</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="tx_erp_bom.h">
|
||||||
|
<Filter>epm-handler</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<None Include="JFOM_CHANGE.txt">
|
||||||
|
<Filter>epm-handler</Filter>
|
||||||
|
</None>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Text Include="Text.txt">
|
||||||
|
<Filter>epm-handler</Filter>
|
||||||
|
</Text>
|
||||||
|
</ItemGroup>
|
||||||
|
</Project>
|
||||||
@ -0,0 +1,276 @@
|
|||||||
|
#include <tc\tc.h>
|
||||||
|
#include <property\propdesc.h>
|
||||||
|
#include <epm\epm.h>
|
||||||
|
#include <epm\epm_toolkit_tc_utils.h>
|
||||||
|
#include <tccore\item.h>
|
||||||
|
#include <tccore\grmtype.h>
|
||||||
|
#include <tccore\grm.h>
|
||||||
|
#include <tccore\imantype.h>
|
||||||
|
#include <sa\am.h>
|
||||||
|
#include <tccore\aom.h>
|
||||||
|
#include <tccore\aom_prop.h>
|
||||||
|
#include <property\prop_errors.h>
|
||||||
|
#include <tccore\workspaceobject.h>
|
||||||
|
#include <ics\ics.h>
|
||||||
|
#include <ics\ics2.h>
|
||||||
|
#include <qry\qry.h>
|
||||||
|
#include <epm\signoff.h>
|
||||||
|
#include <direct.h>
|
||||||
|
#include <pom\pom\pom.h>
|
||||||
|
#include <pom\pom\pom_errors.h>
|
||||||
|
#include <fclasses\tc_date.h>
|
||||||
|
#include <tc/preferences.h>
|
||||||
|
#define MAX_PATH_LENGTH 2000
|
||||||
|
/******************************************************
|
||||||
|
* @headerfile standard c & cpp header files
|
||||||
|
********************************************************/
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <ctype.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
|
#include <map>
|
||||||
|
#include <fstream>
|
||||||
|
#include <iostream>
|
||||||
|
#include <algorithm>
|
||||||
|
|
||||||
|
#include "epm_handler_common.h"
|
||||||
|
#include "error_handling.h"
|
||||||
|
#include "common_itk_util.h"
|
||||||
|
#include "string_helper.h"
|
||||||
|
#include "ocilib.h"
|
||||||
|
#include "erp_utils.h"
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
FILE* jklogFile = NULL;
|
||||||
|
|
||||||
|
void jk2_CreateLogFile(char* FunctionName)
|
||||||
|
{
|
||||||
|
int i=0, ifail = ITK_ok;
|
||||||
|
date_t status_now;
|
||||||
|
//char* date_string = NULL;
|
||||||
|
char date_string[MAX_PATH_LENGTH];
|
||||||
|
char logFileDir[MAX_PATH_LENGTH];
|
||||||
|
char logFileName[MAX_PATH_LENGTH];
|
||||||
|
|
||||||
|
char* session_uid = NULL;
|
||||||
|
tag_t session_tag = NULLTAG;
|
||||||
|
time_t now;
|
||||||
|
struct tm *p;
|
||||||
|
|
||||||
|
time(&now);
|
||||||
|
|
||||||
|
jklogFile = NULL;
|
||||||
|
//current_time(&status_now);
|
||||||
|
p=localtime(&now);
|
||||||
|
|
||||||
|
memset(date_string, 0, sizeof(date_string));
|
||||||
|
sprintf(date_string,"%4d%02d%02d%02d%02d%02d",1900+p->tm_year,p->tm_mon+1 ,p->tm_mday ,p->tm_hour,p->tm_min ,p->tm_sec );
|
||||||
|
//if( DATE_date_to_string( status_now, "%Y%m%d%H%M%S", &date_string) != ITK_ok )
|
||||||
|
//ifail = ITK_date_to_string (status_now, &date_string );
|
||||||
|
//if (ifail)
|
||||||
|
//{
|
||||||
|
// printf("!*ERROR*!: Failed to get current date time\n");
|
||||||
|
// goto CLEANUP;
|
||||||
|
//}
|
||||||
|
|
||||||
|
memset(logFileDir, 0, sizeof(logFileDir));
|
||||||
|
memset(logFileName, 0, sizeof(logFileName));
|
||||||
|
//get log dir
|
||||||
|
sprintf(logFileDir, "%s", getenv("TC_USER_LOG_DIR"));
|
||||||
|
printf("\n log file dir: %s\n", logFileDir);
|
||||||
|
//try to change dir to TC_USER_LOG_DIR
|
||||||
|
if(chdir(logFileDir)!=ITK_ok)
|
||||||
|
{
|
||||||
|
//not set TC_USER_LOG_DIR
|
||||||
|
//log in to default TC_LOG
|
||||||
|
memset(logFileDir, 0, sizeof(logFileDir));
|
||||||
|
sprintf(logFileDir, "%s", getenv("TEMP"));
|
||||||
|
printf("\n TC_USER_LOG_DIR invalide, log file dir: %s\n", logFileDir);
|
||||||
|
if(chdir(logFileDir)!=ITK_ok)
|
||||||
|
{
|
||||||
|
//still can not change to log dir
|
||||||
|
printf("!*ERROR*!: Failed to change dir to TC_USER_LOG_DIR\n");
|
||||||
|
goto CLEANUP;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//get session_uid to make sure the log file name unique
|
||||||
|
POM_ask_session(&session_tag);
|
||||||
|
ITK__convert_tag_to_uid(session_tag, &session_uid);
|
||||||
|
|
||||||
|
|
||||||
|
//get logFileName
|
||||||
|
sprintf(logFileName, "%s_%s_%s.log", FunctionName, session_uid, date_string);
|
||||||
|
printf("log file name: %s\n", logFileName);
|
||||||
|
|
||||||
|
//for(i = 0; _access((char *)logFileName, 4) == 0; i++)
|
||||||
|
{
|
||||||
|
memset(logFileName, 0, sizeof(logFileName));
|
||||||
|
sprintf(logFileName, "%s_%s_%s_%d.log", FunctionName, session_uid, date_string, i);
|
||||||
|
}
|
||||||
|
printf("final log file name: %s\n", logFileName);
|
||||||
|
|
||||||
|
//create log file
|
||||||
|
jklogFile = fopen(logFileName, "w");
|
||||||
|
|
||||||
|
CLEANUP:
|
||||||
|
//DOFREE(date_string);
|
||||||
|
DOFREE(session_uid);
|
||||||
|
}
|
||||||
|
int jk_AutoSign_Handler(EPM_action_message_t msg){
|
||||||
|
int ifail = ITK_ok,arg_cnt=0,i=0;
|
||||||
|
tag_t root_task =NULLTAG;
|
||||||
|
char arg1value[1024] = "",arg2value[1024] = "",arg3value[1024]="",arg4value[1024]="";
|
||||||
|
char *argflag =NULL,*argvalue=NULL ,*arg = NULL;
|
||||||
|
char *rootTaskUid = NULL;
|
||||||
|
char sql[4000] ="\0";
|
||||||
|
char ** sqlArgs =NULL ;
|
||||||
|
// char tc_log_file_name[128]="\0"; //日志文件路径
|
||||||
|
int sqlArgsCount = 9;
|
||||||
|
|
||||||
|
vector<string> pref_vec ;
|
||||||
|
|
||||||
|
time_t now;
|
||||||
|
struct tm *p;
|
||||||
|
time(&now);
|
||||||
|
p = localtime(&now);
|
||||||
|
// sprintf(tc_log_file_name, "%s\\tx_AutoSign_log_[%d-%d-%d-%d-%02d].txt",getenv("TEMP"),1900+p->tm_year,p->tm_mon+1 ,p->tm_mday,p->tm_hour,p->tm_min );
|
||||||
|
// printf("tc_log_file_name=%s\n",tc_log_file_name);
|
||||||
|
// tx_CreateLogFile(tc_log_file_name);
|
||||||
|
|
||||||
|
//TODO 首选项配置
|
||||||
|
getPrefStrings("jk_AutoSign_DB_Configer",TC_preference_site, pref_vec);
|
||||||
|
if(pref_vec.size() < 3){
|
||||||
|
// WriteLog("ERROR:没有获取到首选项[AutoSign_DB_Configer]\n");
|
||||||
|
// CloseLog();
|
||||||
|
return ifail;
|
||||||
|
}
|
||||||
|
if(ConnServer((char*)pref_vec[0].c_str(),(char*)pref_vec[1].c_str(),(char*)pref_vec[2].c_str()) == -1){
|
||||||
|
// WriteLog("ERROR:ORACLE数据库登录失败\n");
|
||||||
|
// CloseLog();
|
||||||
|
return ifail;
|
||||||
|
}
|
||||||
|
cout<<"1-------------------------"<<endl;
|
||||||
|
arg_cnt = TC_number_of_arguments(msg.arguments);
|
||||||
|
cout<<"2-------------------------"<<endl;
|
||||||
|
|
||||||
|
// WriteLog("INFO:参数个数为:%d",arg_cnt);
|
||||||
|
if (arg_cnt > 0)
|
||||||
|
{
|
||||||
|
cout<<"3-------------------------"<<endl;
|
||||||
|
|
||||||
|
for (i=0;i<arg_cnt;i++)
|
||||||
|
{
|
||||||
|
cout<<"4-------------------------"<<endl;
|
||||||
|
|
||||||
|
arg = TC_next_argument(msg.arguments);
|
||||||
|
cout<<"5-------------------------"<<endl;
|
||||||
|
|
||||||
|
ITKCALL(ifail = ITK_ask_argument_named_value((const char*)arg, &argflag, &argvalue));
|
||||||
|
if (stricmp(argflag, "SignUserName") == 0)
|
||||||
|
{
|
||||||
|
if(argvalue != NULL)
|
||||||
|
{
|
||||||
|
strcpy(arg1value,argvalue);//把argvalue值赋值到arg1value中
|
||||||
|
// WriteLog("INFO:SignUserName=%s",arg1value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if(stricmp(argflag, "SignDate") == 0)
|
||||||
|
{
|
||||||
|
if(argvalue != NULL)
|
||||||
|
{
|
||||||
|
strcpy(arg2value,argvalue);
|
||||||
|
// WriteLog("INFO:SignDate=%s",arg2value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if(stricmp(argflag,"SignDateFormat") == 0)
|
||||||
|
{
|
||||||
|
if(argvalue != NULL)
|
||||||
|
{
|
||||||
|
strcpy(arg3value,argvalue);
|
||||||
|
// WriteLog("INFO:SignDateFormat=%s",arg3value);
|
||||||
|
}
|
||||||
|
}else if (stricmp(argflag, "SignName") == 0)
|
||||||
|
{
|
||||||
|
if(argvalue != NULL)
|
||||||
|
{
|
||||||
|
strcpy(arg4value,argvalue);
|
||||||
|
// WriteLog("INFO:SignName=%s",arg4value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
cout<<"6-------------------------"<<endl;
|
||||||
|
|
||||||
|
}
|
||||||
|
MEM_free(argflag);
|
||||||
|
MEM_free(argvalue);
|
||||||
|
}
|
||||||
|
ITKCALL(EPM_ask_root_task( msg.task, &root_task ));
|
||||||
|
ITK__convert_tag_to_uid(root_task,&rootTaskUid);
|
||||||
|
// WriteLog("INFO:ProcessUid=%s",rootTaskUid);
|
||||||
|
//增加发起者 开始日期 作业名
|
||||||
|
char *job_name=NULL;
|
||||||
|
ITKCALL(ifail=AOM_ask_value_string(root_task,"job_name",&job_name));
|
||||||
|
date_t date_t_i;
|
||||||
|
ITKCALL(ifail=AOM_ask_value_date(root_task,"fnd0StartDate",&date_t_i));
|
||||||
|
char shijain[100]="";
|
||||||
|
sprintf(shijain,"%d年%d月%d日 %d分%d秒",date_t_i.year,date_t_i.month +1,date_t_i.day,date_t_i.hour,date_t_i.minute);
|
||||||
|
string timeString=shijain;
|
||||||
|
cout<<"7-------------------------"<<endl;
|
||||||
|
// WriteLog("INFO:ProcessUid=%s",rootTaskUid);
|
||||||
|
tag_t owning_user;
|
||||||
|
cout<<"8-------------------------"<<endl;
|
||||||
|
ITKCALL(ifail=AOM_ask_value_tag(root_task,"owning_user",&owning_user));
|
||||||
|
cout<<"9-------------------------"<<endl;
|
||||||
|
char *user_name=NULL;
|
||||||
|
ITKCALL(ifail=AOM_ask_value_string(owning_user,"user_name",&user_name));
|
||||||
|
cout<<"user_name---------"<<user_name<<endl;
|
||||||
|
string usernameString=user_name;
|
||||||
|
sqlArgs = (char **)MEM_alloc(9*sizeof(char*));
|
||||||
|
|
||||||
|
for(i = 0;i < sqlArgsCount;i++){
|
||||||
|
sqlArgs[i] = (char *)MEM_alloc(1028*sizeof(char));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
strcpy(sqlArgs[0],rootTaskUid);
|
||||||
|
strcpy(sqlArgs[1],arg1value);
|
||||||
|
strcpy(sqlArgs[2],arg2value);
|
||||||
|
strcpy(sqlArgs[3],arg3value);
|
||||||
|
strcpy(sqlArgs[4],arg4value);
|
||||||
|
strcpy(sqlArgs[5],"0");
|
||||||
|
strcpy(sqlArgs[6],job_name);
|
||||||
|
cout<<"9.1-------------------------"<<endl;
|
||||||
|
strcpy(sqlArgs[7],timeString.c_str());
|
||||||
|
cout<<"9.2-------------------------"<<endl;
|
||||||
|
strcpy(sqlArgs[8],usernameString.c_str());
|
||||||
|
cout<<"10-------------------------"<<endl;
|
||||||
|
sprintf(sql,"INSERT INTO JK_PCN_AUTOSIGN ( PUID , SIGN_NAME_INFO , SIGN_DATE_INFO , SIGN_DATE_FORMATE , SIGN_NAME , PSTATUS, JOB_NAME, START_DATE, USER_NAME ) VALUES ( :1 , :2 , :3 , :4 , :5 , :6 , :7 , :8 , :9)");
|
||||||
|
cout<<"11-------------------------"<<endl;
|
||||||
|
if(-1 == ExecuteSQL(sql,sqlArgsCount,sqlArgs)){
|
||||||
|
cout<<"12-------------------------"<<endl;
|
||||||
|
// WriteLog("ERROR:写入数据库失败");
|
||||||
|
}else{
|
||||||
|
// WriteLog("INFO:写入数据库成功");
|
||||||
|
}
|
||||||
|
|
||||||
|
for(i = 0;i < sqlArgsCount;i++){
|
||||||
|
MEM_free(sqlArgs[i]);
|
||||||
|
}
|
||||||
|
MEM_free(rootTaskUid);
|
||||||
|
MEM_free(sqlArgs);
|
||||||
|
if(user_name!=NULL)
|
||||||
|
{
|
||||||
|
MEM_free(user_name);
|
||||||
|
user_name=NULL;
|
||||||
|
}
|
||||||
|
if(job_name!=NULL)
|
||||||
|
{
|
||||||
|
MEM_free(job_name);
|
||||||
|
job_name=NULL;
|
||||||
|
}
|
||||||
|
sqlArgs = NULL;
|
||||||
|
DisConnServer();
|
||||||
|
CloseLog();
|
||||||
|
return ifail;
|
||||||
|
}
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue