使用sourcetree备份

main
何贞泉 6 years ago
commit f48201c70a

3
.gitignore vendored

@ -0,0 +1,3 @@
.git.zip
jf_itk.sdf
JK_itk.sdf

@ -0,0 +1,29 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2012
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "JK_itk", "jf_itk\jf_itk.vcxproj", "{AEABC483-FCBD-45F5-9884-8FA4C5A9892D}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Itanium = Debug|Itanium
Debug|Win32 = Debug|Win32
Debug|x64 = Debug|x64
Release|Itanium = Release|Itanium
Release|Win32 = Release|Win32
Release|x64 = Release|x64
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{AEABC483-FCBD-45F5-9884-8FA4C5A9892D}.Debug|Itanium.ActiveCfg = Debug|Win32
{AEABC483-FCBD-45F5-9884-8FA4C5A9892D}.Debug|Win32.ActiveCfg = Debug|Win32
{AEABC483-FCBD-45F5-9884-8FA4C5A9892D}.Debug|Win32.Build.0 = Debug|Win32
{AEABC483-FCBD-45F5-9884-8FA4C5A9892D}.Debug|x64.ActiveCfg = Debug|x64
{AEABC483-FCBD-45F5-9884-8FA4C5A9892D}.Debug|x64.Build.0 = Debug|x64
{AEABC483-FCBD-45F5-9884-8FA4C5A9892D}.Release|Itanium.ActiveCfg = Release|Win32
{AEABC483-FCBD-45F5-9884-8FA4C5A9892D}.Release|Win32.ActiveCfg = Release|Win32
{AEABC483-FCBD-45F5-9884-8FA4C5A9892D}.Release|Win32.Build.0 = Release|Win32
{AEABC483-FCBD-45F5-9884-8FA4C5A9892D}.Release|x64.ActiveCfg = Release|x64
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal

Binary file not shown.

@ -0,0 +1,2 @@
#v4.0:v100
Release|Win32|F:\Connor项目管理\继峰项目\签名\jf_itk\|

@ -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( &ltime );
today = localtime( &ltime );
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,225 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Itanium">
<Configuration>Debug</Configuration>
<Platform>Itanium</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Itanium">
<Configuration>Release</Configuration>
<Platform>Itanium</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{5B00E072-1EDF-4670-81F0-555DB0C78516}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>jf_erp_check_project</RootNamespace>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Itanium'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Itanium'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Itanium'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Itanium'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>true</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Itanium'">
<LinkIncremental>true</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LinkIncremental>true</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
<EmbedManifest>false</EmbedManifest>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Itanium'">
<LinkIncremental>false</LinkIncremental>
<EmbedManifest>false</EmbedManifest>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LinkIncremental>false</LinkIncremental>
<EmbedManifest>false</EmbedManifest>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;JF_ERP_CHECK_PROJECT_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Itanium'">
<ClCompile>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;JF_ERP_CHECK_PROJECT_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;JF_ERP_CHECK_PROJECT_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>
</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>IPLIB=none;WIN32;NDEBUG;_WINDOWS;_USRDLL;JF_ERP_CHECK_PROJECT_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>F:\Teamcenter10.1.0Env\OCI\include;F:\Teamcenter10.1.0Env\tcbin\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<AdditionalDependencies>F:\Teamcenter10.1.0Env\tcbin\lib\*.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Itanium'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>
</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>IPLIB=none;WIN32;NDEBUG;_WINDOWS;_USRDLL;JF_ERP_CHECK_PROJECT_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>F:\Teamcenter10.1.0Env\OCI\include;F:\Teamcenter10.1.0Env\tcbin\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<AdditionalDependencies>F:\Teamcenter10.1.0Env\tcbin\lib\*.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>
</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>IPLIB=none;WIN32;NDEBUG;_WINDOWS;_USRDLL;JF_ERP_CHECK_PROJECT_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>F:\Teamcenter10.1.0Env\OCI\include;F:\Teamcenter10.1.0Env\tcbin\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<AdditionalDependencies>F:\Teamcenter10.1.0Env\tcbin\lib\*.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="common_itk_util.c" />
<ClCompile Include="jf3_main.cpp" />
<ClCompile Include="ocilib.cxx" />
<ClCompile Include="string_helper.cpp" />
<ClCompile Include="string_utils.cxx" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="common_itk_util.h" />
<ClInclude Include="error_handling.h" />
<ClInclude Include="jf3_main.h" />
<ClInclude Include="ocilib.h" />
<ClInclude Include="string_helper.h" />
<ClInclude Include="string_utils.h" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

@ -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,440 @@
/*=====================================================================================================================
Copyright(c) 2012 ORIGIN.
Unpublished - All rights reserved
=======================================================================================================================
File description:
Filename: ocilib.cxx
Module : OCI
This file describes OCI library Package.
=======================================================================================================================
Date Name Description of Change
1-Feb-2015 Ray li Initialize creation
$HISTORY$
=====================================================================================================================*/
#include "ocilib.h"
#include <stdlib.h>
#define NUM 100
#define USERNAME "infodba"
#define PASSWORD "infodba"
#define DBNAME "tc"
// 定义句柄结构
typedef struct{
OCIEnv *p_env; //OCI environment handle 环境句柄
OCIError *p_err; //OCI error handle 错误句柄
OCISvcCtx *p_svc; //OCI service context handel 服务上下文句柄
OCIServer *p_ser; //OCI server handle 服务器句柄
OCISession *p_usr; //OCI user session handle 用户会话句柄
OCIStmt *p_sql; //OCI statement handle 语句句柄
OCIDefine *p_dfn; //OCI define handle 定义句柄
OCIBind *p_bnd; //OCI bind handle 绑定句柄
}OCIHandleInfo;
// 定义错误句柄结构
typedef struct{
OCIEnv *p_env;
OCIError *p_err;
OCISvcCtx *p_svc;
OCIStmt *p_sql;
OCIDefine *p_dfn;
OCIBind *p_bnd;
}OCIDATA;
// 定义执行语句时候的输入参数
typedef struct{
char value[NUM][NUM];
char type[NUM][NUM];
}SqlField;
// 定义查询语句时候的输入,输出参数
typedef struct{
int naIntValue[NUM];
int nIntNum;
char caCharValue[500][500];
int nCharNum;
}SqlSelField;
OCIHandleInfo *ociHandle = NULL;
OCIHandleInfo ociHand;
int InitHandle();
int _ExeSQL(char *SQL,char ** inputValue,int inputValueCount);
int _QuerySQL(char *SQL, SqlSelField *pOutField, SqlSelField *pSelField);
int GetDataFromQuery(int *pRc, SqlSelField *pOutField);
void QuitFreeHandle();
/****************************************************************************************************************************************
*****************************************************************************************************************************************/
// 初始化Handler
int InitHandle()
{
int swResult;
ociHandle = &ociHand;
/*create OCI environment*/
if(swResult = OCIEnvCreate(&ociHandle->p_env,OCI_DEFAULT,NULL,NULL,NULL,NULL,0,NULL)) //环境句柄
{
printf("environment create error!\n\n");
return -1;
}
else
{
printf("environment create success!\n\n");
//return 0;
}
/*init handle*/
if(swResult = OCIHandleAlloc(ociHandle->p_env,(dvoid **)&ociHandle->p_ser,OCI_HTYPE_SERVER,0,NULL)) //服务器句柄
{
printf("init server handle error!\n\n");
return -1;
}
if(swResult = OCIHandleAlloc(ociHandle->p_env,(dvoid **)&ociHandle->p_err,OCI_HTYPE_ERROR,0,NULL)) //错误句柄
{
printf("init error handle error!\n\n");
return -1;
}
if(swResult = OCIHandleAlloc(ociHandle->p_env,(dvoid **)&ociHandle->p_usr,OCI_HTYPE_SESSION,0,NULL)) //事务句柄
{
printf("init session handle error!\n\n");
return -1;
}
if(swResult = OCIHandleAlloc(ociHandle->p_env,(dvoid **)&ociHandle->p_svc,OCI_HTYPE_SVCCTX,0,NULL)) //上下文句柄
{
printf("init service context handle error!\n\n");
return -1;
}
if(swResult = OCIHandleAlloc(ociHandle->p_env,(dvoid **)&ociHandle->p_sql,OCI_HTYPE_STMT,0,NULL)) //SQL语句句柄
{
printf("init statement handle error!\n\n");
return -1;
}
printf("init handle success!\n\n");
return 0;
}
// 连接数据库服务器
int ConnServer(char *username,char *password,char *dbname)
{
int swResult;
char errbuf[100]={0};
int errcode;
if(InitHandle() == -1)//初始化句柄
return -1;
if(swResult = OCILogon(ociHandle->p_env,ociHandle->p_err,&ociHandle->p_svc,(text *)username,strlen(username),(text *)password,strlen(password),(text *)dbname,strlen(dbname)))
{
OCIErrorGet((dvoid *)ociHandle->p_err, (ub4) 1, (text *) NULL, &errcode, (ub1 *)errbuf, (ub4) sizeof(errbuf), OCI_HTYPE_ERROR);
printf("Error - %.*s/n", 512, errbuf);
return -1;
}
else
printf("数据库连接成功!\n\n");
return 0;
}
// SQL语句的陈述(执行SQL语句)
int _ExeSQL(char *SQL,char ** inputValue,int inputValueCount)
{
int swResult,i;
int errcode;
//设置绑定变量
OCIBind *p_bndp[100];
//准备SQL语句
if(swResult = OCIStmtPrepare(ociHandle->p_sql,ociHandle->p_err,(text *)SQL,strlen(SQL),OCI_NTV_SYNTAX,OCI_DEFAULT))
{
printf("prepare SQL statements error!\n\n");
}
else
{
printf("prepare SQL statements success!\n\n");
}
// 绑定输入变量
for(i=0;i<inputValueCount;i++)
{
char errbuf[100]={0};
if(swResult = OCIBindByPos(ociHandle->p_sql,&p_bndp[i],ociHandle->p_err,i+1,(dvoid *)inputValue[i],(sb4)strlen(inputValue[i])+1,SQLT_STR, (dvoid *) 0, (ub2 *) 0, (ub2 *) 0, (ub4) 0, (ub4 *) 0, OCI_DEFAULT))
{
OCIErrorGet((dvoid *)ociHandle->p_err, (ub4) 1, (text *) NULL, &errcode, (ub1 *)errbuf, (ub4) sizeof(errbuf), OCI_HTYPE_ERROR);
printf("Bind Error - %.*s/n", 512, errbuf);
return -1;
}
}
//执行SQL statements
if(swResult = OCIStmtExecute(ociHandle->p_svc,ociHandle->p_sql,ociHandle->p_err,1,0,NULL,NULL,OCI_DEFAULT))
{
char errbuf[100]={0};
OCIErrorGet((dvoid *)ociHandle->p_err, (ub4) 1, (text *) NULL, &errcode, (ub1 *)errbuf, (ub4) sizeof(errbuf), OCI_HTYPE_ERROR);
printf("execute SQL statement Error - %.*s\n", 512, errbuf);
return -1;
}
else
{
printf("execute SQL statement success!\n\n");
}
return 0;
}
// 查询SQL
int _QuerySQL(char *SQL, SqlSelField *pOutField, SqlSelField *pSelField )
{
sword status;
int rc= 0,ret=0;
char errbuf[100]={0};
int maxNum = 2048;
char chTag[8];
int iIndex = 0;
int outputColumn = 0;
int errcode=0;
char nullValue = '\0'; //
sb2 sb2aInd[30] = {'\0'};
// 准备SQL语句
status = OCIStmtPrepare(ociHandle->p_sql, ociHandle->p_err, (text *)SQL,(ub4)strlen(SQL), (ub4)OCI_NTV_SYNTAX, (ub4)OCI_DEFAULT);
if (status != OCI_SUCCESS)
{
printf("SQL Preparing failed/n");
return -1;
}
// 绑定int类型的, 定义SQL语句时 :1,:2, 定义输入变量
for (iIndex=0; iIndex<pSelField->nIntNum; iIndex++)
{
memset(chTag, 0, 8);
sprintf(chTag, ":%d", iIndex+1);
if(rc = OCIBindByName(ociHandle->p_sql, (OCIBind **)&ociHandle->p_dfn, ociHandle->p_err, (text *)chTag,(sb4)strlen((char *)chTag),(dvoid *) &pSelField->naIntValue[iIndex], sizeof(int), SQLT_INT,(dvoid *) 0,(ub2 *) 0, (ub2 *) 0, (ub4) 0, (ub4 *) 0, OCI_DEFAULT))
{
OCIErrorGet((dvoid *)ociHandle->p_err, (ub4) 1, (text *) NULL, &errcode, (ub1 *)errbuf, (ub4) sizeof(errbuf), OCI_HTYPE_ERROR);
printf("BindByPos Error of ociHandle->p_sql - %.*s\n", 512, errbuf);
return -1;
}
}
// 绑定char *类型的, 定义SQL语句时 :3,:4, 定义输入变量
for (iIndex=0; iIndex<pSelField->nCharNum; iIndex++)
{
int n=0;
memset(chTag, 0, 8);
n = pSelField->nIntNum + iIndex +1;
sprintf(chTag, ":%d", n);
if(rc = OCIBindByName(ociHandle->p_sql, (OCIBind **)&ociHandle->p_dfn, ociHandle->p_err, (text *)chTag,(sb4)strlen((char *)chTag),(dvoid *) &pSelField->caCharValue[iIndex], NUM, SQLT_STR,(dvoid *) 0,(ub2 *) 0, (ub2 *) 0, (ub4) 0, (ub4 *) 0, OCI_DEFAULT))
{
OCIErrorGet((dvoid *)ociHandle->p_err, (ub4) 1, (text *) NULL, &errcode, (ub1 *)errbuf, (ub4) sizeof(errbuf), OCI_HTYPE_ERROR);
printf("BindByPos Error of ociHandle->p_sql - %.*s\n", 512, errbuf);
return -1;
}
}
// 执行SQL语句
if (rc = OCIStmtExecute(ociHandle->p_svc, ociHandle->p_sql, ociHandle->p_err, (ub4) 0, (ub4) 0,(CONST OCISnapshot *) NULL, (OCISnapshot *) NULL, OCI_STMT_SCROLLABLE_READONLY))
{
OCIErrorGet((dvoid *)ociHandle->p_err, (ub4) 1, (text *) NULL, &errcode, (ub1 *)errbuf, (ub4) sizeof(errbuf), OCI_HTYPE_ERROR);
printf("execute SQL Error - %.*s\n", 512, errbuf);
return -1;
}
else
{
printf("execute SQL success!\n\n");
}
if (ret = OCIAttrGet (ociHandle->p_sql, (ub4)OCI_HTYPE_STMT, (dvoid *) &outputColumn, (ub4 *) 0, (ub4)OCI_ATTR_PARAM_COUNT, ociHandle->p_err))
{
OCIErrorGet((dvoid *)ociHandle->p_err, (ub4) 1, (text *) NULL, &errcode, (ub1 *)errbuf, (ub4) sizeof(errbuf), OCI_HTYPE_ERROR);
printf("Get OCIAttr Error of ociHandle->p_sql - %.*s\n", 512, errbuf);
return -1;
}
// 绑定int类型的, 定义SQL语句时 :1,:2, 定义输出变量
for (iIndex=0; iIndex<pOutField->nIntNum; iIndex++)
{
if(rc = OCIDefineByPos(ociHandle->p_sql, &ociHandle->p_dfn, ociHandle->p_err, iIndex+1, (dvoid *)&pOutField->naIntValue[iIndex], sizeof(int), SQLT_INT, (dvoid *) 0, (ub2 *)0,(ub2 *)0, OCI_DEFAULT))
{
OCIErrorGet((dvoid *)ociHandle->p_err, (ub4) 1, (text *) NULL, &errcode, (ub1 *)errbuf, (ub4) sizeof(errbuf), OCI_HTYPE_ERROR);
printf("DefineByPos Error of ociHandle->p_sql - %.*s\n", 512, errbuf);
return -1;
}
}
// 绑定char *类型的, 定义SQL语句时 :1,:2, 定义输出变量
for (iIndex=0; iIndex<outputColumn; iIndex++)
{
int n = iIndex+1 ;
if (rc = OCIDefineByPos(ociHandle->p_sql, &ociHandle->p_dfn, ociHandle->p_err, n, (dvoid *)&pOutField->caCharValue[iIndex], 1000*sizeof(char), SQLT_STR, (dvoid *) 0, (ub2 *)0,(ub2 *)0, OCI_DEFAULT))
{
OCIErrorGet((dvoid *)ociHandle->p_err, (ub4) 1, (text *) NULL, &errcode, (ub1 *)errbuf, (ub4) sizeof(errbuf), OCI_HTYPE_ERROR);
printf("DefineByPos Error of ociHandle->p_sql - %.*s\n", 512, errbuf);
return -1;
}
}
return 0;
}
// 释放Handler
void QuitFreeHandle()
{
// 退出服务器
OCILogoff(ociHandle->p_svc,ociHandle->p_err);
printf("Quit success!\n");
// 释放句柄
OCIHandleFree(ociHandle->p_ser,OCI_HTYPE_SERVER); //释放服务器句柄
OCIHandleFree(ociHandle->p_err,OCI_HTYPE_ERROR); //释放错误句柄
OCIHandleFree(ociHandle->p_usr,OCI_HTYPE_SESSION); //释放事务句柄
OCIHandleFree(ociHandle->p_svc,OCI_HTYPE_SVCCTX); //释放上下文句柄
OCIHandleFree(ociHandle->p_sql,OCI_HTYPE_STMT); //释放SQL语句句柄
}
// 执行类操作
int ExecuteSQL(char *SQL,int valueCount,char **value)
{
int i=0;
if(i=_ExeSQL(SQL,value,valueCount))
{
QuitFreeHandle();
return -1;
}
return 0;
}
// 有输入参数的查询
int QuerySQL(char *SQL, int inputValueCount, char ** inputValue, int * outputColumn, int * outputValueCount, char **** outputValue)
{
int i = 0, j=0 ,ret =0;
int times = 0, temp=0;
SqlSelField infield;
SqlSelField outField;
// 初始化参数结构
infield.nCharNum = inputValueCount;
infield.nIntNum = 0;
outField.nCharNum = 0;
outField.nIntNum = 0;
* outputColumn = 0;
* outputValueCount = 0;
for(i=0;i<inputValueCount;i++)
{
strcpy(infield.caCharValue[i],inputValue[i]);
}
// 执行查询语句
if (ret = _QuerySQL(SQL,&outField,&infield))
{
printf("SQL查询失败!\n");
QuitFreeHandle();
return -1;
}
// 获取结果列数
ret= OCIAttrGet (ociHandle->p_sql, (ub4)OCI_HTYPE_STMT, (dvoid *) outputColumn, (ub4 *) 0, (ub4)OCI_ATTR_PARAM_COUNT, ociHandle->p_err);
// 提取最后一行,便于去行数
ret = OCIStmtFetch2(ociHandle->p_sql, ociHandle->p_err,1, OCI_FETCH_LAST,0, OCI_DEFAULT);
// 获取结果行数
ret= OCIAttrGet (ociHandle->p_sql, (ub4)OCI_HTYPE_STMT, (dvoid *) outputValueCount, (ub4 *) 0, (ub4)OCI_ATTR_ROW_COUNT, ociHandle->p_err);
if(*outputValueCount == 0)
return 0;
// 开始分配内存并且存储
ret = OCIStmtFetch2(ociHandle->p_sql, ociHandle->p_err,1, OCI_FETCH_FIRST,0, OCI_DEFAULT);
*outputValue = (char ***) calloc ((*outputValueCount)+1,sizeof(char**));
do
{
(*outputValue)[i] = (char **) calloc ((*outputColumn)+1,sizeof(char *));
for(j=0;j<(*outputColumn);j++)
{
(*outputValue)[i][j] = (char *) calloc (1000,sizeof(char));
strcpy((*outputValue)[i][j],outField.caCharValue[j]);
//printf("outValue[%d][%d] = %s , 地址=%d, 所指向地址= %d\n ",i,j,(*outputValue)[i][j],&(*outputValue)[i][j],(*outputValue)[i][j]);
}
i++;
}
while((ret = OCIStmtFetch2(ociHandle->p_sql, ociHandle->p_err,1, OCI_FETCH_NEXT, 1, OCI_DEFAULT)!= OCI_NO_DATA));
return 0;
}
// 无输入参数的查询
int QuerySQLNoInputParam(char *SQL, int * outputColumn, int * outputValueCount, char **** outputValue)
{
return QuerySQL(SQL,0,NULL,outputColumn,outputValueCount,outputValue);
}
// 无参数操作
int ExecuteSQLNoInputParam(char *SQL)
{
return ExecuteSQL(SQL,0,NULL);
}
// 断开连接
void DisConnServer()
{
if(ociHandle != NULL)
QuitFreeHandle();
}

@ -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

@ -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>

@ -0,0 +1,2 @@
#v4.0:v100
Release|x64|F:\Connor项目管理\继峰项目\签名\jf_itk\|

@ -0,0 +1,2 @@
#v4.0:v100
Release|Win32|F:\Connor项目管理\继峰项目\签名\jf_itk\|

@ -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( &ltime );
today = localtime( &ltime );
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,176 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Itanium">
<Configuration>Debug</Configuration>
<Platform>Itanium</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Itanium">
<Configuration>Release</Configuration>
<Platform>Itanium</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{375BE822-1125-4D9E-A589-08243D1FF487}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>jf_erp_project</RootNamespace>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Itanium'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Itanium'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Itanium'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Itanium'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>true</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Itanium'">
<LinkIncremental>true</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Itanium'">
<LinkIncremental>false</LinkIncremental>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Itanium'">
<ClCompile>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>
</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>IPLIB=none;WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>F:\Teamcenter10.1.0Env\OCI\include;F:\Teamcenter10.1.0Env\tcbin\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<AdditionalDependencies>F:\Teamcenter10.1.0Env\tcbin\lib\*.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Itanium'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>
</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>IPLIB=none;WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>F:\Teamcenter10.1.0Env\OCI\include;F:\Teamcenter10.1.0Env\tcbin\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<AdditionalDependencies>F:\Teamcenter10.1.0Env\tcbin\lib\*.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<AdditionalIncludeDirectories>F:\Teamcenter10.1.0Env\OCI\include;F:\Teamcenter10.1.0Env\tcbin\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>IPLIB=none;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<AdditionalDependencies>F:\Teamcenter10.1.0Env\tcbin\lib\*.lib;F:\Teamcenter10.1.0Env\tcbin\lib\itk_main.obj;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="common_itk_util.c" />
<ClCompile Include="jf_erp_project.cpp" />
<ClCompile Include="ocilib.cxx" />
<ClCompile Include="string_helper.cpp" />
<ClCompile Include="string_utils.cxx" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="common_itk_util.h" />
<ClInclude Include="error_handling.h" />
<ClInclude Include="jf_erp_project.h" />
<ClInclude Include="ocilib.h" />
<ClInclude Include="string_helper.h" />
<ClInclude Include="string_utils.h" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

@ -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,440 @@
/*=====================================================================================================================
Copyright(c) 2012 ORIGIN.
Unpublished - All rights reserved
=======================================================================================================================
File description:
Filename: ocilib.cxx
Module : OCI
This file describes OCI library Package.
=======================================================================================================================
Date Name Description of Change
1-Feb-2015 Ray li Initialize creation
$HISTORY$
=====================================================================================================================*/
#include "ocilib.h"
#include <stdlib.h>
#define NUM 100
#define USERNAME "infodba"
#define PASSWORD "infodba"
#define DBNAME "tc"
// 定义句柄结构
typedef struct{
OCIEnv *p_env; //OCI environment handle 环境句柄
OCIError *p_err; //OCI error handle 错误句柄
OCISvcCtx *p_svc; //OCI service context handel 服务上下文句柄
OCIServer *p_ser; //OCI server handle 服务器句柄
OCISession *p_usr; //OCI user session handle 用户会话句柄
OCIStmt *p_sql; //OCI statement handle 语句句柄
OCIDefine *p_dfn; //OCI define handle 定义句柄
OCIBind *p_bnd; //OCI bind handle 绑定句柄
}OCIHandleInfo;
// 定义错误句柄结构
typedef struct{
OCIEnv *p_env;
OCIError *p_err;
OCISvcCtx *p_svc;
OCIStmt *p_sql;
OCIDefine *p_dfn;
OCIBind *p_bnd;
}OCIDATA;
// 定义执行语句时候的输入参数
typedef struct{
char value[NUM][NUM];
char type[NUM][NUM];
}SqlField;
// 定义查询语句时候的输入,输出参数
typedef struct{
int naIntValue[NUM];
int nIntNum;
char caCharValue[500][500];
int nCharNum;
}SqlSelField;
OCIHandleInfo *ociHandle = NULL;
OCIHandleInfo ociHand;
int InitHandle();
int _ExeSQL(char *SQL,char ** inputValue,int inputValueCount);
int _QuerySQL(char *SQL, SqlSelField *pOutField, SqlSelField *pSelField);
int GetDataFromQuery(int *pRc, SqlSelField *pOutField);
void QuitFreeHandle();
/****************************************************************************************************************************************
*****************************************************************************************************************************************/
// 初始化Handler
int InitHandle()
{
int swResult;
ociHandle = &ociHand;
/*create OCI environment*/
if(swResult = OCIEnvCreate(&ociHandle->p_env,OCI_DEFAULT,NULL,NULL,NULL,NULL,0,NULL)) //环境句柄
{
printf("environment create error!\n\n");
return -1;
}
else
{
printf("environment create success!\n\n");
//return 0;
}
/*init handle*/
if(swResult = OCIHandleAlloc(ociHandle->p_env,(dvoid **)&ociHandle->p_ser,OCI_HTYPE_SERVER,0,NULL)) //服务器句柄
{
printf("init server handle error!\n\n");
return -1;
}
if(swResult = OCIHandleAlloc(ociHandle->p_env,(dvoid **)&ociHandle->p_err,OCI_HTYPE_ERROR,0,NULL)) //错误句柄
{
printf("init error handle error!\n\n");
return -1;
}
if(swResult = OCIHandleAlloc(ociHandle->p_env,(dvoid **)&ociHandle->p_usr,OCI_HTYPE_SESSION,0,NULL)) //事务句柄
{
printf("init session handle error!\n\n");
return -1;
}
if(swResult = OCIHandleAlloc(ociHandle->p_env,(dvoid **)&ociHandle->p_svc,OCI_HTYPE_SVCCTX,0,NULL)) //上下文句柄
{
printf("init service context handle error!\n\n");
return -1;
}
if(swResult = OCIHandleAlloc(ociHandle->p_env,(dvoid **)&ociHandle->p_sql,OCI_HTYPE_STMT,0,NULL)) //SQL语句句柄
{
printf("init statement handle error!\n\n");
return -1;
}
printf("init handle success!\n\n");
return 0;
}
// 连接数据库服务器
int ConnServer(char *username,char *password,char *dbname)
{
int swResult;
char errbuf[100]={0};
int errcode;
if(InitHandle() == -1)//初始化句柄
return -1;
if(swResult = OCILogon(ociHandle->p_env,ociHandle->p_err,&ociHandle->p_svc,(text *)username,strlen(username),(text *)password,strlen(password),(text *)dbname,strlen(dbname)))
{
OCIErrorGet((dvoid *)ociHandle->p_err, (ub4) 1, (text *) NULL, &errcode, (ub1 *)errbuf, (ub4) sizeof(errbuf), OCI_HTYPE_ERROR);
printf("Error - %.*s/n", 512, errbuf);
return -1;
}
else
printf("数据库连接成功!\n\n");
return 0;
}
// SQL语句的陈述(执行SQL语句)
int _ExeSQL(char *SQL,char ** inputValue,int inputValueCount)
{
int swResult,i;
int errcode;
//设置绑定变量
OCIBind *p_bndp[100];
//准备SQL语句
if(swResult = OCIStmtPrepare(ociHandle->p_sql,ociHandle->p_err,(text *)SQL,strlen(SQL),OCI_NTV_SYNTAX,OCI_DEFAULT))
{
printf("prepare SQL statements error!\n\n");
}
else
{
printf("prepare SQL statements success!\n\n");
}
// 绑定输入变量
for(i=0;i<inputValueCount;i++)
{
char errbuf[100]={0};
if(swResult = OCIBindByPos(ociHandle->p_sql,&p_bndp[i],ociHandle->p_err,i+1,(dvoid *)inputValue[i],(sb4)strlen(inputValue[i])+1,SQLT_STR, (dvoid *) 0, (ub2 *) 0, (ub2 *) 0, (ub4) 0, (ub4 *) 0, OCI_DEFAULT))
{
OCIErrorGet((dvoid *)ociHandle->p_err, (ub4) 1, (text *) NULL, &errcode, (ub1 *)errbuf, (ub4) sizeof(errbuf), OCI_HTYPE_ERROR);
printf("Bind Error - %.*s/n", 512, errbuf);
return -1;
}
}
//执行SQL statements
if(swResult = OCIStmtExecute(ociHandle->p_svc,ociHandle->p_sql,ociHandle->p_err,1,0,NULL,NULL,OCI_DEFAULT))
{
char errbuf[100]={0};
OCIErrorGet((dvoid *)ociHandle->p_err, (ub4) 1, (text *) NULL, &errcode, (ub1 *)errbuf, (ub4) sizeof(errbuf), OCI_HTYPE_ERROR);
printf("execute SQL statement Error - %.*s\n", 512, errbuf);
return -1;
}
else
{
printf("execute SQL statement success!\n\n");
}
return 0;
}
// 查询SQL
int _QuerySQL(char *SQL, SqlSelField *pOutField, SqlSelField *pSelField )
{
sword status;
int rc= 0,ret=0;
char errbuf[100]={0};
int maxNum = 2048;
char chTag[8];
int iIndex = 0;
int outputColumn = 0;
int errcode=0;
char nullValue = '\0'; //
sb2 sb2aInd[30] = {'\0'};
// 准备SQL语句
status = OCIStmtPrepare(ociHandle->p_sql, ociHandle->p_err, (text *)SQL,(ub4)strlen(SQL), (ub4)OCI_NTV_SYNTAX, (ub4)OCI_DEFAULT);
if (status != OCI_SUCCESS)
{
printf("SQL Preparing failed/n");
return -1;
}
// 绑定int类型的, 定义SQL语句时 :1,:2, 定义输入变量
for (iIndex=0; iIndex<pSelField->nIntNum; iIndex++)
{
memset(chTag, 0, 8);
sprintf(chTag, ":%d", iIndex+1);
if(rc = OCIBindByName(ociHandle->p_sql, (OCIBind **)&ociHandle->p_dfn, ociHandle->p_err, (text *)chTag,(sb4)strlen((char *)chTag),(dvoid *) &pSelField->naIntValue[iIndex], sizeof(int), SQLT_INT,(dvoid *) 0,(ub2 *) 0, (ub2 *) 0, (ub4) 0, (ub4 *) 0, OCI_DEFAULT))
{
OCIErrorGet((dvoid *)ociHandle->p_err, (ub4) 1, (text *) NULL, &errcode, (ub1 *)errbuf, (ub4) sizeof(errbuf), OCI_HTYPE_ERROR);
printf("BindByPos Error of ociHandle->p_sql - %.*s\n", 512, errbuf);
return -1;
}
}
// 绑定char *类型的, 定义SQL语句时 :3,:4, 定义输入变量
for (iIndex=0; iIndex<pSelField->nCharNum; iIndex++)
{
int n=0;
memset(chTag, 0, 8);
n = pSelField->nIntNum + iIndex +1;
sprintf(chTag, ":%d", n);
if(rc = OCIBindByName(ociHandle->p_sql, (OCIBind **)&ociHandle->p_dfn, ociHandle->p_err, (text *)chTag,(sb4)strlen((char *)chTag),(dvoid *) &pSelField->caCharValue[iIndex], NUM, SQLT_STR,(dvoid *) 0,(ub2 *) 0, (ub2 *) 0, (ub4) 0, (ub4 *) 0, OCI_DEFAULT))
{
OCIErrorGet((dvoid *)ociHandle->p_err, (ub4) 1, (text *) NULL, &errcode, (ub1 *)errbuf, (ub4) sizeof(errbuf), OCI_HTYPE_ERROR);
printf("BindByPos Error of ociHandle->p_sql - %.*s\n", 512, errbuf);
return -1;
}
}
// 执行SQL语句
if (rc = OCIStmtExecute(ociHandle->p_svc, ociHandle->p_sql, ociHandle->p_err, (ub4) 0, (ub4) 0,(CONST OCISnapshot *) NULL, (OCISnapshot *) NULL, OCI_STMT_SCROLLABLE_READONLY))
{
OCIErrorGet((dvoid *)ociHandle->p_err, (ub4) 1, (text *) NULL, &errcode, (ub1 *)errbuf, (ub4) sizeof(errbuf), OCI_HTYPE_ERROR);
printf("execute SQL Error - %.*s\n", 512, errbuf);
return -1;
}
else
{
printf("execute SQL success!\n\n");
}
if (ret = OCIAttrGet (ociHandle->p_sql, (ub4)OCI_HTYPE_STMT, (dvoid *) &outputColumn, (ub4 *) 0, (ub4)OCI_ATTR_PARAM_COUNT, ociHandle->p_err))
{
OCIErrorGet((dvoid *)ociHandle->p_err, (ub4) 1, (text *) NULL, &errcode, (ub1 *)errbuf, (ub4) sizeof(errbuf), OCI_HTYPE_ERROR);
printf("Get OCIAttr Error of ociHandle->p_sql - %.*s\n", 512, errbuf);
return -1;
}
// 绑定int类型的, 定义SQL语句时 :1,:2, 定义输出变量
for (iIndex=0; iIndex<pOutField->nIntNum; iIndex++)
{
if(rc = OCIDefineByPos(ociHandle->p_sql, &ociHandle->p_dfn, ociHandle->p_err, iIndex+1, (dvoid *)&pOutField->naIntValue[iIndex], sizeof(int), SQLT_INT, (dvoid *) 0, (ub2 *)0,(ub2 *)0, OCI_DEFAULT))
{
OCIErrorGet((dvoid *)ociHandle->p_err, (ub4) 1, (text *) NULL, &errcode, (ub1 *)errbuf, (ub4) sizeof(errbuf), OCI_HTYPE_ERROR);
printf("DefineByPos Error of ociHandle->p_sql - %.*s\n", 512, errbuf);
return -1;
}
}
// 绑定char *类型的, 定义SQL语句时 :1,:2, 定义输出变量
for (iIndex=0; iIndex<outputColumn; iIndex++)
{
int n = iIndex+1 ;
if (rc = OCIDefineByPos(ociHandle->p_sql, &ociHandle->p_dfn, ociHandle->p_err, n, (dvoid *)&pOutField->caCharValue[iIndex], 1000*sizeof(char), SQLT_STR, (dvoid *) 0, (ub2 *)0,(ub2 *)0, OCI_DEFAULT))
{
OCIErrorGet((dvoid *)ociHandle->p_err, (ub4) 1, (text *) NULL, &errcode, (ub1 *)errbuf, (ub4) sizeof(errbuf), OCI_HTYPE_ERROR);
printf("DefineByPos Error of ociHandle->p_sql - %.*s\n", 512, errbuf);
return -1;
}
}
return 0;
}
// 释放Handler
void QuitFreeHandle()
{
// 退出服务器
OCILogoff(ociHandle->p_svc,ociHandle->p_err);
printf("Quit success!\n");
// 释放句柄
OCIHandleFree(ociHandle->p_ser,OCI_HTYPE_SERVER); //释放服务器句柄
OCIHandleFree(ociHandle->p_err,OCI_HTYPE_ERROR); //释放错误句柄
OCIHandleFree(ociHandle->p_usr,OCI_HTYPE_SESSION); //释放事务句柄
OCIHandleFree(ociHandle->p_svc,OCI_HTYPE_SVCCTX); //释放上下文句柄
OCIHandleFree(ociHandle->p_sql,OCI_HTYPE_STMT); //释放SQL语句句柄
}
// 执行类操作
int ExecuteSQL(char *SQL,int valueCount,char **value)
{
int i=0;
if(i=_ExeSQL(SQL,value,valueCount))
{
QuitFreeHandle();
return -1;
}
return 0;
}
// 有输入参数的查询
int QuerySQL(char *SQL, int inputValueCount, char ** inputValue, int * outputColumn, int * outputValueCount, char **** outputValue)
{
int i = 0, j=0 ,ret =0;
int times = 0, temp=0;
SqlSelField infield;
SqlSelField outField;
// 初始化参数结构
infield.nCharNum = inputValueCount;
infield.nIntNum = 0;
outField.nCharNum = 0;
outField.nIntNum = 0;
* outputColumn = 0;
* outputValueCount = 0;
for(i=0;i<inputValueCount;i++)
{
strcpy(infield.caCharValue[i],inputValue[i]);
}
// 执行查询语句
if (ret = _QuerySQL(SQL,&outField,&infield))
{
printf("SQL查询失败!\n");
QuitFreeHandle();
return -1;
}
// 获取结果列数
ret= OCIAttrGet (ociHandle->p_sql, (ub4)OCI_HTYPE_STMT, (dvoid *) outputColumn, (ub4 *) 0, (ub4)OCI_ATTR_PARAM_COUNT, ociHandle->p_err);
// 提取最后一行,便于去行数
ret = OCIStmtFetch2(ociHandle->p_sql, ociHandle->p_err,1, OCI_FETCH_LAST,0, OCI_DEFAULT);
// 获取结果行数
ret= OCIAttrGet (ociHandle->p_sql, (ub4)OCI_HTYPE_STMT, (dvoid *) outputValueCount, (ub4 *) 0, (ub4)OCI_ATTR_ROW_COUNT, ociHandle->p_err);
if(*outputValueCount == 0)
return 0;
// 开始分配内存并且存储
ret = OCIStmtFetch2(ociHandle->p_sql, ociHandle->p_err,1, OCI_FETCH_FIRST,0, OCI_DEFAULT);
*outputValue = (char ***) calloc ((*outputValueCount)+1,sizeof(char**));
do
{
(*outputValue)[i] = (char **) calloc ((*outputColumn)+1,sizeof(char *));
for(j=0;j<(*outputColumn);j++)
{
(*outputValue)[i][j] = (char *) calloc (1000,sizeof(char));
strcpy((*outputValue)[i][j],outField.caCharValue[j]);
//printf("outValue[%d][%d] = %s , 地址=%d, 所指向地址= %d\n ",i,j,(*outputValue)[i][j],&(*outputValue)[i][j],(*outputValue)[i][j]);
}
i++;
}
while((ret = OCIStmtFetch2(ociHandle->p_sql, ociHandle->p_err,1, OCI_FETCH_NEXT, 1, OCI_DEFAULT)!= OCI_NO_DATA));
return 0;
}
// 无输入参数的查询
int QuerySQLNoInputParam(char *SQL, int * outputColumn, int * outputValueCount, char **** outputValue)
{
return QuerySQL(SQL,0,NULL,outputColumn,outputValueCount,outputValue);
}
// 无参数操作
int ExecuteSQLNoInputParam(char *SQL)
{
return ExecuteSQL(SQL,0,NULL);
}
// 断开连接
void DisConnServer()
{
if(ociHandle != NULL)
QuitFreeHandle();
}

@ -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

@ -0,0 +1,2 @@
#v4.0:v100
Release|x64|F:\Connor项目管理\继峰项目\签名\jf_itk\|

@ -0,0 +1,213 @@
#include <tc/tc.h>
#include "epm_handler_common.h"
#include <ict/ict_userservice.h>
#include <tccore/custom.h>
#include <epm/epm_toolkit_tc_utils.h>
#include <tccore/aom.h>
#include <tccore/aom_prop.h>
#include <tccore/item.h>
#include <bom/bom.h>
#include "ps/ps.h"
#include "ps/vrule.h"
#include "sstream"
#include <tccore/grm.h>
#include "epm/epm.h"
#include "sa/sa.h"
//#include "libxl.h"
#include <map>
#include "epm/signoff.h"
#include <ctime>
#include <vector>
#include <locale>
#include <codecvt>
#include "ae/dataset.h"
#include <iostream>
#include <regex>
#include "string_utils.h"
#include <list>
#include "tc_log.h"
#include <tc/tc.h>
#include "epm_handler_common.h"
#include <ict/ict_userservice.h>
#include <tccore/custom.h>
#include <epm/epm_toolkit_tc_utils.h>
#include <tccore/aom.h>
#include <tccore/aom_prop.h>
#include <tccore/item.h>
#include <bom/bom.h>
#include <tccore/grm.h>
#include "epm/epm.h"
//#include "libxl.h"
#include <iostream>
#include <regex>
using namespace std;
typedef struct
{
string ITEM_ID;//id号
}PRO_STRUCT;
int BOMDiscontinuation(EPM_rule_message_t msg)
{
cout<<"检查BOM能否发起物料停用流程"<<endl;
int ifail = ITK_ok;
EPM_decision_t decision = EPM_go;
tag_t task_tag = NULLTAG, rootTask_tag = NULLTAG, *attachments = NULLTAG,*revision_list=NULLTAG,bom_window_tag=NULLTAG,top_line_tag=NULLTAG,*c_line_tags=NULLTAG;
int arg_cnt = 0, i = 0, att_cnt = 0,c_line_count=0,item_num=0;
int release_nums=0,revtion_nums=0;
tag_t *release_list=NULLTAG;
tag_t *item=NULLTAG;
char* object_type;
//获取当前触发的任务
task_tag = msg.task;
//获取根流程节点
ifail = EPM_ask_root_task(task_tag, &rootTask_tag);
//获取目标引用对象
ifail = EPM_ask_attachments(rootTask_tag, EPM_target_attachment, &att_cnt, &attachments);
//循环目标对象
cout<<"数量------->"<<att_cnt<<endl;
vector<PRO_STRUCT> item_vec;
for (i = 0; i < att_cnt; i++)
{
//获得该bom下所有子集
ITKCALL(ifail=AOM_ask_value_string(attachments[i],"object_type",&object_type));
if(strcmp(object_type,"BOMView Revision")==0)
{
ITKCALL( ifail = BOM_create_window(&bom_window_tag));//创建window视图
ITKCALL(ifail = BOM_set_window_top_line_bvr(bom_window_tag,attachments[i],&top_line_tag));//获取顶层bomline
ITKCALL(ifail =BOM_line_ask_all_child_lines(top_line_tag,&c_line_count,&c_line_tags));
for (int j=0;j<c_line_count;j++)
{
//获得所在版本的物料
ITKCALL(ifail=AOM_ask_value_tags(c_line_tags[j],"bl_child_item",&item_num,&item));
ITKCALL(ifail=AOM_ask_value_string(item[0],"object_type",&object_type));
if(strcmp(object_type,"JK8Material")==0)//LP2_Design_Part JK8Material
{
ITKCALL( ifail=AOM_ask_value_tags(item[0],"revision_list",&revtion_nums,&revision_list));
int mark=0;
for (int k=0;k<revtion_nums;k++)
{
PRO_STRUCT elements ;
ITKCALL( ifail=AOM_ask_value_tags(revision_list[k],"release_status_list",&release_nums,&release_list));
//TODO 如果存在object_name 为jk8Disabled即为失效状态的物料就提示
for (int f=0;f<release_nums;f++)
{
AOM_ask_value_string(release_list[f],"object_name",&object_type);
if(strcmp(object_type,"jk8Disabled")==0)
{
ITKCALL( ifail=AOM_ask_value_string(item[0],"item_id",&object_type));
elements.ITEM_ID.assign(object_type);
item_vec.push_back(elements);
mark=1;
break;
}
}
if(mark==1)
{
mark=0;
break;
}
// if(release_nums>0)
// {
// ITKCALL( ifail=AOM_ask_value_string(item[0],"item_id",&object_type));
// elements.ITEM_ID.assign(object_type);
// item_vec.push_back(elements);
// break;
// }
}
}
}
ITKCALL(ifail=BOM_close_window(bom_window_tag));
}
}
cout<<"item_vec.size()--------------"<<item_vec.size()<<endl;
if(item_vec.size()>0)
{
for (int i=0;i<item_vec.size();i++)
{
string error_string="\nBOM子阶存在失效物料";
for (int i=0;i<item_vec.size();i++)
{
error_string=error_string+item_vec[i].ITEM_ID.c_str()+";";
}
EMH_store_error_s1(EMH_severity_warning, EMH_AE_error_base, error_string.c_str());
if (attachments != NULL)
{
MEM_free(attachments);
attachments = NULL;
}
if (revision_list != NULL)
{
MEM_free(revision_list);
revision_list = NULL;
}
if (c_line_tags != NULL)
{
MEM_free(c_line_tags);
c_line_tags = NULL;
}
if (c_line_tags != NULL)
{
MEM_free(c_line_tags);
c_line_tags = NULL;
}
if (release_list != NULL)
{
MEM_free(release_list);
release_list = NULL;
}
if (object_type != NULL)
{
MEM_free(object_type);
object_type = NULL;
}
return EPM_nogo;
}
}else
{
if (attachments != NULL)
{
MEM_free(attachments);
attachments = NULL;
}
if (revision_list != NULL)
{
MEM_free(revision_list);
revision_list = NULL;
}
if (c_line_tags != NULL)
{
MEM_free(c_line_tags);
c_line_tags = NULL;
}
if (c_line_tags != NULL)
{
MEM_free(c_line_tags);
c_line_tags = NULL;
}
if (release_list != NULL)
{
MEM_free(release_list);
release_list = NULL;
}
if (object_type != NULL)
{
MEM_free(object_type);
object_type = NULL;
}
return EPM_go;
}
return EPM_go;
}

@ -0,0 +1,789 @@
/*===================================================================================================
Copyright(c) 2011 Siemens PLM Software Corp. All rights reserved.
Unpublished - All rights reserved
====================================================================================================
File description:
Filename : epm_autosign_hander.cpp
This file describes action handler function : PLA8-signoff
将流程签审信息写入表单
====================================================================================================
Date Name Description of Change
19-Jan-2013 Ray Li creation
$HISTORY$
==================================================================================================*/
#pragma warning (disable: 4996)
#pragma warning (disable: 4819)
/**
* @headerfile tcua 头文件
*/
#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>
/**
* @headerfile standard c & cpp header files
*/
#include <stdio.h>
#include <ctype.h>
#include <string.h>
//#include <time.h>
//#include <math.h>
#include <string>
#include <vector>
#include <map>
#include <fstream>
#include <iostream>
#include <algorithm>
using namespace std;
/**
* @headerfile user's header files
*/
#include "epm_handler_common.h"
#include "error_handling.h"
#include "common_itk_util.h"
//#include "string_helper.h"
//流程节点信息
struct FLOWNODEINFOS
{
char taskname[128];
char username[128];
char timeinfo[128];
char group[128];
}flownode_s[64];
//参数人员信息
struct USERINFOS
{
char taskname[128];
char propertyname[128];
char group[128];
}userinfo_s[64];
//参数日期信息
struct TIMEINFOS
{
char taskname[128];
char propertyname[128];
char group[128];
}timeinfo_s[64];
////会签信息
//struct SIGNCOUNTERINFO
//{
// char taskname[128];
// char group[128];
// char propertyname[128];
//}counter_s[64];
int nodecount = 0;
int userinfoscount = 0;
int timeinfoscount = 0;
//int counterinfocount = 0;
#define DOFREE(obj) \
{ \
if(obj) \
{ \
MEM_free(obj); \
obj = NULL; \
} \
}
//struct SIGN_INFO_STRUCT
//{
// string userid;
// string username;
// string taskname;
// string signdate;
//};
//struct SIGN_PROPS_STRUCT
//{
// string taskname;
// string propname;
//};
//struct SIGN_TIME_STRUCT
//{
// string taskname;
// string propname;
//};
extern "C" int POM_AM__set_application_bypass(logical bypass);
//void ECHO(char *format, ...)
//{
// //if( !YFJC_OPT_DEBUG )
// // return;
//
// char msg[2048];
// va_list args;
//
// va_start( args, format );
// vsprintf( msg, format, args );
// va_end( args );
//
// printf( msg );
// TC_write_syslog( msg );
//}
//分割字符串
int ORIGIN_ask_sign_info(tag_t task_node, char *output_str,char *task_name,char *arg3value)
{
int ifail = ITK_ok;
tag_t cur_perform_task = NULLTAG,tempTask = NULLTAG;
char cur_task_name[WSO_name_size_c+1]="",buf[128] = "";
//编制判断变量
int s = 0;
EPM_decision_t decision = EPM_nogo;
char* userName;
char *timeinfo1 = "",person_name[SA_name_size_c+1]="",*prop_name = "last_mod_date";
tag_t aUserTag = NULLTAG,responsibleParty = NULLTAG;
date_t decision_date;
//其他节点相关
int perform_count = 0;
int *attach_type;
tag_t *perform_attaches = NULLTAG;
tag_t memberTag = NULLTAG;
SIGNOFF_TYPE_t memberType;
CR_signoff_decision_t signoff_decision;
char comments[CR_comment_size_c+1],*timeinfo="",*group_full_name = NULL;
tag_t user_tag=NULLTAG, group_tag = NULLTAG;
//循环判断变量
int i=0;
ITKCALL( EPM_ask_name( task_node, cur_task_name ) );
ECHO("cur_task_name = %s\n",cur_task_name);
if ( stricmp( cur_task_name, "perform-signoffs" ) == 0 )
{
cur_perform_task = task_node;
ITKCALL( EPM_ask_parent_task( cur_perform_task, &tempTask ) );
ITKCALL( EPM_ask_name( tempTask, cur_task_name ) );
}
else if( strcmp( cur_task_name, "编制" ) == 0 )
{
cur_perform_task = task_node;
}
else
{
ITKCALL( EPM_ask_sub_task(task_node, "perform-signoffs", &cur_perform_task) );
if ( cur_perform_task != NULLTAG )
{
ITKCALL( EPM_ask_name( task_node, cur_task_name ) );
ECHO( "---------> cur_task_name = %s\n" , cur_task_name );
}
}
if(cur_perform_task != NULLTAG )
{
if( strcmp( cur_task_name, "编制" ) == 0 )
{
//ECHO("task_name=%s",task_name);
//s = EPM_ask_responsible_party(cur_perform_task,&responsibleParty);
//if(responsibleParty != NULLTAG)
//{
// decision = EPM_go;
//}
//s = POM_get_user(&userName,&aUserTag);
//ITKCALL(SA_ask_user_person_name(aUserTag, person_name));
//strcat(output_str, cur_task_name);
//strcat(output_str, "=");
//strcat(output_str, person_name);
//strcat(output_str, "|");
//strcat(output_str, cur_task_name);
//strcat(output_str, "日期=");
//ITKCALL(AOM_ask_value_date(cur_perform_task,prop_name,&decision_date));
//ITKCALL(DATE_date_to_string(decision_date,arg3value,&timeinfo1));
////ECHO("timeinfo : %s",timeinfo1);
////ITK_date_to_string (decision_date, &timeinfo1);
//strcat( output_str, timeinfo1 );
//strcat(output_str,"|");
//ECHO("timeinfo : %s",timeinfo1);
//strcpy(flownode_s[nodecount].taskname,cur_task_name);
//strcpy(flownode_s[nodecount].username,person_name);
//strcpy(flownode_s[nodecount].timeinfo,timeinfo1);
//nodecount = nodecount + 1;
//MEM_free(userName);
}
else
{
//发起人即所有者
tag_t owner = NULLTAG;
date_t date;
logical is_valid;
char *d_value = NULL;
CALL(AOM_ask_owner( cur_perform_task, &owner));
if( owner != NULLTAG )
CALL(SA_ask_user_person_name(owner, person_name));
ITKCALL(AOM_ask_value_date(cur_perform_task,"creation_date", &date));//fnd0StartDate
DATE_date_to_string(date,arg3value,&d_value);
//ITKCALL(AOM_UIF_ask_value( cur_perform_task, "fnd0StartDate", &d_value));
ECHO("d_value : %s",d_value);
strcat(output_str, "申请人");
strcat(output_str, "=");
strcat(output_str, person_name);
strcat(output_str, "|");
strcat(output_str, "申请人日期=");
//CALL(DATE_date_to_string(date,arg3value,&timeinfo));
//ITKCALL(DATE_string_to_date_t(d_value, &is_valid,&date));
//CALL(DATE_date_to_string(date,arg3value,&timeinfo));
//ECHO("timeinfo : %s",timeinfo);
//vector<string> ans;
//if( d_value != NULL )
//{
// Split(d_value, ' ', ans);
// if(ans.size() > 1)
// strcat(output_str,ans[0].c_str());
//}
strcat(output_str,d_value);
//DOFREE(timeinfo);
strcat(output_str, "|");
strcpy(flownode_s[nodecount].taskname,"申请人");
strcpy(flownode_s[nodecount].username,person_name);
//if(ans.size() > 1)
strcpy(flownode_s[nodecount].timeinfo,d_value);
nodecount = nodecount + 1;
ECHO("output_str=%s",output_str);
ITKCALL(EPM_ask_all_attachments(cur_perform_task,&perform_count,&perform_attaches,&attach_type));
ECHO("EPM_signoff_attachment Counts = %d", perform_count);
for(i=0;i<perform_count;i++)
{
ITKCALL(EPM_ask_signoff_member(perform_attaches[i], &memberTag, &memberType));
ITKCALL(CR_ask_signoff_decision(perform_attaches[i], &signoff_decision, comments, &decision_date));
if(memberType == SIGNOFF_GROUPMEMBER)
{
ECHO("cur_task_name = %s",cur_task_name);
CALL(SA_ask_groupmember_user(memberTag, &user_tag));
CALL(SA_ask_user_person_name(user_tag, person_name));
strcat(output_str, cur_task_name);
strcat(output_str, "=");
strcat(output_str, person_name);
strcat(output_str, "|");
strcat(output_str, cur_task_name);
strcat(output_str, "日期=");
char date_buf[128]="";
CALL(DATE_date_to_string(decision_date,arg3value,&timeinfo));
//ITKCALL(ITK_date_to_string(decision_date, &timeinfo));
//sprintf( date_buf, "%4d-%02d-%02d", decision_date.year, decision_date.month+1, decision_date.day );
ECHO("timeinfo : %s",timeinfo);
strcat(output_str,timeinfo);
strcat(output_str, "|");
strcpy(flownode_s[nodecount].taskname,cur_task_name);
strcpy(flownode_s[nodecount].username,person_name);
strcpy(flownode_s[nodecount].timeinfo,timeinfo);
nodecount = nodecount + 1;
}
}
}
}
ECHO("output_str=%s",output_str);
return ifail;
}
//
void SplitUserInfo(char *userinfo)
{
char* token = NULL, *ptr = NULL, temp[512] = "";
token = strtok( userinfo, ";");
while( token != NULL )
{
/* While there are tokens in "string" */
strcpy(temp,token);
ECHO( "token=%s\n", token );
ptr = strstr(temp, "=");
if (ptr != NULL)
{
strcpy(userinfo_s[userinfoscount].propertyname, ptr +1);
strcpy(ptr,"\0");
strcpy(userinfo_s[userinfoscount].taskname ,temp);
ECHO("\nuserinfo_s[userinfoscount].taskname=%s,userinfo_s[userinfoscount].propertyname=%s\n",
userinfo_s[userinfoscount].taskname,userinfo_s[userinfoscount].propertyname);
}
userinfoscount ++;
/* Get next token: */
token = strtok( NULL, ";");
}
}
void SplitTimeInfo(char *userinfo)
{
char* token = NULL, *ptr = NULL, temp[512] = "";
token = strtok( userinfo, ";");
while( token != NULL )
{
/* While there are tokens in "string" */
strcpy(temp,token);
ECHO( "token=%s\n", token );
ptr = strstr(temp, "=");
if (ptr != NULL)
{
strcpy(timeinfo_s[timeinfoscount].propertyname, ptr +1);
strcpy(ptr,"\0");
strcpy(timeinfo_s[timeinfoscount].taskname ,temp);
ECHO("\ntimeinfo_s[timeinfoscount].taskname=%s,timeinfo_s[timeinfoscount].propertyname=%s\n",
timeinfo_s[timeinfoscount].taskname,timeinfo_s[timeinfoscount].propertyname);
}
timeinfoscount ++;
/* Get next token: */
token = strtok( NULL, ";");
}
}
//获取参数1
void getUserinfo(char *userinfo)
{
int ulen = 0,i=0,tempcount=0;
char temp[128]="";
BOOL has =FALSE;
ulen = strlen(userinfo);
for(i=0;i < ulen;i++)
{
if(userinfo[i] == '=')
{
temp[tempcount] = '\0';
strcpy(userinfo_s[userinfoscount].taskname,temp);
strcpy(temp,"");
tempcount = 0;
has = TRUE;
}
else if(userinfo[i] == ';' && has)
{
temp[tempcount] = '\0';
strcpy(userinfo_s[userinfoscount].propertyname,temp);
strcpy(temp,"");
tempcount = 0;
userinfoscount = userinfoscount + 1;
has = FALSE;
}
else
{
temp[tempcount] = userinfo[i];
tempcount = tempcount + 1;
}
}
}
//获取参数2
void getTimeinfo(char *timeinfo)
{
int ulen = 0,i=0,tempcount=0;
char temp[128]="";
BOOL has =FALSE;
ulen = strlen(timeinfo);
for(i=0;i < ulen;i++)
{
if(timeinfo[i] == '=')
{
temp[tempcount] = '\0';
if(strcmp(temp,"") == 0)
continue;
strcpy(timeinfo_s[timeinfoscount].taskname,temp);
strcpy(temp,"");
tempcount = 0;
has = TRUE;
}
else if(timeinfo[i] == ';' && has)
{
temp[tempcount] = '\0';
strcpy(timeinfo_s[timeinfoscount].propertyname,temp);
strcpy(temp,"");
tempcount = 0;
timeinfoscount = timeinfoscount + 1;
has = FALSE;
}
else
{
temp[tempcount] = timeinfo[i];
tempcount = tempcount + 1;
}
}
}
/*************************************************************************************************
* jf_sign_ir_master()
*
* Description:
* This handler will set signoff infomation to properties of form
*
* Syntax:
* jf-signoff [-debug=true|false]
*
* -SignUserName: 编制=c7Formation;设计=c7Design;审核=c7Review
*
* -SignDate: 编制=c7Formationtime;校对=c7DesignTime;审核=c7ReviewTime
*
* -SignDateFormate: %Y-%m-%d
*
* -bypass
* Placement:
* no request
*
**************************************************************************************************/
int jf_sign_ir_master(EPM_action_message_t msg)
{
int ifail = ITK_ok, rcode = 0;
//参数相关
char arg1value[1024] = "",arg2value[1024] = "",arg3value[1024]="",arg4value[1024]="",
signcounter_info[1024] = "";
char *argflag =NULL,*argvalue=NULL ,*arg = NULL;
BOOL bypass = FALSE;
int arg_cnt = 0;
//流程节点相关
tag_t root_task = NULLTAG,*sub_tasks = NULL,current_task = NULLTAG,type_tag = NULLTAG;
int sub_task_count = 0;
char root_task_name[128]="",task_name[128] = "";
int occur_of_counts = 0;
tag_t *taskAttches = NULLTAG;
char tgt_type[WSO_name_size_c+1]="",type_class[TCTYPE_class_name_size_c+1]="";
////循环内部变量
tag_t cur_task = NULLTAG;
char task_type[WSO_name_size_c+1] = "";
//循环变量
int i=0, j=0, k=0, count = 0, n = 0;
//节点信息变量
char sign_info[2048]="";
//节点循环处理变量
tag_t itemrevision = NULLTAG,master_form_rel_type = NULLTAG;
char rev_id[ITEM_id_size_c+1]="";
char item_id[ITEM_id_size_c+1]="";
int form_count = 0;
tag_t *form_list = NULL,master_form = NULLTAG;
char local_path[128]="";
//编制节点
int s=0;
char *timeinfo2="";
EPM_decision_t decision = EPM_nogo;
tag_t aUserTag,responsibleParty;
char *userName;
date_t decision_date;
char person_name[SA_name_size_c + 1] = "";
char *prop_name="last_mod_date";
////登录信息
//char *user_name = NULL, *group_full_name = NULL;
//tag_t user_tag = NULLTAG, group_tag = NULLTAG;
//char *txtfile = NULL;
//会签相关
int n_prop=0, q = 0;
char **prop_names=NULL, hq_name[128] = "", hq_time_name[128] = "", *hq_value=NULL;
char exclude_type[256]="", item_type[ITEM_type_size_c+ 1]= "";
tag_t item = NULLTAG;
logical is_sign = false;
current_task = msg.task;
//CreateLogFile("PLA8_signoff",&txtfile);
ECHO("=========================================================\n");
ECHO("jf_sign_ir_master 开始执行\n");
ECHO("=========================================================\n");
arg_cnt = TC_number_of_arguments(msg.arguments);
ECHO("参数个数为:%d\n",arg_cnt);
if (arg_cnt > 0)
{
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, "SignUserName") == 0)
{
if(argvalue != NULL)
{
strcpy(arg1value,argvalue);
}
}
else if(stricmp(argflag, "SignDate") == 0)
{
if(argvalue != NULL)
{
strcpy(arg2value,argvalue);
}
}
else if(stricmp(argflag,"SignDateFormat") == 0)
{
if(argvalue != NULL)
{
strcpy(arg3value,argvalue);
}
}
else if(stricmp(argflag,"bypass") == 0)
{
bypass = TRUE;
}
//else if(stricmp(argflag,"exclude_type") == 0)
//{
// if(argvalue != NULL)
// {
// strcpy(exclude_type,argvalue);
// }
//}
}
MEM_free(argflag);
MEM_free(argvalue);
}
//if(bypass)
// AM__set_application_bypass(TRUE);
ITK_set_bypass(TRUE);
ECHO("SignUserName : %s\n",arg1value);
ECHO("SignDate : %s\n",arg2value);
ECHO("SignDateFormat : %s\n",arg3value);
//ECHO("exclude_type : %s",exclude_type);
//getUserinfo(arg1value);
SplitUserInfo(arg1value);
//getTimeinfo(arg2value);
SplitTimeInfo(arg2value);
//getCounterinfo(signcounter_info);
vector<string> type_vec;
//Split(exclude_type,";",type_vec);
ECHO("参数1个数%d\n",userinfoscount);
ECHO("参数2个数%d\n",timeinfoscount);
ITKCALL( EPM_ask_root_task( msg.task, &root_task ) );
ITKCALL( EPM_ask_sub_tasks( root_task, &sub_task_count, &sub_tasks) );
ITKCALL( EPM_ask_name( root_task, root_task_name ) );
ECHO("root_task_name=%s\n",root_task_name);
ITKCALL( EPM_ask_name( current_task, task_name ) );
ECHO( "sub_task_count = %d\n", sub_task_count );
//test==========================
//tag_t user = NULLTAG, *tasks = NULL;
//int n_task= 0;
//ITKCALL(SA_find_user( "admin", &user ));
//ITKCALL(SA_ask_user_work_contexts ( user, &n_task, &tasks));
//ECHO("==========n_task=%d",n_task);
//==============================
//单独处理DO节点
if(strcmp(task_name,"编制") == 0)
{
ECHO("task_name:%s",task_name);
s = EPM_ask_responsible_party(current_task,&responsibleParty);
if(responsibleParty != NULLTAG)
{
decision = EPM_go;
}
s = POM_get_user(&userName,&aUserTag);
ITKCALL(SA_ask_user_person_name(aUserTag,person_name));
strcat(sign_info,task_name);
strcat(sign_info,"=");
strcat(sign_info,person_name);
strcat(sign_info,"|");
strcat(sign_info,task_name);
strcat(sign_info,"日期=");
AOM_ask_value_date(current_task,prop_name,&decision_date);
//AOM_UIF_ask_value(current_task,prop_name, &timeinfo2);
DATE_date_to_string(decision_date,arg3value,&timeinfo2);
ECHO("timeinfo2=%s",timeinfo2);
strcat(sign_info,timeinfo2);
strcat(sign_info,"|");
strcpy(flownode_s[nodecount].taskname,task_name);
strcpy(flownode_s[nodecount].username,person_name);
strcpy(flownode_s[nodecount].timeinfo,timeinfo2);
nodecount = nodecount + 1;
}
else //perform节点
{
for(i=0;i<sub_task_count;i++)
{
cur_task = sub_tasks[i];
ITKCALL(WSOM_ask_object_type(cur_task,task_type));
ECHO("current task type = %s\n", task_type);
ORIGIN_ask_sign_info( cur_task, sign_info, task_name,arg3value);
}
}
ECHO("sign_info = %s\n", sign_info);
ECHO("the node number is %d",nodecount);
if(current_task != NULLTAG)
{
ITKCALL(EPM_ask_attachments(root_task, EPM_target_attachment, &occur_of_counts, &taskAttches));
ECHO("%d target attachment found",occur_of_counts);
for( count=0; count<occur_of_counts; count++ )
{
ECHO("the %dth work",count);
ITKCALL(TCTYPE_ask_object_type(taskAttches[count], &type_tag));
ITKCALL(ifail = TCTYPE_ask_class_name(type_tag, type_class));
ECHO("type_class : %s",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))
{
ECHO("==================WORKING======================");
is_sign = true;
itemrevision = taskAttches[count];
ITKCALL(ITEM_ask_rev_id(itemrevision,rev_id));
ITKCALL(ITEM_ask_item_of_rev( itemrevision, &item));
//ITKCALL(ITEM_ask_type( item, item_type));
//for( q = 0; q <type_vec.size(); q++)
//{
// if( type_vec[q].compare(item_type) == 0)
// {
// is_sign = false;
// }
//}
//if( !is_sign )
//{
// ECHO("item_type=%s, don't sign.",item_type);
// continue;
//}
ITKCALL( GRM_find_relation_type( TC_master_form_rtype, &master_form_rel_type ) );
ITKCALL(GRM_list_secondary_objects_only(itemrevision, master_form_rel_type, &form_count, &form_list ));
if( form_count ==0 )
{
ECHO("未找到签名form,继续...");
continue;
}
master_form = form_list[0]; //属性写到版本上
ECHO("Begin set properties for name\n");
ITKCALL(AOM_load (master_form));
//if(bypass)
// AM__set_application_bypass(TRUE);
POM_AM__set_application_bypass(true);
for(j=0; j<userinfoscount; j++)
{
//ECHO("userinfo_s[j].taskname:%s",userinfo_s[j].taskname);
for(k=0; k<nodecount; k++)
{
ECHO("userinfo_s[%d].taskname=%s, flownode_s[%d].taskname=%s, flownode_s[%d].username=%s\n",j,userinfo_s[j].taskname,k,flownode_s[k].taskname,k,flownode_s[k].username);
if(strcmp(userinfo_s[j].taskname,flownode_s[k].taskname) == 0)
{
POM_AM__set_application_bypass(true);
ITKCALL(AOM_lock(master_form));
ECHO("set prop %s=%s\n",userinfo_s[j].propertyname,flownode_s[k].username);
ITKCALL( AOM_set_value_string( master_form, userinfo_s[j].propertyname, flownode_s[k].username) );
ITKCALL( AOM_save( master_form ) );
ITKCALL( AOM_unlock( master_form ) );
//break;
}
else if (strcmp(userinfo_s[j].taskname,flownode_s[k].taskname) != 0
//&& strstr(flownode_s[k].taskname, userinfo_s[j].taskname) != NULL
//&& strstr(userinfo_s[j].taskname,group_full_name) != NULL
&& strstr(userinfo_s[j].taskname,flownode_s[k].group) != NULL)
{
////printf("flownode_s[k].username=%s\n",flownode_s[k].username);
//set_bypass(true);
//CALL(AOM_lock(master_form));
//CALL( AOM_set_value_string( master_form, userinfo_s[j].propertyname, flownode_s[k].username) );
//CALL( AOM_save( master_form ) );
//CALL( AOM_unlock( master_form ) );
////break;
}
}
}
ECHO("Begin set properties for time\n");
POM_AM__set_application_bypass(true);
for(j=0;j< timeinfoscount;j++)
{
//ECHO("%s : ",timeinfo_s[j].taskname);
for(k=0;k<nodecount;k++)
{
//printf("group_full_name =%s, timeinfo_s[j].taskname=%s\n",group_full_name,timeinfo_s[j].taskname);
ECHO("timeinfo_s[%d].taskname=%s, flownode_s[%d].taskname=%s,flownode_s[%d].username=%s\n",j,timeinfo_s[j].taskname,k, flownode_s[k].taskname,k,flownode_s[k].username);
if(strcmp(timeinfo_s[j].taskname,flownode_s[k].taskname) == 0)
{
ECHO("set time prop:%s value:%s\n",timeinfo_s[j].propertyname,flownode_s[k].timeinfo);
POM_AM__set_application_bypass(true);
ITKCALL(AOM_lock(master_form));
PROP_value_type_t valtype;
char *valtype_n = NULL;
ITKCALL(AOM_ask_value_type( master_form, timeinfo_s[j].propertyname, &valtype, &valtype_n));
if( valtype == PROP_date )
{
date_t a_date;
ITK_string_to_date(flownode_s[k].timeinfo, &a_date);
EMH_clear_errors();
AOM_set_value_date(master_form, timeinfo_s[j].propertyname, a_date);
//ITKCALL(AOM_UIF_set_value(itemrevision, timeinfo_s[j].propertyname,flownode_s[k].timeinfo));
}
else
ITKCALL( AOM_set_value_string( master_form, timeinfo_s[j].propertyname, flownode_s[k].timeinfo) );
DOFREE(valtype_n);
ITKCALL( AOM_save( master_form ) );
ITKCALL( AOM_unlock( master_form ) );
//break;
}
else if(strcmp(timeinfo_s[j].taskname,flownode_s[k].taskname) != 0
//&& strstr(flownode_s[k].taskname,timeinfo_s[j].taskname) != NULL
//&& strstr(timeinfo_s[j].taskname,group_full_name ) != NULL
&& strstr(timeinfo_s[j].taskname,flownode_s[k].group ) != NULL)
{
//ECHO("222 set prop:%s value:%s",timeinfo_s[j].propertyname,flownode_s[k].timeinfo);
//set_bypass(true);
//ITKCALL(AOM_lock(master_form));
//ITKCALL( AOM_set_value_string( master_form, timeinfo_s[j].propertyname, "222") );
//ITKCALL( AOM_save( master_form ) );
//ITKCALL( AOM_unlock( master_form ) );
////break;
}
}
}
ECHO("==================WORK END====================");
}
}
ECHO("close bypass...");
//AM__set_application_bypass(FALSE);
POM_AM__set_application_bypass(false);
}
EMH_clear_errors();
MEM_free(form_list);
//CloseLog();
nodecount = 0;
userinfoscount = 0;
timeinfoscount = 0;
end_handler:
//CloseLog();
DOFREE(taskAttches);
//DOFREE(pref_values);
//if (debug)
{
printf("=========================================================\n");
printf("hander jf_sign_ir_master 执行完成\n");
printf("=========================================================\n");
}
return rcode;
}

@ -0,0 +1,134 @@
/*检查EBOM派生出来的所有MBOM的最新版本是否已经发布或者说最新版本是否在流程中或工作中的状态如果未发布就提示*/
#pragma warning (disable: 4996)
#pragma warning (disable: 4819)
#pragma warning (disable: 4995)
#include <tc/tc.h>
#include "epm_handler_common.h"
#include <ict/ict_userservice.h>
#include <tccore/custom.h>
#include <epm/epm_toolkit_tc_utils.h>
#include <tccore/aom.h>
#include <tccore/aom_prop.h>
#include <tccore/item.h>
#include <bom/bom.h>
#include "ps/ps.h";
#include "ps/vrule.h"
#include "sstream"
#include <tccore/grm.h>
#include "epm/epm.h"
#include "sa/sa.h"
#include "libxl.h"
#include <map>
#include "epm/signoff.h"
#include <ctime>
#include <vector>
#include <locale>
#include <codecvt>
#include "ae/dataset.h"
#include <iostream>
#include <stdlib.h>
#include <tccore/aom.h>
#include <tc/emh.h>
#include <ict/ict_userservice.h>
#include <tc/tc.h>
#include <tccore/tctype.h>
#include <sa/tcfile.h>
#include <ss/ss_errors.h>
int JK_check_workflow(EPM_rule_message_t msg)
{
EPM_decision_t decision = EPM_go;
int ifail = ITK_ok, arg_cnt = 0, i = 0, att_cnt = 0;
tag_t task_tag = NULLTAG, rootTask_tag = NULLTAG, *attachments = NULL;
char * object_TYPE_1 = NULL;
char * object_string1=NULL;
string value_type = "";
string value_property="";
string errorMessage="以下EBOM对应的MBOM最新版未发布禁止升版:\n";
//获取当前触发的任务
task_tag = msg.task;
//获取根流程节点
ifail = EPM_ask_root_task(task_tag, &rootTask_tag);
//获取目标引用对象
ifail = EPM_ask_attachments(rootTask_tag, EPM_target_attachment, &att_cnt, &attachments);
int reference_count=0;tag_t * reference_attachment=NULLTAG;
ifail = EPM_ask_attachments(rootTask_tag, EPM_reference_attachment, &reference_count, &reference_attachment);
vector<string> errorVec;//存放的是未发布的MBOMID和EBOM的id加版本
//循环目标对象
for (i = 0; i < att_cnt; i++) {
ITKCALL(ifail = AOM_ask_value_string(attachments[i], "object_type", &object_TYPE_1));//对象类型
cout << object_TYPE_1;
cout << endl;
if(strcmp("JK8MaterialRevision",object_TYPE_1)==0)
{
int MBOMNums=0;
tag_t *MBOMTags=NULLTAG;
ITKCALL(ifail=AOM_ask_value_tags(attachments[i],"JK8MBOMRelation",&MBOMNums,&MBOMTags));
for (int j=0;j<MBOMNums;j++)
{
ITKCALL(ifail = AOM_ask_value_string(MBOMTags[j], "object_type", &object_TYPE_1));//对象类型
if(strcmp(object_TYPE_1,"JK8Material")==0)
{
tag_t latest_rev;
ITEM_ask_latest_rev(MBOMTags[j],&latest_rev);//获得最新版本
int is_released=0;
EPM_ask_if_released(latest_rev,&is_released);//0未发布1发布
// ITEM_rev_vi_revise_and_update()
if(is_released==0)
{
char *item_id=NULL;
char *item_revision_id=NULL;
char *item_id2=NULL;
string hint="";
AOM_ask_value_string(attachments[i],"item_id",&item_id);
AOM_ask_value_string(attachments[i],"item_revision_id",&item_revision_id);
AOM_ask_value_string(MBOMTags[j],"item_id",&item_id2);
hint=hint.append(item_id).append("/").append(item_revision_id).append("-").append(item_id2).append(" ");
errorVec.push_back(hint);
if(item_id!=NULL)
{
MEM_free(item_id);
item_id=NULL;
}
if(item_revision_id!=NULL)
{
MEM_free(item_revision_id);
item_revision_id=NULL;
}
if(item_id2!=NULL)
{
MEM_free(item_id2);
item_id2=NULL;
}
}
}
}
if(MBOMTags!=NULL)
{
MEM_free(MBOMTags);
MBOMTags=NULL;
}
}
}
if(errorVec.size()>0)
{
for (int i=0;i<errorVec.size();i++)
{
errorMessage=errorMessage+errorVec[i];
}
EMH_store_error_s1(EMH_severity_warning, EMH_AE_error_base, errorMessage.c_str());
return EPM_nogo;
}
return EPM_go;
}

@ -0,0 +1,165 @@
#include <tc/tc.h>
#include "epm_handler_common.h"
#include <ict/ict_userservice.h>
#include <tccore/custom.h>
#include <epm/epm_toolkit_tc_utils.h>
#include <tccore/aom.h>
#include <tccore/aom_prop.h>
#include <tccore/item.h>
#include <bom/bom.h>
#include "ps/ps.h"
#include "ps/vrule.h"
#include "sstream"
#include <tccore/grm.h>
#include "epm/epm.h"
#include "sa/sa.h"
//#include "libxl.h"
#include <map>
#include "epm/signoff.h"
#include <ctime>
#include <vector>
#include <locale>
#include <codecvt>
#include "ae/dataset.h"
#include <iostream>
#include <regex>
#include "string_utils.h"
#include <list>
#include "tc_log.h"
#include <tc/tc.h>
#include "epm_handler_common.h"
#include <ict/ict_userservice.h>
#include <tccore/custom.h>
#include <epm/epm_toolkit_tc_utils.h>
#include <tccore/aom.h>
#include <tccore/aom_prop.h>
#include <tccore/item.h>
#include <bom/bom.h>
#include <tccore/grm.h>
#include "epm/epm.h"
//#include "libxl.h"
#include <iostream>
#include <regex>
using namespace std;
typedef struct
{
string ITEM_ID;//id号
string ITEM_REVISION_ID;//类型
}PRO_STRUCT1;
//物料停用逻辑:对选中的物料发起流程,检查其下所有的版本是否发布,如果有未发布的版本,就阻止进入流程,并且提示信息
//注意:可能对多个物料发起流程
int MaterialDiscontinuation(EPM_rule_message_t msg)
{
cout<<"检查能否发起物料停用流程"<<endl;
int ifail = ITK_ok;
EPM_decision_t decision = EPM_go;
tag_t task_tag = NULLTAG, rootTask_tag = NULLTAG, *attachments = NULLTAG,*revision_list=NULLTAG;
int arg_cnt = 0, i = 0, att_cnt = 0,revtion_nums=0;
int release_nums=0;
tag_t *release_list=NULLTAG;
char* object_type;
//获取当前触发的任务
task_tag = msg.task;
//获取根流程节点
ifail = EPM_ask_root_task(task_tag, &rootTask_tag);
//获取目标引用对象
ifail = EPM_ask_attachments(rootTask_tag, EPM_target_attachment, &att_cnt, &attachments);
//循环目标对象
cout<<"数量dd------->"<<att_cnt<<endl;
vector<PRO_STRUCT1> item_vec;
for (i = 0; i < att_cnt; i++)
{
//获得该物料下所有版本版本revision_list
ITKCALL(ifail=AOM_ask_value_string(attachments[i],"object_type",&object_type));
if(strcmp("JK8Material",object_type)==0)//LP2_Design_Part
{
ITKCALL( ifail=AOM_ask_value_tags(attachments[i],"revision_list",&revtion_nums,&revision_list));
for (int j=0;j<revtion_nums;j++)
{
PRO_STRUCT1 elements ;
ITKCALL( ifail= AOM_ask_value_tags(revision_list[j],"release_status_list",&release_nums,&release_list));
ITKCALL(ifail=AOM_ask_value_string(revision_list[j],"object_string",&object_type));
cout<<"object_string--------------"<<object_type<<endl;
cout<<"release_nums--------------"<<release_nums<<endl;
if(release_nums==0)
{
ITKCALL(ifail=AOM_ask_value_string(attachments[i],"item_id",&object_type));
cout<<"item id-----------------------"<<object_type<<endl;
elements.ITEM_ID.assign(object_type);
ITKCALL(ifail=AOM_ask_value_string(revision_list[j],"item_revision_id",&object_type));
cout<<"item_revision_id--------------"<<object_type<<endl;
elements.ITEM_REVISION_ID.assign(object_type);
item_vec.push_back(elements);
}
}
}
}
cout<<"item_vec.size()---------------"<<item_vec.size()<<endl;
if(item_vec.size()>0)
{
cout<<"111111111111"<<endl;
string error_string="\n";
for (int i=0;i<item_vec.size();i++)
{
// cout<<"i----------"<<i<<endl;
// cout<<"item_vec[i].ITEM_ID-------------"<<item_vec[i].ITEM_REVISION_ID.c_str()<<endl;
// cout<<"item_vec[i].ITEM_REVISION_ID-------------"<<item_vec[i].ITEM_REVISION_ID.c_str()<<endl;
error_string=error_string+item_vec[i].ITEM_ID.c_str()+"物料"+item_vec[i].ITEM_REVISION_ID.c_str()+"版本,";
}
error_string=error_string+"未发布,不允许做停用操作!";
cout<<"error_string--------"<<error_string.c_str()<<endl;
EMH_store_error_s1(EMH_severity_warning, EMH_AE_error_base, error_string.c_str());
if (attachments != NULL)
{
MEM_free(attachments);
attachments = NULL;
}
if (revision_list != NULL)
{
MEM_free(revision_list);
revision_list = NULL;
}
if (release_list != NULL)
{
MEM_free(release_list);
release_list = NULL;
}
if (object_type != NULL)
{
MEM_free(object_type);
object_type = NULL;
}
return EPM_nogo;
}else if(item_vec.size()==0)
{
if (attachments != NULL)
{
MEM_free(attachments);
attachments = NULL;
}
if (revision_list != NULL)
{
MEM_free(revision_list);
revision_list = NULL;
}
if (release_list != NULL)
{
MEM_free(release_list);
release_list = NULL;
}
if (object_type != NULL)
{
MEM_free(object_type);
object_type = NULL;
}
return EPM_go;
}
}

@ -0,0 +1,144 @@
#include <tc/tc.h>
#include "epm_handler_common.h"
#include <ict/ict_userservice.h>
#include <tccore/custom.h>
#include <epm/epm_toolkit_tc_utils.h>
#include <tccore/aom.h>
#include <tccore/aom_prop.h>
#include <tccore/item.h>
#include <bom/bom.h>
#include "ps/ps.h"
#include "ps/vrule.h"
#include "sstream"
#include <tccore/grm.h>
#include "epm/epm.h"
#include "sa/sa.h"
//#include "libxl.h"
#include <map>
#include "epm/signoff.h"
#include <ctime>
#include <vector>
#include <locale>
#include <codecvt>
#include "ae/dataset.h"
#include <iostream>
#include <regex>
#include "string_utils.h"
#include <list>
#include "tc_log.h"
#include <tc/tc.h>
#include "epm_handler_common.h"
#include <ict/ict_userservice.h>
#include <tccore/custom.h>
#include <epm/epm_toolkit_tc_utils.h>
#include <tccore/aom.h>
#include <tccore/aom_prop.h>
#include <tccore/item.h>
#include <bom/bom.h>
#include <tccore/grm.h>
#include "epm/epm.h"
//#include "libxl.h"
#include <iostream>
#include <regex>
using namespace std;
typedef struct
{
string ITEM_ID;//id号
}PRO_STRUCT;
int MaterialOpenning(EPM_rule_message_t msg)
{
cout<<"检查能否发起物料启用流程"<<endl;
int ifail = ITK_ok;
EPM_decision_t decision = EPM_go;
tag_t task_tag = NULLTAG, rootTask_tag = NULLTAG, *attachments = NULLTAG,*revision_list=NULLTAG;
int arg_cnt = 0, i = 0, att_cnt = 0,revtion_nums=0;
int release_nums=0;
tag_t *release_list=NULLTAG;
char* object_type;
//获取当前触发的任务
task_tag = msg.task;
//获取根流程节点
ifail = EPM_ask_root_task(task_tag, &rootTask_tag);
//获取目标引用对象
ifail = EPM_ask_attachments(rootTask_tag, EPM_target_attachment, &att_cnt, &attachments);
//循环目标对象
cout<<"数量------->"<<att_cnt<<endl;
vector<PRO_STRUCT> item_vec;
for (i = 0; i < att_cnt; i++)
{
//获得该物料下所有版本版本revision_list不是判断版本有没有失效状态而是判断物料有没有失效状态
ifail=AOM_ask_value_string(attachments[i],"object_type",&object_type);
if(strcmp("JK8Material",object_type)==0)
{
ifail=AOM_ask_value_tags(attachments[i],"release_status_list",&release_nums,&release_list);
if(release_nums==0)
{
PRO_STRUCT elements ;
ifail=AOM_ask_value_string(attachments[i],"item_id",&object_type);
elements.ITEM_ID.assign(object_type);
item_vec.push_back(elements);
}
for (int k=0;k<release_nums;k++)
{
ifail=AOM_ask_value_string(release_list[k],"object_name",&object_type);
if(strcmp(object_type,"jk8Disabled")==0)
{
break;
}else
{
PRO_STRUCT elements ;
ifail=AOM_ask_value_string(attachments[i],"item_id",&object_type);
elements.ITEM_ID.assign(object_type);
item_vec.push_back(elements);
}
}
}
if (revision_list != NULL)
{
MEM_free(revision_list);
revision_list = NULL;
}
}
if(item_vec.size()>0)
{
string error_string="\n";
for (int i=0;i<item_vec.size();i++)
{
error_string=error_string+item_vec[i].ITEM_ID.c_str()+";";
}
error_string=error_string+"物料不是失效物料,不允许做启用操作!";
EMH_store_error_s1(EMH_severity_warning, EMH_AE_error_base, error_string.c_str());
if (attachments != NULL)
{
MEM_free(attachments);
attachments = NULL;
}
if (release_list != NULL)
{
MEM_free(release_list);
release_list = NULL;
}
if (object_type != NULL)
{
MEM_free(object_type);
object_type = NULL;
}
return EPM_nogo;
}
return EPM_go;
}

@ -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,123 @@
#include "epm_handler_common.h"
#include "jk_custom_erp.h"
#include <tc/tc.h>
#include <ict/ict_userservice.h>
#include <tccore/custom.h>
#include <epm/epm_toolkit_tc_utils.h>
#include <tccore/aom.h>
#include <tccore/aom_prop.h>
#include <tccore/item.h>
#include <bom/bom.h>
#include "ps/ps.h";
#include "ps/vrule.h"
#include "sstream"
#include <tccore/grm.h>
#include "epm/epm.h"
#include "sa/sa.h"
#include <map>
#include "epm/signoff.h"
#include <ctime>
#include <vector>
#include <locale>
#include <codecvt>
#include "ae/dataset.h"
#include <server_exits/user_server_exits.h>
#include <tccore/custom.h>
#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 <form/form.h>
#include <form/formtype.h>
#include <ics\ics.h>
#include <stdarg.h>
#include <iostream>
# include "common_itk_util.h"
using namespace std;
extern "C" int POM_AM__set_application_bypass(logical bypass);
int addDisabled(EPM_action_message_t msg)
{
int ifail=ITK_ok;
EPM_decision_t decision = EPM_go;
tag_t task_tag = NULLTAG, rootTask_tag = NULLTAG, *attachments = NULLTAG,*revision_list=NULLTAG;
int arg_cnt = 0, i = 0, att_cnt = 0,revtion_nums=0;
int release_nums=0;
tag_t *release_list=NULLTAG;
char* object_type;
tag_t release_stat = NULLTAG;
vector<tag_t> attatcgments;
string dateType="dis";
ITKCALL(ifail=RELSTAT_create_release_status("jk8Disabled", &release_stat));//TCM Released jk8Disabled
//获取当前触发的任务
task_tag = msg.task;
//获取根流程节点
ITKCALL(ifail = EPM_ask_root_task(task_tag, &rootTask_tag));
//获取目标引用对象
ITKCALL(ifail = EPM_ask_attachments(rootTask_tag, EPM_target_attachment, &att_cnt, &attachments));
//循环目标对象
cout<<"数量------->"<<att_cnt<<endl;
for (i = 0; i < att_cnt; i++)
{
//获得该物料下所有版本版本revision_list
ITKCALL(ifail=AOM_ask_value_string(attachments[i],"object_type",&object_type));
if(strcmp("JK8Material",object_type)==0)//LP2_Design_Part JK8Material
{
//TODO 给物料添加失效状态和失效时间
ITKCALL(ifail=RELSTAT_add_release_status(release_stat, 1, &attachments[i], true));
ITKCALL(ifail=AOM_ask_value_tags(attachments[i],"revision_list",&revtion_nums,&revision_list));
date_t current_date;
char create_date_str[32] = "\0";
current_time(&current_date);
sprintf(create_date_str,"%04d-%02d-%02d",current_date.year,1+ current_date.month,current_date.day);
cout<<"create_date_str-------------------"<<create_date_str;
string ddd=create_date_str;
ITKCALL(ifail=AOM_ask_value_string(attachments[i],"object_string",&object_type));
cout<<"attachments[i]--------------"<<object_type;
POM_AM__set_application_bypass(true);
AOM_lock(attachments[i]);
ITKCALL(ifail=AOM_set_value_string(attachments[i],"jk8DisabledDate",ddd.c_str()));//jk8DisabledDate TCM Released
AOM_save(attachments[i]);
AOM_unlock(attachments[i]);
POM_AM__set_application_bypass(false);
for (int j=0;j<revtion_nums;j++)
{
//给每一个版本添加失效状态
POM_AM__set_application_bypass(true);
ITKCALL(ifail=RELSTAT_add_release_status(release_stat, 1, &revision_list[j], true));
POM_AM__set_application_bypass(false);
if(j==revtion_nums-1)
{
attatcgments.push_back(revision_list[j]);//把最新版本加到版本集合中
}
}
}
}
//TODO 把最新版本的属性信息发送到U8附带失效时间
JK_send_material1(attatcgments,dateType);
return ifail;
}

@ -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( &ltime );
today = localtime( &ltime );
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,389 @@
#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 <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, ...)
{
//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 );
}
int getBomView(tag_t rev_tag, char* viewtype, tag_t *bomView, tag_t *bomBVR, int debug)
{
int ifail = ITK_ok, rcode = 0, count = 0, i = 0, j =0, p =0, q = 0, length = 0,child_cnt = 0,
bvr_count =0, n = 0, bom_attr_id = 0, itemid_attr_id = 0,revid_attr_id = 0, view_count =0,
itemrev_attr_id = 0, qty_attr_id = 0, seq_attr_id = 0, child_bvr_count = 0, factory_count =0;
tag_t item = NULLTAG, new_bom_line = NULLTAG, folder = NULLTAG, *bomview_list = NULL, *bvr_list = NULL,
p_rev_tag = NULLTAG, bom_view = NULLTAG, bvr = NULLTAG, child_item_tag = NULLTAG, view_type = NULLTAG,
mbom_bvr = NULLTAG, ebom_bvr = NULLTAG,ebom_view = NULLTAG, mbom_view = NULLTAG;
char object_type[WSO_object_type_size_c+1]="",*value = NULL;
*bomBVR = NULLTAG;
*bomView = NULLTAG;
ITKCALL( ITEM_rev_list_bom_view_revs( rev_tag, &bvr_count, &bvr_list ) );
if( bvr_count > 0 )
{
mbom_bvr = NULLTAG;
for( i=0; i < bvr_count; i++ )
{
ITKCALL(PS_ask_bom_view_of_bvr(bvr_list[i], &bom_view));
ITKCALL(PS_ask_bom_view_type(bom_view, &view_type));
//ITKCALL( PS_find_view_type(bom_view, &view_type));
char *view_type_name = NULL;
ITKCALL(PS_ask_view_type_name(view_type, &view_type_name));
if( debug )
ECHO("\nDEBUG: view_type_name=%s\n", view_type_name);
if (tc_strcmp(view_type_name, viewtype) == 0)
{
*bomBVR = bvr_list[i];
*bomView = bom_view;
}
DOFREE(view_type_name);
}
}
DOFREE(bvr_list);
return ifail;
}
//equal=0为>=,equal=1为>
int getAfterStatus( vector<string> &full_vec,int equal,char *status, vector<string> &after_vec )
{
int ifail = 0, i =0, j=0;
logical flag = false;
for( i = 0; i <full_vec.size(); i++ )
{
if( stricmp(full_vec[i].c_str(), status) ==0 )
{
flag = true;
break;
}
}
if( flag )
{
if( equal == 0 )
{
for( j = i;j < full_vec.size(); j++ )
{
ECHO("起始:%d, full_vec[%d]:%s\n",i, j, full_vec[j].c_str());
after_vec.push_back(full_vec[j]);
}
}
else if( equal == 1 )
{
for( j = i+1;j < full_vec.size(); j++ )
{
ECHO("起始:%d, full_vec[%d]:%s\n",i, j, full_vec[j].c_str());
after_vec.push_back(full_vec[j]);
}
}
}
return ifail;
}
logical isInVec(vector<string> &full_vec,char *arg_status, int equal,char *status )
{
int ifail = 0, i =0, j=0;
logical isInclude = false;
vector<string> after_vec;
getAfterStatus(full_vec, equal, arg_status, after_vec);
for( i = 0; i < after_vec.size(); i ++ )
{
ECHO("after_vec[%d]:%s status:%s\n",i,after_vec[i].c_str(), status);
if( stricmp(after_vec[i].c_str(), status) ==0 )
{
isInclude = true;
break;
}
}
return isInclude;
}
int CycleBOM( tag_t bomline,char *process_owner, char *arg_status, vector<string> &status_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,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));
ITKCALL(WSOM_ask_release_status_list(child_rev_tag,&status_count,&status_tag_list));
//if( debug )
ECHO("status_count%d\n",status_count);
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",arg_status,status_type);
if( strcmp( process_owner, user_id ) ==0 )
{
if( isInVec(status_vec,arg_status,0,status_type) ) //>=
{
isInculde = true;
}
}
else if( strcmp( process_owner, user_id ) !=0 &&
stricmp( status_type,"H9_Released" ) != 0)
{
if( isInVec(status_vec,arg_status,1,status_type) ) //>
{
isInculde = true;
}
}
}
if( !isInculde )
{
ITKCALL(ITEM_ask_rev_id(child_rev_tag, child_rev_id));
ITKCALL(ITEM_ask_item_of_rev( child_rev_tag, &child_item_tag ));
ITKCALL(ITEM_ask_id( child_item_tag, child_item_id ));
string errMsg;
errMsg.assign(child_item_id).append("/").append(child_rev_id).append(" 成熟度不符合发布要求");
errMap.insert(pair<string,int>(errMsg,ERROR_STATUS_ERROR));
}
}
else //working状态
{
ECHO("无状态, process_owner:%s, user_id:%s\n",arg_status,user_id);
if( strcmp( process_owner, user_id ) !=0 )
{
ITKCALL(ITEM_ask_rev_id(child_rev_tag, child_rev_id));
ITKCALL(ITEM_ask_item_of_rev( child_rev_tag, &child_item_tag ));
ITKCALL(ITEM_ask_id( child_item_tag, child_item_id ));
string errMsg;
errMsg.assign(child_item_id).append("/").append(child_rev_id).append(" 成熟度不符合发布要求");
errMap.insert(pair<string,int>(errMsg,ERROR_STATUS_ERROR));
}
}
DOFREE(status_tag_list);
}
for( int i = 0; i < child_cnt; i++ )
{
ifail = CycleBOM(child_lines[i],process_owner, arg_status, status_vec, errMap, debug);
}
return ifail;
}
int HZ_Check_BOM_Condition(EPM_rule_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, user = 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]="";
tag_t bomWindow = NULLTAG, bom_top_line = NULLTAG, bom_config_rule = NULLTAG;
map<string,int> errMap;
vector<string> status_vec;
//map<string,string> zuhaoMap;
EPM_decision_t decision = EPM_go;
logical debug = true;
ECHO("*************************************************************\n");
ECHO("* HZ_Check_BOM_Condition is comming ! *\n");
ECHO("*************************************************************\n");
task_tag = msg.task;
if(task_tag == NULLTAG)
{
ifail = ITK_ok;
//goto end_handler;
return EPM_nogo;
}
tag_t rootTask = NULLTAG;
status_vec.clear();
status_vec.push_back("working");
status_vec.push_back("H9_M0");
status_vec.push_back("H9_M1");
status_vec.push_back("H9_M2");
status_vec.push_back("H9_P");
status_vec.push_back("H9_M3");
status_vec.push_back("H9_B");
status_vec.push_back("H9_D");
status_vec.push_back("H9_Released");
//获得参数
arg_cnt = TC_number_of_arguments(msg.arguments);
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;
}
}
}
}
if( strlen(arg_status) <2 )
{
string key_id;
key_id.assign("缺少status参数");
errMap.insert(pair<string,int>(key_id,HANDLER_ARGUMENT_ERROR));
return EPM_nogo;
}
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));
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 ) );
CycleBOM(ebom_line,userid,arg_status,status_vec,errMap,debug);
ITKCALL(BOM_close_window(ebom_window));
}
}
}
DOFREE(attachments);
if( debug )
ECHO("DEBUG: errMap.size is %d\n", errMap.size());
if( errMap.size() > 0 )
decision = EPM_nogo;
else
decision = EPM_go;
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());
}
errMap.clear();
ECHO("\n************************************************************\n");
ECHO("* HZ_Check_BOM_Condition is end! *\n");
ECHO("*************************************************************\n");
return decision;
}

@ -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,868 @@
/*===================================================================================================
Copyright(c) 2011 Siemens PLM Software Corp. All rights reserved.
Unpublished - All rights reserved
====================================================================================================
File description:
Filename : epm_register_handler.c
This file registers functions which are called when Teamcenter is being initialized
====================================================================================================
Date Name Description of Change
2011-8-21 Ray creation
$HISTORY$
==================================================================================================*/
#pragma warning (disable: 4819)
/**
* @headerfile tcua
*/
#include <server_exits/user_server_exits.h>
#include <tccore/custom.h>
#include <tccore/item_msg.h>
#include <epm/epm.h>
/**
* @headerfile standard c & cpp header files
*/
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>
#include <time.h>
#include <tc/tc.h>
#include <tccore/method.h>
/**
* @headerfile user's header files
*/
#include "epm_register_handler.h"
#include "epm_handler_common.h"
#include "erp_send_item.h"
#include "hz_custom.h"
#include "hx_custom.h"
#include "jk_custom.h"
#include "jk_custom_erp.h"
#define LIMITDAY 2016
int checkvalue(char* str)
{
int i;
for (i=0;i<strlen(str);i++)
{
if (isdigit(str[i]) == 0)
return 0;
}
return 1;
}
char* decrypt(char *lic_file)
{
char* p = NULL, buf[512], *str;
int i = 0;
FILE *fp1=NULL;
if((fp1 = fopen(lic_file,"r")) == NULL)
{
printf("can not open the license file\n");
return "";
}
fgets(buf, 9, fp1);
//printf("buf=%s\n",buf);
p = buf;
while(*p != '\0')
*p++ ^= i++;
p = buf;
while(*p != '\0')
*p++ ^= i++;
p = buf;
while(*p != '\0')
*p++ ^= i++;
return buf;
}
char* encrypt(char* str)
{
char* p = str;
int i = 0;
while(*p != '\0')
*p++ ^= i++;
return str;
}
//供流程调用的
// 标准的注册供流程调用服务handler的入口 TC_save_msg
extern DLLAPI int USERSERVICE_custom_register_handlers(int *decision, va_list args)
{
int ifail = ITK_ok, n=0;
char date_buf[80],*expire_date, env[512], temp1[512], temp2[512];
time_t now;
struct tm *p;
*decision = ALL_CUSTOMIZATIONS;
//宏协
METHOD_id_t mth_tag;
/* ITKCALL(ifail = METHOD_find_method("Item",ITEM_create_msg,&mth_tag));
if (mth_tag.id != 0){
ITKCALL(ifail = METHOD_add_action2(mth_tag, METHOD_post_action_type, HX3_create_item_post, NULL,true));
fprintf(stdout,"regist Item_create pre_action successfully !\n");
}else{
fprintf(stdout,"regist Item_create pre_action fiald !\n");
}*/
//保存对象后操作
/* ITKCALL(ifail = METHOD_find_method("BOMWindow",BOMWindow_save_msg,&mth_tag));
if (mth_tag.id != 0){
ITKCALL(ifail = METHOD_add_action(mth_tag, METHOD_pre_action_type, HX3_bom_save, NULL));
fprintf(stdout,"regist BOMWindow BOMWindow_save_msg pre_action successfully !\n");
}else{
char *errMsg = NULL;
fprintf(stdout,"regist BOMWindow BOMWindow_save_msg post_action fiald !\n");
EMH_ask_error_text(ifail, &errMsg);
printf("ERROR:登陆错误 : \"%d\", \"%s\"\n", ifail, errMsg);
if(errMsg!=NULL){
errMsg =NULL;
MEM_free(errMsg);
}
}
*/
//
//保存对象后操作
*decision = ALL_CUSTOMIZATIONS;
//int status = ITK_ok;
// //EBP SP-EXT-FUN-04. 修改项目状态后自动设置项目结束日期并通知SAP --zhanggl
//{
// ITKCALL( METHOD_find_prop_method ( "HX3_GYTRevision", "HX3_MUJT", PROP_set_value_tags_msg, &mth_tag ) );
// if ( mth_tag.id != NULLTAG )
// {
// printf("find HX3_GYTRevision HX3_MUJT \n ");
// ITKCALL(status = METHOD_add_action( mth_tag, METHOD_post_action_type,( METHOD_function_t ) HX3_post_prop_set, NULL ) );
// if(status == ITK_ok){
// printf("success HX3_MUJT \n ");
// }else{
// printf("faild HX3_MUJT \n ");
// }
// }else{
// printf("not find HX3_GYTRevision HX3_MUJT \n ");
// }
//}
//标准的注册action_handler的入口
ifail = EPM_register_action_handler("JK-signoff-form", "JK-signoff-form",
(EPM_action_handler_t)jf_sign_ir_master);
if(ifail == ITK_ok)
{
fprintf(stdout,"Registering action handler JK-signoff-form completed!\n");
}
else
{
fprintf(stdout , "Registering action handler JK-signoff-form failed %d!\n",ifail);
}
ifail = EPM_register_action_handler("TX-signoff-form", "TX-signoff-form",
(EPM_action_handler_t)tx_sign_ir_master);
if(ifail == ITK_ok)
{
fprintf(stdout,"Registering action handler TX-signoff-form completed!\n");
}
else
{
fprintf(stdout , "Registering action handler TX-signoff-form failed %d!\n",ifail);
}
ifail = EPM_register_action_handler("tx_AutoSign_Handler", "tx_AutoSign_Handler",
(EPM_action_handler_t)tx_AutoSign_Handler);
if(ifail == ITK_ok)
{
fprintf(stdout,"Registering action handler tx_AutoSign_Handler completed!\n");
}
else
{
fprintf(stdout , "Registering action handler tx_AutoSign_Handler failed %d!\n",ifail);
}
ifail = EPM_register_action_handler("jk_AutoSign_Handler", "jk_AutoSign_Handler",
(EPM_action_handler_t)jk_AutoSign_Handler);
if(ifail == ITK_ok)
{
fprintf(stdout,"Registering action handler jk_AutoSign_Handler completed!\n");
}
else
{
fprintf(stdout , "Registering action handler jk_AutoSign_Handler failed %d!\n",ifail);
}
//DWG签名
ifail = EPM_register_action_handler("JK-signoff-dataset", "JK-signoff-dataset",
(EPM_action_handler_t)jf_signoff_dataset);
if(ifail == ITK_ok)
{
fprintf(stdout,"Registering action handler JK-signoff-dataset completed!\n");
}
else
{
fprintf(stdout,"Registering action handler JK-signoff-dataset failed %d!\n",ifail);
}
//新建物料传递ERP
/* ifail = EPM_register_action_handler("tm-erp-send-items", "tm-erp-send-items",
(EPM_action_handler_t)jf_erp_send_items);
if(ifail == ITK_ok)
{
fprintf(stdout,"Registering action handler tm-erp-send-items completed!\n");
}
else
{
fprintf(stdout,"Registering action handler tm-erp-send-items failed %d!\n",ifail);
}
//新建BOM传递ERP
ifail = EPM_register_action_handler("tm-erp-send-boms", "tm-erp-send-boms",
(EPM_action_handler_t)jf_erp_send_boms);
if(ifail == ITK_ok)
{
fprintf(stdout,"Registering action handler tm-erp-send-boms completed!\n");
}
else
{
fprintf(stdout,"Registering action handler tm-erp-send-boms failed %d!\n",ifail);
}
//新建物料传递HL
ifail = EPM_register_action_handler("tm-hl-send-items", "tm-hl-send-items",
(EPM_action_handler_t)jf_hl_send_items);
if(ifail == ITK_ok)
{
fprintf(stdout,"Registering action handler tm-hl-send-items completed!\n");
}
else
{
fprintf(stdout,"Registering action handler tm-hl-send-items failed %d!\n",ifail);
}
//新建BOM传递混料
ifail = EPM_register_action_handler("tm-hl-send-boms", "tm-hl-send-boms",
(EPM_action_handler_t)jf_hl_send_boms);
if(ifail == ITK_ok)
{
fprintf(stdout,"Registering action handler tm-hl-send-boms completed!\n");
}
else
{
fprintf(stdout,"Registering action handler tm-hl-send-boms failed %d!\n",ifail);
}
//PDF插入图片
ifail = EPM_register_action_handler("tm_insert_img_pdf", "tm_insert_img_pdf",
(EPM_action_handler_t)jf_insert_img_pdf);
if(ifail == ITK_ok)
{
fprintf(stdout,"Registering action handler tm_insert_img_pdf completed!\n");
}
else
{
fprintf(stdout,"Registering action handler tm_insert_img_pdf failed %d!\n",ifail);
}
//检查文件夹是否为空rule_handler
ifail = EPM_register_rule_handler("tm_check_folder_null", "tm_check_folder_null",
(EPM_rule_handler_t)check_target_null);
if(ifail == ITK_ok)
{
fprintf(stdout,"Registering rule handler tm_check_folder_null completed!\n");
}
else
{
fprintf(stdout,"Registering rule handler tm_check_folder_null failed %d!\n",ifail);
}
//通知节点属性签名
ifail = EPM_register_action_handler("tm_sign_tongzhi", "tm_sign_tongzhi",
(EPM_action_handler_t)tm_sign_tongzhi);
if(ifail == ITK_ok)
{
fprintf(stdout,"Registering action handler tm_sign_tongzhi completed!\n");
}
else
{
fprintf(stdout,"Registering action handler tm_sign_tongzhi failed %d!\n",ifail);
}
*/
//显示时间表名称
ifail = EPM_register_action_handler("CN_show_schedule_name", "CN_show_schedule_name",
(EPM_action_handler_t)tm_show_object_name);
if(ifail == ITK_ok)
{
fprintf(stdout,"Registering action handler CN_show_schedule_name completed!\n");
}else
{
fprintf(stdout,"Registering action handler CN_show_schedule_name failed %d!\n",ifail);
}
//传递控制计划 jf_control_plan_send
/*
ifail = EPM_register_action_handler("tm_control_plan_send", "tm_control_plan_send",
(EPM_action_handler_t)jf_control_plan_send);
if(ifail == ITK_ok)
{
fprintf(stdout,"Registering action handler tm_control_plan_send completed!\n");
}
else
{
fprintf(stdout,"Registering action handler tm_control_plan_send failed %d!\n",ifail);
}
*/
( ifail = EPM_register_rule_handler("JK_summary_form", "JK_summary_form",(EPM_rule_handler_t) JK_summary_form));
if(ifail==0) {
printf("Registering rule handler JK_summary_form successful\n");
} else {
printf("Registering rule handler JK_summary_form failed %d\n", ifail);
}
( ifail = EPM_register_rule_handler("jk_water_summary", "jk_water_summary",(EPM_rule_handler_t) jk_water_summary));
if(ifail==0) {
printf("Registering rule handler jk_water_summary successful\n");
} else {
printf("Registering rule handler jk_water_summary failed %d\n", ifail);
}
( ifail = EPM_register_rule_handler("jk_decide_time", "jk_decide_time",(EPM_rule_handler_t) jk_decide_time));
if(ifail==0) {
printf("Registering rule handler jk_decide_time successful\n");
} else {
printf("Registering rule handler jk_decide_time failed %d\n", ifail);
}
( ifail = EPM_register_rule_handler("check_target_null", "check_target_null",(EPM_rule_handler_t) check_target_null));
if(ifail==0) {
printf("Registering rule handler check_target_null successful\n");
} else {
printf("Registering rule handler check_target_null failed %d\n", ifail);
}
( ifail = EPM_register_rule_handler("jk_check_virtual", "jk_check_virtual",(EPM_rule_handler_t) jk_check_virtual));
if(ifail==0) {
printf("Registering rule handler jk_check_virtual successful\n");
} else {
printf("Registering rule handler jk_check_virtual failed %d\n", ifail);
}
( ifail = EPM_register_rule_handler("JK_check_workflow", "JK_check_workflow",(EPM_rule_handler_t) JK_check_workflow));
if(ifail==0) {
printf("Registering rule handler JK_check_workflow successful\n");
} else {
printf("Registering rule handler JK_check_workflow failed %d\n", ifail);
}
( ifail = EPM_register_action_handler("jk_add_actual", "jk_add_actual",(EPM_action_handler_t) jk_add_actual));
if(ifail==0) {
printf("Registering rule handler jk_add_actual successful\n");
} else {
printf("Registering rule handler jk_add_actual failed %d\n", ifail);
}
( ifail = EPM_register_action_handler("jk_exportExcel", "jk_exportExcel",(EPM_action_handler_t) jk_exportExcel));
if(ifail==0) {
printf("Registering rule handler jk_exportExcel successful\n");
} else {
printf("Registering rule handler jk_exportExcel failed %d\n", ifail);
}
( ifail = EPM_register_action_handler("jk_auto_create_process", "jk_auto_create_process",(EPM_action_handler_t) jk_auto_create_process));
if(ifail==0) {
printf("Registering rule handler jk_auto_create_process successful\n");
} else {
printf("Registering rule handler jk_auto_create_process failed %d\n", ifail);
}
( ifail = EPM_register_action_handler("jk_remove_allStatus", "删除版本状态",(EPM_action_handler_t) jk_remove_allStatus));
if(ifail==0) {
printf("Registering rule handler jk_remove_allStatus successful\n");
} else {
printf("Registering rule handler jk_remove_allStatus failed %d\n", ifail);
}
( ifail = EPM_register_action_handler("JK_send_email", "JK_send_email",(EPM_action_handler_t) JK_send_email));
if(ifail==0) {
printf("Registering rule handler JK_send_email successful\n");
} else {
printf("Registering rule handler JK_send_email failed %d\n", ifail);
}
( ifail = EPM_register_action_handler("JK_send_email_2", "JK_send_email_2",(EPM_action_handler_t) JK_send_email_2));
if(ifail==0) {
printf("Registering rule handler JK_send_email_2 successful\n");
} else {
printf("Registering rule handler JK_send_email_2 failed %d\n", ifail);
}
//JK_matereial_summary_fee JK_change_qx
( ifail = EPM_register_action_handler("JK_matereial_summary_fee", "JK_matereial_summary_fee",(EPM_action_handler_t) JK_matereial_summary_fee));
if(ifail==0) {
printf("Registering rule handler JK_matereial_summary_fee successful\n");
} else {
printf("Registering rule handler JK_matereial_summary_fee failed %d\n", ifail);
}
( ifail = EPM_register_action_handler("JK_change_qx", "JK_change_qx",(EPM_action_handler_t) JK_change_qx));
if(ifail==0) {
printf("Registering rule handler JK_change_qx successful\n");
} else {
printf("Registering rule handler JK_change_qx failed %d\n", ifail);
}
( ifail = EPM_register_action_handler("jk_add_attatchments", "jk_add_attatchments",(EPM_action_handler_t) jk_add_attatchments));
if(ifail==0) {
printf("Registering rule handler jk_add_attatchments successful\n");
} else {
printf("Registering rule handler jk_add_attatchments failed %d\n", ifail);
}
( ifail = EPM_register_action_handler("JK_send_material", "JK_send_material",(EPM_action_handler_t) JK_send_material));
if(ifail==0) {
printf("Registering rule handler JK_send_material successful\n");
} else {
printf("Registering rule handler JK_send_material failed %d\n", ifail);
}
( ifail = EPM_register_action_handler("jk_test_ask_icoAttribute", "jk_test_ask_icoAttribute",(EPM_action_handler_t) jk_test_ask_icoAttribute));
if(ifail==0) {
printf("Registering rule handler jk_test_ask_icoAttribute successful\n");
} else {
printf("Registering rule handler jk_test_ask_icoAttribute failed %d\n", ifail);
}
( ifail = EPM_register_action_handler("JK_send_bom", "JK_send_bom",(EPM_action_handler_t) JK_send_bom));
if(ifail==0) {
printf("Registering rule handler JK_send_bom successful\n");
} else {
printf("Registering rule handler JK_send_bom failed %d\n", ifail);
}
( ifail = EPM_register_action_handler("JK_bypass", "JK_bypass",(EPM_action_handler_t) JK_bypass));
if(ifail==0) {
printf("Registering action handler JK_bypass successful\n");
} else {
printf("Registering action handler JK_bypass failed %d\n", ifail);
}
( ifail = EPM_register_rule_handler("JK_class_null", "JK_class_null",(EPM_rule_handler_t) JK_class_null));
if(ifail==0) {
printf("Registering rule handler JK_class_null successful\n");
} else {
printf("Registering rule handler JK_class_null failed %d\n", ifail);
}
( ifail = EPM_register_rule_handler("JK_summary_pcb_form", "JK_summary_pcb_form",(EPM_rule_handler_t) JK_summary_pcb_form));
if(ifail==0) {
printf("Registering rule handler JK_summary_pcb_form successful\n");
} else {
printf("Registering rule handler JK_summary_pcb_form failed %d\n", ifail);
}
( ifail = EPM_register_rule_handler("JK_Bom_is_release", "JK_Bom_is_release",(EPM_rule_handler_t) JK_Bom_is_release));
if(ifail==0) {
printf("Registering rule handler JK_Bom_is_release successful\n");
} else {
printf("Registering rule handler JK_Bom_is_release failed %d\n", ifail);
}
//检查能否发起物料停用流程
( ifail = EPM_register_rule_handler("MaterialDiscontinuation", "检查能否发起物料停用流程",(EPM_rule_handler_t) MaterialDiscontinuation));
if(ifail==0) {
printf("Registering rule handler MaterialDiscontinuation successful\n");
} else {
printf("Registering rule handler MaterialDiscontinuation failed %d\n", ifail);
}
//检查能否发起物料停用流程
( ifail = EPM_register_rule_handler("tx_checkMaterialReleased", "天信检查能否发起物料停用流程",(EPM_rule_handler_t) tx_checkMaterialReleased));
if(ifail==0) {
printf("Registering rule handler tx_checkMaterialReleased successful\n");
} else {
printf("Registering rule handler tx_checkMaterialReleased failed %d\n", ifail);
}
//检查能否发起物料启用流程MaterialOpenning
( ifail = EPM_register_rule_handler("MaterialOpenning", "检查能否发起物料启用流程",(EPM_rule_handler_t) MaterialOpenning));
if(ifail==0) {
printf("Registering rule handler MaterialOpenning successful\n");
} else {
printf("Registering rule handler MaterialOpenning failed %d\n", ifail);
}
//检查能否发起物料启用流程MaterialOpenning
( ifail = EPM_register_rule_handler("tx_checkMaterialDisabled", "天信检查能否发起物料启用流程",(EPM_rule_handler_t) tx_checkMaterialDisabled));
if(ifail==0) {
printf("Registering rule handler tx_checkMaterialDisabled successful\n");
} else {
printf("Registering rule handler tx_checkMaterialDisabled failed %d\n", ifail);
}
//检查BOM子阶物料审核流程
( ifail = EPM_register_rule_handler("BOMDiscontinuation", "BOM子阶物料审核流程",(EPM_rule_handler_t) BOMDiscontinuation));
if(ifail==0) {
printf("Registering rule handler BOMDiscontinuation successful\n");
} else {
printf("Registering rule handler BOMDiscontinuation failed %d\n", ifail);
}
//添加失效状态并传递中间表
( ifail = EPM_register_action_handler("addDisabled", "添加失效状态",(EPM_action_handler_t) addDisabled));
if(ifail==0) {
printf("Registering action handler addDisabled successful\n");
} else {
printf("Registering action handler addDisabled failed %d\n", ifail);
}
//添加失效状态并传递中间表
( ifail = EPM_register_action_handler("tx_addDisabled", "天信添加失效状态",(EPM_action_handler_t) tx_addDisabled));
if(ifail==0) {
printf("Registering action handler tx_addDisabled successful\n");
} else {
printf("Registering action handler tx_addDisabled failed %d\n", ifail);
}
//给历史物料添加状态,状态可以自定义
( ifail = EPM_register_action_handler("historicalDataAddMark", "历史物料添加状态",(EPM_action_handler_t) historicalDataAddMark));
if(ifail==0) {
printf("Registering action handler historicalDataAddMark successful\n");
} else {
printf("Registering action handler historicalDataAddMark failed %d\n", ifail);
}
//天信erp集成
( ifail = EPM_register_action_handler("tx_erp_bom", "天信erp集成传递BOM",(EPM_action_handler_t) tx_erp_bom));
if(ifail==0) {
printf("Registering action handler tx_erp_bom successful\n");
} else {
printf("Registering action handler tx_erp_bom failed %d\n", ifail);
}
//天信erp集成
( ifail = EPM_register_action_handler("tx_erp", "天信erp集成传递物料",(EPM_action_handler_t) tx_erp));
if(ifail==0) {
printf("Registering action handler tx_erp successful\n");
} else {
printf("Registering action handler tx_erp failed %d\n", ifail);
}
//删除失效状态
( ifail = EPM_register_action_handler("removeDisabled", "添加失效状态",(EPM_action_handler_t) removeDisabled));
if(ifail==0) {
printf("Registering action handler removeDisabled successful\n");
} else {
printf("Registering action handler removeDisabled failed %d\n", ifail);
}
//删除失效状态
( ifail = EPM_register_action_handler("tx_removeDisabled", "天信添加失效状态",(EPM_action_handler_t) tx_removeDisabled));
if(ifail==0) {
printf("Registering action handler tx_removeDisabled successful\n");
} else {
printf("Registering action handler tx_removeDisabled failed %d\n", ifail);
}
//EBOM变更驱动MBOM变更
( ifail = EPM_register_action_handler("jk_upgrade_version", "EBOM变更驱动MBOM变更",(EPM_action_handler_t) jk_upgrade_version));
if(ifail==0) {
printf("Registering action handler jk_upgrade_version successful\n");
} else {
printf("Registering action handler jk_upgrade_version failed %d\n", ifail);
}
// ifail = EPM_register_action_handler("sendMaterialInfomationAddDisabled", "发送失效状态",(EPM_action_handler_t) sendMaterialInfomationAddDisabled);
// if(ifail==0) {
// printf("Registering action handler sendMaterialInfomationAddDisabled successful\n");
// } else {
// printf("Registering action handler sendMaterialInfomationAddDisabled failed %d\n", ifail);
// }
//合众
/*( ifail = EPM_register_action_handler("HZ_attach_assembly", "HZ_attach_assembly",(EPM_action_handler_t) HZ_attach_assembly));
if(ifail==0) {
printf("Registering action handler HZ_attach_assembly successful\n");
} else {
printf("Registering action handler HZ_attach_assembly failed %d\n", ifail);
}
( ifail = EPM_register_rule_handler("HZ_Check_BOM_Condition", "HZ_Check_BOM_Condition",(EPM_rule_handler_t) HZ_Check_BOM_Condition));
if(ifail==0) {
printf("Registering rule handler HZ_Check_BOM_Condition successful\n");
} else {
printf("Registering rule handler HZ_Check_BOM_Condition failed %d\n", ifail);
}
( ifail = EPM_register_action_handler("HZ_Doc_Released", "HZ_Doc_Released",(EPM_action_handler_t) hz_auto_revison_to_folder));
if(ifail==0) {
printf("Registering action handler HZ_Doc_Released successful\n");
} else {
printf("Registering action handler HZ_Doc_Released failed %d\n", ifail);
}
//检查状态
( ifail = EPM_register_rule_handler("HZ-check-related-objects", "HZ-check-related-objects",(EPM_rule_handler_t) hz_status_check));
if(ifail==0) {
printf("Registering action handler HZ-check-related-objects successful\n");
} else {
printf("Registering action handler HZ-check-related-objects failed %d\n", ifail);
}
*/
//ifail = EPM_register_action_handler("QTM2_attach_components","attach components",
// (EPM_action_handler_t)qtm2_attach_components);
//if(ifail == ITK_ok)
//{
// fprintf(stdout,"Registering QTM2_attach_components\n");
//}
return ifail;
}
//
//定义JAVA调用的服务
//register service method
extern DLLAPI int USERSERVICE_custom_register_methods(int *decision, va_list args)
{
int
status = ITK_ok,
numberOfArguments = 0,
returnValueType = USERARG_STRING_TYPE,
*argumentList = NULL;
USER_function_t functionPtr;
//QTM_ebom_to_pbom
//规定java需要传递过来的个数
numberOfArguments = 1;
//需要调用的函数地址函数地址
functionPtr = ORIGIN_set_bypass;
//定义java需要传递的参数
argumentList = (int*)MEM_alloc(numberOfArguments * sizeof(int) );
argumentList[0] = USERARG_STRING_TYPE;
//argumentList[1] = USERARG_DATE_TYPE;
//argumentList[2] = USERARG_STRING_TYPE +USERARG_ARRAY_TYPE;
//argumentList[1] = USERARG_STRING_TYPE + USERARG_ARRAY_TYPE;
//returnValueType = USERARG_STRING_TYPE;
//定义返回值的类型
returnValueType = USERARG_VOID_TYPE;
ITKCALL(status = USERSERVICE_register_method("Connor_set_bypass", functionPtr, numberOfArguments,
argumentList, returnValueType ));
MEM_free(argumentList);
if(status == ITK_ok)
{
fprintf( stdout, "\n Registering Connor_set_bypass finished\n" );
}
else
{
fprintf( stdout, "\n Registering Connor_set_bypass failed %d\n" , status );
}
//===========================================
numberOfArguments = 1;
//需要调用的函数地址函数地址
functionPtr = remove_class;
//定义java需要传递的参数
argumentList = (int*)MEM_alloc(numberOfArguments * sizeof(int) );
argumentList[0] = USERARG_STRING_TYPE;
returnValueType = USERARG_VOID_TYPE;
ITKCALL(status = USERSERVICE_register_method("IcoRemove", functionPtr, numberOfArguments,
argumentList, returnValueType ));
MEM_free(argumentList);
if(status == ITK_ok)
{
fprintf( stdout, "\n Registering ORIGIN_set_bypass finished\n" );
}
else
{
fprintf( stdout, "\n Registering ORIGIN_set_bypass failed %d\n" , status );
}
//===========================================
numberOfArguments = 1;
//需要调用的函数地址函数地址
functionPtr = ORIGIN_set_bypass;
//定义java需要传递的参数
argumentList = (int*)MEM_alloc(numberOfArguments * sizeof(int) );
argumentList[0] = USERARG_STRING_TYPE;
//argumentList[1] = USERARG_DATE_TYPE;
//argumentList[2] = USERARG_STRING_TYPE +USERARG_ARRAY_TYPE;
//argumentList[1] = USERARG_STRING_TYPE + USERARG_ARRAY_TYPE;
//returnValueType = USERARG_STRING_TYPE;
//定义返回值的类型
returnValueType = USERARG_VOID_TYPE;
ITKCALL(status = USERSERVICE_register_method("ORIGIN_set_bypass", functionPtr, numberOfArguments,
argumentList, returnValueType ));
MEM_free(argumentList);
if(status == ITK_ok)
{
fprintf( stdout, "\n Registering ORIGIN_set_bypass finished\n" );
}
else
{
fprintf( stdout, "\n Registering ORIGIN_set_bypass failed %d\n" , status );
}
//===========================================
numberOfArguments = 1;
functionPtr = ORIGIN_close_bypass;
argumentList = (int*)MEM_alloc(numberOfArguments * sizeof(int) );
argumentList[0] = USERARG_STRING_TYPE;
//argumentList[1] = USERARG_STRING_TYPE + USERARG_ARRAY_TYPE;
//returnValueType = USERARG_STRING_TYPE;
returnValueType = USERARG_VOID_TYPE;
ITKCALL(status = USERSERVICE_register_method("Connor_close_bypass", functionPtr, numberOfArguments,
argumentList, returnValueType ));
MEM_free(argumentList);
if(status == ITK_ok)
{
fprintf( stdout, "\n Registering Connor_close_bypass finished\n" );
}
else
{
fprintf( stdout, "\n Registering Connor_close_bypass failed %d\n" , status );
}
//=============================================
numberOfArguments = 1;
functionPtr = ORIGIN_close_bypass;
argumentList = (int*)MEM_alloc(numberOfArguments * sizeof(int) );
argumentList[0] = USERARG_STRING_TYPE;
//argumentList[1] = USERARG_STRING_TYPE + USERARG_ARRAY_TYPE;
//returnValueType = USERARG_STRING_TYPE;
returnValueType = USERARG_VOID_TYPE;
ITKCALL(status = USERSERVICE_register_method("ORIGIN_close_bypass", functionPtr, numberOfArguments,
argumentList, returnValueType ));
MEM_free(argumentList);
if(status == ITK_ok)
{
fprintf( stdout, "\n Registering ORIGIN_close_bypass finished\n" );
}
else
{
fprintf( stdout, "\n Registering ORIGIN_close_bypass failed %d\n" , status );
}
//=================================================================
numberOfArguments = 1;
functionPtr = getDbMsg;
argumentList = (int*)MEM_alloc(numberOfArguments * sizeof(int) );
argumentList[0] = USERARG_STRING_TYPE;
//argumentList[1] = USERARG_STRING_TYPE + USERARG_ARRAY_TYPE;
//returnValueType = USERARG_STRING_TYPE;
returnValueType = USERARG_VOID_TYPE;
ITKCALL(status = USERSERVICE_register_method("HX_GetProjMsg", functionPtr, numberOfArguments,
argumentList, returnValueType ));
MEM_free(argumentList);
if(status == ITK_ok)
{
fprintf( stdout, "\n Registering HX_GetProjMsg finished\n" );
}
else
{
fprintf( stdout, "\n Registering HX_GetProjMsg failed %d\n" , status );
}
//=============================================
numberOfArguments = 2;
functionPtr = connor_set_release_status;
argumentList = (int*)MEM_alloc(numberOfArguments * sizeof(int) );
argumentList[0] =USERARG_TAG_TYPE ;
argumentList[1] =USERARG_STRING_TYPE ;
returnValueType = USERARG_VOID_TYPE;
ITKCALL(status = USERSERVICE_register_method("connor_set_release_status", functionPtr, numberOfArguments,
argumentList, returnValueType ));
MEM_free(argumentList);
if(status == ITK_ok)
{
fprintf( stdout, "\n Registering connor_set_release_status finished\n" );
}
else
{
fprintf( stdout, "\n Registering connor_set_release_status failed %d\n" , status );
}
//=======================
numberOfArguments = 1;
functionPtr = USERSEVICE_TEST;
argumentList = (int*)MEM_alloc(numberOfArguments * sizeof(int) );
argumentList[0] =USERARG_TAG_TYPE ;
returnValueType = USERARG_VOID_TYPE;
ITKCALL(status = USERSERVICE_register_method("SendItem", functionPtr, numberOfArguments,
argumentList, returnValueType ));
MEM_free(argumentList);
if(status == ITK_ok)
{
fprintf( stdout, "\n Registering SendItem finished\n" );
}
else
{
fprintf( stdout, "\n Registering SendItem failed %d\n" , status );
}
//=======================
*decision = ALL_CUSTOMIZATIONS;
METHOD_id_t mth_tag;
//int status = ITK_ok;
/*
{
ITKCALL( METHOD_find_prop_method ( "HX3_GYTRevision", "HX3_MUJT", PROP_set_value_tags_msg, &mth_tag ) );
if ( mth_tag.id != NULLTAG )
{
printf("find HX3_GYTRevision HX3_MUJT \n ");
ITKCALL(status = METHOD_add_action( mth_tag, METHOD_post_action_type,( METHOD_function_t ) HX3_post_prop_set_MJ, NULL ) );
if(status == ITK_ok){
printf("success HX3_MUJT \n ");
}else{
printf("faild HX3_MUJT \n ");
}
}else{
printf("not find HX3_GYTRevision HX3_MUJT \n ");
}
}
{
ITKCALL( METHOD_find_prop_method ( "JK8MaterialRevisionMaster", "jk8SpecModel", PROP_set_value_string_msg, &mth_tag ) );
if ( mth_tag.id != NULLTAG )
{
printf("find HX3_GYTRevision JK8Material \n ");
ITKCALL(status = METHOD_add_action( mth_tag, METHOD_pre_action_type,( METHOD_function_t ) LP_set_prop, NULL ) );
if(status == ITK_ok){
printf("success JK8Material \n ");
}else{
printf("faild JK8Material \n ");
}
}else{
printf("not find JK8Material HX3_JIANJT \n ");
}
}
{
ITKCALL( METHOD_find_prop_method ( "HX3_ZPTRevision", "last_mod_date", PROP_set_value_date_msg, &mth_tag ) );
if ( mth_tag.id != NULLTAG )
{
printf("find HX3_ZPTRevision last_mod_date \n ");
ITKCALL(status = METHOD_add_action( mth_tag, METHOD_post_action_type,( METHOD_function_t ) HX3_mod_date, NULL ) );
if(status == ITK_ok){
printf("success last_mod_date \n ");
}else{
printf("faild last_mod_date \n ");
}
}else{
printf("not find HX3_ZPTRevision last_mod_date \n ");
}
}
*/
return(status);
}
extern DLLAPI int USERSERVICE_custom_register_runtime_methods(int *decision, va_list args)
{
int status = ITK_ok;
METHOD_id_t method;
ITKCALL(status = METHOD_register_prop_method ("JCI6_ProgramInfo", "", PROP_ask_value_string_msg,
(METHOD_function_t) HX3_regist_runtime_prop,0, &method));
if(status != ITK_ok){
printf("进行Runtime属性注册的时候失败\n");
}
if (method.id == 0){
}
return(status);
}

@ -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,117 @@
#include "epm_handler_common.h"
#include "jk_custom_erp.h"
#include <tc/tc.h>
#include <ict/ict_userservice.h>
#include <tccore/custom.h>
#include <epm/epm_toolkit_tc_utils.h>
#include <tccore/aom.h>
#include <tccore/aom_prop.h>
#include <tccore/item.h>
#include <bom/bom.h>
#include "ps/ps.h";
#include "ps/vrule.h"
#include "sstream"
#include <tccore/grm.h>
#include "epm/epm.h"
#include "sa/sa.h"
#include <map>
#include "epm/signoff.h"
#include <ctime>
#include <vector>
#include <locale>
#include <codecvt>
#include "ae/dataset.h"
#include <server_exits/user_server_exits.h>
#include <tccore/custom.h>
#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 <form/form.h>
#include <form/formtype.h>
#include <ics\ics.h>
#include <stdarg.h>
#include <iostream>
# include "common_itk_util.h"
using namespace std;
extern "C" int POM_AM__set_application_bypass(logical bypass);
int historicalDataAddMark(EPM_action_message_t msg)
{
int ifail=ITK_ok;
tag_t task_tag = NULLTAG, rootTask_tag = NULLTAG, *attachments = NULLTAG;
int arg_cnt = 0, att_cnt = 0;
char* object_type ;
char * argflag = NULL ,
*argvalue =NULL ,
*arg = NULL ,
statusMark[1024]="\0";
tag_t release_stat = NULLTAG;
vector<tag_t> attatcgments;
arg_cnt = TC_number_of_arguments(msg.arguments);
ECHO("参数个数为:%d\n",arg_cnt);
if (arg_cnt > 0)
{
for (int i=0;i<arg_cnt;i++)
{
//获取下一个参数从0开始
arg = TC_next_argument(msg.arguments);
//获取参数的名称和值
ifail = ITK_ask_argument_named_value((const char*)arg, &argflag, &argvalue);
//给状态标记设置真实值
if(stricmp(argflag, "addStatus_mark") == 0)
{
if(argvalue != NULL)
{
strcpy(statusMark,argvalue);
}
}
}
MEM_free(argflag);
MEM_free(argvalue);
}
ITKCALL(ifail=RELSTAT_create_release_status(statusMark, &release_stat));//TCM Released jk8Disabled
//获取当前触发的任务
task_tag = msg.task;
//获取根流程节点
ITKCALL(ifail = EPM_ask_root_task(task_tag, &rootTask_tag));
//获取目标引用对象
ITKCALL(ifail = EPM_ask_attachments(rootTask_tag, EPM_target_attachment, &att_cnt, &attachments));
//循环目标对象
cout<<"数量------->"<<att_cnt<<endl;
for (int i = 0; i < att_cnt; i++)
{
//获得该物料下所有版本版本revision_list
ITKCALL(ifail=AOM_ask_value_string(attachments[i],"object_type",&object_type));
if(strcmp("JK8Material",object_type)==0)
{
//TODO 给物料添加状态
POM_AM__set_application_bypass(true);
ITKCALL(ifail=RELSTAT_add_release_status(release_stat, 1, &attachments[i], true));
POM_AM__set_application_bypass(false);
}
}
return ifail;
}

@ -0,0 +1,953 @@
#include "hx_custom.h"
int HX3_create_item_post(METHOD_message_t* msg , va_list va)
{
tag_t current_group_mem_tag =NULLTAG,current_user_tag =NULLTAG;
char userid[SA_user_size_c + 1] = "\0";
ITKCALL(SA_ask_current_groupmember(&current_group_mem_tag));
ITKCALL(SA_ask_groupmember_user(current_group_mem_tag,&current_user_tag));
ITKCALL(SA_ask_user_identifier(current_user_tag,userid));
char file_name[SS_MAXPATHLEN] ="\0";
ITKCALL(SA_ask_user_pfile(userid,file_name));
printf("user_pfile = %s \n",file_name);
//RevisionAnchor
fprintf(stdout,"get into post method ====================== \n");
int ifail = ITK_ok ;
char new_item_rev_name[ITEM_type_size_c+1] = "";
char errorStr[10240] = "\0";
string error_string;
// logical istrue = FALSE;
const char* item_id = va_arg(va,const char*);
const char* item_name = va_arg(va,const char*);
const char* item_type = va_arg(va,const char*);
const char* rev_id = va_arg(va,const char*);
tag_t* item_tag = va_arg(va,tag_t*);
// tag_t* rev_tag = va_arg(va,tag_t*);
char * cd9_codeDesc =NULL;
AOM_ask_value_string(*item_tag,"cd9_codeDesc",&cd9_codeDesc);
printf("\ncd9 code => %s\n",cd9_codeDesc);
if(cd9_codeDesc !=NULL){
MEM_free(cd9_codeDesc);
cd9_codeDesc =NULL;
}
if(*item_tag != NULLTAG && strcmp(item_type,"HX3_XXM")==0){
int count = 0 ,entry_count = 0,status = 0,num_found=0;
char ** values_list = NULL ;//** values = NULL, ** entries = NULL;
tag_t query_tag = NULLTAG ,*results = NULL;
//构建器
ITKCALL(QRY_find("KHDH-TO-XM",&query_tag));
if(query_tag==NULLTAG)
{
printf("没找到 [%s]查询构建器!\n","KHDH-TO-XM" );
return 0;
}
printf("找到 [%s]查询构建器!\n","KHDH-TO-XM" );
ITKCALL(AOM_ask_value_strings(*item_tag,"hx3_khdh",&count,&values_list));
//char other_entrys[1][64] = {"客户代号"};//hx3_khdh 客户代号
//char other_values[1][64] = {""};
for(int i = 0 ;i < count;i++){
char *other_values[1] ;
char *other_entrys[1] ;
other_values[0]= (char*)calloc(48,sizeof(char));
other_entrys[0] = (char*)calloc(48,sizeof(char));
tc_strcpy(other_entrys[0],"客户代号");
tc_strcpy(other_values[0],values_list[i]);
printf("执行查询[%s][%s]\n",other_entrys[0],other_values[0]);
ITKCALL(status = QRY_execute(query_tag,1,other_entrys,other_values,&num_found,&results));
printf("执行查询结果[%d]\n",status);
free(other_values[0]);
free(other_entrys[0]);
//printf("11111111111111\n");
if(status !=ITK_ok){
char * message =NULL;
EMH_ask_error_text(status, &message);
printf("查询异常 : \"%d\",\"%s\"\n",status,message);
MEM_free(message);
message =NULL;
return 0;
}
for(int j =0;j < num_found;j++){
//记录错误信息
char item_id1[ITEM_id_size_c + 1] = "\0";
ITEM_ask_id(results[j],item_id1);
if(strcmp(item_id,item_id1)!=0){
ifail = ITEM_unable_to_create;
//char msg[214] = "\0";
char * object_string =NULL;
AOM_ask_value_string(results[j],"object_string",&object_string);
error_string.append("项目代号[").append(values_list[i]).append("]").append("已经存在于项目[").append(object_string).append("]客户代号中\n");
if(object_string!=NULL){
MEM_free(object_string);
object_string =NULL;
}
}
}
if(results!=NULL){
MEM_free(results);
results =NULL;
}
}
//printf("222222222222\n");
//释放属性
if(values_list!=NULL){
for(int i = 0 ;i < count;i++){
if(values_list[i]!=NULL){
MEM_free(values_list[i]);
values_list[i] = NULL;
}
}
MEM_free(values_list);
values_list =NULL;
}
}
// printf("333333333\n");
//
if(ITEM_unable_to_create == ifail){
// 添加错误信息
EMH_store_error_s1(EMH_severity_user_error,ERROR_QRY_NOT_FOUND,error_string.c_str());
error_string.clear();
}
return ifail;
}
int HX3_post_prop_set_MJ( METHOD_message_t *msg, va_list args )
{
int ifail = ITK_ok ,
count = 0,
form_count = 0;
tag_t prop_tag =NULLTAG,
obj_tag=NULLTAG,
form_tag=NULLTAG,
* values_tags =NULL,
* form_tags =NULL;
//获取属性对象
prop_tag = va_arg( args, tag_t );
//获取个数
count = va_arg( args, int );
//获取值
values_tags = va_arg( args, tag_t* );
printf("set prop \n");
vector<string> vec;
if(prop_tag!=NULLTAG ){
//char * name =NULL;
//获取属性对象
PROP_ask_owning_object(prop_tag,&obj_tag);
//获取版本表单
AOM_ask_value_tags(obj_tag,"IMAN_master_form_rev",&form_count,&form_tags);
if(form_count > 0){
//清空属性
for(int i = 0 ;i < 8;i++){
char mj_propName[16] = "\0";
char mj_propValue[12] = "\0";
//mj_propValue=(char*)malloc(256*sizeof(char));
sprintf(mj_propName,"hx3_mjt%d",(i+1));
ITKCALL(AOM_lock(form_tags[0]));
ITKCALL(AOM_set_value_string(form_tags[0],mj_propName,mj_propValue));
ITKCALL(AOM_save(form_tags[0]));
//free(mj_propValue);
//mj_propValue =NULL;
}
char ** value_list =NULL;
if(count > 0){
//开辟空间
value_list=(char**)malloc(count*sizeof(char*));
for(int i=0;i<count;i++) {
char * object_string =NULL;
value_list[i]=(char*)malloc(256*sizeof(char));
ITKCALL(AOM_ask_value_string(values_tags[i],"object_string",&object_string));
strcpy(value_list[i],object_string);
char mj_propName[16] = "\0";
sprintf(mj_propName,"hx3_mjt%d",(i+1));
ITKCALL(AOM_lock(form_tags[0]));
ITKCALL(AOM_set_value_string(form_tags[0],mj_propName,object_string));
ITKCALL(AOM_save(form_tags[0]));
if(object_string!=NULL){
MEM_free(object_string);
object_string =NULL;
}
}
}
//设置属性
ITKCALL(AOM_lock(form_tags[0]));
ITKCALL(AOM_set_value_strings(form_tags[0],"hx3_mjt",count,value_list));
ITKCALL(AOM_save(form_tags[0]));
AOM_unlock(form_tags[0]);
//请缓存
if(value_list!=NULL){
for(int i=0;i<count;i++){
free(value_list[i]);
value_list[i] =NULL;
}
free(value_list);
value_list =NULL;
}
}
if(form_tags!=NULL){
MEM_free(form_tags);
form_tags =NULL;
}
//ITKCALL(AOM_ask_value_string(obj_tag,"object_string",&name));
}
return ifail;
}
int Test_set_string( METHOD_message_t *msg, va_list args )
{
tag_t prop_tag = va_arg( args, tag_t );
char * prop_value = va_arg( args, char* );
printf("\nMY_CD9 CODE = >%s \n",prop_value);
return 0 ;
}
int LP_set_prop( METHOD_message_t *msg, va_list args )
{
printf("-----------------------------------------\n");
printf("----------属性判断开始-------------------\n");
printf("-----------------------------------------\n");
int ifail = ITK_ok ;
//获取属性对象
tag_t prop_tag = va_arg( args, tag_t );
//获取值
char * values = va_arg( args, char* );
char propContents[1024] = "\0";
if(prop_tag!=NULLTAG ){
char * propname = NULL;
char propOptionName[128] = "\0";
strcpy(propContents,"\0");
int isContents = 0;
//获取属性
PROP_ask_name(prop_tag,&propname);
sprintf(propOptionName,"LP_%s_Option",propname);
printf("首选项名称[%s]\n",propOptionName);
vector<string> pref_vec;
getPrefStrings(propOptionName,TC_preference_site, pref_vec);
strcat(propContents,"属性值:");
strcat(propContents,values);
strcat(propContents,",不包含在下列值中:\n");
for(int i = 0 ;i <pref_vec.size();i++ ){
if(strcmp(pref_vec[i].c_str(),values)==0)
{
isContents = 1;
}
strcat(propContents,pref_vec[i].c_str());
strcat(propContents,"\n");
}
if(isContents){
ifail = ITK_ok;
}else{
ifail = PROP_unable_to_set_cp_value;
}
if(propname!=NULL){
MEM_free(propname);
propname =NULL;
}
}
if(ifail != ITK_ok){
EMH_store_error_s1(EMH_severity_user_error,ifail,propContents);
}
printf("-----------------------------------------\n");
printf("----------------属性判断结束-------------\n");
printf("-----------------------------------------\n");
return ifail;
}
int HX3_post_prop_set_JJ( METHOD_message_t *msg, va_list args )
{
int ifail = ITK_ok ,
count = 0,
form_count = 0;
tag_t prop_tag =NULLTAG,
obj_tag=NULLTAG,
form_tag=NULLTAG,
* values_tags =NULL,
* form_tags =NULL;
//获取属性对象
prop_tag = va_arg( args, tag_t );
//获取个数
count = va_arg( args, int );
//获取值
values_tags = va_arg( args, tag_t* );
printf("set prop \n");
vector<string> vec;
if(prop_tag!=NULLTAG ){
//char * name =NULL;
//获取属性对象
PROP_ask_owning_object(prop_tag,&obj_tag);
//获取版本表单
AOM_ask_value_tags(obj_tag,"IMAN_master_form_rev",&form_count,&form_tags);
if(form_count > 0){
//清空属性
for(int i = 0 ;i < 12;i++){
char mj_propName[16] = "\0";
char mj_propValue[12] = "\0";
//mj_propValue=(char*)malloc(256*sizeof(char));
//strcpy(mj_propValue,"");
sprintf(mj_propName,"hx3_jjt%d",(i+1));
ITKCALL(AOM_lock(form_tags[0]));
ITKCALL(AOM_set_value_string(form_tags[0],mj_propName,mj_propValue));
ITKCALL(AOM_save(form_tags[0]));
//free(mj_propValue);
//mj_propValue =NULL;
}
char ** value_list =NULL;
if(count > 0){
//开辟空间
value_list=(char**)malloc(count*sizeof(char*));
for(int i=0;i<count;i++) {
char * object_string =NULL;
value_list[i]=(char*)malloc(256*sizeof(char));
ITKCALL(AOM_ask_value_string(values_tags[i],"object_string",&object_string));
strcpy(value_list[i],object_string);
char mj_propName[16] = "\0";
sprintf(mj_propName,"hx3_jjt%d",(i+1));
ITKCALL(AOM_lock(form_tags[0]));
ITKCALL(AOM_set_value_string(form_tags[0],mj_propName,object_string));
ITKCALL(AOM_save(form_tags[0]));
if(object_string!=NULL){
MEM_free(object_string);
object_string =NULL;
}
}
}
//设置属性
ITKCALL(AOM_lock(form_tags[0]));
ITKCALL(AOM_set_value_strings(form_tags[0],"hx3_jjt",count,value_list));
ITKCALL(AOM_save(form_tags[0]));
AOM_unlock(form_tags[0]);
//请缓存
if(value_list!=NULL){
for(int i=0;i<count;i++){
free(value_list[i]);
value_list[i] =NULL;
}
free(value_list);
value_list =NULL;
}
}
if(form_tags!=NULL){
MEM_free(form_tags);
form_tags =NULL;
}
//ITKCALL(AOM_ask_value_string(obj_tag,"object_string",&name));
}
return ifail;
}
int HX3_regist_runtime_prop(METHOD_message_t* msg, va_list args){
printf("========================================================\n");
printf("进入Runtime属性\n");
printf("========================================================\n");
double value=0.00;
int ifail = ITK_ok;
tag_t prop_tag = NULL_TAG;
char ** string_value = NULL;
//获取属性对象
prop_tag = va_arg(args,tag_t );
//获取属性值
string_value=va_arg(args, char**);
return ifail;
}
void getAllBomline(tag_t line_tag,vector<tag_t> & line_vec){
int count = 0 , ifail =ITK_ok;
tag_t *lineS = NULL,rev_tag =NULL_TAG;
ITKCALL(ifail = AOM_ask_value_tag(line_tag,"bl_line_object",&rev_tag));
line_vec.push_back(rev_tag);
ITKCALL(ifail = BOM_line_ask_all_child_lines(line_tag,&count,&lineS));
//遍历所有的子
for(int i = 0 ;i < count;i++){
getAllBomline(lineS[i],line_vec);
}
//资源释放
if(lineS!=NULL){
MEM_free(lineS);
lineS =NULL;
}
}
/****************************************
*
* BOM
*
*****************************************/
void getBomClassInfo(vector<CLASS_DEFINE_STRUCT> & class_define_vec){
vector<string> pref_vec;
getPrefStrings("HXsortmapping",TC_preference_site, pref_vec);
for(int i = 0;i < pref_vec.size();i++){
vector<string> vec_1 ;
Split(pref_vec[i],"/",vec_1);
if(vec_1.size() != 2){
continue;
}
vector<string> vec_2;
Split(vec_1[0],"&",vec_2);
if(vec_2.size() != 3){
continue;
}
CLASS_DEFINE_STRUCT class_struct;
class_struct.id.assign(vec_2[0]);
class_struct.class_dis_name.assign(vec_2[1]);
class_struct.class_rel_name.assign(vec_2[2]);
vector<string> vec_3;
Split(vec_1[1],"|",vec_3);
for(int j = 0 ;j < vec_3.size();j++){
vector<string> vec_4;
Split(vec_3[j],":",vec_4);
if(vec_4.size()!=4){
continue;
}
//TODO
ATTR_NODE attr_node;
attr_node.p_attr_id.assign(vec_4[0]);
attr_node.c_class_name.assign(vec_4[1]);
attr_node.c_class_id.assign(vec_4[2]);
attr_node.c_attr_id.assign(vec_4[3]);
//
class_struct.attr_node_vec.push_back(attr_node);
}
class_define_vec.push_back(class_struct);
}
}
/***************************************
*
* id
*
*****************************************/
void getNameIDMapping(map<string,string> & name_id_mapping){
vector<string> pref_vec;
getPrefStrings("HXpartname_IDmapping",TC_preference_site, pref_vec);
for(int i = 0;i < pref_vec.size();i++){
vector<string> name_id;
Split(pref_vec[i],":",name_id);
if(name_id.size()==2){
name_id_mapping.insert(pair<string,string>(name_id[0],name_id[1]));
}
}
}
int HX3_bom_save(METHOD_message_t* msg, va_list args){
printf("\n========================================================\n");
printf("进入保存后操作\n");
printf("========================================================\n");
double value=0.00;
int ifail = ITK_ok;
tag_t window_tag = NULL_TAG,top_line =NULL_TAG,top_rev_tag =NULL_TAG, top_classificationObject = NULL_TAG,top_class_tag=NULL_TAG;
char * top_rev_item_id =NULL ,* top_class_id = NULL,* top_class_name = NULL;
int classNameCount = 0;
vector<tag_t> child_rev_vec ;
vector<CLASS_DEFINE_STRUCT> class_define_vec;
map<string,string> name_id_mapping;
//获取首选项,并解析首选项
getBomClassInfo(class_define_vec);
getNameIDMapping(name_id_mapping);
//获取保存的bomwindow
window_tag = va_arg(args,tag_t );
if(window_tag ==NULL_TAG)
{
return ITK_ok;
}
ITKCALL(ifail = BOM_ask_window_top_line(window_tag,&top_line));
if(top_line == NULL_TAG)
{
return ITK_ok;
}
ITKCALL(ifail = AOM_ask_value_tag(top_line,"bl_line_object",&top_rev_tag));
if(top_rev_tag == NULL_TAG)
{
return ITK_ok;
}
if(!(checkIsTypeOrSubtype(top_rev_tag,"HX3_ZPTRevision") || checkIsTypeOrSubtype(top_rev_tag,"HX3_LJTRevision")))
{
printf("类型不匹配 HX3_ZPTRevision HX3_LJTRevision\n ");
return ITK_ok;
}
//获取ITEM_ID判断是否是以“FD、FC”开头
char id_temp[8] = "\0";
ITKCALL(ifail = AOM_ask_value_string(top_rev_tag,"item_id",&top_rev_item_id));
if(top_rev_item_id!=NULL)
{
sprintf(id_temp,"%c%c",top_rev_item_id[0],top_rev_item_id[1]);
if(!(strcmp(id_temp,"FD")==0 || strcmp(id_temp,"FC")==0))
{
printf("ID 不匹配 FD FC \n ");
MEM_free(top_rev_item_id);
top_rev_item_id =NULL;
return ITK_ok;
}
MEM_free(top_rev_item_id);
top_rev_item_id =NULL;
}
//获取顶层 REVISION 对应的分类
ICS_ask_classification_object(top_rev_tag,&top_classificationObject);
if(top_classificationObject == NULL_TAG)
{
printf("顶层对象没有发送到分类\n");
return 0;
}
ICS_ask_class_of_classification_obj(top_classificationObject,&top_class_tag);
ICS_ask_id_name(top_class_tag,&top_class_id,&top_class_name);
printf("BOM TOP LINE CLASS ID = %s | NAME = %s \n",top_class_id,top_class_name);
//获取所有的子对应的版本
getAllBomline(top_line,child_rev_vec);
//获取分类的名称
for(int j = 0 ;j < class_define_vec.size();j++)
{
if(!(strcmp(id_temp,class_define_vec[j].id.c_str())==0
&& strcmp(class_define_vec[j].class_dis_name.c_str(),top_class_name)==0
&& strcmp(class_define_vec[j].class_rel_name.c_str(),top_class_id)==0))
{
continue;
}
vector<ATTR_NODE> attr_node_vec = class_define_vec[j].attr_node_vec;
//获取遍历版本的分类
for(int w = 1;w < child_rev_vec.size();w++)
{
//
int child_rev_class_names_count = 0,child_attr_count = 0;
char * child_rev_class_name =NULL,*child_rev_class_id =NULL,**child_attr_names =NULL,**child_attr_values =NULL;
tag_t child_classfication_tag = NULL_TAG, child_class_tag = NULL_TAG,*child_attr_list = NULL;
//获取子的分类的信息
ICS_ask_classification_object(child_rev_vec[w],&child_classfication_tag);
if(child_classfication_tag == NULL_TAG)
{
continue;
}
ICS_ask_class_of_classification_obj(child_classfication_tag,&child_class_tag);
ICS_ask_id_name(child_class_tag,&child_rev_class_id,&child_rev_class_name);
//ICS_ask_attributes(child_class_tag,&child_attr_count,&child_attr_list);
ICS_ask_attributes_of_classification_obj(child_classfication_tag,&child_attr_count,&child_attr_names,&child_attr_values);
//对配置循环
for(int w_1 = 0;w_1 < attr_node_vec.size();w_1++)
{
if(!(strcmp(attr_node_vec[w_1].c_class_id.c_str(),child_rev_class_id)==0
&&strcmp(attr_node_vec[w_1].c_class_name.c_str(),child_rev_class_name)==0 ))
{
continue;
}
for(int w_2 = 0 ;w_2 < child_attr_count;w_2++){
printf("attr[%d] name = %s | value =%s \n",w_2,child_attr_names[w_2],child_attr_values[w_2]);
}
}
if(child_attr_names !=NULL)
{
for(int i = 0;i < child_attr_count;i++){
MEM_free(child_attr_names[i]);
child_attr_names[i] =NULL;
}
MEM_free(child_attr_names);
child_attr_names =NULL;
}
if(child_attr_values !=NULL)
{
for(int i = 0;i < child_attr_count;i++){
MEM_free(child_attr_values[i]);
child_attr_values[i] =NULL;
}
MEM_free(child_attr_values);
child_attr_values =NULL;
}
if(child_attr_list == NULL)
{
MEM_free(child_attr_list);
child_attr_list =NULL;
}
if(child_rev_class_id!=NULL)
{
MEM_free(child_rev_class_id);
child_rev_class_id =NULL;
}
if(child_rev_class_name!=NULL)
{
MEM_free(child_rev_class_name);
child_rev_class_name =NULL;
}
}
}
//释放资源
FREE_ALL:
if(top_class_id!=NULL){
MEM_free(top_class_id);
top_class_id =NULL;
}
if(top_class_name!=NULL){
MEM_free(top_class_name);
top_class_name =NULL;
}
printf("========================================================\n");
printf("结束保存后操作\n");
printf("========================================================\n");
return 0;
}
int HX3_mod_date(METHOD_message_t* msg, va_list args){
printf("========================================================\n");
printf("进入HX3_mod_date保存后操作\n");
printf("========================================================\n");
double value=0.00;
int ifail = ITK_ok;
tag_t prop_tag = NULL_TAG;
logical isNew = NULL;
printf("========================================================\n");
printf("结束HX3_mod_date保存后操作\n");
printf("========================================================\n");
return 0;
}
/************************************************
*
*
* -attachement = target reference
* -includeType = ItemRevision,HX3_WLRevision
* -relation = IMAN_master_form_rev,IMAN_specification
* -targetType = ItemRevisionMastreForm,Form
* -properties = hx3_gy,hx3_wl
*
*************************************************/
int HX3_check_prop_is_not_empty(EPM_rule_message_t msg)
{
int ifail = ITK_ok,arg_cnt = 0,i = 0,att_cnt = 0;
tag_t task_tag = NULLTAG ,rootTask_tag = NULLTAG, *attachments =NULL;
char *arg = NULL,*argflag = NULL, *argvalue = NULL,type_class[WSO_object_type_size_c+1] ="\0";
string attachement,includeType,relation,targetType,properties;
vector<string> includeTypeVec,relationVec,targetTypeVec,propertiesVec;
EPM_decision_t decision = EPM_go;
task_tag = msg.task;
if(task_tag == NULLTAG)
{
return EPM_nogo;
}
//获得参数
arg_cnt = TC_number_of_arguments(msg.arguments);
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, "attachement") == 0)
{
if(argvalue != NULL)
{
attachement.assign(argvalue);
}
}
else if(stricmp(argflag, "includeType") == 0)
{
if(argvalue != NULL)
{
includeType.assign(argvalue);
}
}
else if(stricmp(argflag,"relation") == 0)
{
if( argvalue!= NULL)
{
relation.assign(argvalue);
}
}
else if(stricmp(argflag,"targetType") == 0)
{
if( argvalue!= NULL)
{
targetType.assign(argvalue);
}
}
else if(stricmp(argflag,"properties") == 0)
{
if( argvalue!= NULL)
{
properties.assign(argvalue);
}
}
//释放资源
if(argflag != NULL){
MEM_free(argflag);
argflag = NULL;
}
if(argvalue != NULL){
MEM_free(argvalue);
argvalue = NULL;
}
}
ITKCALL(ifail = EPM_ask_root_task(task_tag, &rootTask_tag));
if(strcmp(attachement.c_str(),"target") == 0)
{
ITKCALL(ifail = EPM_ask_attachments(rootTask_tag, EPM_target_attachment, &att_cnt, &attachments));
}else if(strcmp(attachement.c_str(),"reference") == 0)
{
ITKCALL(ifail = EPM_ask_attachments(rootTask_tag, EPM_reference_attachment, &att_cnt, &attachments));
}else{
return EPM_nogo;
}
for( i = 0; i < att_cnt; i++ )
{
//获取对象的类型
/**********************************************
* JK8DerPIdenNOAppForm
* JK8SpecPINOAppForm
* JK8NewPIdenNOAppForm
* JK8NPModINOAppForm
**********************************************/
ITKCALL( WSOM_ask_object_type(attachments[i], type_class));
printf("对象类型:%s \n",type_class);
if(strcmp(type_class,"JK8DerPIdenNOAppForm") ==0
||strcmp(type_class,"JK8SpecPINOAppForm") ==0
||strcmp(type_class,"JK8NewPIdenNOAppForm") ==0
||strcmp(type_class,"JK8NPModINOAppForm") ==0 )
{
}
}
if(attachments!=NULL){
MEM_free(attachments);
attachments = NULL;
}
return decision;
}
int HX3_check_prop_is_not_empty_2(EPM_rule_message_t msg)
{
EPM_decision_t decision = EPM_go;
/*
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, user = 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]="";
tag_t bomWindow = NULLTAG, bom_top_line = NULLTAG, bom_config_rule = NULLTAG;
map<string,int> errMap;
vector<string> status_vec;
//map<string,string> zuhaoMap;
EPM_decision_t decision = EPM_go;
logical debug = true;
ECHO("*************************************************************\n");
ECHO("* HZ_Check_BOM_Condition is comming ! *\n");
ECHO("*************************************************************\n");
task_tag = msg.task;
if(task_tag == NULLTAG)
{
ifail = ITK_ok;
//goto end_handler;
return EPM_nogo;
}
tag_t rootTask = NULLTAG;
status_vec.clear();
status_vec.push_back("working");
status_vec.push_back("H9_M0");
status_vec.push_back("H9_M1");
status_vec.push_back("H9_M2");
status_vec.push_back("H9_P");
status_vec.push_back("H9_M3");
status_vec.push_back("H9_B");
status_vec.push_back("H9_D");
status_vec.push_back("H9_Released");
//获得参数
arg_cnt = TC_number_of_arguments(msg.arguments);
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;
}
}
}
}
if( strlen(arg_status) <2 )
{
string key_id;
key_id.assign("缺少status参数");
errMap.insert(pair<string,int>(key_id,HANDLER_ARGUMENT_ERROR));
return EPM_nogo;
}
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));
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 ) );
CycleBOM(ebom_line,userid,arg_status,status_vec,errMap,debug);
ITKCALL(BOM_close_window(ebom_window));
}
}
}
DOFREE(attachments);
if( debug )
ECHO("DEBUG: errMap.size is %d\n", errMap.size());
if( errMap.size() > 0 )
decision = EPM_nogo;
else
decision = EPM_go;
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());
}
errMap.clear();
ECHO("\n************************************************************\n");
ECHO("* HZ_Check_BOM_Condition is end! *\n");
ECHO("*************************************************************\n");
*/
return decision;
}

@ -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,352 @@
#include"hz_custom.h"
/**
*
*
*
*/
int hz_auto_revison_to_folder(EPM_action_message_t msg)
{
POM_AM__set_application_bypass(true);
int ifail = ITK_ok,att_cnt =0 ,i = 0;
tag_t task_tag = NULL_TAG,rootTask_tag=NULL_TAG,type_tag =NULL_TAG,proj_folder_tag= NULL_TAG;
tag_t * attachments = NULL;
char type_class[TCTYPE_class_name_size_c+1] = "\0";
vector<string> pref_vec;
getPrefStrings("Connor_ProjectFolderUidOption",TC_preference_site, pref_vec);
if(pref_vec.size()>0){
ITK__convert_uid_to_tag(pref_vec[0].c_str(),&proj_folder_tag);
}
if(proj_folder_tag ==NULL){
ifail = 2;
}
task_tag = msg.task;
if(task_tag == NULLTAG)
{
POM_AM__set_application_bypass(false);
return ITK_ok;
}
EPM_ask_root_task(task_tag, &rootTask_tag);
EPM_ask_attachments(rootTask_tag, EPM_target_attachment, &att_cnt, &attachments);
for( i = 0; i < att_cnt; i++ )
{
TCTYPE_ask_object_type(attachments[i], &type_tag);
TCTYPE_ask_class_name(type_tag, type_class);
ECHO("type_class : %s\n",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))
{
char * h9_DocProject =NULL;
char * h9_DocLevel2 = NULL;
char * h9_DocLevel3 = NULL;
char * name = NULL;
int mycount = 0,mycount2 = 0,mycount3 = 0,j =0,k = 0,w = 0;
tag_t *folder_tags = NULL,*folder_tags2 = NULL,*folder_tags3 = NULL;
AOM_UIF_ask_value(attachments[i],"h9_DocProject",&h9_DocProject);
AOM_UIF_ask_value(attachments[i],"h9_DocLevel2",&h9_DocLevel2);
AOM_UIF_ask_value(attachments[i],"h9_DocLevel3",&h9_DocLevel3);
AOM_ask_value_tags(proj_folder_tag,"contents",&mycount,&folder_tags);
for(j = 0;j< mycount;j++){
AOM_ask_value_string(folder_tags[j],"object_name",&name);
if(strcmp(h9_DocProject,name)==0){
if(name!=NULL){
MEM_free(name);
name = NULL;
}
AOM_ask_value_tags(folder_tags[j],"contents",&mycount2,&folder_tags2);
for(k = 0;k < mycount2;k++){
AOM_ask_value_string(folder_tags2[k],"object_name",&name);
if(strcmp(name,h9_DocLevel2)==0){
if(name!=NULL){
MEM_free(name);
name = NULL;
}
AOM_ask_value_tags(folder_tags2[k],"contents",&mycount3,&folder_tags3);
for(w = 0 ;w < mycount3;w++){
AOM_ask_value_string(folder_tags3[w],"object_name",&name);
if(strcmp(name,h9_DocLevel3)==0){
FL_insert(folder_tags3[w],attachments[i],999);
//保存
AOM_save(folder_tags3[w]);
break;
}
if(name!=NULL){
MEM_free(name);
name = NULL;
}
}
break;
}
if(name!=NULL){
MEM_free(name);
name = NULL;
}
}
if(folder_tags2!=NULL){
MEM_free(folder_tags2);
folder_tags2 =NULL;
}
break;
}
if(name!=NULL){
MEM_free(name);
name = NULL;
}
}
if(h9_DocProject!=NULL){
MEM_free(h9_DocProject);
h9_DocProject =NULL;
}
if(h9_DocLevel2!=NULL){
MEM_free(h9_DocLevel2);
h9_DocLevel2 =NULL;
}
if(h9_DocLevel3!=NULL){
MEM_free(h9_DocLevel3);
h9_DocLevel3 =NULL;
}
if(folder_tags!=NULL){
MEM_free(folder_tags);
folder_tags =NULL;
}
if(folder_tags3!=NULL){
MEM_free(folder_tags3);
folder_tags3 =NULL;
}
}
}
if(attachments!=NULL){
MEM_free(attachments);
attachments =NULL;
}
if(ifail == ITK_ok){
EMH_clear_errors();
}
POM_AM__set_application_bypass(false);
return 0;
}
/**
*
*
*/
int hz_status_check(EPM_rule_message_t msg)
{
EPM_decision_t decision = EPM_go;
int ifail = ITK_ok,att_cnt =0 ,i = 0,j = 0,arg_cnt = 0;
tag_t task_tag = NULL_TAG,rootTask_tag=NULL_TAG,type_tag =NULL_TAG,proj_folder_tag= NULL_TAG,relation_type;
tag_t * attachments = NULL;
char type_class[TCTYPE_class_name_size_c+1] = "\0";
char * argflag = NULL,*argvalue =NULL,*arg = NULL;
char arg1value[1024] = "",arg2value[1024] = "",arg3value[1024]="",arg4value[1024]="";
vector<string> include_type_v;
vector<string> secondary_type_v;
vector<string> allowed_status_v;
map<string,int> errMap;
map<string,int>::iterator err_it;
arg_cnt = TC_number_of_arguments(msg.arguments);
ECHO("参数个数为:%d\n",arg_cnt);
if (arg_cnt > 0)
{
for (i=0;i<arg_cnt;i++)
{
//获取下一个参数从0开始
arg = TC_next_argument(msg.arguments);
//获取参数的名称和值
ifail = ITK_ask_argument_named_value((const char*)arg, &argflag, &argvalue);
//检查对象类型
if (stricmp(argflag, "include_type") == 0)
{
if(argvalue != NULL)
{
strcpy(arg1value,argvalue);
}else{
string key_id;
key_id.assign("缺少include_type参数");
errMap.insert(pair<string,int>(key_id,HANDLER_ARGUMENT_ERROR));
}
}
//检查次附件对象类型
else if(stricmp(argflag, "secondary_type") == 0)
{
if(argvalue != NULL)
{
strcpy(arg2value,argvalue);
}
else{
string key_id;
key_id.assign("缺少secondary_type参数");
errMap.insert(pair<string,int>(key_id,HANDLER_ARGUMENT_ERROR));
}
}
//伪文件夹的名称
else if(stricmp(argflag,"relation") == 0)
{
if(argvalue != NULL)
{
strcpy(arg3value,argvalue);
}else{
string key_id;
key_id.assign("缺少relation参数");
errMap.insert(pair<string,int>(key_id,HANDLER_ARGUMENT_ERROR));
}
}
//检查满足条件的状态
else if(stricmp(argflag,"allowed_status") == 0)
{
if(argvalue != NULL)
{
strcpy(arg4value,argvalue);
}else{
string key_id;
key_id.assign("缺少allowed_status参数");
errMap.insert(pair<string,int>(key_id,HANDLER_ARGUMENT_ERROR));
}
}
}
MEM_free(argflag);
MEM_free(argvalue);
}
if(errMap.size() !=0){
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());
}
errMap.clear();
return EPM_nogo;
}
ECHO("include_type : %s\n",arg1value);
ECHO("secondary_type : %s\n",arg2value);
ECHO("relation : %s\n",arg3value);
ECHO("allowed_status : %s \n",arg4value);
Split(arg1value,",",include_type_v);
Split(arg2value,",",secondary_type_v);
Split(arg4value,",",allowed_status_v);
task_tag = msg.task;
if(task_tag == NULLTAG)
{
return EPM_nogo;
}
EPM_ask_root_task(task_tag, &rootTask_tag);
EPM_ask_attachments(rootTask_tag, EPM_target_attachment, &att_cnt, &attachments);
for( i = 0; i < att_cnt; i++ )
{
TCTYPE_ask_object_type(attachments[i], &type_tag);
TCTYPE_ask_class_name(type_tag, type_class);
ECHO("include_type : %s\n",type_class);
//判断类型是否属于配置的类型
if(isInVec(type_class,include_type_v)){
GRM_find_relation_type(arg3value, &relation_type);
int second_tags_count = 0 ;
tag_t * second_tags =NULL;
GRM_list_secondary_objects_only(attachments[i],relation_type,&second_tags_count,&second_tags);
for(j = 0;j < second_tags_count;j++){
TCTYPE_ask_object_type(second_tags[j], &type_tag);
TCTYPE_ask_class_name(type_tag, type_class);
ECHO("secondary_type : %s\n",type_class);
//判断是否属于子类型
if(isInVec(type_class,secondary_type_v)){
int status_count = 0;
tag_t * status_tag_list = NULL;;
WSOM_ask_release_status_list(second_tags[j],&status_count,&status_tag_list);
char status_type[WSO_name_size_c+1] = "";
char * object_string =NULL;
AOM_ask_value_string(second_tags[j],"object_string",&object_string);
if(status_count == 0){
string errMsg;
errMsg.assign(object_string).append("不满足发布状态!");
errMap.insert(pair<string,int>(errMsg,HANDLER_ARGUMENT_ERROR));
decision = EPM_nogo;
}
for(int w = 0; w < status_count ;w++){
ITKCALL(CR_ask_release_status_type(status_tag_list[w],status_type));
if(!isInVec(status_type,allowed_status_v)){
//char * object_string =NULL;
//AOM_ask_value_string(second_tags[j],"object_string",&object_string);
string errMsg;
errMsg.assign(object_string).append("不满足发布状态!");
errMap.insert(pair<string,int>(errMsg,HANDLER_ARGUMENT_ERROR));
decision = EPM_nogo;
//if(object_string!=NULL){
// MEM_free(object_string);
// object_string =NULL;
//}
}
}
if(object_string!=NULL){
MEM_free(object_string);
object_string =NULL;
}
if(status_tag_list!=NULL){
MEM_free(status_tag_list);
status_tag_list =NULL;
}
}
}
if(second_tags!=NULL){
MEM_free(second_tags);
second_tags = NULL;
}
}
}
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());
}
errMap.clear();
return decision;
}
logical isInVec(char *type, vector<string> &type_vec)
{
int i = 0;
logical isInclude = false;
for( i = 0; i < type_vec.size(); i++ )
{
if( type_vec[i].compare(type) ==0 )
{
isInclude = true;
break;
}
}
return isInclude;
}

@ -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,291 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Itanium">
<Configuration>Debug</Configuration>
<Platform>Itanium</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Itanium">
<Configuration>Release</Configuration>
<Platform>Itanium</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{AEABC483-FCBD-45F5-9884-8FA4C5A9892D}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>jf_itk</RootNamespace>
<ProjectName>JK_itk</ProjectName>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Itanium'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
<UseOfMfc>Static</UseOfMfc>
<PlatformToolset>v110</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Itanium'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
<UseOfMfc>Static</UseOfMfc>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Itanium'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Itanium'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>true</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LinkIncremental>true</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Itanium'">
<LinkIncremental>true</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LinkIncremental>false</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Itanium'">
<LinkIncremental>false</LinkIncremental>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Itanium'">
<ClCompile>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>
</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>
</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;IPLIB=none;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>C:\TEAMCENTER\tc\include;C:\TEAMCENTER\Oracle\product\11.2.0\dbhome_1\OCI\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<OutputFile>$(OutDir)JK_itk.dll</OutputFile>
<AdditionalDependencies>C:\TEAMCENTER\tc\lib\*.lib;%(AdditionalDependencies)</AdditionalDependencies>
<IgnoreSpecificDefaultLibraries>libuser_exits.ar.lib</IgnoreSpecificDefaultLibraries>
<AdditionalLibraryDirectories>C:\TEAMCENTER\Oracle\product\11.2.0\dbhome_1\OCI\lib\MSVC</AdditionalLibraryDirectories>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Itanium'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>
</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;IPLIB=none;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>F:\Teamcenter10.1.0Env\tcbin\include;F:\Teamcenter10.1.0Env\OCI\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<OutputFile>$(OutDir)libjf.dll</OutputFile>
<AdditionalDependencies>F:\Teamcenter10.1.0Env\tcbin\lib\*.lib;%(AdditionalDependencies)</AdditionalDependencies>
<IgnoreSpecificDefaultLibraries>libuser_exits.ar.lib</IgnoreSpecificDefaultLibraries>
<AdditionalLibraryDirectories>D:\Work\CONNOR\继峰\CODE\OCI\lib\MSVC;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="addDisabled.cpp" />
<ClCompile Include="BOMDiscontinuation.cpp" />
<ClCompile Include="common_itk_util.c" />
<ClCompile Include="connor_util.cpp" />
<ClCompile Include="epm_attach_objects.cxx" />
<ClCompile Include="epm_check_status.cxx" />
<ClCompile Include="epm_register_handler.cpp" />
<ClCompile Include="epm_signoff_dataset.cxx" />
<ClCompile Include="epm_sign_rev.cxx" />
<ClCompile Include="erp_send_items.cxx" />
<ClCompile Include="erp_utils.cxx" />
<ClCompile Include="historicalDataAddMark.cpp" />
<ClCompile Include="hx_custom.cpp" />
<ClCompile Include="hz_custom.cpp" />
<ClCompile Include="jk_add_actual.cpp" />
<ClCompile Include="jk_add_attatchments.cpp" />
<ClCompile Include="jk_AutoSign.cpp" />
<ClCompile Include="jk_auto_create_process.cpp" />
<ClCompile Include="jk_check_virtual.cpp" />
<ClCompile Include="JK_check_workflow.cpp" />
<ClCompile Include="jk_custom.cpp" />
<ClCompile Include="jk_custom_erp.cpp" />
<ClCompile Include="jk_decide_time.cpp" />
<ClCompile Include="jk_exportExcel.cpp" />
<ClCompile Include="jk_remove_allStatus.cpp" />
<ClCompile Include="jk_test_ask_icoAttribute.cpp" />
<ClCompile Include="jk_upgrade_version.cpp" />
<ClCompile Include="jk_upgrade_version2.cpp" />
<ClCompile Include="jk_water_summary.cpp" />
<ClCompile Include="libjf_custom_main.cpp" />
<ClCompile Include="MaterialDiscontinuation.cpp" />
<ClCompile Include="MaterialOpening.cpp" />
<ClCompile Include="ocilib.cxx" />
<ClCompile Include="removeDisabled.cpp" />
<ClCompile Include="sendMaterialInfomationAddDisabled.cpp" />
<ClCompile Include="string_helper.cpp" />
<ClCompile Include="string_utils.cxx" />
<ClCompile Include="tc_log.cxx" />
<ClCompile Include="tx_addDisabled.cpp" />
<ClCompile Include="tx_autoSign.cpp" />
<ClCompile Include="tx_checkMaterialDisabled.cpp" />
<ClCompile Include="tx_checkMaterialReleased.cpp" />
<ClCompile Include="tx_erp_bom.cpp" />
<ClCompile Include="tx_removeDisabled.cpp" />
<ClCompile Include="tx_sign_ir_master.cpp" />
<ClCompile Include="w2_Clear_Form_PropValue.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="common_itk_util.h" />
<ClInclude Include="connor_util.h" />
<ClInclude Include="epm_handler_common.h" />
<ClInclude Include="epm_register_handler.h" />
<ClInclude Include="epm_sign_rev.h" />
<ClInclude Include="erp_send_item.h" />
<ClInclude Include="erp_utils.h" />
<ClInclude Include="error_handling.h" />
<ClInclude Include="hx_custom.h" />
<ClInclude Include="hz_custom.h" />
<ClInclude Include="jk_custom.h" />
<ClInclude Include="jk_custom_erp.h" />
<ClInclude Include="jk_custom_erp_struct.h" />
<ClInclude Include="jk_custom_erp_struct1.h" />
<ClInclude Include="ocilib.h" />
<ClInclude Include="string_helper.h" />
<ClInclude Include="string_utils.h" />
<ClInclude Include="tc_log.h" />
<ClInclude Include="tx_erp_bom.h" />
<ClInclude Include="w2_Clear_Form_PropValue.h" />
</ItemGroup>
<ItemGroup>
<None Include="JFOM_CHANGE.txt" />
</ItemGroup>
<ItemGroup>
<Text Include="Text.txt" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

@ -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…
Cancel
Save