first commit

main
ChenZichaoczc 2 weeks ago
commit d9a8669135

@ -0,0 +1,63 @@
###############################################################################
# Set default behavior to automatically normalize line endings.
###############################################################################
* text=auto
###############################################################################
# Set default behavior for command prompt diff.
#
# This is need for earlier builds of msysgit that does not have it on by
# default for csharp files.
# Note: This is only used by command line
###############################################################################
#*.cs diff=csharp
###############################################################################
# Set the merge driver for project and solution files
#
# Merging from the command prompt will add diff markers to the files if there
# are conflicts (Merging from VS is not affected by the settings below, in VS
# the diff markers are never inserted). Diff markers may cause the following
# file extensions to fail to load in VS. An alternative would be to treat
# these files as binary and thus will always conflict and require user
# intervention with every merge. To do so, just uncomment the entries below
###############################################################################
#*.sln merge=binary
#*.csproj merge=binary
#*.vbproj merge=binary
#*.vcxproj merge=binary
#*.vcproj merge=binary
#*.dbproj merge=binary
#*.fsproj merge=binary
#*.lsproj merge=binary
#*.wixproj merge=binary
#*.modelproj merge=binary
#*.sqlproj merge=binary
#*.wwaproj merge=binary
###############################################################################
# behavior for image files
#
# image files are treated as binary by default.
###############################################################################
#*.jpg binary
#*.png binary
#*.gif binary
###############################################################################
# diff behavior for common document formats
#
# Convert binary document formats to text before diffing them. This feature
# is only available from the command line. Turn it on by uncommenting the
# entries below.
###############################################################################
#*.doc diff=astextplain
#*.DOC diff=astextplain
#*.docx diff=astextplain
#*.DOCX diff=astextplain
#*.dot diff=astextplain
#*.DOT diff=astextplain
#*.pdf diff=astextplain
#*.PDF diff=astextplain
#*.rtf diff=astextplain
#*.RTF diff=astextplain

@ -0,0 +1,340 @@
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.
##
## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
# User-specific files
*.rsuser
*.suo
*.user
*.userosscache
*.sln.docstates
# User-specific files (MonoDevelop/Xamarin Studio)
*.userprefs
# Build results
[Dd]ebug/
[Dd]ebugPublic/
[Rr]elease/
[Rr]eleases/
x64/
x86/
[Aa][Rr][Mm]/
[Aa][Rr][Mm]64/
bld/
[Bb]in/
[Oo]bj/
[Ll]og/
# Visual Studio 2015/2017 cache/options directory
.vs/
# Uncomment if you have tasks that create the project's static files in wwwroot
#wwwroot/
# Visual Studio 2017 auto generated files
Generated\ Files/
# MSTest test Results
[Tt]est[Rr]esult*/
[Bb]uild[Ll]og.*
# NUNIT
*.VisualState.xml
TestResult.xml
# Build Results of an ATL Project
[Dd]ebugPS/
[Rr]eleasePS/
dlldata.c
# Benchmark Results
BenchmarkDotNet.Artifacts/
# .NET Core
project.lock.json
project.fragment.lock.json
artifacts/
# StyleCop
StyleCopReport.xml
# Files built by Visual Studio
*_i.c
*_p.c
*_h.h
*.ilk
*.meta
*.obj
*.iobj
*.pch
*.pdb
*.ipdb
*.pgc
*.pgd
*.rsp
*.sbr
*.tlb
*.tli
*.tlh
*.tmp
*.tmp_proj
*_wpftmp.csproj
*.log
*.vspscc
*.vssscc
.builds
*.pidb
*.svclog
*.scc
# Chutzpah Test files
_Chutzpah*
# Visual C++ cache files
ipch/
*.aps
*.ncb
*.opendb
*.opensdf
*.sdf
*.cachefile
*.VC.db
*.VC.VC.opendb
# Visual Studio profiler
*.psess
*.vsp
*.vspx
*.sap
# Visual Studio Trace Files
*.e2e
# TFS 2012 Local Workspace
$tf/
# Guidance Automation Toolkit
*.gpState
# ReSharper is a .NET coding add-in
_ReSharper*/
*.[Rr]e[Ss]harper
*.DotSettings.user
# JustCode is a .NET coding add-in
.JustCode
# TeamCity is a build add-in
_TeamCity*
# DotCover is a Code Coverage Tool
*.dotCover
# AxoCover is a Code Coverage Tool
.axoCover/*
!.axoCover/settings.json
# Visual Studio code coverage results
*.coverage
*.coveragexml
# NCrunch
_NCrunch_*
.*crunch*.local.xml
nCrunchTemp_*
# MightyMoose
*.mm.*
AutoTest.Net/
# Web workbench (sass)
.sass-cache/
# Installshield output folder
[Ee]xpress/
# DocProject is a documentation generator add-in
DocProject/buildhelp/
DocProject/Help/*.HxT
DocProject/Help/*.HxC
DocProject/Help/*.hhc
DocProject/Help/*.hhk
DocProject/Help/*.hhp
DocProject/Help/Html2
DocProject/Help/html
# Click-Once directory
publish/
# Publish Web Output
*.[Pp]ublish.xml
*.azurePubxml
# Note: Comment the next line if you want to checkin your web deploy settings,
# but database connection strings (with potential passwords) will be unencrypted
*.pubxml
*.publishproj
# Microsoft Azure Web App publish settings. Comment the next line if you want to
# checkin your Azure Web App publish settings, but sensitive information contained
# in these scripts will be unencrypted
PublishScripts/
# NuGet Packages
*.nupkg
# The packages folder can be ignored because of Package Restore
**/[Pp]ackages/*
# except build/, which is used as an MSBuild target.
!**/[Pp]ackages/build/
# Uncomment if necessary however generally it will be regenerated when needed
#!**/[Pp]ackages/repositories.config
# NuGet v3's project.json files produces more ignorable files
*.nuget.props
*.nuget.targets
# Microsoft Azure Build Output
csx/
*.build.csdef
# Microsoft Azure Emulator
ecf/
rcf/
# Windows Store app package directories and files
AppPackages/
BundleArtifacts/
Package.StoreAssociation.xml
_pkginfo.txt
*.appx
# Visual Studio cache files
# files ending in .cache can be ignored
*.[Cc]ache
# but keep track of directories ending in .cache
!?*.[Cc]ache/
# Others
ClientBin/
~$*
*~
*.dbmdl
*.dbproj.schemaview
*.jfm
*.pfx
*.publishsettings
orleans.codegen.cs
# Including strong name files can present a security risk
# (https://github.com/github/gitignore/pull/2483#issue-259490424)
#*.snk
# Since there are multiple workflows, uncomment next line to ignore bower_components
# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
#bower_components/
# RIA/Silverlight projects
Generated_Code/
# Backup & report files from converting an old project file
# to a newer Visual Studio version. Backup files are not needed,
# because we have git ;-)
_UpgradeReport_Files/
Backup*/
UpgradeLog*.XML
UpgradeLog*.htm
ServiceFabricBackup/
*.rptproj.bak
# SQL Server files
*.mdf
*.ldf
*.ndf
# Business Intelligence projects
*.rdl.data
*.bim.layout
*.bim_*.settings
*.rptproj.rsuser
*- Backup*.rdl
# Microsoft Fakes
FakesAssemblies/
# GhostDoc plugin setting file
*.GhostDoc.xml
# Node.js Tools for Visual Studio
.ntvs_analysis.dat
node_modules/
# Visual Studio 6 build log
*.plg
# Visual Studio 6 workspace options file
*.opt
# Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
*.vbw
# Visual Studio LightSwitch build output
**/*.HTMLClient/GeneratedArtifacts
**/*.DesktopClient/GeneratedArtifacts
**/*.DesktopClient/ModelManifest.xml
**/*.Server/GeneratedArtifacts
**/*.Server/ModelManifest.xml
_Pvt_Extensions
# Paket dependency manager
.paket/paket.exe
paket-files/
# FAKE - F# Make
.fake/
# JetBrains Rider
.idea/
*.sln.iml
# CodeRush personal settings
.cr/personal
# Python Tools for Visual Studio (PTVS)
__pycache__/
*.pyc
# Cake - Uncomment if you are using it
# tools/**
# !tools/packages.config
# Tabs Studio
*.tss
# Telerik's JustMock configuration file
*.jmconfig
# BizTalk build output
*.btp.cs
*.btm.cs
*.odx.cs
*.xsd.cs
# OpenCover UI analysis results
OpenCover/
# Azure Stream Analytics local run output
ASALocalRun/
# MSBuild Binary and Structured Log
*.binlog
# NVidia Nsight GPU debugger configuration file
*.nvuser
# MFractors (Xamarin productivity tool) working folder
.mfractor/
# Local History for Visual Studio
.localhistory/
# BeatPulse healthcheck temp database
healthchecksdb

@ -0,0 +1,163 @@
// Connor_NX.cpp : 此文件包含 "main" 函数。程序执行将在此处开始并结束。
//
#include "Connor_NX.h"
#ifdef __cplusplus
extern "C" {
#endif
/**
* @fn extern "C" DLLAPI int liborigin_register_callbacks
* @return usually return ITK_ok
* @brief liborigin customization entry
* dll"_"
*/
DLLAPI int connor_nx_itk_register_callbacks()
{
int ifail = ITK_ok;
ITKCALL(ifail = CUSTOM_register_exit("connor_nx_itk", "USER_invoke_pdm_server", (CUSTOM_EXIT_ftn_t)K_invoke_pdm_server));
fprintf(stdout, "connor_nx_itk register USER_invoke_pdm_server complete\n");
ITKCALL( ifail = CUSTOM_register_exit( "connor_nx_itk", "USERSERVICE_register_methods",
(CUSTOM_EXIT_ftn_t)USERSERVICE_custom_register_methods) );
fprintf( stdout, "connor_nx_itk register USERSERVICE_custom_register_methods complete\n" );
ITKCALL(ifail = CUSTOM_register_exit("connor_nx_itk", "USER_gs_shell_init_module",
(CUSTOM_EXIT_ftn_t)USERSERVICE_custom_register_handlers));
fprintf(stdout, "connor_nx_itk register USER_gs_shell_init_module complete\n");
return ifail;
}
DLLAPI int USERSERVICE_custom_register_handlers(int* decision, va_list args)
{
int ifail = ITK_ok;
//CONNOR_Check_IP_Classification
ITKCALL(ifail = EPM_register_action_handler("QF_signoff_rev", "QF_signoff_rev", (EPM_action_handler_t)CONNOR_SIGN_MASTER));
if (ifail == 0) {
printf("注册操作处理程序成功QF_signoff_rev\n");
}
else {
printf("注册操作处理程序失败[%d]QF_signoff_rev\n", ifail);
}
ITKCALL(ifail = EPM_register_action_handler("QF_signoff_prt", "QF_signoff_prt", (EPM_action_handler_t)CONNOR_SIGN_DATASET));
if (ifail == 0) {
printf("注册操作处理程序成功QF_signoff_prt\n");
}
else {
printf("注册操作处理程序失败[%d]QF_signoff_prt\n", ifail);
}
return ifail;
}
int Connor_open_bypass(void* returnValue)
{
POM_AM__set_application_bypass(true);
return 0;
}
int Connor_close_bypass(void* returnValue)
{
POM_AM__set_application_bypass(false);
return 0;
}
int Get_New_AutoCode_ID(void* returnValue)
{
int ifail = ITK_ok;
char* old_id, * suffix;
tag_t type_tag;
ITKCALL(ifail = USERARG_get_tag_argument(&type_tag));
ITKCALL(ifail = USERARG_get_string_argument(&old_id));
ITKCALL(ifail = USERARG_get_string_argument(&suffix));
string new_id;
ifail = Get_New_ID(type_tag, old_id, suffix, new_id);
if (ifail == ITK_ok) {
char* returnData;
returnData = (char*)MEM_alloc((ITEM_id_size_c + 1) * sizeof(char));
tc_strcpy(returnData, new_id.c_str());
*((char**)returnValue) = returnData;
MEM_free(old_id);
}
return ifail;
}
DLLAPI int USERSERVICE_custom_register_methods()
{
int
status = ITK_ok,
numberOfArguments = 0,
returnValueType = USERARG_STRING_TYPE,
* argumentList = NULL;
USER_function_t functionPtr;
{
numberOfArguments = 1;
functionPtr = Connor_open_bypass;
argumentList = (int*)MEM_alloc(numberOfArguments * sizeof(int));
argumentList[0] = USERARG_STRING_TYPE;
returnValueType = USERARG_VOID_TYPE;
char* mth_name = (char*)malloc(1 + sizeof(char) * strlen("CONNOR_open_bypass"));
tc_strcpy(mth_name, "CONNOR_open_bypass");
ITKCALL(status = USERSERVICE_register_method(mth_name, functionPtr, numberOfArguments,
argumentList, returnValueType));
MEM_free(argumentList);
if (status == ITK_ok)
{
printf("Method: %s\n", mth_name);
}
else
{
printf("Method register failed [%d]: %s\n", status, mth_name);
}
}
{
numberOfArguments = 1;
functionPtr = Connor_close_bypass;
argumentList = (int*)MEM_alloc(numberOfArguments * sizeof(int));
argumentList[0] = USERARG_STRING_TYPE;
returnValueType = USERARG_VOID_TYPE;
char* mth_name = (char*)malloc(1 + sizeof(char) * strlen("CONNOR_close_bypass"));
tc_strcpy(mth_name, "CONNOR_close_bypass");
ITKCALL(status = USERSERVICE_register_method(mth_name, functionPtr, numberOfArguments,
argumentList, returnValueType));
MEM_free(argumentList);
if (status == ITK_ok)
{
printf("Method: %s\n", mth_name);
}
else
{
printf("Method register failed [%d]: %s\n", status, mth_name);
}
}
{
numberOfArguments = 3;
functionPtr = Get_New_AutoCode_ID;
argumentList = (int*)MEM_alloc(numberOfArguments * sizeof(int));
argumentList[0] = USERARG_TAG_TYPE;
argumentList[1] = USERARG_STRING_TYPE;
argumentList[2] = USERARG_STRING_TYPE;
returnValueType = USERARG_STRING_TYPE;
char* mth_name = (char*)malloc(1 + sizeof(char) * strlen("Get_New_AutoCode_ID"));
tc_strcpy(mth_name, "Get_New_AutoCode_ID");
ITKCALL(status = USERSERVICE_register_method(mth_name, functionPtr, numberOfArguments,
argumentList, returnValueType));
MEM_free(argumentList);
if (status == ITK_ok)
{
printf("Method: %s\n", mth_name);
}
else
{
printf("Method register failed [%d]: %s\n", status, mth_name);
}
}
return ITK_ok;
}
#ifdef __cplusplus
}
#endif

@ -0,0 +1,78 @@
#include <stdarg.h>
#include <tccore/custom.h>
#include <server_exits/user_server_exits.h>
#include "kutil.h"
#include <list>
#ifdef __cplusplus
extern "C" {
#endif
typedef list<tag_t> RetData;
typedef list<tag_t>::iterator RetDataIterator;
typedef map<string, string> SearchCriterionInputs;
DLLAPI int USERSERVICE_custom_register_methods();
DLLAPI int K_invoke_pdm_server(int *decision, va_list args);
DLLAPI int USERSERVICE_custom_register_handlers(int* decision, va_list args);
int Get_New_ID(tag_t item_type_tag, string old_id, string suffix, string& new_item_id);
int CONNOR_SIGN_MASTER(EPM_action_message_t msg);
int CONNOR_SIGN_DATASET(EPM_action_message_t msg);
//int check_form_attribute(EPM_action_message_t msg);
//int check_owner(EPM_rule_message_t msg);
//int check_release(EPM_rule_message_t msg);
void map_insert(map < string, string >* strmap, string index, string x);
void init_search_criteria_map(string searchStr, SearchCriterionInputs& searchCriteria);
void init_search_criteria_vector(string searchStr, vector<string>& propNames, vector<string>& propValues);
int Parse_NX_Template_By_ID(const std::string& itemID, std::string& res);
int Read_NX_Image_By_ID(const std::string& itemID, std::string& res);
int Download_Dataset_By_UID(const std::string& itemID, std::string& res);
int Get_All_SubTypes(const std::string& typeName, std::string& res);
int SEARCH_AUTOCODE_NODE(const std::string& typeName, std::string& res);
int Get_Uid(const std::string& name, std::string& res);
int SEARCH_AUTOCODE_SEGMENT(const std::string& searchStr, std::string& res);
int SEARCH_AUTOCODE_USER(const std::string& searchStr, std::string& res);
int GET_TREE_AND_LIST_STRING_VALUE(const std::string& searchStr, std::string& res);
int GET_NEW_REV_ID(const std::string& typeNameStr, std::string& res);
int GET_LOGICAL_PROP_VALUE(const std::string& str, std::string& res);
int SEARCH_TREE_OR_LIST_NODE(const std::string& searchStr, std::string& res);
int GET_TREE_AND_LIST_STRING_VALUES(const std::string& searchStr, std::string& res);
int SEARCH_PARENT_TREE_OR_LIST_NODE(const std::string& searchStr, std::string& res);
int ICS_GET_ATTRIBUTES(const std::string& str, std::string& res);
int ICS_ATTR_IS_REFERENCE_ATTRIBUTE(const std::string& str, std::string& res);
int ICS_ATTR_ASK_PROPERTY(const std::string& str, std::string& res);
int ICS_ATTR_ASK_KEYLOV(const std::string& str, std::string& res);
int GET_DISPLAY_PROP_VALUE(const std::string& str, std::string& res);
int FIND_LOV_BY_NAME(const std::string& str, std::string& res);
int GET_REFERENCE_PROP_VALUE(const std::string& str, std::string& res);
int QUERY_PART_NO(const std::string& str, std::string& res);
int DELETE_RECYCLE_ID(const std::string& str, std::string& res);
int ITEM_EXIST(const std::string& str, std::string& res);
int ITEM_CREATE(const std::string& str, std::string& res);
int ADD_TO_NEWSTUFF(const std::string& uid, std::string& res);
int GET_CLASSIFICATION_ID(const std::string& uid, std::string& res);
int SEND_ITEM_TO_CLASSIFICATION(const std::string& str, std::string& res);
int GET_ITEMTYPE_BY_ID(const std::string& item_id, std::string& res);
int GET_REVUID_BY_ID(const std::string& item_id, std::string& res);
int ITEM_UPDATE(const std::string& str, std::string& res);
int READ_NX_TEMPLATE_BOM(const std::string& itemID, std::string& res);
int GET_CLONE_INFO(const std::string& uid, std::string& res);
int GET_LATEST_ITEM_REVISION(const std::string& str, std::string& res);
int GRANT_PRIVILEGE(const std::string& str, std::string& res);
int GET_UOM_TAGS(const std::string& str, std::string& res);
int UPDATE_UOM(const std::string& str, std::string& res);
int GET_REFERENCE_PROP_VALUE_ARRAY(const std::string& str, std::string& res);
int ICS_ATTR_ASK_METRIC_UNIT(const std::string& str, std::string& res);
#define debug true
#define OUTPUT_CODE_ERROR -1
#define SPLITTER "&;&"
#define SPLIT_SECTION "&SECTION&"
#define SPLIT_PROP_STR "&PROP&"
#define SPLIT_PROP_NAME_VALUE "&=&"
#ifdef __cplusplus
}
#endif

@ -0,0 +1,183 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<ItemGroup>
<ClCompile Include="Connor_NX.cpp" />
<ClCompile Include="connor_sign_dataset.cpp" />
<ClCompile Include="connor_sign_master.cpp" />
<ClCompile Include="Download_Dataset_By_UID.cpp" />
<ClCompile Include="GET_ALL_SUB_TYPES.cpp" />
<ClCompile Include="Get_Uid.cpp" />
<ClCompile Include="kutil.cpp" />
<ClCompile Include="K_autocode_util.cpp" />
<ClCompile Include="K_getComponentPropertyValue.cpp" />
<ClCompile Include="K_invoke_pdm_server.cpp" />
<ClCompile Include="K_nx_common.cpp" />
<ClCompile Include="K_read_nx_bom.cpp" />
<ClCompile Include="K_recycle_item_id.cpp" />
<ClCompile Include="K_searchClassificationNodes.cpp" />
<ClCompile Include="K_searchTreeOrListNodes.cpp" />
<ClCompile Include="Top_Down_Design.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="Connor_NX.h" />
<ClInclude Include="kutil.h" />
<ClInclude Include="K_autocode_util.h" />
<ClInclude Include="K_recycle_item_id.h" />
<ClInclude Include="origin_PropNames.h" />
</ItemGroup>
<ItemGroup>
<Text Include="..\README.MD" />
</ItemGroup>
<PropertyGroup Label="Globals">
<VCProjectVersion>16.0</VCProjectVersion>
<ProjectGuid>{B66C17FA-78C8-443E-8239-6E8744560AD7}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>ConnorNX</RootNamespace>
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
<ProjectName>connor_nx_itk</ProjectName>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="Shared">
</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 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 Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<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|x64'">
<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)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LinkIncremental>false</LinkIncremental>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>NDEBUG;_CRT_SECURE_NO_WARNINGS;_CONSOLE;IPLIB=none;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>false</ConformanceMode>
<AdditionalIncludeDirectories>D:\WorkEnvironment\QunFeng\nx_itk\oci;D:\WorkEnvironment\QunFeng\nx_itk\include_cpp;D:\WorkEnvironment\QunFeng\nx_itk\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>D:\WorkEnvironment\QunFeng\nx_itk\lib\*.lib;%(AdditionalDependencies)</AdditionalDependencies>
<IgnoreSpecificDefaultLibraries>libuser_exits.ar.lib</IgnoreSpecificDefaultLibraries>
</Link>
</ItemDefinitionGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

@ -0,0 +1,87 @@
<?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;c++;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="头文件">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hh;hpp;hxx;h++;hm;inl;inc;ipp;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>
</ItemGroup>
<ItemGroup>
<ClCompile Include="Connor_NX.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="K_invoke_pdm_server.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="kutil.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="Top_Down_Design.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="Download_Dataset_By_UID.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="GET_ALL_SUB_TYPES.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="K_searchClassificationNodes.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="Get_Uid.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="K_getComponentPropertyValue.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="K_nx_common.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="K_searchTreeOrListNodes.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="K_recycle_item_id.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="K_autocode_util.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="connor_sign_dataset.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="connor_sign_master.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="K_read_nx_bom.cpp">
<Filter>源文件</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="Connor_NX.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="kutil.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="origin_PropNames.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="K_recycle_item_id.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="K_autocode_util.h">
<Filter>头文件</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<Text Include="..\README.MD" />
</ItemGroup>
</Project>

@ -0,0 +1,43 @@
#include "Connor_NX.h"
using namespace std;
int Download_Dataset_By_UID(const std::string& dataset_uid_ref_ext, std::string& res) {
int ifail = ITK_ok;
char* object_string = NULL;
char *dataset_file = NULL, *original_file_name = NULL;
tag_t dataset_tag = NULLTAG;
vector<string> split;
POM_AM__set_application_bypass(true);
WriteLog(debug, "下载数据集:%s", dataset_uid_ref_ext.c_str());
if (tc_strlen(dataset_uid_ref_ext.c_str()) == 0) {
res.append(("数据集UID不可为空"));
ifail = OUTPUT_CODE_ERROR;
goto gx_nx_image_end;
}
Split(dataset_uid_ref_ext, SPLITTER, split);
if (split.size() != 3) {
res.append(("调用参数错误“UID;引用;后缀”"));
ifail = OUTPUT_CODE_ERROR;
goto gx_nx_image_end;
}
ITKCALL(ifail = AOM_string_to_tag(split[0].c_str(), &dataset_tag));
if (ifail != ITK_ok || dataset_tag == NULLTAG) {
res.append(("未找到数据集: ")).append(split[0]);
goto gx_nx_image_end;
}
ITKCALL(ifail = AOM_ask_value_string(dataset_tag, "object_string", &object_string));
WriteLog(debug, "找到数据集:%s", object_string);
export_dataset_file(debug, dataset_tag, split[1].c_str(), split[2].c_str(), &dataset_file, &original_file_name);
if (dataset_file == NULL) {
res.append(("从数据集下载失败: ")).append(object_string);
ifail = OUTPUT_CODE_ERROR;
goto gx_nx_image_end;
}
res.append(dataset_file);
gx_nx_image_end:
POM_AM__set_application_bypass(false);
DOFREE(original_file_name);
DOFREE(object_string);
return ifail;
}

@ -0,0 +1,51 @@
#include "Connor_NX.h"
using namespace std;
int Get_All_SubTypes(const std::string& typeNameStr, std::string& res) {
int ifail = ITK_ok;
tag_t type_tag = NULLTAG;
tag_t *all_type_tags = NULL;
int type_cnt = 0;
vector<string> typeNames;
Split(typeNameStr, SPLITTER, typeNames);
int exclude_type_name_cnt = typeNames.size()-1;
const char** exclude_type_names;
char** names = NULL;
char** uif_names = NULL;
exclude_type_names = (const char**)MEM_alloc(exclude_type_name_cnt * sizeof(const char*));
for (int i = 0; i < exclude_type_name_cnt; i++) {
string typeName = typeNames[i + 1];
exclude_type_names[i] = typeName.c_str(); // (char*)MEM_alloc(typeName.length() * sizeof(char));
// tc_strcpy(exclude_type_names[i], typeName.c_str());
//printf(">> %s\n", exclude_type_names[i]);
}
/*ITKCALL(ifail = TCTYPE_ask_type(typeName.c_str(), &type_tag));
if (ifail != ITK_ok||type_tag==NULLTAG) {
res.append(("未找到对象类型: ")).append(typeName);
ifail = OUTPUT_CODE_ERROR;
goto get_subtype_end;
}
ITKCALL(ifail = TCTYPE_ask_subtypes(type_tag, false, &type_cnt, &all_type_tags));*/
ITKCALL(ifail = TCTYPE_UIF_find_generically_creatable_business_objects(typeNames[0].c_str(), exclude_type_name_cnt, exclude_type_names, &type_cnt, &all_type_tags, &names, &uif_names));
//ITKCALL(ifail = TCTYPE_find_alltypes_for_class(typeName.c_str(), &type_cnt, &all_type_tags));
if (ifail != ITK_ok) {
res.append(("获取类型失败: ")).append(typeNameStr);
goto get_subtype_end;
}
for (int i = 0; i < type_cnt; i++) {
tag_t a_tag = all_type_tags[i];
char* type_name = NULL, * dis_name = NULL;
ITKCALL(ifail = TCTYPE_ask_name2(a_tag, &type_name));
ITKCALL(ifail = TCTYPE_ask_display_name(a_tag, &dis_name));
if (type_name != NULL && dis_name != NULL) {
res.append(type_name).append("=").append(dis_name).append(SPLITTER);
}
}
get_subtype_end:
DOFREE(all_type_tags);
DOFREE(names);
DOFREE(uif_names);
return ifail;
}

@ -0,0 +1,71 @@
#include "Connor_NX.h"
using namespace std;
int Get_Uid(const std::string& name, std::string& res) {
int ifail = ITK_ok;
tag_t member_tag = NULLTAG;
tag_t user_tag = NULLTAG, role_tag = NULLTAG, group_tag = NULLTAG;
char* user_uid = NULL, * role_uid = NULL, * group_uid = NULL;
ITKCALL(ifail = POM_ask_member(&member_tag));
if (ifail != ITK_ok || member_tag == NULLTAG) {
ifail = OUTPUT_CODE_ERROR;
res.append("获取当前成员失败");
goto get_uid_end;
}
if (strcmp("user", name.c_str()) == 0) {
ITKCALL(ifail = SA_ask_groupmember_user(member_tag, &user_tag));
if (ifail != ITK_ok || user_tag == NULLTAG) {
ifail = OUTPUT_CODE_ERROR;
res.append("获取当前用户失败");
goto get_uid_end;
}
ITK__convert_tag_to_uid(user_tag, &user_uid);
res.append(user_uid);
}
else if (strcmp("role", name.c_str()) == 0) {
ITKCALL(ifail = SA_ask_groupmember_role(member_tag, &role_tag));
if (ifail != ITK_ok || role_tag == NULLTAG) {
ifail = OUTPUT_CODE_ERROR;
res.append("获取当前用户角色失败");
goto get_uid_end;
}
ITK__convert_tag_to_uid(role_tag, &role_uid);
res.append(role_uid);
}
else if (strcmp("group", name.c_str()) == 0) {
ITKCALL(ifail = SA_ask_groupmember_group(member_tag, &group_tag));
if (ifail != ITK_ok || group_tag == NULLTAG) {
ifail = OUTPUT_CODE_ERROR;
res.append("获取当前用户组失败");
goto get_uid_end;
}
ITK__convert_tag_to_uid(group_tag, &group_uid);
res.append(group_uid);
}
else if(strcmp("parentgroup", name.c_str()) == 0) {
tag_t parent_group_tag = NULLTAG;
ITKCALL(ifail = SA_ask_groupmember_group(member_tag, &group_tag));
if (ifail != ITK_ok || group_tag == NULLTAG) {
ifail = OUTPUT_CODE_ERROR;
res.append("获取当前用户组失败");
goto get_uid_end;
}
ITKCALL(ifail = AOM_ask_value_tag(group_tag, "parent", &parent_group_tag));
if (ifail != ITK_ok) {
ifail = OUTPUT_CODE_ERROR;
res.append("获取当前用户组的父级组织失败");
goto get_uid_end;
}
if (parent_group_tag != NULLTAG) {
ITK__convert_tag_to_uid(parent_group_tag, &group_uid);
res.append(group_uid);
}
}
get_uid_end:
DOFREE(user_uid);
DOFREE(group_uid);
DOFREE(role_uid);
return ifail;
}

@ -0,0 +1,632 @@
#pragma warning (disable: 4996)
#include "K_autocode_util.h"
#include "kutil.h"
#ifdef __cplusplus
extern "C" {
#endif
tag_t getCurrentUser()
{
char* userName;
tag_t user;
POM_get_user(&userName, &user);
return user;
}
char* filterChar(string str, string filterStr)
{
char* returnValue = (char*)MEM_alloc(10000 * sizeof(char));
size_t postion = str.find(filterStr);
//printf("str::%s\n",str.c_str());
if (postion != string::npos && str.length() > 0)
{
string temp1 = "";
string temp2 = "";
string temp3 = "";
string temp4 = "";
//printf("postion::%d\n",postion);
temp1 = str.substr(0, postion);
temp2 = str.substr(postion + (filterStr.length()));
temp3 = temp1;
temp4 = temp2;
size_t postion2 = temp1.find(",");
//printf("postion2=========%d\n",postion2);
if ((postion2 == (temp1.length() - 1)) && (temp1.length() > 0))
{
temp3 = temp1.substr(0, postion2);
}
else
{
size_t postion3 = temp2.find(",");
//printf("postion3=========%d\n",postion3);
if (postion3 == 0)
{
if (temp2.length() == 1)
{
temp4 = "";
}
else
{
temp4 = temp2.substr(1);
}
}
}
//cout << "temp1 value " <<temp1 << endl;
//cout << "temp2 value " <<temp2 << endl;
//cout << "temp3 value " <<temp3 << endl;
//cout << "temp4 value " <<temp4 << endl;
//日期在前
tc_strcpy(returnValue, temp3.c_str());
tc_strcat(returnValue, temp4.c_str());
//printf("returnValue1::%s\n",returnValue);
return returnValue;
}
else
{
tc_strcpy(returnValue, str.c_str());
return returnValue;
}
}
date_t getCurrentDate()
{
struct tm* p;
time_t now;
date_t modify_date;
time(&now);
p = localtime(&now); /* 取得当前时间 */
modify_date.day = p->tm_mday;
modify_date.hour = p->tm_hour;
modify_date.minute = p->tm_min;
modify_date.month = p->tm_mon;
modify_date.second = p->tm_sec;
modify_date.year = p->tm_year + 1900;
return modify_date;
}
void map_insert(map < string, string >* strmap, string index, string x)
{
//printf("map_insert==1 =====\n");
//strmap->insert(map < string, string >::value_type(index, x));
strmap->insert(pair< string, string >(index, x));
// printf("map_insert==2 =====\n");
}
int select_id_counter_beforeEnquiry(const char* id_counter, int next_id, tag_t* id_counter_tag, logical* is_new)
{
int ifail = ITK_ok;
tag_t class_id = NULLTAG;
ITKCALL(POM_class_id_of_class("Cd9_CodeNextID", &class_id));
int n_instances = 0, n_ret_instances = 0;
tag_t* instances_tags = NULL, * ret_instances = NULL, the_instance = NULLTAG;
ITKCALL(POM_instances_of_class(class_id, FALSE, &n_ret_instances, &ret_instances));
if (n_ret_instances > 0)
{
ITKCALL(POM_load_instances_possible(n_ret_instances, ret_instances, &n_instances, &instances_tags));
}
tag_t name_attr = NULLTAG, nextid_attr = NULLTAG;
ITKCALL(POM_attr_id_of_attr("cd9_name", "Cd9_CodeNextID", &name_attr));
ITKCALL(POM_attr_id_of_attr("cd9_nextID", "Cd9_CodeNextID", &nextid_attr));
for (int i = 0; i < n_instances; i++)
{
the_instance = NULLTAG;
//std::cout << "instances_tags[" << i << "] = " << instances_tags[i] << std::endl;
logical is_loaded = FALSE;
ITKCALL(POM_is_loaded(instances_tags[i], &is_loaded));
if (!is_loaded)
{
ITKCALL(POM_load_instances_any_class(1, &instances_tags[i], POM_no_lock));
}
//check is need refresh or not
logical need_refresh = FALSE;
ITKCALL(POM_refresh_required(instances_tags[i], &need_refresh));
if (need_refresh)
{
POM_refresh_instances_any_class(1, &instances_tags[i], POM_read_lock);
}
char* name_value = NULL;
logical is_it_null = FALSE, is_it_empty = FALSE;
ITKCALL(ifail = POM_ask_attr_string(instances_tags[i], name_attr,
&name_value, &is_it_null, &is_it_empty));
//printf("name_value=====================%s\n",name_value);
//printf("id_counter=====================%s\n",id_counter);
if (ifail == ITK_ok &&
!is_it_null &&
!is_it_empty)
{
if (tc_strcmp(name_value, id_counter) == 0)
{
logical is_it_null = FALSE, is_it_empty = FALSE;
int new_next_id = 0;
the_instance = instances_tags[i];
ITKCALL(ifail = POM_ask_attr_int(instances_tags[i], nextid_attr,
&new_next_id, &is_it_null, &is_it_empty));
int lock_token = 0;
ITKCALL(POM_ask_instance_lock(instances_tags[i], &lock_token));
if (lock_token != POM_modify_lock)
{
ITKCALL(POM_refresh_instances_any_class(1, &instances_tags[i], POM_modify_lock));
}
if (new_next_id < next_id)
{
ITKCALL(POM_set_attr_int(1, &instances_tags[i], nextid_attr, next_id));
}
ITKCALL(ifail = POM_save_instances(1, &instances_tags[i], false));
ITKCALL(ifail = POM_refresh_instances_any_class(1, &instances_tags[i], POM_no_lock));
the_instance = instances_tags[i];
MEM_free(name_value);
break;
}
else
{
int isEqual = 0;
std::vector< std::string > searched_tags1;
std::vector< std::string > searched_tags2;
Split(name_value, "$", searched_tags1);
Split(id_counter, "$", searched_tags2);
//printf("name_value=====================%s\n",name_value);
// printf("id_counter=====================%s\n",id_counter);
int searchLength1 = (int)searched_tags1.size();
int searchLength2 = (int)searched_tags2.size();
//printf("searchLength1=============%d\n",searchLength1);
//printf("searchLength2=============%d\n",searchLength2);
if (searchLength2 == searchLength1) {
int k = 0;
for (int k = 0; k < searchLength1; ++k)
{
if (k > 1)
{
break;
}
if (tc_strcmp(searched_tags1[k].c_str(), searched_tags2[k].c_str()) == 0)
{
isEqual = isEqual + 1;
}
}
if (isEqual > 1)
{
logical is_it_null = FALSE, is_it_empty = FALSE;
int new_next_id = 0;
ITKCALL(ifail = POM_ask_attr_int(instances_tags[i], nextid_attr,
&new_next_id, &is_it_null, &is_it_empty));
ITKCALL(POM_refresh_instances_any_class(1, &instances_tags[i], POM_modify_lock));
ITKCALL(POM_set_attr_string(1, &instances_tags[i], name_attr, id_counter));
if (new_next_id < next_id)
{
ITKCALL(POM_set_attr_int(1, &instances_tags[i], nextid_attr, next_id));
}
ITKCALL(ifail = POM_save_instances(1, &instances_tags[i], false));
ITKCALL(ifail = POM_refresh_instances_any_class(1, &instances_tags[i], POM_no_lock));
the_instance = instances_tags[i];
break;
}
}
}
MEM_free(name_value);
}
}
*id_counter_tag = the_instance;
*is_new = FALSE;
if (the_instance == NULLTAG)
{
tag_t new_inst = NULLTAG;
ITKCALL(POM_create_instance(class_id, &new_inst));
ITKCALL(POM_set_attr_string(1, &new_inst, name_attr, id_counter));
ITKCALL(POM_set_attr_int(1, &new_inst, nextid_attr, next_id));
ITKCALL(POM_save_instances(1, &new_inst, false));
*id_counter_tag = new_inst;
*is_new = TRUE;
}
//MEM_free(instances_tags);
return ITK_ok;
}
int select_id_counter1(const char* id_counter, int next_id, tag_t* id_counter_tag, logical* is_new, string& isSuccess)
{
int ifail = ITK_ok;
tag_t class_id = NULLTAG;
ITKCALL(POM_class_id_of_class("Cd9_CodeNextID", &class_id));
tag_t the_instance = NULLTAG;
tag_t name_attr = NULLTAG, nextid_attr = NULLTAG;
ITKCALL(POM_attr_id_of_attr("cd9_name", "Cd9_CodeNextID", &name_attr));
ITKCALL(POM_attr_id_of_attr("cd9_nextID", "Cd9_CodeNextID", &nextid_attr));
const char* source_Pom_Class = "Cd9_CodeNextID";
const char* selectNextID1 = "Select Cd9_CodeNextID1";
//char *select_nextidAttrs1[1] = {"puid"};
const char* select_nextidAttrs1[1] = { "puid" };
int nextidRows1, nextidCols1;
void*** nextidReport1 = NULL;
ITKCALL(POM_enquiry_create(selectNextID1));
ITKCALL(POM_enquiry_add_select_attrs(selectNextID1, source_Pom_Class,
1, (const char**)select_nextidAttrs1));
POM_enquiry_set_string_value(selectNextID1, "code_name_value",
1, (const char**)(&id_counter), POM_enquiry_asc_order);
POM_enquiry_set_attr_expr(selectNextID1, "code_name_exp",
source_Pom_Class, "cd9_name", POM_enquiry_like, "code_name_value");
POM_enquiry_set_where_expr(selectNextID1, "code_name_exp");
ITKCALL(POM_enquiry_execute(selectNextID1, &nextidRows1, &nextidCols1, &nextidReport1));
//printf("nextidRows1===============%d\n",nextidRows1);
//printf("nextidCols1===============%d\n",nextidCols1);
int i = 0;
if (nextidRows1 <= 0)
{
*id_counter_tag = NULLTAG;
MEM_free(nextidReport1);
ITKCALL(ifail = POM_enquiry_delete(selectNextID1));
return ITK_ok;
}
if (nextidRows1 > 0)
{
tag_t searchTag = NULLTAG;
searchTag = *((tag_t*)nextidReport1[0][0]);
//printf("searchTag===============%d\n",searchTag);
POM_load_instances(1, &searchTag, NULLTAG, POM_no_lock);
logical is_it_null = FALSE, is_it_empty = FALSE;
int new_next_id = 0;
the_instance = searchTag;
ITKCALL(ifail = POM_ask_attr_int(searchTag, nextid_attr,
&new_next_id, &is_it_null, &is_it_empty));
int lock_token = 0;
ITKCALL(POM_ask_instance_lock(searchTag, &lock_token));
if (lock_token != POM_modify_lock)
{
ITKCALL(POM_refresh_instances_any_class(1, &searchTag, POM_modify_lock));
}
if (new_next_id < next_id)
{
ITKCALL(POM_set_attr_int(1, &searchTag, nextid_attr, next_id));
}
ITKCALL(ifail = POM_save_instances(1, &searchTag, false));
ITKCALL(ifail = POM_refresh_instances_any_class(1, &searchTag, POM_no_lock));
the_instance = searchTag;
*id_counter_tag = the_instance;
*is_new = FALSE;
isSuccess.assign("");
isSuccess.append("Y");
// printf("searchTag=id_counter_tag==============%d\n",id_counter_tag);
}
MEM_free(nextidReport1);
ITKCALL(ifail = POM_enquiry_delete(selectNextID1));
return ifail;
}
int select_id_counter2(const char* id_counter, int next_id, tag_t* id_counter_tag, logical* is_new, string& isSuccess) {
int ifail = ITK_ok;
const char* source_Pom_Class = "Cd9_CodeNextID";
tag_t class_id = NULLTAG;
ITKCALL(POM_class_id_of_class("Cd9_CodeNextID", &class_id));
tag_t the_instance = NULLTAG;
tag_t name_attr = NULLTAG, nextid_attr = NULLTAG;
ITKCALL(POM_attr_id_of_attr("cd9_name", "Cd9_CodeNextID", &name_attr));
ITKCALL(POM_attr_id_of_attr("cd9_nextID", "Cd9_CodeNextID", &nextid_attr));
const char* selectNextID2 = "Select Cd9_CodeNextID2";
const char* select_nextidAttrs2[1] = { "puid" };
int m = 0;
int nextidRows2, nextidCols2;
void*** nextidReport2 = NULL;
ITKCALL(POM_enquiry_create(selectNextID2));
ITKCALL(POM_enquiry_add_select_attrs(selectNextID2, source_Pom_Class,
1, (const char**)select_nextidAttrs2));
std::vector< std::string > searched_tags2;
//printf("id_counter===============%s\n",id_counter);
//printf("next_id===============%d\n",next_id);
Split(id_counter, "$", searched_tags2);
int searchLength2 = (int)searched_tags2.size();
//printf("searched_tags2[0]===============%s\n", &(searched_tags2[0]));
char* select_nameValue2[1] = { const_cast<char*>(searched_tags2[0].c_str()) };
POM_enquiry_set_string_value(selectNextID2, "code_name_value",
1, (const char**)(select_nameValue2), POM_enquiry_asc_order);
POM_enquiry_set_attr_expr(selectNextID2, "code_name_exp",
source_Pom_Class, "cd9_name", POM_enquiry_like, "code_name_value");
POM_enquiry_set_where_expr(selectNextID2, "code_name_exp");
ITKCALL(POM_enquiry_execute(selectNextID2, &nextidRows2, &nextidCols2, &nextidReport2));
if (nextidRows2 <= 0)
{
*id_counter_tag = NULLTAG;
MEM_free(nextidReport2);
ITKCALL(ifail = POM_enquiry_delete(selectNextID2));
return ITK_ok;
}
if (nextidRows2 > 0)
{
tag_t searchTag2 = NULLTAG;
searchTag2 = *((tag_t*)nextidReport2[0][0]);
POM_load_instances(1, &searchTag2, NULLTAG, POM_no_lock);
logical is_it_null = FALSE, is_it_empty = FALSE;
int new_next_id = 0;
ITKCALL(ifail = POM_ask_attr_int(searchTag2, nextid_attr,
&new_next_id, &is_it_null, &is_it_empty));
//printf("id_counter===%s new_next_id==%d=================\n",id_counter,new_next_id);
int lock_token = 0;
ITKCALL(POM_ask_instance_lock(searchTag2, &lock_token));
if (lock_token != POM_modify_lock)
{
ITKCALL(POM_refresh_instances_any_class(1, &searchTag2, POM_modify_lock));
}
ITKCALL(POM_set_attr_string(1, &searchTag2, name_attr, id_counter));
//printf("id_counter===%s next_id==%d=================\n",id_counter,next_id);
if (new_next_id < next_id)
{
ITKCALL(POM_set_attr_int(1, &searchTag2, nextid_attr, next_id));
}
ITKCALL(ifail = POM_save_instances(1, &searchTag2, false));
ITKCALL(ifail = POM_refresh_instances_any_class(1, &searchTag2, POM_no_lock));
ITKCALL(ifail = POM_ask_attr_int(searchTag2, nextid_attr, &new_next_id, &is_it_null, &is_it_empty));
//printf("id_counter===%s new_next_id 2==%d=================\n",id_counter,new_next_id);
the_instance = searchTag2;
*id_counter_tag = the_instance;
*is_new = FALSE;
isSuccess.assign("");
isSuccess.append("Y");
}
MEM_free(nextidReport2);
ITKCALL(ifail = POM_enquiry_delete(selectNextID2));
}
int select_id_counter(const char* id_counter, int next_id, tag_t* id_counter_tag, logical* is_new)
{
int ifail = ITK_ok;
tag_t class_id = NULLTAG;
ITKCALL(POM_class_id_of_class("Cd9_CodeNextID", &class_id));
tag_t name_attr = NULLTAG, nextid_attr = NULLTAG;
ITKCALL(POM_attr_id_of_attr("cd9_name", "Cd9_CodeNextID", &name_attr));
ITKCALL(POM_attr_id_of_attr("cd9_nextID", "Cd9_CodeNextID", &nextid_attr));
const char* source_Pom_Class = "Cd9_CodeNextID";
//printf("select_id_counter=======\n");
string isSuccess;
isSuccess.assign("N");
select_id_counter1(id_counter, next_id, id_counter_tag, is_new, isSuccess);
//printf("isSuccess1===========%s\n",isSuccess.c_str());
if (tc_strcmp(isSuccess.c_str(), "Y") != 0) {
select_id_counter2(id_counter, next_id, id_counter_tag, is_new, isSuccess);
// printf("isSuccess2===========%s\n",isSuccess.c_str());
}
//printf("isSuccess13===========%s\n",isSuccess.c_str());
if (tc_strcmp(isSuccess.c_str(), "Y") != 0) {
tag_t new_inst = NULLTAG;
ITKCALL(POM_create_instance(class_id, &new_inst));
ITKCALL(POM_set_attr_string(1, &new_inst, name_attr, id_counter));
ITKCALL(POM_set_attr_int(1, &new_inst, nextid_attr, next_id));
ITKCALL(POM_save_instances(1, &new_inst, false));
*id_counter_tag = new_inst;
*is_new = TRUE;
}
//printf("id_counter_tag4===========%d\n",id_counter_tag);
//MEM_free(instances_tags);
return ITK_ok;
}
int load_current_number(tag_t id_counter_tag, const char* id_counter, int* next_id, logical* is_new)
{
int ifail = ITK_ok, i = 0,
new_next_id = *next_id;
logical is_valid = FALSE;
ITKCALL(POM_is_tag_valid(id_counter_tag, &is_valid));
if (id_counter_tag == NULLTAG || !is_valid)
{
int initial_next_id = 1;
ifail = select_id_counter(id_counter, initial_next_id, &id_counter_tag, is_new);
TEST_ERROR(ifail);
}
//check is loaded or not
logical is_loaded = FALSE;
ITKCALL(POM_is_loaded(id_counter_tag, &is_loaded));
if (!is_loaded)
{
ITKCALL(POM_load_instances_any_class(1, &id_counter_tag, POM_no_lock));
//cout << "load again!" << endl;
}
for (i = 0; i < GET_ID_RETRIES && ifail != ITK_ok; i++)
{
ITKCALL(ifail = POM_refresh_instances_any_class(1,
&id_counter_tag, POM_no_lock));
}
TEST_POM_ERROR(ifail);
tag_t nextid_attr = NULLTAG;
logical is_it_null = FALSE, is_it_empty = FALSE;
ITKCALL(ifail = POM_attr_id_of_attr("cd9_nextID", "Cd9_CodeNextID", &nextid_attr));
ITKCALL(ifail = POM_ask_attr_int(id_counter_tag, nextid_attr,
&new_next_id, &is_it_null, &is_it_empty));
//printf("id_counter=============%d\n",id_counter);
//printf("new_next_id=============%d\n",new_next_id);
TEST_POM_ERROR(ifail);
if (!is_it_null && !is_it_empty)
{
*next_id = new_next_id;
}
return ITK_ok;
}
int filterNewSequence(int new_index, int step)
{
int new_id = new_index + step;
char* optionValue;
ITKCALL(PREF_ask_char_value(origin_autocode_sequence_exclude_number, 0, &optionValue));
//printf(" exclude_number = %s\n",optionValue);
if (optionValue == NULL)
{
return new_id;
}
else
{
string str2;
char new_id_str[64];
sprintf(new_id_str, "%d", new_id);
str2 = new_id_str;
//printf(" exclude_number !=NULL ::str2== %s\n",str2.c_str());
size_t postion = str2.find(optionValue);
if (postion != string::npos)
{
//printf(" find exclude_number new_id==%d\n",new_id);
new_id = filterNewSequence(new_id, step);
}
}
//printf(" filterNewSequence ::new_id === %d\n",new_id);
return new_id;
}
int get_sequence_no(const char* pattern_code, int length, int start_index, int end_index, int step, int* new_id, const char* code_exclude_character)
{
int ifail = ITK_ok;
tag_t id_counter_tag = NULLTAG;
char id_counter[BUFSIZ] = "";
sprintf(id_counter, "%s$%d$%d$%d$%d", pattern_code, length, start_index, end_index, step);
//std::cout << "id_counter : " << id_counter << std::endl;
logical is_new = FALSE;
TEST_ERROR(ifail = select_id_counter(id_counter, start_index, &id_counter_tag, &is_new));
//std::cout << "is_new : " << is_new << ", id_counter_tag : " << id_counter_tag << std::endl;
int new_index = 1;
TEST_ERROR(ifail = load_current_number(id_counter_tag, id_counter, &new_index, &is_new));
//std::cout << "new_index : " << is_new << ", is_new : " << is_new << std::endl;
tag_t nextid_attr = NULLTAG;
ITKCALL(ifail = POM_attr_id_of_attr("cd9_nextID", "Cd9_CodeNextID", &nextid_attr));
logical can_modify = FALSE;
ITKCALL(POM_modifiable(id_counter_tag, &can_modify));
//std::cout << "can_modify : " << (can_modify ? "true" : "false") << std::endl;
if (!can_modify)
{
ITKCALL(POM_refresh_instances(1, &id_counter_tag, NULLTAG, POM_modify_lock));
}
if (is_new)
{
*new_id = start_index;
ITKCALL(ifail = POM_set_attr_int(1, &id_counter_tag, nextid_attr, start_index));
TEST_POM_ERROR(ifail);
}
else
{
if (new_index + step > end_index)
{
*new_id = new_index + step;
return -1;
}
int id = new_index + step;
//当以数字开始过滤掉以4开始编码
if (tc_strlen(pattern_code) > 0) {
char startChar[8];
char startChar2[8];
memcpy(startChar, pattern_code, 1);
memcpy(startChar2, pattern_code, 3);
//printf("startChar====%s\n",startChar);
boolean isDigit = isdigit(startChar[0]);
//printf("isDigit====%d\n",isDigit);
if ((isDigit) || (tc_strcasecmp(startChar2, "BJ0") == 0)) {
id = filterNewSequence(new_index, step);
}
//printf("filterNewSequence====%d\n",id);
}
*new_id = id;
ITKCALL(ifail = POM_set_attr_int(1, &id_counter_tag, nextid_attr, id));
}
ITKCALL(ifail = POM_save_instances(1, &id_counter_tag, true));
//ITKCALL(ifail = POM_refresh_instances_any_class(1, &id_counter_tag, POM_no_lock));
TEST_POM_ERROR(ifail);
//std::cout << "new_id : " << *new_id << endl;
if (tc_strcmp(code_exclude_character, "") == 0)
{
return ITK_ok;
}
else
{
if (filterItemID(code_exclude_character, new_index + step))
{
return ITK_ok;
}
else
{
get_sequence_no(pattern_code, length, start_index, end_index, step, new_id, code_exclude_character);
}
}
return ifail;
}
int filterItemID(const char* filterStr, int new_id)
{
char id_string[64];
sprintf(id_string, "%d", new_id);
string str2;
str2.c_str();
str2 = id_string;
//cout << " str2 =====" << str2 <<endl;
size_t postion = str2.find(filterStr);
if (postion != string::npos)
{
return 0;
}
else
{
return 1;
}
}
int generate_num(const char* pattern_code, int length, int new_index, char** generated_num)
{
char pad_string[64], index_string[64], final_code[BUFSIZ] = "";
tc_strcpy(pad_string, "\0");
sprintf(index_string, "%d", new_index);
int left_length = length - (int)strlen(index_string);
if (left_length > 0)
{
pad_string[left_length] = '\0';
for (int i = 0; i < left_length; i++)
{
pad_string[i] = '0';
}
sprintf(final_code, "%s%s%s", pattern_code, pad_string, index_string);
}
else
{
sprintf(final_code, "%s%s", pattern_code, index_string);
}
*generated_num = (char*)MEM_alloc(sizeof(char) * (strlen(final_code) + 1));
tc_strcpy(*generated_num, final_code);
return ITK_ok;
}
#ifdef __cplusplus
}
#endif

@ -0,0 +1,109 @@
#include<stdio.h>
#include <string>
#include<iostream>
#include <vector>
#include <map>
#include <list>
//tc
#include<tccore\custom.h>
#include<tc\tc_macros.h>
#include<tccore\aom.h>
#include<ict\ict_userservice.h>
#include<fclasses\tc_string.h>
#include<property\prop.h>
#include<tccore\item.h>
//#include<tc\iman.h>
#include <tccore\aom_prop.h>
#include <epm\epm.h>
#include <tccore\grm.h>
#include <sa\am.h>
#include <ps\ps.h>
#include <time.h>
#include <tccore\grmtype.h>
#include "origin_PropNames.h"
#include <pom/enq/enq.h>
#include<tc\preferences.h>
using namespace std;
//#include <libuserext_exports.h>
#ifdef __cplusplus
extern "C" {
#endif
#define GET_ID_RETRIES 10
#define CYCLE_TIMES 10
#define STARTNUMBER 1
#define PADNUMBER 4
#define RETRY_STRING "10"
#define HANDLE_ERROR_S1(E,S) \
{ EMH_store_initial_error_s1(EMH_severity_error,(E),(S)); return(E); }
#define REPORT_IFAIL(M) \
ifail?printf("%s : ERROR : ifail = %d\n",M,ifail):printf("%s : Ok\n",M)
#define HANDLE_ERROR(E) \
{ EMH_store_initial_error(EMH_severity_error,(E)); return(E); }
#define HANDLE_ERROR_S1(E,S) \
{ EMH_store_initial_error_s1(EMH_severity_error,(E),(S)); return(E); }
#define HANDLE_ERROR_AND_RELEASE(E,I) \
{ \
(void)release_number(I); \
EMH_store_initial_error(EMH_severity_error,(E)); \
return(E); \
}
#define TEST_ERROR(E) \
if ((E) != ITK_ok) return(E);
#define TEST_POM_ERROR(E) \
if ((E) != ITK_ok) HANDLE_ERROR(E)
#define TEST_ERROR_AND_RELEASE(E,I) \
if ((E) != ITK_ok) { (void)release_number(I); return(E); }
/* Define the number of retries when fetching the next ID. */
/* This must be stored in both numeric and string forms. */
#define GET_ID_RETRIES 10
#define RETRY_STRING "10"
/* Empty string test macro */
#define IS_EMPTY(S) (!(*(S)))
/* Define the methods by which a new item name can be obtained */
#define SEED_METHOD 0
#define BUILD_METHOD 1
/* The following define the maximum index number to be used. *
* Note that the actual maximum is one less than MAXNUM. *
* NUMERIC_LIMIT must be large enough to store decimal string *
* version of MAXNUM plus a NULL terminator. */
#define NUMERIC_LIMIT 12
#define MAXNUM 0x7FFFFFFF
/* define the class for which id and rev is generated */
#define CLASS_IS_ITEM 0
#define CLASS_IS_DATASET 1
#define origin_autocode_sequence_exclude_number "origin_autocode_sequence_exclude_number"
tag_t getCurrentUser();
char* filterChar(string str, string filterStr);
date_t getCurrentDate();
void map_insert(map < string, string >* strmap, string index, string x);
int select_id_counter(const char* id_counter, int next_id, tag_t* id_counter_tag, logical* is_new);
int load_current_number(tag_t id_counter_tag, const char* id_counter, int* next_id, logical* is_new);
//int load_current_number(tag_t id_counter_tag, const char *id_counter, int *next_id, logical *is_new);
int get_sequence_no(const char* pattern_code, int length, int start_index, int end_index, int step, int* new_id, const char* code_exclude_character);
int generate_num(const char* pattern_code, int length, int new_index, char** generated_num);
int filterItemID(const char* filterStr, int new_id);
int isContainsStr(char* sourceStr, char* containsStr);
#ifdef __cplusplus
}
#endif

@ -0,0 +1,370 @@
#pragma warning (disable: 4996)
#include "Connor_NX.h"
#include "origin_PropNames.h"
#include <pom/enq/enq.h>
const char* getChildrenNodesString(const char** propNames, const char** propValues, int length)
{
int ifail = ITK_ok;
const char* class_name = "Cd9_CodeRelation";
const char* selectTreeNode = "Select Cd9_CodeRelation1";
const char* select_nextidAttrs[1] = { CodeRelation_children_nodes };
int rows, cols;
void*** report = NULL;
int i = 0;
const char* strValues;
ITKCALL(POM_enquiry_create(selectTreeNode));
ITKCALL(POM_enquiry_add_select_attrs(selectTreeNode, class_name,
1, (const char**)select_nextidAttrs));
if (length == 1)
{
if (tc_strlen(propValues[0]) == 0)
{
ifail = POM_enquiry_set_attr_expr(selectTreeNode, "expr1", class_name, propNames[0], POM_enquiry_is_null, NULL);
}
else
{
ifail = POM_enquiry_set_string_value(selectTreeNode, "prop1", 1, (const char**)&propValues[0], POM_enquiry_bind_value);
ifail = POM_enquiry_set_attr_expr(selectTreeNode, "expr1", class_name, propNames[0], POM_enquiry_equal, "prop1");
}
ifail = POM_enquiry_set_where_expr(selectTreeNode, "expr1");
}
else {
if (tc_strlen(propValues[0]) == 0)
{
ifail = POM_enquiry_set_attr_expr(selectTreeNode, "expr1", class_name, propNames[0], POM_enquiry_is_null, NULL);
}
else
{
ifail = POM_enquiry_set_string_value(selectTreeNode, "prop1", 1, (const char**)&propValues[0], POM_enquiry_bind_value);
ifail = POM_enquiry_set_attr_expr(selectTreeNode, "expr1", class_name, propNames[0], POM_enquiry_equal, "prop1");
}
if (tc_strlen(propValues[1]) == 0)
{
ifail = POM_enquiry_set_attr_expr(selectTreeNode, "expr2", class_name, propNames[1], POM_enquiry_is_null, NULL);
}
else
{
ifail = POM_enquiry_set_string_value(selectTreeNode, "prop2", 1, (const char**)&propValues[1], POM_enquiry_bind_value);
ifail = POM_enquiry_set_attr_expr(selectTreeNode, "expr2", class_name, propNames[1], POM_enquiry_equal, "prop2");
}
POM_enquiry_set_expr(selectTreeNode, "expr", "expr1", POM_enquiry_and, "expr2");
ifail = POM_enquiry_set_where_expr(selectTreeNode, "expr");
}
ITKCALL(POM_enquiry_execute(selectTreeNode, &rows, &cols, &report));
//printf("nextidRows===============%d\n",rows);
if (rows > 0)
{
strValues = (char*)report[0][0];
}
else
{
strValues = "";
}
POM_enquiry_delete(selectTreeNode);
return strValues;
}
int isContainChildrenNode(const char** propNames, const char** propValues, int length)
{
int returnValue = 0;;
const char* value = getChildrenNodesString(propNames, propValues, length);
if (tc_strlen(value) > 0)
{
returnValue = 1;
}
return returnValue;
}
char* getCodeNodeInfos(tag_t tag, vector<string> propNames, int propLength, const char* parentString, int isNewComponent)
{
int ifail = 0;
int allocLength = 0;
const char* class_name = "Cd9_TreeAndListCodeNode";
const char** values = (const char**)MEM_alloc(propLength * sizeof(const char*));
for (int m = 0; m < propLength; m++) {
tag_t prop_tag;
// printf("propNames[m].c_str()====%s\n",propNames[m].c_str());
if (tc_strcmp(propNames[m].c_str(), TreeAndListCodeNode_isContainsChildren) == 0)
{
if (isNewComponent == 1)
{
values[m] = (char*)MEM_alloc(3 * sizeof(char));
allocLength += 3;
values[m] = "no";
continue;
}
char* value;
POM_tag_to_uid(tag, &value);
const char* isContainChildrenPropNames[2] = { CodeRelation_parent_nodes,CodeRelation_current_node };
const char* isContainChildrenValues[2] = { parentString, value };
int isContains = isContainChildrenNode(isContainChildrenPropNames, isContainChildrenValues, 2);
if (isContains == 1)
{
values[m] = (char*)MEM_alloc(4 * sizeof(char));
allocLength += 4;
values[m] = "yes";
}
else {
values[m] = (char*)MEM_alloc(3 * sizeof(char));
allocLength += 3;
values[m] = "no";
}
MEM_free(value);
continue;
}
tag_t attr_id = NULLTAG;
// printf("Check Property: %s\n", propNames[m].c_str());
ITKCALL(POM_attr_id_of_attr(propNames[m].c_str(),
class_name, &attr_id));
if (attr_id)
{
if (tc_strcmp(propNames[m].c_str(), TreeAndListCodeNode_node_name) == 0
|| tc_strcmp(propNames[m].c_str(), TreeAndListCodeNode_node_type) == 0
|| tc_strcmp(propNames[m].c_str(), TreeAndListCodeNode_node_value) == 0
|| tc_strcmp(propNames[m].c_str(), TreeAndListCodeNode_node_desc) == 0
|| tc_strcmp(propNames[m].c_str(), TreeAndListCodeNode_code_style) == 0
) {
char* value;
logical is_it_null = FALSE;
logical is_it_empty = FALSE;
ITKCALL(POM_ask_attr_string(tag, attr_id,
&value, &is_it_null, &is_it_empty));
if (is_it_null)
{
values[m] = (char*)MEM_alloc(5 * sizeof(char));
allocLength += 5;
values[m] = "null";
}
else {
values[m] = (char*)MEM_alloc(tc_strlen(value) * sizeof(char));
allocLength += tc_strlen(value);
values[m] = value;
}
}
if (
tc_strcmp(propNames[m].c_str(), TreeAndListCodeNode_is_root) == 0
|| tc_strcmp(propNames[m].c_str(), TreeAndListCodeNode_is_lock) == 0
|| tc_strcmp(propNames[m].c_str(), TreeAndListCodeNode_isDefaultSelected) == 0
) {
logical value;
logical is_it_null = FALSE;
logical is_it_empty = FALSE;
ITKCALL(POM_ask_attr_logical(tag, attr_id,
&value, &is_it_null, &is_it_empty));
if ((is_it_null) || (!value))
{
values[m] = (char*)MEM_alloc(3 * sizeof(char));
allocLength += 3;
values[m] = "no";
}
else {
values[m] = (char*)MEM_alloc(4 * sizeof(char));
allocLength += 4;
values[m] = "yes";
}
}
if (tc_strcmp(propNames[m].c_str(), TreeAndListCodeNode_rule_node) == 0
|| tc_strcmp(propNames[m].c_str(), TreeAndListCodeNode_create_user) == 0
|| tc_strcmp(propNames[m].c_str(), TreeAndListCodeNode_last_revise_user) == 0
) {
tag_t value;
logical is_it_null = FALSE;
logical is_it_empty = FALSE;
ITKCALL(POM_ask_attr_tag(tag, attr_id,
&value, &is_it_null, &is_it_empty));
if ((!is_it_null) && (!is_it_empty) && (value != NULLTAG))
{
if (tc_strcmp(propNames[m].c_str(), TreeAndListCodeNode_rule_node) == 0)
{
char* name;
ITKCALL(ifail = AOM_ask_value_string(value, TreeAndListCodeNode_node_name, &name));
{
values[m] = (char*)MEM_alloc(tc_strlen(name) * sizeof(char));
allocLength += tc_strlen(name);
values[m] = name;
}
}
else {
//char name[WSO_desc_size_c + 1]="";
char* name = NULL;
SA_ask_user_person_name2(value, &name);
values[m] = (char*)MEM_alloc(tc_strlen(name) * sizeof(char));
allocLength += tc_strlen(name);
values[m] = name;
}
}
else {
values[m] = (char*)MEM_alloc(5 * sizeof(char));
allocLength += 5;
values[m] = "null";
}
}
if (tc_strcmp(propNames[m].c_str(), TreeAndListCodeNode_create_date) == 0
|| tc_strcmp(propNames[m].c_str(), TreeAndListCodeNode_last_revise_date) == 0
) {
date_t value;
logical is_it_null = FALSE;
logical is_it_empty = FALSE;
ITKCALL(POM_ask_attr_date(tag, attr_id,
&value, &is_it_null, &is_it_empty));
if ((is_it_null) || (is_it_empty))
{
values[m] = (char*)MEM_alloc(5 * sizeof(char));
allocLength += 5;
values[m] = "null";
}
else {
char str_date[30] = "";
sprintf(str_date, "%4d/%02d/%02d %02d:%02d:%02d", value.year, value.month + 1, value.day,
value.hour, value.minute, value.second);
values[m] = (char*)MEM_alloc(tc_strlen(str_date) * sizeof(char));
allocLength += tc_strlen(str_date);
values[m] = str_date;
}
}
//printf("values[m]====%s\n",values[m]);
}
else
{
values[m] = (char*)MEM_alloc(5 * sizeof(char));
allocLength += 5;
values[m] = "null";
}
}
allocLength = allocLength + (propLength * 2);
char* infos = (char*)MEM_alloc(allocLength * sizeof(char));
tc_strcpy(infos, "");
for (int i = 0; i < propLength; i++)
{
tc_strcat(infos, values[i]);
tc_strcat(infos, "&&");
}
return infos;
}
int GET_TREE_AND_LIST_STRING_VALUES(const std::string& searchStr, std::string& res)
{
int ifail = ITK_ok;
int i, propLength, tagLength;
vector<tag_t> tags;
const char* class_name = "Cd9_TreeAndListCodeNode";
vector<string> propNames;
string parentString;
vector<string> searchStrSplit;
Split(searchStr, SPLITTER, searchStrSplit);
int size = searchStrSplit.size();
char* rtnStr = NULL;
const char** values = NULL;
if (size == 0) {
return ifail;
}
//printf("\nGET_TREE_AND_LIST_STRING_VALUES\n%s\n", searchStr.c_str());
//printf("PARENTSTRING: [%s]\n", searchStrSplit[0].c_str());
parentString = searchStrSplit[0];
for (i = 1; i < size; i++) {
tag_t tag = NULLTAG;
string str = searchStrSplit[i];
//printf("UID: [%s]\n", str.c_str());
if (strcmp(SPLIT_SECTION, str.c_str()) == 0) {
i++;
break;
}
ITK__convert_uid_to_tag(str.c_str(), &tag);
if (tag == NULLTAG) {
res.append("未找到对象 UID").append(str);
ifail = OUTPUT_CODE_ERROR;
goto GET_TREE_AND_LIST_STRING_VALUES_END;
}
tags.push_back(tag);
}
propLength = size - i;
for (; i < size; i++) {
string propName = searchStrSplit[i];
//printf("PROPNAME: [%s]\n", propName.c_str());
propNames.push_back(propName);
}
tagLength = tags.size();
values = (const char**)MEM_alloc(tagLength * sizeof(char*));
rtnStr = (char*)MEM_alloc(40000 * sizeof(char));
memset(rtnStr, 0, sizeof(rtnStr));
for (int i = 0; i < tagLength; i++)
{
tag_t tag = tags[i];
//printf("Load Tag\n");
ITKCALL(ifail = AOM_load(tag));
if (ifail != ITK_ok) {
continue;
}
// printf("\n ---------->i=%d, parentString=%s",i,parentString);
char* info = getCodeNodeInfos(tags[i], propNames, propLength, parentString.c_str(), 0);
values[i] = (char*)MEM_alloc(tc_strlen(info) * sizeof(char));
values[i] = info;
// printf("\n values[i]==============%s\n",values[i]);
strcat(rtnStr, info);
strcat(rtnStr, "@@");
ITKCALL(ifail = AOM_unload(tag));
}
res.append(rtnStr);
GET_TREE_AND_LIST_STRING_VALUES_END:
propNames.clear();
tags.clear();
return ifail;
}
int GET_TREE_AND_LIST_STRING_VALUE(const std::string& searchStr, std::string& res) {
int ifail = ITK_ok;
int i, propLength, tagLength;
tag_t tag;
vector<string> propNames;
const char* class_name = "Cd9_TreeAndListCodeNode";
char* info = NULL;
vector<string> searchStrSplit;
Split(searchStr, SPLITTER, searchStrSplit);
int size = searchStrSplit.size();
if (size == 0) {
return ifail;
}
propLength = size - 1;
//printf("\nGET_TREE_AND_LIST_STRING_VALUE\n%s\n", searchStr.c_str());
//printf("UID: [%s]\n", searchStrSplit[0].c_str());
ITK__convert_uid_to_tag(searchStrSplit[0].c_str(), &tag);
if (tag == NULLTAG) {
res.append("未找到对象 UID").append(searchStrSplit[0]);
ifail = OUTPUT_CODE_ERROR;
goto GET_TREE_AND_LIST_STRING_VALUE_END;
}
//printf("Find Tag\n");
for (i = 0; i < propLength; i++) {
string propName = searchStrSplit[i + 1];
propNames.push_back(propName);
// printf(">> %s\n", propNames[i].c_str());
}
//printf("Load Tag\n");
ITKCALL(ifail = AOM_load(tag));
if (ifail != ITK_ok) {
res.append("无法加载实例 UID").append(searchStrSplit[0]);
goto GET_TREE_AND_LIST_STRING_VALUE_END;
}
//printf("Load Tag Complete\n");
info = getCodeNodeInfos(tag, propNames, propLength, "", 1);
res.append(info);
ITKCALL(ifail = AOM_unload(tag));
GET_TREE_AND_LIST_STRING_VALUE_END:
return ifail;
}

@ -0,0 +1,223 @@
#include "Connor_NX.h"
#define K_GetPrefValue 0
#define K_Parse_NX_Template_By_ID 1
#define K_Read_NX_Image_By_ID 2
#define K_Download_Dataset_By_UID 3
#define INPUTCODE_GET_ALL_SUB_TYPES 4
#define INPUTCODE_SEARCH_AUTOCODE_NODE 5
#define INPUTCODE_GET_UID 6
#define INPUTCODE_SEARCH_AUTOCODE_SEGMENT 7
#define INPUTCODE_SEARCH_AUTOCODE_USER 8
#define INPUTCODE_GET_TREE_AND_LIST_STRING_VALUE 9
#define INPUTCODE_GET_NEW_REV_ID 10
#define INPUTCODE_GET_LOGICAL_PROP_VALUE 11
#define INPUTCODE_SEARCH_TREE_OR_LIST_NODE 12
#define INPUTCODE_GET_TREE_AND_LIST_STRING_VALUES 13
#define INPUTCODE_SEARCH_PARENT_TREE_OR_LIST_NODE 14
#define INPUTCODE_ICS_GET_ATTRIBUTES 15
#define INPUTCODE_ICS_ATTR_IS_REFERENCE_ATTRIBUTE 16
#define INPUTCODE_ICS_ATTR_ASK_PROPERTY 17
#define INPUTCODE_ICS_ATTR_ASK_KEYLOV 18
#define INPUTCODE_GET_DISPLAY_PROP_VALUE 19
#define INPUTCODE_FIND_LOV_BY_NAME 20
#define INPUTCODE_GET_REFERENCE_PROP_VALUE 21
#define INPUTCODE_QUERY_PART_NO 22
#define INPUTCODE_DELETE_RECYCLE_ID 23
#define INPUTCODE_ITEM_EXIST 24
#define INPUTCODE_ITEM_CREATE 25
#define INPUTCODE_ADD_TO_NEWSTUFF 26
#define INPUTCODE_GET_CLASSIFICATION_ID 27
#define INPUTCODE_SEND_ITEM_TO_CLASSIFICATION 28
#define INPUTCODE_GET_ITEMTYPE_BY_ID 29
#define INPUTCODE_GET_REVUID_BY_ID 30
#define INPUTCODE_ITEM_UPDATE 31
#define INPUTCODE_READ_NX_TEMPLATE_BOM 32
#define INPUTCODE_GET_CLONE_INFO 33
#define INPUTCODE_GET_LATEST_ITEM_REVISION 34
#define INPUTCODE_GRANT_PRIVILEGE 35
#define INPUTCODE_GET_UOM_TAGS 36
#define INPUTCODE_UPDATE_UOM 37
#define INPUTCODE_GET_REFERENCE_PROP_VALUE_ARRAY 38
#define INPUTCODE_ICS_ATTR_ASK_METRIC_UNIT 39
using namespace std;
int GetPrefValue(const std::string &pref_name, std::string &prefValue) {
int ifail = ITK_ok;
int pref_len = 0;
char** pref_vals = NULL;
printf("查询首选项:%s\n", pref_name.c_str());
if (tc_strlen(pref_name.c_str()) == 0) {
return ifail;
}
ITKCALL(ifail = PREF_refresh(pref_name.c_str()));
if (ifail != ITK_ok) {
prefValue.append(("未配置首选项:")).append(pref_name);
return ifail;
}
ITKCALL(ifail = PREF_ask_char_values(pref_name.c_str(), &pref_len, &pref_vals));
for (int i = 0;i < pref_len;i++) {
printf(">> %d. %s\n", i + 1, pref_vals[i]);
prefValue.append(pref_vals[i]);
if (i != pref_len - 1) {
prefValue.append(SPLITTER);
}
}
if (ifail != ITK_ok) {
prefValue.append(("未配置首选项:")).append(pref_name);
}
return ifail;
}
DLLAPI int K_invoke_pdm_server(int *decision, va_list args) {
int ifail = ITK_ok;
// get the input parameters from the va_list:
int input_code = va_arg(args, int);
char* input_str = va_arg(args, char*);
int* output_code = va_arg(args, int*);
char** output_str = va_arg(args, char**);
// set decision. We'll let other customizations have
// a chance to handle this PDM Server call too.
*decision = ALL_CUSTOMIZATIONS;
// I do all intermediate string processing with std::string's
// instead of char* strings. Later I'll copy the final
// std::string's contents to the char* output_str
std::string output_string;
// pass the input_code to a switch():
switch (input_code)
{
case K_GetPrefValue:
*output_code = GetPrefValue(input_str, output_string);
break;
case K_Read_NX_Image_By_ID:
*output_code = Read_NX_Image_By_ID(input_str, output_string);
break;
case K_Parse_NX_Template_By_ID:
*output_code = Parse_NX_Template_By_ID(input_str, output_string);
break;
case K_Download_Dataset_By_UID:
*output_code = Download_Dataset_By_UID(input_str, output_string);
break;
case INPUTCODE_GET_ALL_SUB_TYPES:
*output_code = Get_All_SubTypes(input_str, output_string);
break;
case INPUTCODE_SEARCH_AUTOCODE_NODE:
*output_code = SEARCH_AUTOCODE_NODE(input_str, output_string);
break;
case INPUTCODE_GET_UID:
*output_code = Get_Uid(input_str, output_string);
break;
case INPUTCODE_SEARCH_AUTOCODE_SEGMENT:
*output_code = SEARCH_AUTOCODE_SEGMENT(input_str, output_string);
break;
case INPUTCODE_SEARCH_AUTOCODE_USER:
*output_code = SEARCH_AUTOCODE_USER(input_str, output_string);
break;
case INPUTCODE_GET_TREE_AND_LIST_STRING_VALUE:
*output_code = GET_TREE_AND_LIST_STRING_VALUE(input_str, output_string);
break;
case INPUTCODE_GET_NEW_REV_ID:
*output_code = GET_NEW_REV_ID(input_str, output_string);
break;
case INPUTCODE_GET_LOGICAL_PROP_VALUE:
*output_code = GET_LOGICAL_PROP_VALUE(input_str, output_string);
break;
case INPUTCODE_SEARCH_TREE_OR_LIST_NODE:
*output_code = SEARCH_TREE_OR_LIST_NODE(input_str, output_string);
break;
case INPUTCODE_GET_TREE_AND_LIST_STRING_VALUES:
*output_code = GET_TREE_AND_LIST_STRING_VALUES(input_str, output_string);
break;
case INPUTCODE_SEARCH_PARENT_TREE_OR_LIST_NODE:
*output_code = SEARCH_PARENT_TREE_OR_LIST_NODE(input_str, output_string);
break;
case INPUTCODE_ICS_GET_ATTRIBUTES:
*output_code = ICS_GET_ATTRIBUTES(input_str, output_string);
break;
case INPUTCODE_ICS_ATTR_IS_REFERENCE_ATTRIBUTE:
*output_code = ICS_ATTR_IS_REFERENCE_ATTRIBUTE(input_str, output_string);
break;
case INPUTCODE_ICS_ATTR_ASK_PROPERTY:
*output_code = ICS_ATTR_ASK_PROPERTY(input_str, output_string);
break;
case INPUTCODE_ICS_ATTR_ASK_KEYLOV:
*output_code = ICS_ATTR_ASK_KEYLOV(input_str, output_string);
break;
case INPUTCODE_GET_DISPLAY_PROP_VALUE:
*output_code = GET_DISPLAY_PROP_VALUE(input_str, output_string);
break;
case INPUTCODE_FIND_LOV_BY_NAME:
*output_code = FIND_LOV_BY_NAME(input_str, output_string);
break;
case INPUTCODE_GET_REFERENCE_PROP_VALUE:
*output_code = GET_REFERENCE_PROP_VALUE(input_str, output_string);
break;
case INPUTCODE_QUERY_PART_NO:
*output_code = QUERY_PART_NO(input_str, output_string);
break;
case INPUTCODE_DELETE_RECYCLE_ID:
*output_code = DELETE_RECYCLE_ID(input_str, output_string);
break;
case INPUTCODE_ITEM_EXIST:
*output_code = ITEM_EXIST(input_str, output_string);
break;
case INPUTCODE_ITEM_CREATE:
*output_code = ITEM_CREATE(input_str, output_string);
break;
case INPUTCODE_ADD_TO_NEWSTUFF:
*output_code = ADD_TO_NEWSTUFF(input_str, output_string);
break;
case INPUTCODE_GET_CLASSIFICATION_ID:
*output_code = GET_CLASSIFICATION_ID(input_str, output_string);
break;
case INPUTCODE_SEND_ITEM_TO_CLASSIFICATION:
*output_code = SEND_ITEM_TO_CLASSIFICATION(input_str, output_string);
break;
case INPUTCODE_GET_ITEMTYPE_BY_ID:
*output_code = GET_ITEMTYPE_BY_ID(input_str, output_string);
break;
case INPUTCODE_GET_REVUID_BY_ID:
*output_code = GET_REVUID_BY_ID(input_str, output_string);
break;
case INPUTCODE_ITEM_UPDATE:
*output_code = ITEM_UPDATE(input_str, output_string);
break;
case INPUTCODE_READ_NX_TEMPLATE_BOM:
*output_code = READ_NX_TEMPLATE_BOM(input_str, output_string);
break;
case INPUTCODE_GET_CLONE_INFO:
*output_code = GET_CLONE_INFO(input_str, output_string);
break;
case INPUTCODE_GET_LATEST_ITEM_REVISION:
*output_code = GET_LATEST_ITEM_REVISION(input_str, output_string);
break;
case INPUTCODE_GRANT_PRIVILEGE:
*output_code = GRANT_PRIVILEGE(input_str, output_string);
break;
case INPUTCODE_GET_UOM_TAGS:
*output_code = GET_UOM_TAGS(input_str, output_string);
break;
case INPUTCODE_UPDATE_UOM:
*output_code = UPDATE_UOM(input_str, output_string);
break;
case INPUTCODE_GET_REFERENCE_PROP_VALUE_ARRAY:
*output_code = GET_REFERENCE_PROP_VALUE_ARRAY(input_str, output_string);
break;
case INPUTCODE_ICS_ATTR_ASK_METRIC_UNIT:
*output_code = ICS_ATTR_ASK_METRIC_UNIT(input_str, output_string);
break;
default:
*decision = NO_CUSTOMIZATION; // do nothing INPUTCODE_ITEM_UPDATE
// code may be meant for another library using PDM Server
}
// allocate memory for output string and copy
// std::string's contents to it:
TC_write_syslog("NX Return [%d]: %s", *output_code, output_string.c_str());
*output_str =(char*) malloc(sizeof(char) * (output_string.length() + 1));
tc_strcpy(*output_str, output_string.c_str());
return ifail;
}

File diff suppressed because it is too large Load Diff

@ -0,0 +1,121 @@
#include "Connor_NX.h"
using namespace std;
int Cycle_BOM(tag_t bomline, std::string& res, vector<string>& checkedIDs) {
int ifail = ITK_ok, child_cnt = 0;
tag_t rev_tag = NULLTAG, * child_lines = NULL;
char* object_string = NULL, * uid = NULL;
ITKCALL(ifail = AOM_ask_value_tag(bomline, "bl_revision", &rev_tag));
if (ifail != ITK_ok || rev_tag == NULLTAG) {
goto cycle_bom_end;
}
ITK__convert_tag_to_uid(rev_tag, &uid);
if (inArray(checkedIDs, uid)) {
goto cycle_bom_end;
}
ITKCALL(ifail = BOM_line_ask_child_lines(bomline, &child_cnt, &child_lines));
if (child_cnt == 0) {
goto cycle_bom_end;
}
ITKCALL(ifail = AOM_ask_value_string(bomline, "bl_indented_title", &object_string));
if (ifail != ITK_ok) {
goto cycle_bom_end;
}
res.append("<BOM_GROUP/>");
res.append(uid);
res.append("=");
res.append(object_string);
for (int i = 0; i < child_cnt; i++) {
tag_t cLine = child_lines[i];
tag_t cRev = NULLTAG;
DOFREE(uid);
DOFREE(object_string);
ITKCALL(ifail = AOM_ask_value_tag(cLine, "bl_revision", &cRev));
if (ifail != ITK_ok || cRev == NULLTAG) {
continue;
}
ITK__convert_tag_to_uid(cRev, &uid);
ITKCALL(ifail = AOM_ask_value_string(cLine, "bl_indented_title", &object_string));
if (ifail != ITK_ok) {
continue;
}
res.append("<LINE/>");
res.append(uid);
res.append("=");
res.append(object_string);
}
for (int i = 0; i < child_cnt; i++) {
Cycle_BOM(child_lines[i], res, checkedIDs);
}
cycle_bom_end:
DOFREE(object_string);
DOFREE(uid);
DOFREE(child_lines);
return ifail;
}
//READ_NX_TEMPLATE_BOM
int READ_NX_TEMPLATE_BOM(const std::string& itemID, std::string& res) {
int ifail = ITK_ok, release_flag = 0;
int pref_len = 0, ds_count = 0;
char* object_string = NULL;
char* rev_id = NULL;
tag_t item_tag = NULLTAG;
tag_t rev_tag = NULLTAG;
tag_t bom_view = NULLTAG, bvr_tag = NULLTAG, bom_window = NULLTAG, topBomLine = NULLTAG;
vector<string> checkedIDs;
POM_AM__set_application_bypass(true);
WriteLog(debug, "查询NX模板%s", itemID.c_str());
if (tc_strlen(itemID.c_str()) == 0) {
res.append(("NX模板ID不可为空"));
ifail = OUTPUT_CODE_ERROR;
goto gx_nx_template_end;
}
ITKCALL(ifail = ITEM_find_item(itemID.c_str(), &item_tag));
if (ifail != ITK_ok) {
goto gx_nx_template_end;
}
ITKCALL(ifail = AOM_ask_value_string(item_tag, "object_string", &object_string));
WriteLog(debug, "找到对象:%s", object_string);
DOFREE(object_string);
ITKCALL(ifail = ITEM_ask_latest_rev(item_tag, &rev_tag));
if (rev_tag == NULLTAG) {
res.append(("未找到模板对象的最新版本,请检查是否具有查看权限"));
ifail = OUTPUT_CODE_ERROR;
goto gx_nx_template_end;
}
ITKCALL(ifail = AOM_refresh(rev_tag, FALSE));
ITKCALL(ifail = AOM_ask_value_string(rev_tag, "object_string", &object_string));
WriteLog(debug, "最新版本:%s", object_string);
DOFREE(object_string);
// 检查是否发布
ITKCALL(ifail = EPM_ask_if_released(rev_tag, &release_flag));
if (release_flag == 0) {
res.append(("模板对象最新版本未发布"));
ifail = OUTPUT_CODE_ERROR;
goto gx_nx_template_end;
}
ITKCALL(ifail = AOM_ask_value_string(rev_tag, "item_revision_id", &rev_id));
res.append("@DB/").append(itemID).append("/").append(rev_id);
// 加载BOM
ITKCALL(ifail = GetBomView(rev_tag, "view", &bom_view, &bvr_tag, debug));
if (bom_view != NULLTAG) {
BOM_create_window(&bom_window);
BOM_set_window_top_line_bvr(bom_window, bvr_tag, &topBomLine);
ifail = Cycle_BOM(topBomLine, res, checkedIDs);
BOM_close_window(bom_window);
}
else {
WriteLog(debug, "未找到BOM视图");
}
gx_nx_template_end:
if (ifail != ITK_ok) {
res.assign("读取BOM异常");
ifail = OUTPUT_CODE_ERROR;
}
POM_AM__set_application_bypass(false);
DOFREE(object_string);
DOFREE(rev_id);
return ifail;
}

@ -0,0 +1,775 @@
#pragma warning (disable: 4996)
#include "K_recycle_item_id.h"
#ifdef __cplusplus
extern "C" {
#endif
/************************************************************************/
/* 记录空闲item id的schema类或数据库表
* SchemaTempCounter,POM_object
*
* name32abc
* id32idabc0001
* occ32idtrue/false
* create_date
*/
/************************************************************************/
int CheckReference(tag_t one_instance)
{
int n_levels = 1;
int n_instances = 0;
tag_t* ref_instances = NULL;
int* instance_levels = NULL, * instance_where_found = NULL;
int n_classes = 0;
tag_t* ref_classes = NULL;
int* class_levels = NULL, * class_where_found = NULL;
CALL(POM_referencers_of_instance(one_instance,
n_levels,
POM_in_ds_and_db,
&n_instances, /**< (O) Number of referencing instances */
&ref_instances, /**< (OF) n_instances Tags of referencing instances */
&instance_levels, /**< (OF) n_instances Levels of referencing instances */
&instance_where_found, /**< (OF) n_instances Where the instance was found */
&n_classes, /**< (O) Number of referencing classes */
&ref_classes, /**< (OF) n_classes Tags of referencing classes */
&class_levels, /**< (OF) n_classes Levels of referencing classes */
&class_where_found /**< (OF) n_classes Where the class was found (always DB) */
));
if (n_instances == 0)
return 0;
MEM_free(ref_instances);
MEM_free(instance_levels);
MEM_free(instance_where_found);
MEM_free(ref_classes);
MEM_free(class_levels);
MEM_free(class_where_found);
return -1;
}
int enq_like_num(const char* filter_code, int* index)
{
int ifail;
const char* enquiryLikeItem = "Select_ITEM";
const char* select_attrs[1] = { "puid" };
int rows, cols;
void*** report = NULL;
//===============select puid form Item where ITEM_ID like TeZhengManWithNumber%
CALL(POM_enquiry_create(enquiryLikeItem));
CALL(POM_enquiry_add_select_attrs(enquiryLikeItem, ITEM_POM_CLASS,
1, (const char**)select_attrs));
CALL(POM_enquiry_set_string_value(enquiryLikeItem, "item_id_value",
1, (const char**)(&filter_code), POM_enquiry_asc_order));
CALL(POM_enquiry_set_attr_expr(enquiryLikeItem, "item_id_exp",
ITEM_POM_CLASS, "ITEM_ID", POM_enquiry_like, "item_id_value"));
CALL(POM_enquiry_set_where_expr(enquiryLikeItem, "item_id_exp"));
CALL(POM_enquiry_execute(enquiryLikeItem, &rows, &cols, &report));
*index = rows;
MEM_free(report);
CALL(ifail = POM_enquiry_delete(enquiryLikeItem));
return ifail;
}
/************************************************************************/
/*
* Description: Query redundant item id from the recycle item id's table
* Function : QueryReduntantItemId2
* Params : TeZhengMa - item id's TeZhengMa, usually, this is the item
* id counter's name
* : the_item_id - searched item id, maybe null.
* Return : 0 - no error, else errors
*/
/************************************************************************/
int QueryReduntantItemId(char* TeZhengMa, char** the_item_id)
{
int ifail = ITK_ok, i = 0;
const char
* Temp_Pom_Class = "Cd9_CodeCounter";
char
* name_attr_value = NULL,
* id_attr_value = NULL,
* occ_attr_value = NULL;
tag_t
class_id = NULLTAG,
name_attr_id = NULLTAG,
id_attr_id = NULLTAG,
occ_attr_id = NULLTAG,
createdate_attr_id = NULLTAG,
item_exists = NULLTAG;
logical
include_subclasses = FALSE,
is_it_null = FALSE,
is_it_empty = FALSE,
is_old_enough = FALSE;
int
n_instance = 0,
n_ret_instances = 0,
lock_token = 0, lock_token_2 = 0,
day = 0, month = 0, year = 0,
hour = 0, minute = 0, second = 0, zjdnum = 0; //zjd
tag_t
* instance_tags = NULL,
* ret_instances = NULL,
one_instance = NULLTAG,
found_instance = NULLTAG;
struct tm* p;
time_t now;
date_t date_attr_value;
char counter_name1[255];
date_t modify_date; //liny
CALL(POM_class_id_of_class(Temp_Pom_Class, &class_id));
CALL(POM_attr_id_of_attr(CodeCounter_name, Temp_Pom_Class, &name_attr_id));
CALL(POM_attr_id_of_attr(CodeCounter_recycleID, Temp_Pom_Class, &id_attr_id));
CALL(POM_attr_id_of_attr(CodeCounter_isUsed, Temp_Pom_Class, &occ_attr_id));
CALL(POM_attr_id_of_attr(CodeCounter_createDate, Temp_Pom_Class, &createdate_attr_id));
//查询废号表中的所有实例,但尚未加载
CALL(POM_instances_of_class(class_id, include_subclasses, &n_instance, &instance_tags));
//fprintf( stdout, "%d instances found\n", n_instance );
if (n_instance == 0) {
return ITK_ok;
}
//返回所有成功加载的instance
CALL(POM_load_instances_possible(n_instance, instance_tags, &n_ret_instances, &ret_instances));
CALL(POM_refresh_instances(n_ret_instances, ret_instances, NULLTAG, POM_no_lock));
//刷新实例,找到所有的报废号码
for (i = 0; i < n_ret_instances; i++)
{
one_instance = ret_instances[i];
//取得所有occ自动为true的记录如果这些记录合适则更新这些记录的occ字段为false以备取号使用
CALL(POM_ask_attr_string(one_instance, occ_attr_id, &occ_attr_value, &is_it_null, &is_it_empty));
//查询符合条件的实例的时间状态如果已经过期则设置occ为false以备取废号使用
if (tc_strcmp(occ_attr_value, "true") == 0)
{
CALL(POM_ask_attr_date(one_instance, createdate_attr_id, &date_attr_value, &is_it_null, &is_it_empty));
year = date_attr_value.year;
month = date_attr_value.month;
day = date_attr_value.day;
hour = date_attr_value.hour;
minute = date_attr_value.minute;
time(&now);
p = localtime(&now); /* 取得当前时间 */
is_old_enough = FALSE;
//printf("year==%d month==%d day==%d hour==%d minute==%d \n",year,month,day,hour,minute);
//printf("now::year==%d month==%d day==%d hour==%d minute==%d \n",p->tm_year + 1900, p->tm_mon,p->tm_mday,p->tm_hour,p->tm_min);
if ((p->tm_year + 1900) > year) //如果当前年份大于对象的创建年份,则设置标志位
is_old_enough = TRUE;
else
{
if (p->tm_mon > month) //如果当前月份大于对象的创建月份,则设置标志位
is_old_enough = TRUE;
else
{
if (p->tm_mday > day) //如果当前月份大于对象的创建日期,则设置标志位
is_old_enough = TRUE;
//else
// is_old_enough = FALSE;
else
{
//if( p->tm_hour> (hour+1)%24 )
if (p->tm_hour > hour)
is_old_enough = TRUE;
//else
// is_old_enough = FALSE;
else //liny
{
if (p->tm_min > (minute + 5))
is_old_enough = TRUE;
else
is_old_enough = FALSE;
}
}
}
}
if (is_old_enough == TRUE)
{ //查询当前instance是否被加了修改锁如果未被加修改锁则设置这些记录刷新内存记录
CALL(POM_ask_instance_lock(one_instance, &lock_token));
if (lock_token != POM_modify_lock)
{
CALL(POM_refresh_instances_any_class(1, &one_instance, POM_modify_lock));
CALL(POM_set_attr_string(1, &one_instance, occ_attr_id, "false"));
CALL(POM_save_instances(1, &one_instance, false));
CALL(POM_refresh_instances_any_class(1, &one_instance, POM_no_lock));//刷新内存记录,恢复锁的状态
}
}
}
}
//所有的记录被刷新,重新取号
for (i = 0; i < n_ret_instances; i++)
{
one_instance = ret_instances[i];
CALL(POM_ask_attr_string(one_instance, name_attr_id, &name_attr_value, &is_it_null, &is_it_empty));
if (tc_strcmp(name_attr_value, TeZhengMa) == 0)
{
CALL(POM_ask_attr_string(one_instance, occ_attr_id, &occ_attr_value, &is_it_null, &is_it_empty));
//如果当前记录是新创建的且未过时,跳过不处理
if (tc_strcmp(occ_attr_value, "true") == 0)
{
MEM_free(occ_attr_value);
continue;
}
//如果当前instance被别人加了修改锁跳过
CALL(POM_ask_instance_lock(one_instance, &lock_token));
if (lock_token == POM_modify_lock)
{
MEM_free(occ_attr_value);
continue;
}
CALL(POM_ask_attr_string(one_instance, id_attr_id, &id_attr_value, &is_it_empty, &is_it_empty));
//检查数据库是否有记录有则尝试取消这个废号成功则删除记录否则设置当前的instance为nulltag
item_exists = NULLTAG;
/*CALL( ITEM_find_item( id_attr_value, &item_exists ) );
if( item_exists != NULLTAG )*/
tc_strcpy(counter_name1, "%");
tc_strcat(counter_name1, id_attr_value);
tc_strcat(counter_name1, "%");
{
int n_levels = 2;
int where_to_search = POM_in_ds_and_db;
int n_ref_instances;
tag_t* ref_instances;
int* ref_instance_levels;
int* ref_instance_where_found;
int n_ref_classes;
tag_t* ref_classes;
int* class_levels;
int* class_where_found;
POM_referencers_of_instance(one_instance, n_levels, where_to_search, &n_ref_instances, &ref_instances, &ref_instance_levels, &ref_instance_where_found, &n_ref_classes, &ref_classes, &class_levels, &class_where_found);
//printf("id==%s的被%d个实例引用\n",counter_name1,n_ref_instances);
//printf("id==%s的被%d个类引用\n",counter_name1,n_ref_instances);
}
//查找新建的item中是否已存在该ID
ifail = enq_like_num(counter_name1, &zjdnum);
if (zjdnum != 0)
{
int lock_token = 0;
ITKCALL(POM_refresh_instances_any_class(1, &one_instance, POM_no_lock));
ITKCALL(POM_ask_instance_lock(one_instance, &lock_token));
if (lock_token == POM_no_lock)
{
int n_levels = 2;
int where_to_search = POM_in_ds_and_db;
int n_ref_instances;
tag_t* ref_instances;
int* ref_instance_levels;
int* ref_instance_where_found;
int n_ref_classes;
tag_t* ref_classes;
int* class_levels;
int* class_where_found;
POM_referencers_of_instance(one_instance, n_levels, where_to_search, &n_ref_instances, &ref_instances, &ref_instance_levels, &ref_instance_where_found, &n_ref_classes, &ref_classes, &class_levels, &class_where_found);
// printf("id==%s的被%d个实例引用\n",counter_name1,n_ref_instances);
//printf("id==%s的被%d个类引用\n",counter_name1,n_ref_instances);
/*
for(int k=0;k<n_ref_instances;k++)
{
printf("ref_instances=======%u\n",ref_instances[k]);
}
for(int k=0;k<n_ref_classes;k++)
{
printf("ref_classes=======%u\n",ref_classes[k]);
}*/
ITKCALL(POM_delete_instances(1, &one_instance));
}
ret_instances[i] = NULLTAG;
//不管成功与否都要设置当前的instance为nulltag该instance不应再使用
MEM_free(occ_attr_value);
MEM_free(id_attr_value);
MEM_free(name_attr_value);
continue;
}
if (*the_item_id == NULL)
{
*the_item_id = (char*)MEM_alloc(sizeof(char) * (ITEM_id_size_c + 1));
tc_strcpy(*the_item_id, "");
}
if (tc_strcmp(*the_item_id, "") == 0)
{
tc_strcpy(*the_item_id, id_attr_value);
found_instance = one_instance;
}
else
{
if (tc_strcmp(*the_item_id, id_attr_value) > 0)
{
tc_strcpy(*the_item_id, id_attr_value);
found_instance = one_instance;
}
}
MEM_free(id_attr_value);
MEM_free(occ_attr_value);
MEM_free(name_attr_value);
}
else
{
MEM_free(name_attr_value);
continue;
}
}
if (found_instance != NULLTAG)
{
CALL(POM_ask_instance_lock(found_instance, &lock_token));
if (lock_token != POM_modify_lock)
{
CALL(POM_refresh_instances_any_class(1, &found_instance, POM_modify_lock));
CALL(POM_set_attr_string(1, &found_instance, occ_attr_id, "true"));
//刷新记录的修改时间,确保同一时刻不会再次被要出//liny
time(&now);
p = localtime(&now); /* 取得当前时间 */
modify_date.day = p->tm_mday;
modify_date.hour = p->tm_hour;
modify_date.minute = p->tm_min;
modify_date.month = p->tm_mon;
modify_date.second = p->tm_sec;
modify_date.year = p->tm_year + 1900;
CALL(POM_set_attr_date(1, &found_instance, createdate_attr_id, modify_date));
CALL(POM_save_instances(1, &found_instance, true));
}
}
MEM_free(instance_tags);
return ifail;
}
/************************************************************************/
/*
* Description: Query redundant item id from the recycle item id's table
* Function : SaveReduntantItemId
* Params : TeZhengMa - item id's TeZhengMa, usually, this is the item
* id counter's name
* : the_item_id - new created item id
* : occupied - indicate weather current item id was used, almost
* in every case its value is "true"
* Return : 0 - no error, else errors
*/
/************************************************************************/
//保存当前生产的新的itemid到系统的临时itemid表中
int SaveReduntantItemId(char* TeZhengMa, char* new_item_id, const char* occupied)
{
int ifail = ITK_ok;
tag_t
class_id = NULLTAG,
instance_tag = NULLTAG,
attr_id = NULLTAG;
date_t create_date;
struct tm* p;
time_t now;
const char* Temp_Pom_Class = "Cd9_CodeCounter";
CALL(POM_class_id_of_class(Temp_Pom_Class, &class_id));
CALL(POM_create_instance(class_id, &instance_tag));
CALL(POM_attr_id_of_attr(CodeCounter_index, Temp_Pom_Class, &attr_id));
int new_index = 0;
get_sequence_no("OACC", 8, 1, 99999999, 1, &new_index, "");
ITKCALL(POM_set_attr_int(1, &instance_tag, attr_id, new_index));
//now, set the TeZhengMa attribute of the new instance
CALL(POM_attr_id_of_attr(CodeCounter_name, Temp_Pom_Class, &attr_id));
CALL(POM_set_attr_string(1, &instance_tag, attr_id, TeZhengMa));
//set the Id attribute of the new instance
CALL(POM_attr_id_of_attr(CodeCounter_recycleID, Temp_Pom_Class, &attr_id));
CALL(POM_set_attr_string(1, &instance_tag, attr_id, new_item_id));
//set the Occ attribute of the new instance
CALL(POM_attr_id_of_attr(CodeCounter_isUsed, Temp_Pom_Class, &attr_id));
CALL(POM_set_attr_string(1, &instance_tag, attr_id, occupied));
/*
time(&now);
p = localtime(&now); // 取得当前时间
create_date.day = p->tm_mday;
create_date.hour = p->tm_hour;
create_date.minute = p->tm_min;
create_date.month = p->tm_mon;
create_date.second = p->tm_sec;
create_date.year = p->tm_year + 1900; */
CALL(POM_attr_id_of_attr(CodeCounter_createDate, Temp_Pom_Class, &attr_id));
ITKCALL(POM_set_attr_date(1, &instance_tag, attr_id, getCurrentDate()));
CALL(POM_attr_id_of_attr(CodeCounter_last_revise_date, Temp_Pom_Class, &attr_id));
CALL(POM_set_attr_date(1, &instance_tag, attr_id, getCurrentDate()));
CALL(POM_attr_id_of_attr(CodeCounter_createUser, Temp_Pom_Class, &attr_id));
ITKCALL(POM_set_attr_tag(1, &instance_tag, attr_id, getCurrentUser()));
CALL(POM_attr_id_of_attr(CodeCounter_last_revise_user, Temp_Pom_Class, &attr_id));
ITKCALL(POM_set_attr_tag(1, &instance_tag, attr_id, getCurrentUser()));
CALL(POM_save_instances(1, &instance_tag, TRUE));
//CALL( POM_refresh_instances_any_class( 1, &instance_tag, POM_no_lock ) );
//fprintf( stdout, "a new itemid %s created at %d/%d/%d\n", new_item_id, create_date.year, create_date.month, create_date.day );
return ifail;
}
/**
Removes the given object from the database.
@param tag_t object
*/
//#define TC_delete_msg "IMAN_delete"
int recycle_deleted_ItemID(METHOD_message_t* msg, va_list args)
{
int ifail = ITK_ok;
char buf[BUFSIZ] = "";
//retrieve the deleted object (will but not yet) from IMAN_delete msg
tag_t deleted_item = va_arg(args, tag_t);
//char deleted_item_id[ITEM_id_size_c + 1] = "";
//ITKCALL( ifail = ITEM_ask_id(deleted_item, deleted_item_id) );
if (ifail == ITK_ok)
{
char* pattern_code = NULL;
ITKCALL(ifail = AOM_ask_value_string(deleted_item, Item_codePattern, &pattern_code));
if (ifail == ITK_ok && pattern_code != NULL && strlen(pattern_code) > 0)
{
char* item_id;
ITKCALL(ifail = AOM_ask_value_string(deleted_item, Item_codeID, &item_id));
if (tc_strlen(item_id) > 0)
{
SaveReduntantItemId(pattern_code, item_id, "false");
}
MEM_free(pattern_code);
MEM_free(item_id);
}
}
return ITK_ok;
}
int recycleNewProjectId(METHOD_message_t* msg, va_list args)
{
int ifail = ITK_ok, i = 0;
tag_t project = NULLTAG;
//char project_id[ITEM_id_size_c + 1] = "";
char* project_id;
//char* project_idValue ;
const char
* Temp_Pom_Class = "Cd9_CodeCounter";
char
* id_attr_value = NULL;
tag_t
class_id = NULLTAG,
id_attr_id = NULLTAG;
//occ_attr_id = NULLTAG,
//createdate_attr_id = NULLTAG;
logical
include_subclasses = FALSE,
is_it_null = FALSE,
is_it_empty = FALSE,
find_deleted_instance = FALSE;
int
n_instance = 0,
lock_token = 0;
tag_t
* instance_tags = NULL,
one_instance = NULLTAG,
deleted_instance = NULLTAG;
//msg_item_tag = msg->object;
//CALL( ITEM_ask_item_of_rev( msg_item_tag, &item ) );
char* rule_name = NULL;
//project = msg->object_tag;
/* 无法获得按顺序第一个为id
project = va_arg( args, tag_t );
if (project == NULLTAG)
{
printf("FUNCTION : recycleNewProjectId.\nERROR : object tag is NULLTAG.\n");
return ifail;
}
*/
//ITKCALL(PROJ_ask_id( project, project_id ) );
//fprintf( stdout, "project_id == %s\n", project_id );
project_id = va_arg(args, char*);
//fprintf( stdout, "project_id == %s\n", project_id );
ITKCALL(POM_class_id_of_class(Temp_Pom_Class, &class_id));
ITKCALL(POM_attr_id_of_attr(CodeCounter_recycleID, Temp_Pom_Class, &id_attr_id));
ITKCALL(POM_instances_of_class(class_id, include_subclasses, &n_instance, &instance_tags));
//fprintf( stdout, "%d instances found\n", n_instance );
if (n_instance == 0) {
return ITK_ok;
}
//加载所有的实例,但是不要锁定
ITKCALL(POM_load_instances_any_class(n_instance, instance_tags, POM_no_lock));
for (i = 0; i < n_instance; i++)
{
one_instance = instance_tags[i];
ITKCALL(POM_ask_attr_string(one_instance, id_attr_id, &id_attr_value, &is_it_null, &is_it_empty));
if (tc_strcmp(id_attr_value, project_id) == 0 && find_deleted_instance == FALSE)
{
deleted_instance = one_instance;
find_deleted_instance = TRUE;
ITKCALL(POM_refresh_instances_any_class(1, &deleted_instance, POM_no_lock));
ITKCALL(POM_ask_instance_lock(deleted_instance, &lock_token));
if (lock_token == POM_no_lock)
{
ITKCALL(POM_delete_instances(1, &deleted_instance));
//fprintf( stdout, "\n\nDelete a instance, its id is %s\n\n", id_attr_value );
instance_tags[i] = NULLTAG;
}
MEM_free(id_attr_value);
break;
}
else
{
MEM_free(id_attr_value);
}
}
MEM_free(instance_tags);
return ifail;
}
int recycleNewItemId(METHOD_message_t* msg, va_list args)
{
int ifail = ITK_ok, i = 0;
tag_t item = NULLTAG;
//char item_id[ITEM_id_size_c + 1] = "";
char* item_id = NULL;
char* item_idValue;
const char
* Temp_Pom_Class = "Cd9_CodeCounter";
char
* id_attr_value = NULL;
tag_t
class_id = NULLTAG,
id_attr_id = NULLTAG;
//occ_attr_id = NULLTAG,
//createdate_attr_id = NULLTAG;
logical
include_subclasses = FALSE,
is_it_null = FALSE,
is_it_empty = FALSE,
find_deleted_instance = FALSE;
int
n_instance = 0,
lock_token = 0;
tag_t
* instance_tags = NULL,
one_instance = NULLTAG,
deleted_instance = NULLTAG;
//msg_item_tag = msg->object;
//CALL( ITEM_ask_item_of_rev( msg_item_tag, &item ) );
char* rule_name = NULL;
item = msg->object;
if (item == NULLTAG)
{
printf("FUNCTION : recycleRedundantItemId.\nERROR : object tag is NULLTAG.\n");
return ifail;
}
// tag_t deleted_item = va_arg( args, tag_t );
ITKCALL(ITEM_ask_id2(item, &item_id));
//fprintf( stdout, "item id %s\n", item_id );
ITKCALL(POM_class_id_of_class(Temp_Pom_Class, &class_id));
ITKCALL(POM_attr_id_of_attr(CodeCounter_recycleID, Temp_Pom_Class, &id_attr_id));
ITKCALL(POM_instances_of_class(class_id, include_subclasses, &n_instance, &instance_tags));
//fprintf( stdout, "%d instances found\n", n_instance );
if (n_instance == 0) {
return ITK_ok;
}
//加载所有的实例,但是不要锁定
ITKCALL(POM_load_instances_any_class(n_instance, instance_tags, POM_no_lock));
for (i = 0; i < n_instance; i++)
{
one_instance = instance_tags[i];
ITKCALL(POM_ask_attr_string(one_instance, id_attr_id, &id_attr_value, &is_it_null, &is_it_empty));
if (tc_strcmp(id_attr_value, item_id) == 0 && find_deleted_instance == FALSE)
{
deleted_instance = one_instance;
find_deleted_instance = TRUE;
ITKCALL(POM_refresh_instances_any_class(1, &deleted_instance, POM_no_lock));
ITKCALL(POM_ask_instance_lock(deleted_instance, &lock_token));
if (lock_token == POM_no_lock)
{
ITKCALL(POM_delete_instances(1, &deleted_instance));
//fprintf( stdout, "\n\nDelete a instance, its id is %s\n\n", id_attr_value );
instance_tags[i] = NULLTAG;
}
MEM_free(id_attr_value);
break;
}
else
{
MEM_free(id_attr_value);
}
}
MEM_free(instance_tags);
MEM_free(item_id);
return ifail;
}
/*
int recycle_ItemID( void *returnValue)
{
int ifail = ITK_ok;
char* class_name = "Cd9_CodeCounter";
char* codeID;;
int length=0,i=0;
USERARG_get_string_argument(&codeID);
tag_t class_id = NULLTAG;
ITKCALL(POM_class_id_of_class(class_name, &class_id));
//find all instance
int n_instances = 0, n_ret_instances = 0;
tag_t *instance_tags = NULL, *ret_instances = NULL;
ITKCALL(POM_instances_of_class(class_id, FALSE, &n_instances,
&instance_tags));
if (n_instances > 0)
{
ITKCALL(POM_load_instances_possible(n_instances, instance_tags, &n_ret_instances, &ret_instances));
}
for (int i = 0; i < n_ret_instances; ++i) {
tag_t bo_inst = ret_instances[i];
tag_t recycleID_attr_id = NULLTAG;
tag_t occ_attr_id = NULLTAG;
char *recycleID_value = NULL;
logical is_it_null = FALSE;
logical is_it_empty = FALSE;
ITKCALL( POM_attr_id_of_attr( CodeCounter_isUsed, class_name, &occ_attr_id ) );
ITKCALL(POM_attr_id_of_attr(CodeCounter_recycleID,
class_name, &recycleID_attr_id));
ITKCALL(POM_ask_attr_string(bo_inst,recycleID_attr_id,
&recycleID_value, &is_it_null, &is_it_empty));
// printf("recycleID_value=============%s\n",recycleID_value);
if( tc_strcmp( recycleID_value, codeID ) == 0 )
{
ITKCALL( POM_refresh_instances_any_class( 1, &ret_instances[i], POM_modify_lock ) );
ITKCALL( POM_set_attr_string( 1, &ret_instances[i], occ_attr_id, "false" ) );
ITKCALL(ifail = POM_save_instances(1, &ret_instances[i], false));
ITKCALL(ifail = POM_refresh_instances_any_class(1, &ret_instances[i], POM_no_lock));
MEM_free( recycleID_value );
break;
}
MEM_free( recycleID_value );
}
CALL( POM_unload_instances( n_instances, instance_tags ) );
MEM_free( codeID );
MEM_free( instance_tags );
MEM_free( ret_instances );
return ifail;
}*/
int delete_recycleID(void* returnValue)
{
int ifail = ITK_ok;
const char* class_name = "Cd9_CodeCounter";
char* codeID;;
int length = 0, i = 0;
USERARG_get_string_argument(&codeID);
tag_t class_id = NULLTAG;
ITKCALL(POM_class_id_of_class(class_name, &class_id));
//find all instance
int n_instances = 0, n_ret_instances = 0;
tag_t* instance_tags = NULL, * ret_instances = NULL;
ITKCALL(POM_instances_of_class(class_id, FALSE, &n_instances,
&instance_tags));
if (n_instances > 0)
{
ITKCALL(POM_load_instances_possible(n_instances, instance_tags, &n_ret_instances, &ret_instances));
}
for (int i = 0; i < n_ret_instances; ++i) {
tag_t bo_inst = ret_instances[i];
tag_t recycleID_attr_id = NULLTAG;
tag_t occ_attr_id = NULLTAG;
char* recycleID_value = NULL;
logical is_it_null = FALSE;
logical is_it_empty = FALSE;
ITKCALL(POM_refresh_instances_any_class(1, &bo_inst, POM_no_lock));
ITKCALL(POM_attr_id_of_attr(CodeCounter_isUsed, class_name, &occ_attr_id));
ITKCALL(POM_attr_id_of_attr(CodeCounter_recycleID,
class_name, &recycleID_attr_id));
ITKCALL(POM_ask_attr_string(bo_inst, recycleID_attr_id,
&recycleID_value, &is_it_null, &is_it_empty));
//printf("recycleID_value=============%s\n",recycleID_value);
//printf("codeID=============%s\n",codeID);
if (tc_strcmp(recycleID_value, codeID) == 0)
{
int lock_token = 0;
ITKCALL(POM_refresh_instances_any_class(1, &ret_instances[i], POM_no_lock));
ITKCALL(POM_ask_instance_lock(ret_instances[i], &lock_token));
if (lock_token == POM_no_lock)
{
ITKCALL(POM_delete_instances(1, &ret_instances[i]));
ret_instances[i] = NULLTAG;
}
MEM_free(recycleID_value);
break;
}
MEM_free(recycleID_value);
}
MEM_free(codeID);
MEM_free(instance_tags);
MEM_free(ret_instances);
return ifail;
}
#ifdef __cplusplus
}
#endif

@ -0,0 +1,53 @@
#include <user_exits\user_exits.h>
#include <tccore\item.h>
#include <tccore\aom_prop.h>
#include <tccore\tc_msg.h>
#include <pom\pom\pom.h>
#include <pom\enq\enq.h>
#include <string>
#include <map>
#include <stdlib.h>
#include <time.h>
#include<tc\tc_util.h>
#include<tc\preferences.h>
#include <ae\dataset.h>
#include "K_autocode_util.h"
#include "origin_PropNames.h"
#ifdef __cplusplus
extern "C" {
#endif
#define ECHO(X) printf X;
#define SYS_LOG(X) TC_write_syslog X;
#define LOG_ECHO(X) printf X; TC_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); \
} \
}
#define ITEM_POM_CLASS "ITEM"
int QueryReduntantItemId(char* TeZhengMa, char** the_item_id);
int recycle_ItemID(void* returnValue);
int recycle_deleted_ItemID(METHOD_message_t* msg, va_list args);
int SaveReduntantItemId(char* TeZhengMa, char* new_item_id, const char* occupied);
int recycleNewItemId(METHOD_message_t* msg, va_list args);
int recycleNewProjectId(METHOD_message_t* msg, va_list args);
int delete_recycleID(void* returnValue);
#ifdef __cplusplus
}
#endif

@ -0,0 +1,589 @@
#include "Connor_NX.h"
#include "origin_PropNames.h"
#include <list>
#include <sa/groupmember.h>
using namespace std;
#ifdef __cplusplus
extern "C" {
#endif
//void map_insert(map < string, string >* strmap, string index, string x)
//{
// //printf("map_insert==1 =====\n");
// //strmap->insert(map < string, string >::value_type(index, x));
// strmap->insert(pair< string, string >(index, x));
// // printf("map_insert==2 =====\n");
//}
void init_search_criteria_map(string searchStr, SearchCriterionInputs &searchCriteria) {
vector<string> searchStrSplit;
// printf("Search AutoCode_Node: %s \n", searchStr.c_str());
Split(searchStr, SPLITTER, searchStrSplit);
int length = searchStrSplit.size();
for (int i = 0; i < length; i++) {
string str = searchStrSplit[i];
int ind = str.find_first_of('=');
if (ind <= 0) {
continue;
}
string s1 = str.substr(0, ind);
string s2 = str.substr(ind + 1);
map_insert(&searchCriteria, s1, s2);
}
}
void init_search_criteria_vector(string searchStr, vector<string> &propNames, vector<string> &propValues) {
vector<string> searchStrSplit;
// printf("Search AutoCode_Node: %s \n", searchStr.c_str());
Split(searchStr, SPLITTER, searchStrSplit);
int length = searchStrSplit.size();
for (int i = 0; i < length; i++) {
string str = searchStrSplit[i];
int ind = str.find_first_of('=');
if (ind <= 0) {
continue;
}
string s1 = str.substr(0, ind);
string s2 = str.substr(ind + 1);
propNames.push_back(s1);
propValues.push_back(s2);
}
}
int SEARCH_AUTOCODE_USER(const std::string& searchStr, std::string& res) {
int ifail = ITK_ok;
const char* class_name = "Cd9_ClassificationCodeNode";
RetData retData;
SearchCriterionInputs searchCriteria;
init_search_criteria_map(searchStr, searchCriteria);
//get class id and attr id
tag_t class_id = NULLTAG;
ITKCALL(POM_class_id_of_class(class_name, &class_id));
std::map<string, tag_t> prop_to_attrid;
std::map<string, string> prop_value_type;
for (SearchCriterionInputs::const_iterator searchIter =
searchCriteria.begin(); searchIter != searchCriteria.end(); searchIter++) {
tag_t attr_id = NULLTAG;
ITKCALL(POM_attr_id_of_attr(searchIter->first.c_str(),
class_name, &attr_id));
if (prop_to_attrid.find(searchIter->first) == prop_to_attrid.end()) {
prop_to_attrid.insert(make_pair(searchIter->first, attr_id));
if (searchIter->first.compare(ClassificationCodeNode_node_name) == 0
|| searchIter->first.compare(ClassificationCodeNode_segment) == 0
) {
prop_value_type.insert(make_pair(searchIter->first,
"String"));
continue;
}
}
}
//find all instance
int n_instances = 0, n_ret_instances = 0;
tag_t* instance_tags = NULL, * ret_instances = NULL;
ITKCALL(POM_instances_of_class(class_id, FALSE, &n_instances,
&instance_tags));
if (n_instances > 0)
{
ITKCALL(POM_load_instances_possible(n_instances, instance_tags, &n_ret_instances, &ret_instances));
}
for (int i = 0; i < n_ret_instances; ++i) {
tag_t bo_inst = ret_instances[i];
logical is_same = TRUE;
for (SearchCriterionInputs::const_iterator searchIter =
searchCriteria.begin(); searchIter != searchCriteria.end(); searchIter++) {
std::map<string, tag_t>::iterator prop_to_attrid_iter =
prop_to_attrid.find(searchIter->first);
std::map<string, string>::iterator prop_value_type_iter =
prop_value_type.find(searchIter->first);
if (prop_value_type_iter->second.compare("String") == 0) {
char* str_val = NULL;
logical is_it_null = FALSE;
logical is_it_empty = FALSE;
ITKCALL(POM_ask_attr_string(bo_inst, prop_to_attrid_iter->second,
&str_val, &is_it_null, &is_it_empty));
if ((is_it_empty || is_it_null) && ((tc_strlen(searchIter->second.c_str()) == 0) || (searchIter->second.c_str() == NULL)))
{
continue;
}
if (tc_strcmp(searchIter->second.c_str(), str_val) != 0) {
is_same = FALSE;
MEM_free(str_val);
break;
}
MEM_free(str_val);
}
}
if (is_same) {
tag_t attr_id = NULLTAG;
logical* is_it_null = FALSE, * is_it_empty = FALSE;
tag_t* values;
int targetNum = 0;
ITKCALL(POM_attr_id_of_attr(ClassificationCodeNode_grant_users, class_name, &attr_id));
POM_length_of_attr(bo_inst, attr_id, &targetNum);
if (targetNum > 0) {
ITKCALL(POM_ask_attr_tags(bo_inst, attr_id, 0, targetNum, &values, &is_it_null, &is_it_empty));
for (int i = 0; i < targetNum; i++)
{
if (values[i] != NULLTAG)
{
retData.insert(retData.end(), values[i]);
}
}
}
ITKCALL(POM_attr_id_of_attr(ClassificationCodeNode_grant_roles, class_name, &attr_id));
POM_length_of_attr(bo_inst, attr_id, &targetNum);
if (targetNum > 0) {
ITKCALL(POM_ask_attr_tags(bo_inst, attr_id, 0, targetNum, &values, &is_it_null, &is_it_empty));
for (int i = 0; i < targetNum; i++)
{
if (values[i] != NULLTAG)
{
retData.insert(retData.end(), values[i]);
}
}
}
ITKCALL(POM_attr_id_of_attr(ClassificationCodeNode_grant_groups, class_name, &attr_id));
POM_length_of_attr(bo_inst, attr_id, &targetNum);
if (targetNum > 0) {
ITKCALL(POM_ask_attr_tags(bo_inst, attr_id, 0, targetNum, &values, &is_it_null, &is_it_empty));
for (int i = 0; i < targetNum; i++)
{
if (values[i] != NULLTAG)
{
retData.insert(retData.end(), values[i]);
}
}
}
MEM_free(is_it_null);
MEM_free(is_it_empty);
}
continue;
}
int arraySize = 0;
tag_t* tag_array;
USERSERVICE_array_t arrayStruct;
arraySize = retData.size();
tag_array = (tag_t*)MEM_alloc(arraySize * sizeof(tag_t));
//printf("arraySize=======%d\n",arraySize);
RetDataIterator retDataIterator = retData.begin();
for (int i = 0; i < arraySize; i++)
{
char* uid = NULL;
tag_array[i] = static_cast<tag_t>(*retDataIterator);
//printf("tag_array[i]=======%u\n",tag_array[i]);
ITK__convert_tag_to_uid(tag_array[i], &uid);
if (uid != NULL) {
res.append(uid).append(SPLITTER);
}
++retDataIterator;
DOFREE(uid);
}
/*ITKCALL(USERSERVICE_return_tag_array(tag_array, arraySize,
&arrayStruct));
if (arrayStruct.length != 0) {
*((USERSERVICE_array_t*)returnValue) = arrayStruct;
}*/
MEM_free(instance_tags);
MEM_free(ret_instances);
MEM_free(tag_array);
return ifail;
}
int SEARCH_AUTOCODE_SEGMENT(const std::string& searchStr, std::string& res) {
int ifail = ITK_ok;
const char* class_name = "Cd9_ClassificationCodeNode";
RetData retData;
SearchCriterionInputs searchCriteria;
init_search_criteria_map(searchStr, searchCriteria);
tag_t class_id = NULLTAG;
ITKCALL(POM_class_id_of_class(class_name, &class_id));
std::map<string, tag_t> prop_to_attrid;
std::map<string, string> prop_value_type;
for (SearchCriterionInputs::const_iterator searchIter =
searchCriteria.begin(); searchIter != searchCriteria.end(); searchIter++) {
tag_t attr_id = NULLTAG;
ITKCALL(POM_attr_id_of_attr(searchIter->first.c_str(),
class_name, &attr_id));
if (prop_to_attrid.find(searchIter->first) == prop_to_attrid.end()) {
prop_to_attrid.insert(make_pair(searchIter->first, attr_id));
if (searchIter->first.compare(ClassificationCodeNode_node_name) == 0) {
prop_value_type.insert(make_pair(searchIter->first,
"String"));
continue;
}
}
else
if (searchIter->first.compare(ClassificationCodeNode_grant_users) == 0
|| searchIter->first.compare(ClassificationCodeNode_grant_roles) == 0
|| searchIter->first.compare(ClassificationCodeNode_grant_groups) == 0
) {
prop_value_type.insert(make_pair(searchIter->first,
"TCComponents"));
continue;
}
}
int n_instances = 0, n_ret_instances = 0;
tag_t* instance_tags = NULL, * ret_instances = NULL;
ITKCALL(POM_instances_of_class(class_id, FALSE, &n_instances,
&instance_tags));
if (n_instances > 0)
{
ITKCALL(POM_load_instances_possible(n_instances, instance_tags, &n_ret_instances, &ret_instances));
}
for (int i = 0; i < n_ret_instances; ++i) {
tag_t bo_inst = ret_instances[i];
logical is_same = TRUE;
int nullUserCount = 0;
for (SearchCriterionInputs::const_iterator searchIter =
searchCriteria.begin(); searchIter != searchCriteria.end(); searchIter++) {
std::map<string, tag_t>::iterator prop_to_attrid_iter =
prop_to_attrid.find(searchIter->first);
std::map<string, string>::iterator prop_value_type_iter =
prop_value_type.find(searchIter->first);
if (prop_value_type_iter->second.compare("String") == 0) {
char* str_val = NULL;
logical is_it_null = FALSE;
logical is_it_empty = FALSE;
ITKCALL(POM_ask_attr_string(bo_inst, prop_to_attrid_iter->second,
&str_val, &is_it_null, &is_it_empty));
if ((is_it_empty || is_it_null) && ((tc_strlen(searchIter->second.c_str()) == 0) || (searchIter->second.c_str() == NULL)))
{
continue;
}
if (tc_strcmp(searchIter->second.c_str(), str_val) != 0) {
is_same = FALSE;
MEM_free(str_val);
break;
}
MEM_free(str_val);
}
else {
if (prop_value_type_iter->second.compare("TCComponents") == 0) {
}
}
}
if (is_same) {
tag_t attr_id = NULLTAG;
logical is_it_null = FALSE, is_it_empty = FALSE;
char* strValues = NULL;
ITKCALL(POM_attr_id_of_attr(ClassificationCodeNode_segment, class_name, &attr_id));
ITKCALL(POM_ask_attr_string(bo_inst, attr_id, &strValues, &is_it_null, &is_it_empty));
if (tc_strlen(strValues) == 0)
{
continue;
}
std::vector< std::string > searched_tags;
Split(strValues, ",", searched_tags);
for (int i = 0; i < (int)searched_tags.size(); i++)
{
if (tc_strlen(searched_tags[i].c_str()) > 0)
{
tag_t ref_obj = NULLTAG;
ITKCALL(POM_string_to_tag(searched_tags[i].c_str(), &ref_obj));
if (ref_obj != NULLTAG)
{
retData.insert(retData.end(), ref_obj);
}
}
}
MEM_free(strValues);
}
continue;
}
int arraySize = 0;
tag_t* tag_array;
USERSERVICE_array_t arrayStruct;
arraySize = retData.size();
tag_array = (tag_t*)MEM_alloc(arraySize * sizeof(tag_t));
//printf("arraySize=======%d\n",arraySize);
RetDataIterator retDataIterator = retData.begin();
for (int i = 0; i < arraySize; i++)
{
char* uid = NULL;
tag_array[i] = static_cast<tag_t>(*retDataIterator);
ITK__convert_tag_to_uid(tag_array[i], &uid);
if (uid != NULL) {
res.append(uid).append(SPLITTER);
}
DOFREE(uid);
//printf("tag_array[i]=======%u\n",tag_array[i]);
++retDataIterator;
}
MEM_free(instance_tags);
MEM_free(ret_instances);
MEM_free(tag_array);
return ifail;
}
int SEARCH_AUTOCODE_NODE(const std::string& searchStr, std::string& res) {
int ifail = ITK_ok;
const char* class_name = "Cd9_ClassificationCodeNode";
RetData retData;
SearchCriterionInputs searchCriteria;
int length = 0, i = 0;
std::map<string, tag_t> prop_to_attrid;
std::map<string, string> prop_value_type;
tag_t class_id = NULLTAG;
int n_instances = 0, n_ret_instances = 0;
tag_t* instance_tags = NULL, * ret_instances = NULL;
tag_t* tag_array = NULL;
// printf("Search AutoCode_Node: %s \n", searchStr.c_str());
init_search_criteria_map(searchStr, searchCriteria);
ITKCALL(POM_class_id_of_class(class_name, &class_id));
for (SearchCriterionInputs::const_iterator searchIter =
searchCriteria.begin(); searchIter != searchCriteria.end(); searchIter++) {
tag_t attr_id = NULLTAG;
ITKCALL(POM_attr_id_of_attr(searchIter->first.c_str(),
class_name, &attr_id));
if (prop_to_attrid.find(searchIter->first) == prop_to_attrid.end()) {
prop_to_attrid.insert(make_pair(searchIter->first, attr_id));
if (searchIter->first.compare(ClassificationCodeNode_node_name) == 0
|| searchIter->first.compare(ClassificationCodeNode_segment) == 0) {
prop_value_type.insert(make_pair(searchIter->first,
"String"));
continue;
}
else
if (searchIter->first.compare(ClassificationCodeNode_grant_users) == 0
|| searchIter->first.compare(ClassificationCodeNode_grant_roles) == 0
|| searchIter->first.compare(ClassificationCodeNode_grant_groups) == 0
) {
prop_value_type.insert(make_pair(searchIter->first,
"TCComponents"));
continue;
}
}
}
//find all instance
ITKCALL(POM_instances_of_class(class_id, FALSE, &n_instances,
&instance_tags));
if (n_instances > 0)
{
ITKCALL(POM_load_instances_possible(n_instances, instance_tags, &n_ret_instances, &ret_instances));
}
for (int i = 0; i < n_ret_instances; ++i) {
tag_t bo_inst = ret_instances[i];
logical is_same = TRUE;
int nullUserCount = 0;
for (SearchCriterionInputs::const_iterator searchIter =
searchCriteria.begin(); searchIter != searchCriteria.end(); searchIter++) {
std::map<string, tag_t>::iterator prop_to_attrid_iter =
prop_to_attrid.find(searchIter->first);
std::map<string, string>::iterator prop_value_type_iter =
prop_value_type.find(searchIter->first);
//printf("searchIter->first===========%s\n",searchIter->first.c_str());
//printf("searchIter->second.c_str()==========%s\n\n",searchIter->second.c_str());
if (prop_value_type_iter->second.compare("String") == 0) {
char* str_val = NULL;
logical is_it_null = FALSE;
logical is_it_empty = FALSE;
ITKCALL(POM_ask_attr_string(bo_inst, prop_to_attrid_iter->second,
&str_val, &is_it_null, &is_it_empty));
//printf("searchIter->second.c_str()=======%s\n",searchIter->second.c_str());
if ((is_it_empty || is_it_null) && ((tc_strlen(searchIter->second.c_str()) == 0) || (searchIter->second.c_str() == NULL)))
{
continue;
}
if (tc_strcmp(searchIter->second.c_str(), str_val) != 0) {
is_same = FALSE;
MEM_free(str_val);
break;
}
MEM_free(str_val);
}
else {
if (prop_value_type_iter->second.compare("TCComponents") == 0) {
logical* is_it_null = FALSE, * is_it_empty = FALSE;
tag_t* values;
int targetNum = 0, m = 0;
tag_t currentGroupTag;
if (tc_strlen(searchIter->second.c_str()) == 0)
{
continue;
}
ITKCALL(POM_string_to_tag(searchIter->second.c_str(), &currentGroupTag));
if (currentGroupTag == NULLTAG)
{
continue;
}
POM_length_of_attr(bo_inst, prop_to_attrid_iter->second, &targetNum);
if (targetNum == 0)
{
nullUserCount = nullUserCount + 1;
continue;
}
if (targetNum > 0) {
logical isEqual = FALSE;
ITKCALL(POM_ask_attr_tags(bo_inst, prop_to_attrid_iter->second, 0, targetNum, &values, &is_it_null, &is_it_empty));
for (int m = 0; m < targetNum; m++)
{
char* user;
ITKCALL(POM_tag_to_string(values[m], &user));
if (tc_strcmp(user, searchIter->second.c_str()) == 0)
{
// printf("searchIter->first.c_str()=======%s\n",searchIter->first.c_str());
isEqual = TRUE;
continue;
}
//char objectType[TCTYPE_class_name_size_c+1]="";
char* objectType = NULL;
tag_t typetag;
ITKCALL(TCTYPE_ask_object_type(values[m], &typetag));
TCTYPE_ask_class_name2(typetag, &objectType);
if (tc_strcmp("Group", objectType) != 0)
{
MEM_free(user);
MEM_free(objectType);
continue;
}
MEM_free(objectType);
tag_t parent1;
char* parentString1;
SA_ask_group_parent(currentGroupTag, &parent1);
if (parent1 == NULLTAG)
{
MEM_free(user);
continue;
}
ITKCALL(POM_tag_to_string(parent1, &parentString1));
if (tc_strcmp(parentString1, user) == 0)
{
isEqual = TRUE;
MEM_free(user);
MEM_free(parentString1);
continue;
}
MEM_free(parentString1);
tag_t parent2;
char* parentString2;
SA_ask_group_parent(parent1, &parent2);
if (parent2 == NULLTAG)
{
MEM_free(user);
continue;
}
ITKCALL(POM_tag_to_string(parent2, &parentString2));
if (tc_strcmp(parentString2, user) == 0)
{
isEqual = TRUE;
MEM_free(user);
MEM_free(parentString2);
continue;
}
else
{
MEM_free(user);
MEM_free(parentString2);
continue;
}
}
MEM_free(values);
MEM_free(is_it_null);
MEM_free(is_it_empty);
if (isEqual == FALSE)
{
nullUserCount = nullUserCount + 1;
}
}
}
}
}
if (is_same) {
// printf("is_same=======%d\n",is_same);
if (nullUserCount < 3)
{
retData.insert(retData.end(), bo_inst);
}
}
continue;
}
{
int arraySize = 0;
USERSERVICE_array_t arrayStruct;
arraySize = retData.size();
tag_array = (tag_t*)MEM_alloc(arraySize * sizeof(tag_t));
//printf("arraySize=======%d\n",arraySize);
RetDataIterator retDataIterator = retData.begin();
for (i = 0; i < arraySize; i++)
{
char* uid = NULL;
tag_array[i] = static_cast<tag_t>(*retDataIterator);
ITK__convert_tag_to_uid(tag_array[i], &uid);
if (uid != NULL) {
res.append(uid).append(SPLITTER);
}
//printf("tag_array[i]=======%u\n",tag_array[i]);
++retDataIterator;
DOFREE(uid);
}
}
search_autocode_node_end:
DOFREE(instance_tags);
DOFREE(ret_instances);
DOFREE(tag_array);
return ifail;
}
#ifdef __cplusplus
}
#endif

@ -0,0 +1,279 @@
#include "Connor_NX.h"
#include "origin_PropNames.h"
#include <sa/groupmember.h>
#include <pom/enq/enq.h>
#ifdef __cplusplus
extern "C" {
#endif
const char* getChildrenNodesString(vector<string> propNames, vector<string> propValues, int length)
{
int ifail = ITK_ok;
const char* class_name = "Cd9_CodeRelation";
const char* selectTreeNode = "Select Cd9_CodeRelation1";
const char* select_nextidAttrs[1] = { CodeRelation_children_nodes };
int rows, cols;
void*** report = NULL;
int i = 0;
const char* strValues;
ITKCALL(POM_enquiry_create(selectTreeNode));
ITKCALL(POM_enquiry_add_select_attrs(selectTreeNode, class_name,
1, (const char**)select_nextidAttrs));
if (length == 1)
{
if (tc_strlen(propValues[0].c_str()) == 0)
{
ifail = POM_enquiry_set_attr_expr(selectTreeNode, "expr1", class_name, propNames[0].c_str(), POM_enquiry_is_null, NULL);
}
else
{
const char* temp = propValues[0].c_str();
ifail = POM_enquiry_set_string_value(selectTreeNode, "prop1", 1, (const char**)&temp, POM_enquiry_bind_value);
ifail = POM_enquiry_set_attr_expr(selectTreeNode, "expr1", class_name, propNames[0].c_str(), POM_enquiry_equal, "prop1");
}
ifail = POM_enquiry_set_where_expr(selectTreeNode, "expr1");
}
else {
if (tc_strlen(propValues[0].c_str()) == 0)
{
ifail = POM_enquiry_set_attr_expr(selectTreeNode, "expr1", class_name, propNames[0].c_str(), POM_enquiry_is_null, NULL);
}
else
{
const char* temp = propValues[0].c_str();
ifail = POM_enquiry_set_string_value(selectTreeNode, "prop1", 1, (const char**)&temp, POM_enquiry_bind_value);
ifail = POM_enquiry_set_attr_expr(selectTreeNode, "expr1", class_name, propNames[0].c_str(), POM_enquiry_equal, "prop1");
}
if (tc_strlen(propValues[1].c_str()) == 0)
{
ifail = POM_enquiry_set_attr_expr(selectTreeNode, "expr2", class_name, propNames[1].c_str(), POM_enquiry_is_null, NULL);
}
else
{
const char* temp = propValues[1].c_str();
ifail = POM_enquiry_set_string_value(selectTreeNode, "prop2", 1, (const char**)&temp, POM_enquiry_bind_value);
ifail = POM_enquiry_set_attr_expr(selectTreeNode, "expr2", class_name, propNames[1].c_str(), POM_enquiry_equal, "prop2");
}
POM_enquiry_set_expr(selectTreeNode, "expr", "expr1", POM_enquiry_and, "expr2");
ifail = POM_enquiry_set_where_expr(selectTreeNode, "expr");
}
ITKCALL(POM_enquiry_execute(selectTreeNode, &rows, &cols, &report));
//printf("nextidRows===============%d\n",rows);
if (rows > 0)
{
strValues = (char*)report[0][0];
}
else
{
strValues = "";
}
POM_enquiry_delete(selectTreeNode);
return strValues;
}
int isContainChildrenNode(vector<string> propNames, vector<string>propValues, int length)
{
int returnValue = 0;;
const char* value = getChildrenNodesString(propNames, propValues, length);
if (tc_strlen(value) > 0)
{
returnValue = 1;
}
return returnValue;
}
int SEARCH_TREE_OR_LIST_NODE(const std::string& searchStr, std::string& res) {
int ifail = ITK_ok;
const char* class_name = "Cd9_CodeRelation";
int i = 0;
int length = 0;
vector<string> propNames;
vector<string> propValues;
//clock_t start, finish;
//double duration;
//start = clock();
init_search_criteria_vector(searchStr, propNames, propValues);
length = propNames.size();
const char* strValues = getChildrenNodesString(propNames, propValues, length);
if (tc_strlen(strValues) > 0)
{
int arraySize = 0;
std::vector< std::string > searched_tags;
Split(strValues, ",", searched_tags);
arraySize = (int)searched_tags.size();
for (int i = 0; i < (int)searched_tags.size(); i++)
{
if (tc_strlen(searched_tags[i].c_str()) > 0)
{
tag_t ref_obj = NULLTAG;
ITKCALL(POM_string_to_tag(searched_tags[i].c_str(), &ref_obj));
if (ref_obj != NULLTAG)
{
res.append(searched_tags[i].c_str()).append(SPLITTER);
}
}
}
}
//finish = clock();
//duration = (double)(finish - start) / CLOCKS_PER_SEC;
//printf("%f seconds²éѯʱ¼ä\n",duration);
propNames.clear();
propValues.clear();
return ifail;
}
int IS_CONTAIN_CHILD_NODE(const std::string& searchStr, std::string& res)
{
int ifail = ITK_ok;
const char* class_name = "Cd9_CodeRelation";
RetData retData;
vector<string> propNames;
vector<string> propValues;
int length = 0, i = 0;
/*ITKCALL(ifail = USERARG_get_string_array_argument(&length, &propNames));
ITKCALL(ifail = USERARG_get_string_array_argument(&length, &propValues));
for (i = 0; i < length; i++)
{
string s1 = (propNames[i]);
string s2 = (propValues[i]);
}*/
init_search_criteria_vector(searchStr, propNames, propValues);
length = propNames.size();
int isContains = isContainChildrenNode(propNames, propValues, length);
char* returnData;
returnData = (char*)MEM_alloc(5 * sizeof(char));
if (isContains == 1)
{
tc_strcpy(returnData, "true");
}
else
{
tc_strcpy(returnData, "false");
}
res.append(returnData);
propNames.clear();
propValues.clear();
return ifail;
}
int SEARCH_PARENT_TREE_OR_LIST_NODE(const std::string& searchStr, std::string& res) {
int ifail = ITK_ok;
const char* class_name = "Cd9_CodeRelation";
SearchCriterionInputs searchCriteria;
init_search_criteria_map(searchStr, searchCriteria);
tag_t class_id = NULLTAG;
ITKCALL(POM_class_id_of_class(class_name, &class_id));
std::map<string, tag_t> prop_to_attrid;
std::map<string, string> prop_value_type;
for (SearchCriterionInputs::const_iterator searchIter =
searchCriteria.begin(); searchIter != searchCriteria.end(); searchIter++) {
tag_t attr_id = NULLTAG;
ITKCALL(POM_attr_id_of_attr(searchIter->first.c_str(),
class_name, &attr_id));
if (prop_to_attrid.find(searchIter->first) == prop_to_attrid.end()) {
prop_to_attrid.insert(make_pair(searchIter->first, attr_id));
if (searchIter->first.compare(CodeRelation_children_nodes) == 0
|| searchIter->first.compare(CodeRelation_current_node) == 0) {
prop_value_type.insert(make_pair(searchIter->first,
"String"));
continue;
}
}
}
//find all instance
int n_instances = 0, n_ret_instances = 0;
tag_t* instance_tags = NULL, * ret_instances = NULL;
ITKCALL(POM_instances_of_class(class_id, FALSE, &n_instances,
&instance_tags));
if (n_instances > 0)
{
ITKCALL(POM_load_instances_possible(n_instances, instance_tags, &n_ret_instances, &ret_instances));
}
for (int i = 0; i < n_ret_instances; ++i) {
tag_t bo_inst = ret_instances[i];
logical is_same = TRUE;
for (SearchCriterionInputs::const_iterator searchIter =
searchCriteria.begin(); searchIter != searchCriteria.end(); searchIter++) {
std::map<string, tag_t>::iterator prop_to_attrid_iter =
prop_to_attrid.find(searchIter->first);
std::map<string, string>::iterator prop_value_type_iter =
prop_value_type.find(searchIter->first);
//printf("searchIter->first===========%s\n",searchIter->first.c_str());
//printf("searchIter->second.c_str()==========%s\n\n",searchIter->second.c_str());
if (prop_value_type_iter->second.compare("String") == 0) {
char* str_val = NULL;
logical is_it_null = FALSE;
logical is_it_empty = FALSE;
ITKCALL(POM_ask_attr_string(bo_inst, prop_to_attrid_iter->second,
&str_val, &is_it_null, &is_it_empty));
if ((is_it_empty || is_it_null) && ((tc_strlen(searchIter->second.c_str()) == 0) || (searchIter->second.c_str() == NULL)))
{
continue;
}
if (tc_strcmp(searchIter->second.c_str(), str_val) != 0) {
is_same = FALSE;
MEM_free(str_val);
break;
}
MEM_free(str_val);
}
}
if (is_same) {
tag_t attr_id = NULLTAG;
logical is_it_null = FALSE, is_it_empty = FALSE;
char* strValues = NULL;
ITKCALL(POM_attr_id_of_attr(CodeRelation_parent_nodes, class_name, &attr_id));
ITKCALL(POM_ask_attr_string(bo_inst, attr_id, &strValues, &is_it_null, &is_it_empty));
if (is_it_empty || is_it_null)
{
continue;
}
std::vector< std::string > searched_tags;
Split(strValues, ",", searched_tags);
for (int i = 0; i < (int)searched_tags.size(); i++)
{
if (tc_strlen(searched_tags[i].c_str()) > 0)
{
tag_t ref_obj = NULLTAG;
ITKCALL(POM_string_to_tag(searched_tags[i].c_str(), &ref_obj));
if (ref_obj != NULLTAG)
{
res.append(searched_tags[i]).append(SPLITTER);
}
}
}
MEM_free(strValues);
}
continue;
}
MEM_free(instance_tags);
MEM_free(ret_instances);
// MEM_free(tag_array);
return ifail;
}
#ifdef __cplusplus
}
#endif

@ -0,0 +1,378 @@
#include "Connor_NX.h"
using namespace std;
//#define PROPNAME_CLONE "object_desc"
//#define PROPVALUE_CLONE "clone"
//#define IMAGE_DSNAME_SANWEI "三维简图.bmp"
//#define IMAGE_DSNAME_ERWEI "二维简图.bmp"
#define PREF_NX_TEMPLATE "Connor_NXBomClone"
string PROPNAME_CLONE, PROPVALUE_CLONE, IMAGE_DSNAME_SANWEI, IMAGE_DSNAME_ERWEI, INPUT_SUFFIX;
string err;
int Get_New_ID(tag_t item_type_tag, char** new_item_id) {
int ifail = ITK_ok;
logical isModified = FALSE;
ITKCALL(ifail = USER_new_item_id(NULLTAG, item_type_tag, &isModified, new_item_id));
return ifail;
}
int Get_New_ID(tag_t item_type_tag, string old_id, string suffix, string &new_item_id) {
int ifail = ITK_ok;
logical isModified = FALSE;
logical exist = true;
printf("Get New ID From: %s\n", old_id.c_str());
if (old_id.length() <= 4) {
exist = false;
char* newid = NULL;
ITKCALL(ifail = USER_new_item_id(NULLTAG, item_type_tag, &isModified, &newid));
if (ifail != ITK_ok) {
goto end;
}
new_item_id.append(newid);
DOFREE(newid);
printf("Use Assigned ID: %s\n", new_item_id.c_str());
}
else {
string featureCode = old_id.substr(0, 4);
featureCode.append(suffix);
int ii = 0;
string temp_id = "";
ifail = QUERY_PART_NO(featureCode, temp_id);
if (ifail != ITK_ok) {
goto end;
}
printf("Autocode ID: %s\n", temp_id.c_str());
ITKCALL(ifail = ITEM_id_exists(temp_id.c_str(), &exist));
if (ifail != ITK_ok) {
goto end;
}
while (exist && ii != 15) {
ii++;
temp_id = "";
string delete_resp="";
ifail = QUERY_PART_NO(featureCode, temp_id);
if (ifail != ITK_ok) {
goto end;
}
printf("再次尝试获取 ID: %s\n", temp_id.c_str());
DELETE_RECYCLE_ID(temp_id, delete_resp);
ITKCALL(ITEM_id_exists(temp_id.c_str(), &exist));
}
ITKCALL(ITEM_id_exists(temp_id.c_str(), &exist));
new_item_id.append(temp_id);
if (exist) {
err.append("获取新编码失败:").append(old_id);
printf("获取ID失败!\n");
ifail = OUTPUT_CODE_ERROR;
}
}
end:
return ifail;
}
int Check_Rev(tag_t rev_tag, std::string& res, vector<string>& checkedIDs, bool is_top_line) {
int ifail = ITK_ok;
tag_t item_tag = NULLTAG;
char *item_id = NULL, *rev_id = NULL, *prop_value = NULL;
char * new_rev_id = NULL;
tag_t tType = NULLTAG;
logical isModified = FALSE;
string id_str, new_item_id;
if (!is_top_line) {
ITKCALL(ifail = AOM_ask_value_string(rev_tag, PROPNAME_CLONE.c_str(), &prop_value));
if (ifail != ITK_ok || strcmp(PROPVALUE_CLONE.c_str(), prop_value) != 0) {
goto check_rev_end;
}
}
ITKCALL(ifail = ITEM_ask_item_of_rev(rev_tag, &item_tag));
if (item_tag == NULLTAG) {
goto check_rev_end;
}
ITKCALL(ifail = AOM_ask_value_string(item_tag, "item_id", &item_id));
if (ifail != ITK_ok) {
goto check_rev_end;
}
if(inArray(checkedIDs, item_id)){
goto check_rev_end;
}
id_str.append(item_id);
ITKCALL(ifail = TCTYPE_ask_object_type(item_tag, &tType));
ITKCALL(ifail = AOM_ask_value_string(rev_tag, "item_revision_id", &rev_id));
ITKCALL(ifail = Get_New_ID(tType, id_str, INPUT_SUFFIX, new_item_id));
if (ifail != ITK_ok) {
res.clear();
res.append(err);
goto check_rev_end;
}
ITKCALL(ifail = USER_new_revision_id(NULLTAG, tType, &isModified, &new_rev_id));
res.append(SPLITTER);
res.append("@DB/").append(item_id).append("/").append(rev_id);
res.append("=");
res.append("@DB/").append(new_item_id).append("/").append(new_rev_id);
checkedIDs.push_back(item_id);
check_rev_end:
DOFREE(item_id);
DOFREE(rev_id);
DOFREE(new_rev_id);
DOFREE(prop_value);
return ifail;
}
int Cycle_BOM(tag_t bomline, std::string& res, vector<string>& checkedIDs, bool is_top_line){
int ifail = ITK_ok, child_cnt = 0;
tag_t rev_tag = NULLTAG, *child_lines = NULL;
ITKCALL(ifail = AOM_ask_value_tag(bomline, "bl_revision", &rev_tag));
ifail = Check_Rev(rev_tag, res, checkedIDs, is_top_line);
if (ifail != ITK_ok) {
goto cycle_bom_end;
}
ITKCALL(ifail = BOM_line_ask_child_lines(bomline, &child_cnt, &child_lines));
for (int i = 0;i < child_cnt;i++) {
ifail = Cycle_BOM(child_lines[i], res, checkedIDs, false);
if (ifail != ITK_ok) {
goto cycle_bom_end;
}
}
DOFREE(child_lines);
cycle_bom_end:
return ifail;
}
int Read_NX_Image_By_ID(const std::string& itemID, std::string& res) {
int ifail = ITK_ok, release_flag = 0;
int pref_len = 0, ds_count = 0;
char* object_string = NULL;
char* rev_id = NULL;
string erwei_file, sanwei_file;
tag_t item_tag = NULLTAG;
tag_t rev_tag = NULLTAG;
tag_t* ds_tags = NULL;
vector<string> checkedIDs;
vector<string> prefVals;
POM_AM__set_application_bypass(true);
getPrefStrings(PREF_NX_TEMPLATE, TC_preference_site, prefVals);
if (prefVals.size() != 5) {
res.append(("首选项配置错误:")).append(PREF_NX_TEMPLATE);
ifail = OUTPUT_CODE_ERROR;
goto gx_nx_image_end;
}
PROPNAME_CLONE = prefVals[0];
PROPVALUE_CLONE = prefVals[1];
IMAGE_DSNAME_SANWEI = prefVals[2];
IMAGE_DSNAME_ERWEI = prefVals[3];
INPUT_SUFFIX = prefVals[4];
err = "";
WriteLog(debug, "查询NX模板%s", itemID.c_str());
if (tc_strlen(itemID.c_str()) == 0) {
res.append(("NX模板ID不可为空"));
ifail = OUTPUT_CODE_ERROR;
goto gx_nx_image_end;
}
ITKCALL(ifail = ITEM_find_item(itemID.c_str(), &item_tag));
if (ifail != ITK_ok) {
goto gx_nx_image_end;
}
ITKCALL(ifail = AOM_ask_value_string(item_tag, "object_string", &object_string));
WriteLog(debug, "找到对象:%s", object_string);
DOFREE(object_string);
ITKCALL(ifail = ITEM_ask_latest_rev(item_tag, &rev_tag));
if (rev_tag == NULLTAG) {
res.append(("未找到模板对象的最新版本,请检查是否具有查看权限"));
ifail = OUTPUT_CODE_ERROR;
goto gx_nx_image_end;
}
ITKCALL(ifail = AOM_refresh(rev_tag, FALSE));
ITKCALL(ifail = AOM_ask_value_string(rev_tag, "object_string", &object_string));
WriteLog(debug, "最新版本:%s", object_string);
DOFREE(object_string);
// 检查是否发布
ITKCALL(ifail = EPM_ask_if_released(rev_tag, &release_flag));
if (release_flag == 0) {
res.append(("模板对象最新版本未发布"));
ifail = OUTPUT_CODE_ERROR;
goto gx_nx_image_end;
}
// 读取简图
ITKCALL(ifail = AOM_ask_value_tags(rev_tag, "IMAN_specification", &ds_count, &ds_tags));
for (int i = 0;i < ds_count;i++) {
tag_t ds_tag = ds_tags[i];
char* ds_type = NULL, * ds_name = NULL, * original_file_name = NULL;
ITKCALL(ifail = AOM_refresh(ds_tag, false));
ITKCALL(ifail = AOM_ask_value_string(ds_tag, "object_name", &ds_name));
ITKCALL(ifail = WSOM_ask_object_type2(ds_tag, &ds_type));
WriteLog(debug, "Find Child: %s[%s]", ds_name, ds_type);
//res.append(ds_name).append("->").append(ds_type).append(";");
if (strcmp("Bitmap", ds_type) == 0) {
if (strcmp((IMAGE_DSNAME_ERWEI.c_str()), ds_name) == 0) {
char* uid = NULL;
ITK__convert_tag_to_uid(ds_tag, &uid);
if (uid != NULL) {
erwei_file.assign(uid);
}
//res.append(erwei_file).append(";");
}
else if (strcmp((IMAGE_DSNAME_SANWEI.c_str()), ds_name) == 0) {
char* uid = NULL;
ITK__convert_tag_to_uid(ds_tag, &uid);
if (uid != NULL) {
sanwei_file.assign(uid);
}
//DOFREE(sanwei_file);
//export_dataset_file(debug, ds_tag, "Image", "bmp", &sanwei_file, &original_file_name);
//res.append(sanwei_file).append(";");
}
}
DOFREE(ds_type);
DOFREE(ds_name);
DOFREE(original_file_name);
}
if (erwei_file.length()==0 || sanwei_file.length()==0) {
res.append(("获取图纸简图失败"));
ifail = OUTPUT_CODE_ERROR;
goto gx_nx_image_end;
}
ITKCALL(ifail = AOM_ask_value_string(rev_tag, "item_revision_id", &rev_id));
res.append("@DB/").append(itemID).append("/").append(rev_id);
res.append(SPLITTER).append((IMAGE_DSNAME_ERWEI)).append("=").append((erwei_file));
res.append(SPLITTER).append((IMAGE_DSNAME_SANWEI)).append("=").append((sanwei_file));
gx_nx_image_end:
POM_AM__set_application_bypass(false);
DOFREE(ds_tags);
DOFREE(object_string);
DOFREE(rev_id);
return ifail;
}
int Parse_NX_Template_By_ID(const std::string& itemID, std::string& res) {
int ifail = ITK_ok, release_flag = 0;
int pref_len = 0, ds_count = 0;
char* object_string = NULL;
char* rev_id = NULL;
tag_t item_tag = NULLTAG;
tag_t rev_tag = NULLTAG;
tag_t bom_view = NULLTAG, bvr_tag = NULLTAG, bom_window = NULLTAG, topBomLine = NULLTAG;
vector<string> checkedIDs;
vector<string> prefVals;
POM_AM__set_application_bypass(true);
getPrefStrings(PREF_NX_TEMPLATE, TC_preference_site, prefVals);
if (prefVals.size() != 5) {
res.append(("首选项配置错误:")).append(PREF_NX_TEMPLATE);
ifail = OUTPUT_CODE_ERROR;
goto gx_nx_template_end;
}
PROPNAME_CLONE = prefVals[0];
PROPVALUE_CLONE = prefVals[1];
IMAGE_DSNAME_SANWEI = prefVals[2];
IMAGE_DSNAME_ERWEI = prefVals[3];
INPUT_SUFFIX = prefVals[4];
err = "";
WriteLog(debug, "查询NX模板%s", itemID.c_str());
if (tc_strlen(itemID.c_str()) == 0) {
res.append(("NX模板ID不可为空"));
ifail = OUTPUT_CODE_ERROR;
goto gx_nx_template_end;
}
ITKCALL(ifail = ITEM_find_item(itemID.c_str(), &item_tag));
if (ifail != ITK_ok) {
goto gx_nx_template_end;
}
ITKCALL(ifail = AOM_ask_value_string(item_tag, "object_string", &object_string));
WriteLog(debug, "找到对象:%s", object_string);
DOFREE(object_string);
ITKCALL(ifail = ITEM_ask_latest_rev(item_tag, &rev_tag));
if (rev_tag == NULLTAG) {
res.append(("未找到模板对象的最新版本,请检查是否具有查看权限"));
ifail = OUTPUT_CODE_ERROR;
goto gx_nx_template_end;
}
ITKCALL(ifail = AOM_refresh(rev_tag, FALSE));
ITKCALL(ifail = AOM_ask_value_string(rev_tag, "object_string", &object_string));
WriteLog(debug, "最新版本:%s", object_string);
DOFREE(object_string);
// 检查是否发布
ITKCALL(ifail = EPM_ask_if_released(rev_tag, &release_flag));
if (release_flag == 0) {
res.append(("模板对象最新版本未发布"));
ifail = OUTPUT_CODE_ERROR;
goto gx_nx_template_end;
}
ITKCALL(ifail = AOM_ask_value_string(rev_tag, "item_revision_id", &rev_id));
res.append("@DB/").append(itemID).append("/").append(rev_id);
// 加载BOM
ITKCALL(ifail = GetBomView(rev_tag, "view", &bom_view, &bvr_tag, debug));
if (bom_view != NULLTAG) {
BOM_create_window(&bom_window);
BOM_set_window_top_line_bvr(bom_window, bvr_tag, &topBomLine);
ifail = Cycle_BOM(topBomLine, res, checkedIDs, true);
BOM_close_window(bom_window);
}
else {
WriteLog(debug, "未找到BOM视图");
}
gx_nx_template_end:
POM_AM__set_application_bypass(false);
DOFREE(object_string);
DOFREE(rev_id);
return ifail;
}
int GET_CLONE_INFO(const std::string& uid, std::string& res) {
int ifail = ITK_ok;
tag_t item_tag = NULLTAG, rev_tag = NULLTAG;
char* item_id = NULL, * rev_id = NULL, * prop_value = NULL;
char* new_rev_id = NULL;
tag_t tType = NULLTAG;
logical isModified = FALSE;
string id_str, new_item_id;
vector<string> prefVals;
if (uid.size() < 1) {
goto end;
}
getPrefStrings(PREF_NX_TEMPLATE, TC_preference_site, prefVals);
if (prefVals.size() != 5) {
res.append(("首选项配置错误:")).append(PREF_NX_TEMPLATE);
ifail = OUTPUT_CODE_ERROR;
goto end;
}
PROPNAME_CLONE = prefVals[0];
PROPVALUE_CLONE = prefVals[1];
IMAGE_DSNAME_SANWEI = prefVals[2];
IMAGE_DSNAME_ERWEI = prefVals[3];
INPUT_SUFFIX = prefVals[4];
err = "";
ITK__convert_uid_to_tag(uid.c_str(), &rev_tag);
if (rev_tag == NULLTAG) {
res.assign("无法加载版本UID=").append(uid);
ifail = OUTPUT_CODE_ERROR;
goto end;
}
ITKCALL(ifail = ITEM_ask_item_of_rev(rev_tag, &item_tag));
if (item_tag == NULLTAG) {
goto end;
}
ITKCALL(ifail = AOM_ask_value_string(item_tag, "item_id", &item_id));
if (ifail != ITK_ok) {
goto end;
}
id_str.append(item_id);
ITKCALL(ifail = TCTYPE_ask_object_type(item_tag, &tType));
ITKCALL(ifail = AOM_ask_value_string(rev_tag, "item_revision_id", &rev_id));
ITKCALL(ifail = Get_New_ID(tType, id_str, INPUT_SUFFIX, new_item_id));
if (ifail != ITK_ok) {
res.clear();
res.append(err);
goto end;
}
ITKCALL(ifail = USER_new_revision_id(NULLTAG, tType, &isModified, &new_rev_id));
res.append("@DB/").append(item_id).append("/").append(rev_id);
res.append("=");
res.append("@DB/").append(new_item_id).append("/").append(new_rev_id);
end:
prefVals.clear();
DOFREE(rev_id);
return ifail;
}

@ -0,0 +1,292 @@
#pragma warning (disable: 4996)
#include "Connor_NX.h"
#define ITK_err 919013
#define TYPE_REV "ItemRevision"
#define PREF_EXE "Connor_Sign_NX_EXE_Path"
string exe_path;
int signoff_NX(tag_t dataset, char *dat_file, char *ext)
{
int ifail = ITK_ok;
WriteLog(debug, "开始签名到NX数据集");
tag_t spec_dataset_rev = NULLTAG, ref_object = NULLTAG;
AE_reference_type_t reference_type;
ITKCALL(ifail = AE_ask_dataset_latest_rev(dataset, &spec_dataset_rev));
char ref_name[WSO_name_size_c + 1] = "UGPART";
ITKCALL(ifail = AE_ask_dataset_named_ref2(spec_dataset_rev, ref_name, &reference_type, &ref_object));
if (reference_type == AE_PART_OF)
{
char *pathname = NULL;
ITKCALL(ifail = IMF_ask_file_pathname2(ref_object, SS_WNT_MACHINE, &pathname));
char *origin_file_name = NULL;
IMF_ask_original_file_name2(ref_object, &origin_file_name);
char new_ds_name[WSO_name_size_c + 1] = "";
char *new_file_name = USER_new_file_name(new_ds_name, ref_name, ext, 0);
char *temp_dir = getenv("temp");
char temp_file[SS_MAXPATHLEN] = "";
strcpy_s(temp_file, temp_dir);
strcat_s(temp_file, "\\");
strcat_s(temp_file, new_file_name);
ITKCALL(ifail = IMF_export_file(ref_object, temp_file));
int iCnt;
char *user_lib_env, pTempStr[500];
char local_path[MAX_PATH] = "";
char cmd[256] = "";
strcpy_s(cmd, exe_path.c_str());
strcat_s(cmd, " \"");
strcat_s(cmd, temp_file);
strcat_s(cmd, "\" \"");
strcat_s(cmd, dat_file);
strcat_s(cmd, "\"");
WriteLog(debug, "CMD%s", cmd);
// runCMD(cmd, debug);
system(cmd);
WriteLog(debug, "执行完成,开始上传文件");
tag_t new_file_tag = NULLTAG;
IMF_file_t file_descriptor;
WriteLog(debug, "上传文件...");
ITKCALL(ifail = IMF_import_file(temp_file, new_file_name, SS_BINARY, &new_file_tag, &file_descriptor));
ITKCALL(ifail = AOM_lock(new_file_tag));
ITKCALL(ifail = IMF_set_original_file_name2(new_file_tag, origin_file_name));
ITKCALL(ifail = IMF_close_file(file_descriptor));
ITKCALL(ifail = AOM_save(new_file_tag));
ITKCALL(ifail = AOM_unlock(new_file_tag));
WriteLog(debug, "移除旧文件引用...");
ITKCALL(ifail =AOM_lock(spec_dataset_rev));
ITKCALL(ifail = AE_remove_dataset_named_ref_by_tag2(spec_dataset_rev, ref_name, ref_object));
WriteLog(debug, "添加新文件引用...");
ITKCALL(ifail = AE_add_dataset_named_ref2(spec_dataset_rev, ref_name, AE_PART_OF, new_file_tag));
ITKCALL(ifail = AE_save_myself(spec_dataset_rev));
ITKCALL(ifail = AOM_unlock(spec_dataset_rev));
WriteLog(debug, "上传完成");
DOFREE(pathname);
DOFREE(origin_file_name);
}
return ITK_ok;
}
int sign(tag_t rev_tag, map<string, string> sign_config_NX, char* user_id){
int ifail = ITK_ok, rf_cnt = 0;
FILE* NXfile = NULL;
tag_t *rf_tags = NULL;
char NXinfo[2048];
memset(NXinfo, 0, sizeof(NXinfo));
char *NXfilepath = NULL;
//创建映射文件
WriteLog(debug, "创建数据文件...");
ifail = CreateUserFile(debug, "CONNOR_Sign_NX", user_id, &NXfilepath, &NXfile);
if (ifail == ITK_ok) {
WriteLog(debug, "数据文件:%s", NXfile);
}
else {
WriteLog(debug, "创建数据文件失败");
EMH_store_error_s1(EMH_severity_error, ITK_err, ("创建数据文件失败"));
ifail = ITK_err;
goto sign_end;
}
{
map<string,string>::iterator it;
for(it = sign_config_NX.begin();it!=sign_config_NX.end();it++){
string flag = it->first;
string propname = it->second;
string propvalstr;
vector<string> split;
int index = 0;
Split(propname,";",split);
if(split.size()==2){
propname.assign(split[0]);
index = atoi(split[1].c_str());
}
char* propval = NULL;
ITKCALL(ifail = AOM_UIF_ask_value(rev_tag, propname.c_str(), &propval));
if(ifail!=ITK_ok){
WriteLog(debug,">> Error Reading Property [%s][%d]", propname.c_str(), ifail);
ITKCALL(EMH_clear_last_error(ifail));
continue;
}
propvalstr.assign((propval));
WriteLog(debug, ">> Reflect [%s]: [%s] = [%s]",flag.c_str(), propname.c_str(), propvalstr.c_str());
if(index>=0){
vector<string> tempvec;
Split(propvalstr,";",tempvec);
if(tempvec.size()>index){
propvalstr.assign(tempvec[index]);
}else{
propvalstr.assign("");
}
WriteLog(debug, ">> Split [%d]: %s", index, propvalstr.c_str());
tempvec.clear();
}
strcat_s(NXinfo, flag.c_str());
strcat_s(NXinfo, "=");
strcat_s(NXinfo, propvalstr.c_str());
strcat_s(NXinfo, "|");
DOFREE(propval);
split.clear();
}
}
WriteLog(debug, "NX 映射数据:\n%s", NXinfo);
ifail = WriteToFile(debug, NXfile, NXinfo);
if (ifail != ITK_ok) {
WriteLog(debug, "写入数据文件失败");
EMH_store_error_s1(EMH_severity_error, ITK_err, ("写入数据文件失败"));
ifail = ITK_err;
goto sign_end;
}
//关闭数据文件
if (NXfile) {
fclose(NXfile);
NXfile = NULL;
}
ITKCALL(ifail = AOM_ask_value_tags(rev_tag, "IMAN_specification", &rf_cnt, &rf_tags));
for (int i = 0; i < rf_cnt; i++)
{
char *objectstring = NULL, *object_type = NULL;
tag_t ds = rf_tags[i];
ITKCALL(ifail = AOM_ask_value_string(ds, "object_string", &objectstring));
ITKCALL(ifail = AOM_ask_value_string(ds, "object_type", &object_type));
WriteLog(debug, ">> %d. 子对象 [%s] 类型 [%s]", i+1, objectstring, object_type);
if (strcmp(object_type, "UGMASTER") == 0)
{
signoff_NX(ds, NXfilepath, "prt");
}
DOFREE(objectstring);
DOFREE(object_type);
}
sign_end:
DOFREE(rf_tags);
//关闭数据文件
if (NXfile) {
fclose(NXfile);
NXfile = NULL;
}
//deleteFile(debug, NXfilepath);
return ifail;
}
int CONNOR_SIGN_DATASET(EPM_action_message_t msg)
{
int ifail = ITK_ok, att_cnt = 0, arg_cnt=0;
char* arg = NULL, * argflag = NULL, * argvalue = NULL;
map<string, string> sign_config_NX;
vector<string> sign_config;
vector<string> pref_values;
tag_t current_task = NULLTAG, root_task = NULLTAG, *attachments = NULL, rev_type = NULLTAG;
char *user_name = NULL;
tag_t user_tag = NULLTAG;
char *user_id = NULL;
string sign_name_str;
arg_cnt = TC_number_of_arguments(msg.arguments);
if (arg_cnt > 0) {
for (int i = 0; i < arg_cnt; i++) {
arg = TC_next_argument(msg.arguments);
ITKCALL(ifail = ITK_ask_argument_named_value(arg, &argflag, &argvalue));
if (strcmp(argflag, "SignName") == 0) {
sign_name_str.assign(argvalue);
}
MEM_free(argflag);
MEM_free(argvalue);
}
}
current_task = msg.task;
EPM_ask_root_task(msg.task, &root_task);
//生成日志
ITKCALL(POM_get_user(&user_name, &user_tag));
ITKCALL(SA_ask_user_identifier2(user_tag, &user_id));
WriteLog(debug, "=========================================================");
WriteLog(debug, "签名 开始执行");
WriteLog(debug, "=========================================================");
initUserDir(user_id);
ITKCALL(ifail = TCTYPE_ask_type(TYPE_REV,&rev_type));
if(rev_type==NULLTAG){
EMH_store_error_s2(EMH_severity_error, ITK_err, ("未找到版本类型"),TYPE_REV);
goto end;
}
getPrefStrings(PREF_EXE, TC_preference_site, pref_values);
if (pref_values.size() == 0) {
EMH_store_error_s2(EMH_severity_error, ITK_err, ("未配置首选项"), PREF_EXE);
goto end;
}
exe_path = pref_values[0];
ITKCALL(ifail = EPM_ask_attachments(root_task, EPM_target_attachment, &att_cnt, &attachments));
if(att_cnt==0){
goto end;
}
POM_AM__set_application_bypass(true);
//获取首选项配置
Split(sign_name_str, ";", sign_config);
WriteLog(debug,"解析 NX 签名配置...");
for each (string conf in sign_config)
{
conf.assign((conf.c_str()));
WriteLog(debug,">> %s",conf.c_str());
vector<string> strs;
Split(conf,"=",strs);
if(strs.size()==2){
if(sign_config_NX.count(strs[1])==0){
sign_config_NX.insert(make_pair(strs[1], strs[0]));
WriteLog(debug, ">> [%s] = [%s]", strs[0].c_str(), strs[1].c_str());
}else{
WriteLog(debug, ">> 重复配置 [%s] = [%s]", strs[0].c_str(), strs[1].c_str());
}
}else{
EMH_store_error_s2(EMH_severity_error, ITK_err, ("无效签名配置"),conf.c_str());
}
strs.clear();
}
if(sign_config_NX.size()==0){
WriteLog(debug,"获取 NX 签名配置失败");
EMH_store_error_s1(EMH_severity_error, ITK_err, ("获取 NX 签名配置失败"));
goto end;
}
sign_config.clear();
for(int i=0;i<att_cnt;i++){
tag_t attachment = attachments[i];
tag_t type = NULLTAG;
char* objectstring = NULL;
bool isRev = false;
ITKCALL(ifail = TCTYPE_ask_object_type(attachment, &type));
ITKCALL(ifail = AOM_ask_value_string(attachment,"object_string",&objectstring));
if(ifail!=ITK_ok){
DOFREE(objectstring);
continue;
}
WriteLog(debug, "%d. 签名: %s",i+1,objectstring);
ITKCALL(ifail = TCTYPE_is_type_of(type, rev_type, &isRev));
if(!isRev){
WriteLog(debug, ">> 非版本类型");
DOFREE(objectstring);
continue;
}
sign(attachment, sign_config_NX, user_id);
}
end:
POM_AM__set_application_bypass(false);
DOFREE(attachments);
DOFREE(user_id);
sign_config.clear();
pref_values.clear();
sign_config_NX.clear();
WriteLog(debug, "=========================================================");
WriteLog(debug, "签名 执行结束");
WriteLog(debug, "=========================================================");
return ifail;
}

@ -0,0 +1,293 @@
#include "Connor_NX.h"
#define ITK_err 919012
#define SIGN_DATE_FORMAT "%Y-%m-%d"
#define TYPE_REV "ItemRevision"
struct Sign_Info{
string node_name;
string propname_user;
string propname_date;
};
int CONNOR_SIGN_MASTER(EPM_action_message_t msg){
int ifail = ITK_ok, arg_cnt = 0,att_cnt=0, task_count=0;
char *arg = NULL,*argflag =NULL,*argvalue=NULL,*propvalue=NULL,*objectstring=NULL,*task_name=NULL,*task_type=NULL;
char *user_id = NULL, *user_name = NULL, *logPath = NULL;
tag_t task_tag = NULLTAG,rootTask_tag=NULLTAG, user_tag=NULLTAG;
tag_t *attachments = NULL, *task_tags=NULL;
string attr_sign_name, attr_sign_date;
vector<string> attr_sign_name_split, attr_sign_date_split;
map<string, Sign_Info*> sign_config_map;
map<string, string> property_map;
string dateFormat, prop_name_bianzhi;
tag_t rev_type = NULLTAG;
dateFormat.assign(SIGN_DATE_FORMAT);
arg_cnt = TC_number_of_arguments(msg.arguments);
if (arg_cnt > 0) {
for (int i = 0;i < arg_cnt;i++) {
arg = TC_next_argument(msg.arguments);
ITKCALL(ifail = ITK_ask_argument_named_value(arg, &argflag, &argvalue));
if(strcmp(argflag, "SignUserName") == 0){
attr_sign_name.assign(argvalue);
}else if(strcmp(argflag, "SignDate") == 0){
attr_sign_date.assign(argvalue);
}else if(strcmp(argflag, "SignDateFormat") == 0){
dateFormat.assign(argvalue);
}
MEM_free(argflag);
MEM_free(argvalue);
}
}
ITKCALL(POM_get_user(&user_name, &user_tag));
ITKCALL(SA_ask_user_identifier2(user_tag, &user_id));
DOFREE(user_id);
WriteLog(debug, "=============================================================");
WriteLog(debug, "开始执行CONNOR_SIGN_MASTER");
WriteLog(debug, "=============================================================");
task_tag=msg.task;
if(task_tag==NULLTAG){
goto end;
}
ITKCALL(ifail = TCTYPE_ask_type(TYPE_REV, &rev_type));
if (rev_type == NULLTAG) {
EMH_store_error_s2(EMH_severity_error, ITK_err, ("未找到版本类型"), TYPE_REV);
goto end;
}
WriteLog(debug, "sign_user_name: %s", attr_sign_name.c_str());
WriteLog(debug, "sign_date: %s", attr_sign_date.c_str());
WriteLog(debug, "date_format: %s", dateFormat.c_str());
ITKCALL(ifail = EPM_ask_root_task(task_tag, &rootTask_tag));
ITKCALL(ifail = EPM_ask_attachments(rootTask_tag, EPM_target_attachment, &att_cnt, &attachments));
if(att_cnt==0){
goto end;
}
POM_AM__set_application_bypass(true);
//获取首选项配置
WriteLog(debug,"解析签名配置...");
Split(attr_sign_name, ";", attr_sign_name_split);
Split(attr_sign_date, ";", attr_sign_date_split);
for each (string conf in attr_sign_name_split)
{
WriteLog(debug,">> %s",conf.c_str());
vector<string> strs;
Split(conf,"=",strs);
if(strs.size()==2){
if (sign_config_map.count(strs[0]) == 0) {
Sign_Info* info = new Sign_Info();
info->node_name = strs[0];
info->propname_user = strs[1];
sign_config_map.insert(make_pair(info->node_name, info));
if (info->node_name._Equal("编制")) {
prop_name_bianzhi.assign(info->propname_user);
}
}
}else{
EMH_store_error_s2(EMH_severity_error, ITK_err, ("无效签名配置"),conf.c_str());
}
strs.clear();
}
for each (string conf in attr_sign_date_split)
{
WriteLog(debug, ">> %s", conf.c_str());
vector<string> strs;
Split(conf, "=", strs);
if (strs.size() == 2) {
if (sign_config_map.count(strs[0]) == 0) {
Sign_Info* info = new Sign_Info();
info->node_name = strs[0];
info->propname_date = strs[1];
sign_config_map.insert(make_pair(info->node_name, info));
}
else {
sign_config_map[strs[0]]->propname_date = strs[1];
}
}
else {
EMH_store_error_s2(EMH_severity_error, ITK_err, ("无效签名配置"), conf.c_str());
}
strs.clear();
}
if(sign_config_map.size()==0){
WriteLog(debug,"获取签名配置失败");
EMH_store_error_s1(EMH_severity_error, ITK_err, ("获取签名配置失败"));
goto end;
}
WriteLog(debug, "编制属性 [%s]", prop_name_bianzhi.c_str());
WriteLog(debug,"读取签名信息...");
ITKCALL(ifail=EPM_ask_sub_tasks(rootTask_tag,&task_count,&task_tags));
for(int i=0;i<task_count;i++){
tag_t sub_task = task_tags[i];
ITKCALL(ifail=EPM_ask_name2(sub_task,&task_name));
ITKCALL(ifail =AOM_ask_value_string(sub_task, "task_type", &task_type));
if(ifail!=ITK_ok){
DOFREE(task_name);
DOFREE(task_type);
continue;
}
WriteLog(debug, "%d. 读取任务信息 %s -> %s",i+1, task_name,task_type);
if (sign_config_map.count(task_name) == 0) {
WriteLog(debug, ">> SKIP");
DOFREE(task_name);
DOFREE(task_type);
continue;
}
if(strcmp("EPMDoTask", task_type)==0){
tag_t user_tag = NULLTAG;
ITKCALL(ifail = AOM_ask_value_tag(sub_task,"fnd0Performer",&user_tag));
if(user_tag==NULLTAG){
WriteLog(debug, "未找到执行者");
continue;
}
char *date_str = NULL, *user_name = NULL, *task_state=NULL;
date_t date;
ITKCALL(ifail = AOM_ask_value_string(user_tag,"user_name",&user_name));
ITKCALL(ifail = AOM_ask_value_date(sub_task, "fnd0EndDate", &date));
ITKCALL(ifail = AOM_ask_value_string(sub_task,"task_state", &task_state));
ITKCALL(ifail = DATE_date_to_string(date,dateFormat.c_str(),&date_str));
WriteLog(debug, ">> DO任务信息%s|%s|%s",user_name, date_str, task_state);
if(date.year<=0){
WriteLog(debug, "任务未完成");
continue;
}
Sign_Info* info = sign_config_map[task_name];
if(info->propname_user.length()>0){
WriteLog(debug, ">>>> 记录用户信息 %s = %s", info->propname_user.c_str(), user_name);
if (property_map.count(info->propname_user) == 0) {
property_map.insert(make_pair(info->propname_user, user_name));
}
else {
WriteLog(debug, "重复属性");
}
}
if(info->propname_date.length() > 0){
WriteLog(debug, ">>>> 记录时间信息 %s = %s", info->propname_date.c_str(), date_str);
if (property_map.count(info->propname_date) == 0) {
property_map.insert(make_pair(info->propname_date, date_str));
}
else {
WriteLog(debug, "重复属性");
}
}
DOFREE(user_name);
DOFREE(date_str);
DOFREE(task_state);
}else if(strcmp("EPMReviewTask",task_type)==0||strcmp("EPMAcknowledgeTask",task_type)==0){
int reviewer_cnt=0;
tag_t *reviewers=NULL;
ITKCALL(ifail = EPM_ask_reviewers(sub_task,&reviewer_cnt,&reviewers));
for(int j=0;j<reviewer_cnt;j++){
tag_t reviewer = reviewers[j];
tag_t user_tag=NULLTAG;
tag_t group_tag = NULLTAG;
EPM_signoff_decision_t decision;
char *comment = NULL, *date_str = NULL, *group_full_name=NULL, *user_name = NULL;
date_t date;
ITKCALL(ifail = AOM_ask_value_tag(reviewer,"user",&user_tag));
ITKCALL(ifail = AOM_ask_value_tag(reviewer,"group",&group_tag));
ITKCALL(ifail = AOM_ask_value_string(user_tag,"user_name",&user_name));
ITKCALL(ifail = AOM_ask_value_string(group_tag,"full_name",&group_full_name));
ITKCALL(ifail = EPM_ask_decision(sub_task, user_tag, &decision, &comment, &date));
ITKCALL(ifail = DATE_date_to_string(date,dateFormat.c_str(),&date_str));
WriteLog(debug, ">> %d. 审核信息:%s|%s|%s",j+1,user_name,group_full_name, date_str);
if(decision != EPM_approve_decision){
WriteLog(debug, "审核未同意");
DOFREE(comment);
DOFREE(user_name);
DOFREE(group_full_name);
DOFREE(date_str);
continue;
}
Sign_Info* info = sign_config_map[task_name];
if (info->propname_user.length() > 0) {
WriteLog(debug, ">>>> 记录用户信息 %s = %s", info->propname_user.c_str(), user_name);
if (property_map.count(info->propname_user) == 0) {
property_map.insert(make_pair(info->propname_user, user_name));
}
else {
WriteLog(debug, "重复属性");
}
}
if (info->propname_date.length() > 0) {
WriteLog(debug, ">>>> 记录时间信息 %s = %s", info->propname_date.c_str(), date_str);
if (property_map.count(info->propname_date) == 0) {
property_map.insert(make_pair(info->propname_date, date_str));
}
else {
WriteLog(debug, "重复属性");
}
}
DOFREE(comment);
DOFREE(user_name);
DOFREE(group_full_name);
DOFREE(date_str);
}
DOFREE(reviewers);
}else{
WriteLog(debug, ">> 未知任务类型");
}
DOFREE(task_name);
DOFREE(task_type);
}
//获取最高文件密级
for(int i=0;i<att_cnt;i++){
tag_t attachment = attachments[i];
tag_t type = NULLTAG, rev_owner = NULLTAG;
char* rev_owner_name = NULL;
bool isForm = false;
ITKCALL(ifail = TCTYPE_ask_object_type(attachment, &type));
ITKCALL(ifail = AOM_ask_value_string(attachment,"object_string",&objectstring));
if(ifail!=ITK_ok){
DOFREE(objectstring);
continue;
}
WriteLog(debug, "%d. 写入版本 %s",i+1,objectstring);
ITKCALL(ifail = TCTYPE_is_type_of(type, rev_type, &isForm));
if(!isForm){
WriteLog(debug, ">> 非版本类型");
DOFREE(objectstring);
continue;
}
ITKCALL(ifail = AOM_lock(attachment));
if(ifail!=ITK_ok){
continue;
}
ITKCALL(ifail = AOM_ask_value_tag(attachment, "owning_user", &rev_owner));
ITKCALL(ifail = AOM_ask_value_string(rev_owner, "user_name", &rev_owner_name));
WriteLog(debug, ">> 所有者 %s", rev_owner_name);
map<string,string>::iterator it;
for(it = property_map.begin();it!=property_map.end();it++){
string propname = it->first;
string propval = it->second;
if (prop_name_bianzhi._Equal(propname)) {
propval.assign(rev_owner_name);
}
WriteLog(debug, ">> 设置属性: [%s] = [%s]", propname.c_str(), propval.c_str());
ITKCALL(ifail = AOM_set_value_string(attachment, propname.c_str(), propval.c_str()));
if(ifail!=ITK_ok){
WriteLog(debug, ">> 设置属性失败:%d", ifail);
EMH_clear_last_error(ifail);
}
}
ITKCALL(AOM_save(attachment));
AOM_unlock(attachment);
}
end:
POM_AM__set_application_bypass(false);
DOFREE(attachments);
sign_config_map.clear();
property_map.clear();
attr_sign_name_split.clear();
attr_sign_date_split.clear();
WriteLog(debug, "=============================================================");
WriteLog(debug, "执行结束CONNOR_SIGN_MASTER");
WriteLog(debug, "=============================================================");
return ITK_ok;
}

@ -0,0 +1,693 @@
#pragma warning (disable: 4996)
#pragma warning (disable: 4819)
#include "kutil.h"
FILE* logFile = NULL;
#define MAX_PATH_LENGTH 200
#define MAX_PRINTLINE_LENGTH 2000
void initUserDir(char* userId) {
char logFileDir[MAX_PATH_LENGTH];
memset(logFileDir, 0, sizeof(logFileDir));
sprintf(logFileDir, "%s", getenv("TEMP"));
strcat(logFileDir, "\\tc_");
strcat(logFileDir, userId);
if (chdir(logFileDir) != ITK_ok) {
printf(">> Create Path: %s\n", logFileDir);
mkdir(logFileDir);
}
}
void WriteLog(logical debug, const char* format, ...)
{
va_list arg;
char tmp[MAX_PRINTLINE_LENGTH];
char date_string[MAX_PATH_LENGTH];
time_t now;
struct tm* p;
//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);
printf("%s\n", tmp);
//print message to log file
TC_write_syslog("%s\n", tmp);
}
void WriteLog2(logical debug, const char* format, ...)
{
va_list arg;
char tmp[MAX_PRINTLINE_LENGTH];
char date_string[MAX_PATH_LENGTH];
time_t now;
struct tm* p;
//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);
printf("%s\n", tmp);
//print message to log file
if (!debug) {
return;
}
if (logFile)
{
time(&now);
//current_time(&status_now);
p = localtime(&now);
memset(date_string, 0, sizeof(date_string));
sprintf(date_string, "%02d:%02d:%02d", p->tm_hour, p->tm_min, p->tm_sec);
fprintf(logFile, "[%s] %s\n", date_string, tmp);
fflush(logFile);
}
else
{
printf("*!Error!*: Log File Not Exist\n");
}
}
void CloseLog(void)
{
if (logFile)
{
fclose(logFile);
logFile = NULL;
}
}
void CreateLogFile(char* FunctionName, char* userId, char** fullname)
{
int 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 );
sprintf(date_string, "%4d%02d%02d", 1900 + p->tm_year, p->tm_mon + 1, p->tm_mday);
//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"));
strcat(logFileDir, "\\tc_");
strcat(logFileDir, userId);
//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, userId, 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, "a");
CLEANUP:;
//DOFREE(date_string);
/*if(session_uid!=NULL){
MEM_free(session_uid);
session_uid=NULL;
}*/
}
void set_bypass(logical bypass)
{
//AM__set_application_bypass(bypass);
POM_AM__set_application_bypass(bypass);
}
bool isClass(tag_t class_id, char* className) {
tag_t* pclass_ids = NULL;
char* class_name = NULL;
int pclass_count = 0, ifail = ITK_ok;
ITKCALL(POM_name_of_class(class_id, &class_name));
printf("class name = %s\n", class_name);
bool isType = false;
if (strcmp(class_name, className) == 0) {
isType = true;
}
DOFREE(class_name);
if (isType) {
return true;
}
ITKCALL(ifail = POM_superclasses_of_class(class_id, &pclass_count, &pclass_ids));
for (int i = 0;i < pclass_count;i++) {
isType = isClass(pclass_ids[i], className);
if (isType) {
return true;
}
}
return false;
}
bool isType(tag_t item, char* type) {
tag_t class_id = NULLTAG, * pclass_ids = NULL;
char* class_name = NULL;
int pclass_count = 0, ifail = ITK_ok;
ITKCALL(POM_class_of_instance(item, &class_id));
return isClass(class_id, type);
}
void deleteFile(bool debug, char* path) {
//ɾ³ýÎļþ
if (remove(path) == 0) {
WriteLog(debug, "Delete File: %s", path);
}
else {
WriteLog(debug, "Delete File failed: %s", path);
}
}
int readError(bool debug, char* errFilePath, int errCode) {
fstream _file;
_file.open(errFilePath, ios::in);
if (_file) {
WriteLog(debug, "Find Error File: %s", errFilePath);
ifstream fin(errFilePath);
string s;
while (getline(fin, s))
{
WriteLog(debug, s.c_str());
EMH_store_error_s1(EMH_severity_error, errCode, s.c_str());
}
_file.close();
return errCode;
}
return ITK_ok;
}
//µ¼ÈëÊý¾Ý¼¯
int import_dataset_file(tag_t dataset, const char* ref_name, char* ext, char* fullfilename, char* original_name)
{
int ifail = ITK_ok;
tag_t new_file_tag = NULLTAG;
IMF_file_t file_descriptor = NULL;
AOM_refresh(dataset, FALSE);
char* new_file_name = NULL;
char new_ds_name[WSO_name_size_c + 1] = "";
char* filename = NULL;
new_file_name = USER_new_file_name(new_ds_name, ref_name, ext, 0);
filename = strrchr(fullfilename, '\\') + 1;
if (filename == NULL)
return ITK_ok;
set_bypass(true);
ITKCALL(ifail = IMF_import_file(fullfilename, new_file_name, SS_TEXT, &new_file_tag, &file_descriptor));
if (ifail != ITK_ok) {
ITKCALL(ifail = IMF_import_file(fullfilename, new_file_name, SS_BINARY, &new_file_tag, &file_descriptor));
}
ITKCALL(ifail = IMF_set_original_file_name2(new_file_tag, original_name));
ITKCALL(ifail = IMF_close_file(file_descriptor));
ITKCALL(ifail = AOM_save(new_file_tag));
AOM_unlock(new_file_tag);
ITKCALL(ifail = AOM_refresh(new_file_tag, FALSE));
//Ìí¼ÓÖÁÃüÃûÒýÓÃ
set_bypass(true);
ITKCALL(AOM_lock(dataset));
ITKCALL(ifail = AE_remove_dataset_named_ref2(dataset, ref_name));
ITKCALL(ifail = AOM_save(dataset));
set_bypass(true);
ITKCALL(ifail = AE_add_dataset_named_ref2(dataset, ref_name, AE_PART_OF, new_file_tag));
AOM_save(dataset);
AOM_unlock(dataset);
set_bypass(false);
//ITKCALL( AOM_refresh( dataset, FALSE ) );
return ifail;
}
//µ¼ÈëÊý¾Ý¼¯
int import_dataset_file_binary(tag_t dataset, const char* ref_name, char* ext, char* fullfilename, char* original_name)
{
int ifail = ITK_ok;
tag_t new_file_tag = NULLTAG;
IMF_file_t file_descriptor = NULL;
AOM_refresh(dataset, FALSE);
char* new_file_name = NULL;
char new_ds_name[WSO_name_size_c + 1] = "";
char* filename = NULL;
new_file_name = USER_new_file_name(new_ds_name, ref_name, ext, 0);
filename = strrchr(fullfilename, '\\') + 1;
if (filename == NULL)
return ITK_ok;
set_bypass(true);
ITKCALL(ifail = IMF_import_file(fullfilename, new_file_name, SS_BINARY, &new_file_tag, &file_descriptor));
ITKCALL(ifail = IMF_set_original_file_name2(new_file_tag, original_name));
ITKCALL(ifail = IMF_close_file(file_descriptor));
ITKCALL(ifail = AOM_save(new_file_tag));
AOM_unlock(new_file_tag);
ITKCALL(ifail = AOM_refresh(new_file_tag, FALSE));
//Ìí¼ÓÖÁÃüÃûÒýÓÃ
set_bypass(true);
ITKCALL(AOM_lock(dataset));
ITKCALL(ifail = AE_remove_dataset_named_ref2(dataset, ref_name));
ITKCALL(ifail = AOM_save(dataset));
set_bypass(true);
ITKCALL(ifail = AE_add_dataset_named_ref2(dataset, ref_name, AE_PART_OF, new_file_tag));
AOM_save(dataset);
AOM_unlock(dataset);
set_bypass(false);
//ITKCALL( AOM_refresh( dataset, FALSE ) );
return ifail;
}
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 = 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;
}
}
}
bool inArray(vector<string> types, string type) {
int len = types.size();
for (int i = 0;i < len;i++) {
if (strcmp(types[i].c_str(), type.c_str()) == 0) {
return true;
}
}
return false;
}
int getIndexInArray(vector<string> types, string type) {
int len = types.size();
for (int i = 0;i < len;i++) {
if (strcmp(types[i].c_str(), type.c_str()) == 0) {
return i;
}
}
return -1;
}
bool CheckType(string config, char* type, char spliter) {
vector<string> types;
Split(config, spliter, types);
int len = types.size();
for (int i = 0;i < len;i++) {
if (strcmp(types[i].c_str(), type) == 0) {
return true;
}
}
return false;
}
int GetProcessTargets(bool debug, int att_cnt, tag_t* attachments, vector<tag_t>& targets, char* formType, char splitter) {
char* object_name = NULL, * object_type = NULL;
int ifail = ITK_ok;
WriteLog(debug, "Get Targets of Process: %d", att_cnt);
for (int i = 0;i < att_cnt;i++) {
ITKCALL(ifail = WSOM_ask_name2(attachments[i], &object_name));
ITKCALL(ifail = WSOM_ask_object_type2(attachments[i], &object_type));
WriteLog(debug, "%d. Target [%s], type: %s", i + 1, object_name, object_type);
//if (strcmp(object_type, TYPE_ITEM_PZJ.c_str()) == 0) {
if (CheckType(formType, object_type, splitter)) {
targets.push_back(attachments[i]);
}
DOFREE(object_name);
DOFREE(object_type);
}
return ITK_ok;
}
int findUser(bool debug, string userStr, tag_t* user_tag) {
int ind1 = userStr.find_first_of('(');
int ind2 = userStr.find_first_of(')');
WriteLog(debug, "Search User: %s", userStr.c_str());
if (ind1 != string::npos && ind2 != string::npos && ind1 < ind2) {
userStr = userStr.substr(ind1 + 1, ind2 - ind1 - 1);
WriteLog(debug, ">> User id: %s", userStr.c_str());
}
int ifail = ITK_ok;
ITKCALL(ifail = SA_find_user2(userStr.c_str(), user_tag));
return ifail;
}
int GetBomLinePropString(bool debug, tag_t line, char* propName, int errCode, char** attr_val) {
int attribute_id = 0, ifail = ITK_ok;
ITKCALL(ifail = BOM_line_look_up_attribute(propName, &attribute_id));
if (attribute_id == 0) {
WriteLog(debug, "BOMLine property not exist: %s", propName);
EMH_store_error_s2(EMH_severity_error, errCode, "BOMLine property not exist", propName);
return errCode;
}
else {
ITKCALL(ifail = BOM_line_ask_attribute_string(line, attribute_id, &*attr_val));
return ifail;
}
return ITK_ok;
}
int GetStringProp(tag_t obj, char* propName, char** attr_val) {
return AOM_ask_value_string(obj, propName, &*attr_val);
}
bool isRev(char* object_type) {
if (((strstr(object_type, "Revision") != NULL) || (strstr(object_type, "revision") != NULL))
&& (strstr(object_type, "Master") == NULL) && (strstr(object_type, "master") == NULL)
&& (strstr(object_type, "BOM") == NULL) && (strstr(object_type, "bom") == NULL) && (strstr(object_type, "Bom") == NULL)) {
return true;
}
return false;
}
int GetBomView(tag_t rev_tag, char* viewtype, tag_t* bomView, tag_t* bomBVR, bool debug)
{
WriteLog(debug, "Get BOM View: %s", viewtype);
int ifail = ITK_ok, bvr_count = 0;
tag_t* bvr_list = NULL, bom_view = NULLTAG, view_type = NULLTAG;
*bomBVR = NULLTAG;
*bomView = NULLTAG;
ITKCALL(ITEM_rev_list_bom_view_revs(rev_tag, &bvr_count, &bvr_list));
if (bvr_count > 0)
{
for (int 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));
WriteLog(debug, "Find View: %s", view_type_name);
if (tc_strcmp(view_type_name, viewtype) == 0)
{
*bomBVR = bvr_list[i];
*bomView = bom_view;
}
DOFREE(view_type_name);
}
}
//else {
// WriteLog(debug, "ûÓÐÕÒµ½bvr¿ªÊ¼½øÐд´½¨");
// tag_t bv = NULLTAG, bvr = NULLTAG, item_tag = NULLTAG;
// int bvCnt = 0;
// tag_t* bvTags = NULL;
// ITKCALL(ifail = ITEM_ask_item_of_rev(rev_tag, &item_tag));
// tag_t tWindow = NULLTAG;
// ITKCALL(BOM_create_window(&tWindow));
// tag_t tTopLine = NULLTAG;
// ITKCALL(BOM_set_window_top_line(tWindow, item_tag, NULLTAG, NULLTAG, &tTopLine));
// //²éÕÒÔ­BOMÊÓͼ
// ITKCALL(ifail=ITEM_list_bom_views(item_tag, &bvCnt, &bvTags));
// if (bvCnt > 0) {
// WriteLog(debug, "¶ÔÏóÒÑ´æÔÚBOMÊÓͼ£º%d", bvCnt);
// bv = bvTags[0];
// }
// ITKCALL(AOM_lock(item_tag));
// if (bv == NULLTAG) {
// ITKCALL(ifail=PS_create_bom_view(NULLTAG, "", "", item_tag, &bv));
// if (ifail != ITK_ok) {
// ITKCALL(AOM_unlock(item_tag));
// return ifail;
// }
// ITKCALL(AOM_save(bv));
// }
// ITKCALL(ifail=PS_create_bvr(bv, "", "", false, rev_tag, &bvr));
// if (ifail != ITK_ok) {
// ITKCALL(AOM_unlock(item_tag));
// return ifail;
// }
// ITKCALL(AOM_save(bvr));
// ITKCALL(AOM_save(bv));
// ITKCALL(AOM_save(item_tag));
// tag_t tChildLine = NULLTAG;
// ITKCALL(BOM_save_window(tWindow));
// ITKCALL(BOM_close_window(tWindow));
// ITKCALL(AOM_unlock(item_tag));
// *bomBVR = bvr;
// *bomView = bv;
// WriteLog(debug, "bvrн¨Íê³É");
// DOFREE(bvTags);
//}
DOFREE(bvr_list);
return ifail;
}
bool propExist(bool debug, tag_t obj, const char* propName) {
tag_t clTag = NULLTAG, * superClass = NULL;
char* clName = NULL;
int ifail = ITK_ok, cnt = 0;
logical exists = false;
ITKCALL(ifail = POM_class_of_instance(obj, &clTag));
if (ifail != ITK_ok) { return false; }
ITKCALL(ifail = POM_name_of_class(clTag, &clName));
if (ifail != ITK_ok) { return false; }
WriteLog(debug, ">> [%s] Check Property: %s", clName, propName);
ITKCALL(ifail = POM_attr_exists(propName, clName, &exists));
if (ifail != ITK_ok) { return false; }
DOFREE(clName);
if (exists) {
//WriteLog(debug,"ÊôÐÔ´æÔÚ");
return exists;
}
ITKCALL(ifail = POM_superclasses_of_class(clTag, &cnt, &superClass));
for (int i = 0;i < cnt;i++) {
ITKCALL(ifail = POM_name_of_class(superClass[i], &clName));
if (ifail != ITK_ok) { return false; }
WriteLog(debug, ">> [%s] Check Property: %s", clName, propName);
ITKCALL(ifail = POM_attr_exists(propName, clName, &exists));
DOFREE(clName);
if (exists) {
//WriteLog(debug, "ÊôÐÔ´æÔÚ");
return exists;
}
}
WriteLog(debug, "Property not exist");
return exists;
}
char* G2U(const char* gb2312)
{
int len = MultiByteToWideChar(CP_ACP, 0, gb2312, -1, NULL, 0);
wchar_t* wstr = new wchar_t[len + 1];
memset(wstr, 0, len + 1);
MultiByteToWideChar(CP_ACP, 0, gb2312, -1, wstr, len);
len = WideCharToMultiByte(CP_UTF8, 0, wstr, -1, NULL, 0, NULL, NULL);
char* str = new char[len + 1];
memset(str, 0, len + 1);
WideCharToMultiByte(CP_UTF8, 0, wstr, -1, str, len, NULL, NULL);
if (wstr) delete[] wstr;
return str;
}
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));
ITKCALL(ifail = PREF_ask_char_values_at_location(preference, scope, &num, &values));
if (ifail != ITK_ok) {
return ifail;
}
for (i = 0; i < num; i++)
{
pref_vec.push_back(values[i]);
}
DOFREE(values);
//ITKCALL(ifail = PREF_set_search_scope(old_scope));
return ifail;
}
int getPrefStrings2(const char* preference, TC_preference_search_scope_t scope, char splitter, 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));
ITKCALL(ifail = PREF_ask_char_values_at_location(preference, scope, &num, &values));
if (ifail != ITK_ok) {
return ifail;
}
for (i = 0; i < num; i++)
{
vector<string> split;
Split(values[i], splitter, split);
int size = split.size();
for (j = 0;j < size;j++) {
pref_vec.push_back(split[j]);
}
/*for each (string val in split) {
pref_vec.push_back(val);
}*/
}
DOFREE(values);
//ITKCALL(ifail = PREF_set_search_scope(old_scope));
return ifail;
}
//µ¼³öÊý¾Ý¼¯Îļþ
int export_dataset_file(bool debug, tag_t dataset, const char* ref_name, char* userId, char* ext, char** filename, char** original_name)
{
int ifail = ITK_ok;
tag_t ref_object = NULLTAG,
datasettype = NULLTAG,
new_ds = NULLTAG,
tool = NULLTAG,
folder_tag = NULLTAG,
spec_dataset_rev = NULLTAG;
AE_reference_type_t reference_type;
tag_t new_file_tag = NULLTAG;
IMF_file_t file_descriptor;
char* target_ds_name = NULL;
char* new_file_name;
WSOM_ask_name2(dataset, &target_ds_name);
WriteLog(debug, "Download file from dataset %s", target_ds_name);
DOFREE(target_ds_name);
*filename = (char*)MEM_alloc(sizeof(char) * 512);
*original_name = (char*)MEM_alloc(sizeof(char) * 512);
strcpy(*filename, "");
AE_ask_dataset_latest_rev(dataset, &spec_dataset_rev);
AE_ask_dataset_named_ref2(dataset, ref_name, &reference_type, &ref_object);
if (ref_object == NULLTAG)
{
WriteLog(debug, "File ref not exist");
return 1;
}
if (reference_type == AE_PART_OF)
{
char* pathname2 = NULL;
IMF_ask_file_pathname2(ref_object, SS_WNT_MACHINE, &pathname2);
DOFREE(pathname2);
char* origin_file_name2 = NULL;
IMF_ask_original_file_name2(ref_object, &origin_file_name2);
strcpy(*original_name, origin_file_name2);
DOFREE(origin_file_name2);
char new_ds_name[WSO_name_size_c + 1] = "";
char* new_file_name = USER_new_file_name(new_ds_name, ref_name, ext, 0);
char* temp_dir = getenv("TEMP");
char temp_file[SS_MAXPATHLEN] = "";
strcpy(temp_file, temp_dir);
strcat(temp_file, "\\tc_");
strcat(temp_file, userId);
strcat(temp_file, "\\");
strcat(temp_file, new_file_name);
WriteLog(debug, "Temp path: %s", temp_file);
if ((_access(temp_file, 0)) != -1) {
if (!remove(temp_file)) {
remove(temp_file);
}
}
IMF_export_file(ref_object, temp_file);
strcpy(*filename, temp_file);
return ITK_ok;
}
return -1;
}

@ -0,0 +1,693 @@
#pragma warning (disable: 4996)
#pragma warning (disable: 4819)
#include "kutil.h"
FILE* logFile = NULL;
#define MAX_PATH_LENGTH 200
#define MAX_PRINTLINE_LENGTH 2000
void initUserDir(char* userId) {
char logFileDir[MAX_PATH_LENGTH];
memset(logFileDir, 0, sizeof(logFileDir));
sprintf(logFileDir, "%s", getenv("TEMP"));
strcat(logFileDir, "\\tc_");
strcat(logFileDir, userId);
if (chdir(logFileDir) != ITK_ok) {
printf(">> н¨Â·¾¶£º%s\n", logFileDir);
mkdir(logFileDir);
}
}
void WriteLog(logical debug, const char* format, ...)
{
va_list arg;
char tmp[MAX_PRINTLINE_LENGTH];
char date_string[MAX_PATH_LENGTH];
time_t now;
struct tm* p;
//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);
printf("%s\n", tmp);
//print message to log file
TC_write_syslog("%s\n", tmp);
}
void WriteLog2(logical debug, const char* format, ...)
{
va_list arg;
char tmp[MAX_PRINTLINE_LENGTH];
char date_string[MAX_PATH_LENGTH];
time_t now;
struct tm* p;
//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);
printf("%s\n", tmp);
//print message to log file
if (!debug) {
return;
}
if (logFile)
{
time(&now);
//current_time(&status_now);
p = localtime(&now);
memset(date_string, 0, sizeof(date_string));
sprintf(date_string, "%02d:%02d:%02d", p->tm_hour, p->tm_min, p->tm_sec);
fprintf(logFile, "[%s] %s\n", date_string, tmp);
fflush(logFile);
}
else
{
printf("*!Error!*: Log File Not Exist\n");
}
}
void CloseLog(void)
{
if (logFile)
{
fclose(logFile);
logFile = NULL;
}
}
void CreateLogFile(char* FunctionName, char* userId, char** fullname)
{
int 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 );
sprintf(date_string, "%4d%02d%02d", 1900 + p->tm_year, p->tm_mon + 1, p->tm_mday);
//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"));
strcat(logFileDir, "\\tc_");
strcat(logFileDir, userId);
//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, userId, 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, "a");
CLEANUP:;
//DOFREE(date_string);
/*if(session_uid!=NULL){
MEM_free(session_uid);
session_uid=NULL;
}*/
}
void set_bypass(logical bypass)
{
//AM__set_application_bypass(bypass);
POM_AM__set_application_bypass(bypass);
}
bool isClass(tag_t class_id, char* className) {
tag_t* pclass_ids = NULL;
char* class_name = NULL;
int pclass_count = 0, ifail = ITK_ok;
ITKCALL(POM_name_of_class(class_id, &class_name));
printf("class name = %s\n", class_name);
bool isType = false;
if (strcmp(class_name, className) == 0) {
isType = true;
}
DOFREE(class_name);
if (isType) {
return true;
}
ITKCALL(ifail = POM_superclasses_of_class(class_id, &pclass_count, &pclass_ids));
for (int i = 0;i < pclass_count;i++) {
isType = isClass(pclass_ids[i], className);
if (isType) {
return true;
}
}
return false;
}
bool isType(tag_t item, char* type) {
tag_t class_id = NULLTAG, * pclass_ids = NULL;
char* class_name = NULL;
int pclass_count = 0, ifail = ITK_ok;
ITKCALL(POM_class_of_instance(item, &class_id));
return isClass(class_id, type);
}
void deleteFile(bool debug, char* path) {
//ɾ³ýÎļþ
if (remove(path) == 0) {
WriteLog(debug, "ɾ³ýÎļþ³É¹¦£º%s", path);
}
else {
WriteLog(debug, "ɾ³ýÎļþʧ°Ü£º%s", path);
}
}
int readError(bool debug, char* errFilePath, int errCode) {
fstream _file;
_file.open(errFilePath, ios::in);
if (_file) {
WriteLog(debug, "ÕÒµ½Òì³£ÁÙʱÎļþ£º%s", errFilePath);
ifstream fin(errFilePath);
string s;
while (getline(fin, s))
{
WriteLog(debug, s.c_str());
EMH_store_error_s1(EMH_severity_error, errCode, s.c_str());
}
_file.close();
return errCode;
}
return ITK_ok;
}
//µ¼ÈëÊý¾Ý¼¯
int import_dataset_file(tag_t dataset, const char* ref_name, char* ext, char* fullfilename, char* original_name)
{
int ifail = ITK_ok;
tag_t new_file_tag = NULLTAG;
IMF_file_t file_descriptor = NULL;
AOM_refresh(dataset, FALSE);
char* new_file_name = NULL;
char new_ds_name[WSO_name_size_c + 1] = "";
char* filename = NULL;
new_file_name = USER_new_file_name(new_ds_name, ref_name, ext, 0);
filename = strrchr(fullfilename, '\\') + 1;
if (filename == NULL)
return ITK_ok;
set_bypass(true);
ITKCALL(ifail = IMF_import_file(fullfilename, new_file_name, SS_TEXT, &new_file_tag, &file_descriptor));
if (ifail != ITK_ok) {
ITKCALL(ifail = IMF_import_file(fullfilename, new_file_name, SS_BINARY, &new_file_tag, &file_descriptor));
}
ITKCALL(ifail = IMF_set_original_file_name2(new_file_tag, original_name));
ITKCALL(ifail = IMF_close_file(file_descriptor));
ITKCALL(ifail = AOM_save(new_file_tag));
AOM_unlock(new_file_tag);
ITKCALL(ifail = AOM_refresh(new_file_tag, FALSE));
//Ìí¼ÓÖÁÃüÃûÒýÓÃ
set_bypass(true);
ITKCALL(AOM_lock(dataset));
ITKCALL(ifail = AE_remove_dataset_named_ref2(dataset, ref_name));
ITKCALL(ifail = AOM_save(dataset));
set_bypass(true);
ITKCALL(ifail = AE_add_dataset_named_ref2(dataset, ref_name, AE_PART_OF, new_file_tag));
AOM_save(dataset);
AOM_unlock(dataset);
set_bypass(false);
//ITKCALL( AOM_refresh( dataset, FALSE ) );
return ifail;
}
//µ¼ÈëÊý¾Ý¼¯
int import_dataset_file_binary(tag_t dataset, const char* ref_name, char* ext, char* fullfilename, char* original_name)
{
int ifail = ITK_ok;
tag_t new_file_tag = NULLTAG;
IMF_file_t file_descriptor = NULL;
AOM_refresh(dataset, FALSE);
char* new_file_name = NULL;
char new_ds_name[WSO_name_size_c + 1] = "";
char* filename = NULL;
new_file_name = USER_new_file_name(new_ds_name, ref_name, ext, 0);
filename = strrchr(fullfilename, '\\') + 1;
if (filename == NULL)
return ITK_ok;
set_bypass(true);
ITKCALL(ifail = IMF_import_file(fullfilename, new_file_name, SS_BINARY, &new_file_tag, &file_descriptor));
ITKCALL(ifail = IMF_set_original_file_name2(new_file_tag, original_name));
ITKCALL(ifail = IMF_close_file(file_descriptor));
ITKCALL(ifail = AOM_save(new_file_tag));
AOM_unlock(new_file_tag);
ITKCALL(ifail = AOM_refresh(new_file_tag, FALSE));
//Ìí¼ÓÖÁÃüÃûÒýÓÃ
set_bypass(true);
ITKCALL(AOM_lock(dataset));
ITKCALL(ifail = AE_remove_dataset_named_ref2(dataset, ref_name));
ITKCALL(ifail = AOM_save(dataset));
set_bypass(true);
ITKCALL(ifail = AE_add_dataset_named_ref2(dataset, ref_name, AE_PART_OF, new_file_tag));
AOM_save(dataset);
AOM_unlock(dataset);
set_bypass(false);
//ITKCALL( AOM_refresh( dataset, FALSE ) );
return ifail;
}
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 = 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;
}
}
}
bool inArray(vector<string> types, string type) {
int len = types.size();
for (int i = 0;i < len;i++) {
if (strcmp(types[i].c_str(), type.c_str()) == 0) {
return true;
}
}
return false;
}
int getIndexInArray(vector<string> types, string type) {
int len = types.size();
for (int i = 0;i < len;i++) {
if (strcmp(types[i].c_str(), type.c_str()) == 0) {
return i;
}
}
return -1;
}
bool CheckType(string config, char* type, char spliter) {
vector<string> types;
Split(config, spliter, types);
int len = types.size();
for (int i = 0;i < len;i++) {
if (strcmp(types[i].c_str(), type) == 0) {
return true;
}
}
return false;
}
int GetProcessTargets(bool debug, int att_cnt, tag_t* attachments, vector<tag_t>& targets, char* formType, char splitter) {
char* object_name = NULL, * object_type = NULL;
int ifail = ITK_ok;
WriteLog(debug, "¿ªÊ¼¼ìË÷Á÷³ÌÄ¿±ê¶ÔÏó£º%d", att_cnt);
for (int i = 0;i < att_cnt;i++) {
ITKCALL(ifail = WSOM_ask_name2(attachments[i], &object_name));
ITKCALL(ifail = WSOM_ask_object_type2(attachments[i], &object_type));
WriteLog(debug, "%d. Á÷³Ì¶ÔÏó<%s>£¬ÀàÐÍ£º%s", i + 1, object_name, object_type);
//if (strcmp(object_type, TYPE_ITEM_PZJ.c_str()) == 0) {
if (CheckType(formType, object_type, splitter)) {
targets.push_back(attachments[i]);
}
DOFREE(object_name);
DOFREE(object_type);
}
return ITK_ok;
}
int findUser(bool debug, string userStr, tag_t* user_tag) {
int ind1 = userStr.find_first_of('(');
int ind2 = userStr.find_first_of(')');
WriteLog(debug, "²éѯÓû§£º%s", userStr.c_str());
if (ind1 != string::npos && ind2 != string::npos && ind1 < ind2) {
userStr = userStr.substr(ind1 + 1, ind2 - ind1 - 1);
WriteLog(debug, ">> Óû§id: %s", userStr.c_str());
}
int ifail = ITK_ok;
ITKCALL(ifail = SA_find_user2(userStr.c_str(), user_tag));
return ifail;
}
int GetBomLinePropString(bool debug, tag_t line, char* propName, int errCode, char** attr_val) {
int attribute_id = 0, ifail = ITK_ok;
ITKCALL(ifail = BOM_line_look_up_attribute(propName, &attribute_id));
if (attribute_id == 0) {
WriteLog(debug, "BOMÐÐÊôÐÔ²»´æÔÚ£º%s", propName);
EMH_store_error_s2(EMH_severity_error, errCode, "BOMÐÐÊôÐÔ²»´æÔÚ", propName);
return errCode;
}
else {
ITKCALL(ifail = BOM_line_ask_attribute_string(line, attribute_id, &*attr_val));
return ifail;
}
return ITK_ok;
}
int GetStringProp(tag_t obj, char* propName, char** attr_val) {
return AOM_ask_value_string(obj, propName, &*attr_val);
}
bool isRev(char* object_type) {
if (((strstr(object_type, "Revision") != NULL) || (strstr(object_type, "revision") != NULL))
&& (strstr(object_type, "Master") == NULL) && (strstr(object_type, "master") == NULL)
&& (strstr(object_type, "BOM") == NULL) && (strstr(object_type, "bom") == NULL) && (strstr(object_type, "Bom") == NULL)) {
return true;
}
return false;
}
int GetBomView(tag_t rev_tag, char* viewtype, tag_t* bomView, tag_t* bomBVR, bool debug)
{
WriteLog(debug, "¿ªÊ¼»ñÈ¡BOMÊÓͼ£º%s", viewtype);
int ifail = ITK_ok, bvr_count = 0;
tag_t* bvr_list = NULL, bom_view = NULLTAG, view_type = NULLTAG;
*bomBVR = NULLTAG;
*bomView = NULLTAG;
ITKCALL(ITEM_rev_list_bom_view_revs(rev_tag, &bvr_count, &bvr_list));
if (bvr_count > 0)
{
for (int 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));
WriteLog(debug, "ÕÒµ½ÊÓͼ ÀàÐÍ£º%s", view_type_name);
if (tc_strcmp(view_type_name, viewtype) == 0)
{
*bomBVR = bvr_list[i];
*bomView = bom_view;
}
DOFREE(view_type_name);
}
}
//else {
// WriteLog(debug, "ûÓÐÕÒµ½bvr¿ªÊ¼½øÐд´½¨");
// tag_t bv = NULLTAG, bvr = NULLTAG, item_tag = NULLTAG;
// int bvCnt = 0;
// tag_t* bvTags = NULL;
// ITKCALL(ifail = ITEM_ask_item_of_rev(rev_tag, &item_tag));
// tag_t tWindow = NULLTAG;
// ITKCALL(BOM_create_window(&tWindow));
// tag_t tTopLine = NULLTAG;
// ITKCALL(BOM_set_window_top_line(tWindow, item_tag, NULLTAG, NULLTAG, &tTopLine));
// //²éÕÒÔ­BOMÊÓͼ
// ITKCALL(ifail=ITEM_list_bom_views(item_tag, &bvCnt, &bvTags));
// if (bvCnt > 0) {
// WriteLog(debug, "¶ÔÏóÒÑ´æÔÚBOMÊÓͼ£º%d", bvCnt);
// bv = bvTags[0];
// }
// ITKCALL(AOM_lock(item_tag));
// if (bv == NULLTAG) {
// ITKCALL(ifail=PS_create_bom_view(NULLTAG, "", "", item_tag, &bv));
// if (ifail != ITK_ok) {
// ITKCALL(AOM_unlock(item_tag));
// return ifail;
// }
// ITKCALL(AOM_save(bv));
// }
// ITKCALL(ifail=PS_create_bvr(bv, "", "", false, rev_tag, &bvr));
// if (ifail != ITK_ok) {
// ITKCALL(AOM_unlock(item_tag));
// return ifail;
// }
// ITKCALL(AOM_save(bvr));
// ITKCALL(AOM_save(bv));
// ITKCALL(AOM_save(item_tag));
// tag_t tChildLine = NULLTAG;
// ITKCALL(BOM_save_window(tWindow));
// ITKCALL(BOM_close_window(tWindow));
// ITKCALL(AOM_unlock(item_tag));
// *bomBVR = bvr;
// *bomView = bv;
// WriteLog(debug, "bvrн¨Íê³É");
// DOFREE(bvTags);
//}
DOFREE(bvr_list);
return ifail;
}
bool propExist(bool debug, tag_t obj, const char* propName) {
tag_t clTag = NULLTAG, * superClass = NULL;
char* clName = NULL;
int ifail = ITK_ok, cnt = 0;
logical exists = false;
ITKCALL(ifail = POM_class_of_instance(obj, &clTag));
if (ifail != ITK_ok) { return false; }
ITKCALL(ifail = POM_name_of_class(clTag, &clName));
if (ifail != ITK_ok) { return false; }
WriteLog(debug, ">> ¼ì²é%sÊôÐÔ: %s", clName, propName);
ITKCALL(ifail = POM_attr_exists(propName, clName, &exists));
if (ifail != ITK_ok) { return false; }
DOFREE(clName);
if (exists) {
//WriteLog(debug,"ÊôÐÔ´æÔÚ");
return exists;
}
ITKCALL(ifail = POM_superclasses_of_class(clTag, &cnt, &superClass));
for (int i = 0;i < cnt;i++) {
ITKCALL(ifail = POM_name_of_class(superClass[i], &clName));
if (ifail != ITK_ok) { return false; }
WriteLog(debug, ">> ¼ì²é%sÊôÐÔ: %s", clName, propName);
ITKCALL(ifail = POM_attr_exists(propName, clName, &exists));
DOFREE(clName);
if (exists) {
//WriteLog(debug, "ÊôÐÔ´æÔÚ");
return exists;
}
}
WriteLog(debug, "ÊôÐÔ²»´æÔÚ");
return exists;
}
char* G2U(const char* gb2312)
{
int len = MultiByteToWideChar(CP_ACP, 0, gb2312, -1, NULL, 0);
wchar_t* wstr = new wchar_t[len + 1];
memset(wstr, 0, len + 1);
MultiByteToWideChar(CP_ACP, 0, gb2312, -1, wstr, len);
len = WideCharToMultiByte(CP_UTF8, 0, wstr, -1, NULL, 0, NULL, NULL);
char* str = new char[len + 1];
memset(str, 0, len + 1);
WideCharToMultiByte(CP_UTF8, 0, wstr, -1, str, len, NULL, NULL);
if (wstr) delete[] wstr;
return str;
}
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));
ITKCALL(ifail = PREF_ask_char_values_at_location(preference, scope, &num, &values));
if (ifail != ITK_ok) {
return ifail;
}
for (i = 0; i < num; i++)
{
pref_vec.push_back(values[i]);
}
DOFREE(values);
//ITKCALL(ifail = PREF_set_search_scope(old_scope));
return ifail;
}
int getPrefStrings2(const char* preference, TC_preference_search_scope_t scope, char splitter, 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));
ITKCALL(ifail = PREF_ask_char_values_at_location(preference, scope, &num, &values));
if (ifail != ITK_ok) {
return ifail;
}
for (i = 0; i < num; i++)
{
vector<string> split;
Split(values[i], splitter, split);
int size = split.size();
for (j = 0;j < size;j++) {
pref_vec.push_back(split[j]);
}
/*for each (string val in split) {
pref_vec.push_back(val);
}*/
}
DOFREE(values);
//ITKCALL(ifail = PREF_set_search_scope(old_scope));
return ifail;
}
//µ¼³öÊý¾Ý¼¯Îļþ
int export_dataset_file(bool debug, tag_t dataset, const char* ref_name, char* userId, char* ext, char** filename, char** original_name)
{
int ifail = ITK_ok;
tag_t ref_object = NULLTAG,
datasettype = NULLTAG,
new_ds = NULLTAG,
tool = NULLTAG,
folder_tag = NULLTAG,
spec_dataset_rev = NULLTAG;
AE_reference_type_t reference_type;
tag_t new_file_tag = NULLTAG;
IMF_file_t file_descriptor;
char* target_ds_name = NULL;
char* new_file_name;
WSOM_ask_name2(dataset, &target_ds_name);
WriteLog(debug, "¿ªÊ¼´ÓÊý¾Ý¼¯<%s>ÏÂÔØÎļþ", target_ds_name);
DOFREE(target_ds_name);
*filename = (char*)MEM_alloc(sizeof(char) * 512);
*original_name = (char*)MEM_alloc(sizeof(char) * 512);
strcpy(*filename, "");
AE_ask_dataset_latest_rev(dataset, &spec_dataset_rev);
AE_ask_dataset_named_ref2(dataset, ref_name, &reference_type, &ref_object);
if (ref_object == NULLTAG)
{
WriteLog(debug, "ÎļþÒýÓÃΪ¿Õ");
return 1;
}
if (reference_type == AE_PART_OF)
{
char* pathname2 = NULL;
IMF_ask_file_pathname2(ref_object, SS_WNT_MACHINE, &pathname2);
DOFREE(pathname2);
char* origin_file_name2 = NULL;
IMF_ask_original_file_name2(ref_object, &origin_file_name2);
strcpy(*original_name, origin_file_name2);
DOFREE(origin_file_name2);
char new_ds_name[WSO_name_size_c + 1] = "";
char* new_file_name = USER_new_file_name(new_ds_name, ref_name, ext, 0);
char* temp_dir = getenv("TEMP");
char temp_file[SS_MAXPATHLEN] = "";
strcpy(temp_file, temp_dir);
strcat(temp_file, "\\tc_");
strcat(temp_file, userId);
strcat(temp_file, "\\");
strcat(temp_file, new_file_name);
WriteLog(debug, "ÁÙʱÎļþ·¾¶£º%s", temp_file);
if ((_access(temp_file, 0)) != -1) {
if (!remove(temp_file)) {
remove(temp_file);
}
}
IMF_export_file(ref_object, temp_file);
strcpy(*filename, temp_file);
return ITK_ok;
}
return -1;
}

@ -0,0 +1,800 @@
#pragma warning (disable: 4996)
#pragma warning (disable: 4819)
#include "kutil.h"
FILE* logFile = NULL;
#define MAX_PATH_LENGTH 200
#define MAX_PRINTLINE_LENGTH 8000
void initUserDir(char* userId) {
char logFileDir[MAX_PATH_LENGTH];
memset(logFileDir, 0, sizeof(logFileDir));
sprintf(logFileDir, "%s", getenv("TEMP"));
strcat(logFileDir, "\\tc_");
strcat(logFileDir, userId);
if (chdir(logFileDir) != ITK_ok) {
printf(">> Create Path: %s\n", logFileDir);
mkdir(logFileDir);
}
}
int WriteToFile(logical debug, FILE* file, const char* format, ...)
{
va_list arg;
char tmp[MAX_PRINTLINE_LENGTH];
//get the message
memset(tmp, 0, sizeof(tmp));
va_start(arg, format);
vsprintf(tmp, format, arg);
va_end(arg);
//print message to log file
WriteLog(debug, "写入内容:%s", tmp);
if (file)
{
fprintf(file, "%s", tmp);
fflush(file);
return ITK_ok;
}
else
{
WriteLog(debug, "写入文件失败,文件不存在");
return -1;
}
}
int CreateUserFile(logical debug, const char* FunctionName, char* userId, char** fullname, FILE** file)
{
int 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);
//sprintf(date_string, "%4d%02d%02d", 1900 + p->tm_year, p->tm_mon + 1, p->tm_mday);
//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"));
strcat(logFileDir, "\\tc_");
strcat(logFileDir, userId);
//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"));
WriteLog(debug, "TC_USER_LOG_DIR invalide, log file dir: %s", logFileDir);
//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
WriteLog(debug, "!*ERROR*!: Failed to change dir to TC_USER_LOG_DIR");
//printf("!*ERROR*!: Failed to change dir to TC_USER_LOG_DIR\n");
return -1;
}
}
//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.txt", FunctionName, userId, 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
*file = fopen(logFileName, "a");
return ITK_ok;
//CLEANUP:;
//DOFREE(date_string);
/*if(session_uid!=NULL){
MEM_free(session_uid);
session_uid=NULL;
}*/
}
void WriteLog(logical debug, const char* format, ...)
{
va_list arg;
char tmp[MAX_PRINTLINE_LENGTH];
memset(tmp, 0, sizeof(tmp));
va_start(arg, format);
vsprintf(tmp, format, arg);
va_end(arg);
printf("%s\n", tmp);
TC_write_syslog("%s\n", tmp);
}
void WriteLog2(logical debug, const char* format, ...)
{
va_list arg;
char tmp[MAX_PRINTLINE_LENGTH];
char date_string[MAX_PATH_LENGTH];
time_t now;
struct tm* p;
//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);
printf("%s\n", tmp);
//print message to log file
if (!debug) {
return;
}
if (logFile)
{
time(&now);
//current_time(&status_now);
p = localtime(&now);
memset(date_string, 0, sizeof(date_string));
sprintf(date_string, "%02d:%02d:%02d", p->tm_hour, p->tm_min, p->tm_sec);
fprintf(logFile, "[%s] %s\n", date_string, tmp);
fflush(logFile);
}
else
{
printf("*!Error!*: Log File Not Exist\n");
}
}
void CloseLog(void)
{
if (logFile)
{
fclose(logFile);
logFile = NULL;
}
}
void CreateLogFile(char* FunctionName, char* userId, char** fullname)
{
int 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 );
sprintf(date_string, "%4d%02d%02d", 1900 + p->tm_year, p->tm_mon + 1, p->tm_mday);
//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"));
strcat(logFileDir, "\\tc_");
strcat(logFileDir, userId);
//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, userId, 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, "a");
CLEANUP:;
//DOFREE(date_string);
/*if(session_uid!=NULL){
MEM_free(session_uid);
session_uid=NULL;
}*/
}
void set_bypass(logical bypass)
{
//AM__set_application_bypass(bypass);
POM_AM__set_application_bypass(bypass);
}
bool isClass(tag_t class_id, char* className) {
tag_t* pclass_ids = NULL;
char* class_name = NULL;
int pclass_count = 0, ifail = ITK_ok;
ITKCALL(POM_name_of_class(class_id, &class_name));
printf("class name = %s\n", class_name);
bool isType = false;
if (strcmp(class_name, className) == 0) {
isType = true;
}
DOFREE(class_name);
if (isType) {
return true;
}
ITKCALL(ifail = POM_superclasses_of_class(class_id, &pclass_count, &pclass_ids));
for (int i = 0;i < pclass_count;i++) {
isType = isClass(pclass_ids[i], className);
if (isType) {
return true;
}
}
return false;
}
bool isType(tag_t item, char* type) {
tag_t class_id = NULLTAG, * pclass_ids = NULL;
char* class_name = NULL;
int pclass_count = 0, ifail = ITK_ok;
ITKCALL(POM_class_of_instance(item, &class_id));
return isClass(class_id, type);
}
void deleteFile(bool debug, char* path) {
//é?3y???t
if (remove(path) == 0) {
WriteLog(debug, "Delete File: %s", path);
}
else {
WriteLog(debug, "Delete File failed: %s", path);
}
}
int readError(bool debug, char* errFilePath, int errCode) {
fstream _file;
_file.open(errFilePath, ios::in);
if (_file) {
WriteLog(debug, "Find Error File: %s", errFilePath);
ifstream fin(errFilePath);
string s;
while (getline(fin, s))
{
WriteLog(debug, s.c_str());
EMH_store_error_s1(EMH_severity_error, errCode, s.c_str());
}
_file.close();
return errCode;
}
return ITK_ok;
}
//μ?è?êy?Y?ˉ
int import_dataset_file(tag_t dataset, const char* ref_name, char* ext, char* fullfilename, char* original_name)
{
int ifail = ITK_ok;
tag_t new_file_tag = NULLTAG;
IMF_file_t file_descriptor = NULL;
AOM_refresh(dataset, FALSE);
char* new_file_name = NULL;
char new_ds_name[WSO_name_size_c + 1] = "";
char* filename = NULL;
new_file_name = USER_new_file_name(new_ds_name, ref_name, ext, 0);
filename = strrchr(fullfilename, '\\') + 1;
if (filename == NULL)
return ITK_ok;
set_bypass(true);
ITKCALL(ifail = IMF_import_file(fullfilename, new_file_name, SS_TEXT, &new_file_tag, &file_descriptor));
if (ifail != ITK_ok) {
ITKCALL(ifail = IMF_import_file(fullfilename, new_file_name, SS_BINARY, &new_file_tag, &file_descriptor));
}
ITKCALL(ifail = IMF_set_original_file_name2(new_file_tag, original_name));
ITKCALL(ifail = IMF_close_file(file_descriptor));
ITKCALL(ifail = AOM_save(new_file_tag));
AOM_unlock(new_file_tag);
ITKCALL(ifail = AOM_refresh(new_file_tag, FALSE));
//ìí?ó?á?ü??òyó?
set_bypass(true);
ITKCALL(AOM_lock(dataset));
ITKCALL(ifail = AE_remove_dataset_named_ref2(dataset, ref_name));
ITKCALL(ifail = AOM_save(dataset));
set_bypass(true);
ITKCALL(ifail = AE_add_dataset_named_ref2(dataset, ref_name, AE_PART_OF, new_file_tag));
AOM_save(dataset);
AOM_unlock(dataset);
set_bypass(false);
//ITKCALL( AOM_refresh( dataset, FALSE ) );
return ifail;
}
//μ?è?êy?Y?ˉ
int import_dataset_file_binary(tag_t dataset, const char* ref_name, char* ext, char* fullfilename, char* original_name)
{
int ifail = ITK_ok;
tag_t new_file_tag = NULLTAG;
IMF_file_t file_descriptor = NULL;
AOM_refresh(dataset, FALSE);
char* new_file_name = NULL;
char new_ds_name[WSO_name_size_c + 1] = "";
char* filename = NULL;
new_file_name = USER_new_file_name(new_ds_name, ref_name, ext, 0);
filename = strrchr(fullfilename, '\\') + 1;
if (filename == NULL)
return ITK_ok;
set_bypass(true);
ITKCALL(ifail = IMF_import_file(fullfilename, new_file_name, SS_BINARY, &new_file_tag, &file_descriptor));
ITKCALL(ifail = IMF_set_original_file_name2(new_file_tag, original_name));
ITKCALL(ifail = IMF_close_file(file_descriptor));
ITKCALL(ifail = AOM_save(new_file_tag));
AOM_unlock(new_file_tag);
ITKCALL(ifail = AOM_refresh(new_file_tag, FALSE));
//ìí?ó?á?ü??òyó?
set_bypass(true);
ITKCALL(AOM_lock(dataset));
ITKCALL(ifail = AE_remove_dataset_named_ref2(dataset, ref_name));
ITKCALL(ifail = AOM_save(dataset));
set_bypass(true);
ITKCALL(ifail = AE_add_dataset_named_ref2(dataset, ref_name, AE_PART_OF, new_file_tag));
AOM_save(dataset);
AOM_unlock(dataset);
set_bypass(false);
//ITKCALL( AOM_refresh( dataset, FALSE ) );
return ifail;
}
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 = 0;
string one_arg;
if (strArg.find_first_not_of(' ') == string::npos)
strArg = "";
int len = spliter.size();
while (strArg.size() > 0)
{
index0 = strArg.find(spliter);
if (index0 != string::npos)
{
one_arg = strArg.substr(0, index0);
strArg = strArg.substr(index0 + len);
ans.push_back(one_arg);
if (strArg.size() == 0) {
ans.push_back(strArg);
}
}
else
{
ans.push_back(strArg);
break;
}
}
}
bool inArray(vector<string> types, string type) {
int len = types.size();
for (int i = 0;i < len;i++) {
if (strcmp(types[i].c_str(), type.c_str()) == 0) {
return true;
}
}
return false;
}
int getIndexInArray(vector<string> types, string type) {
int len = types.size();
for (int i = 0;i < len;i++) {
if (strcmp(types[i].c_str(), type.c_str()) == 0) {
return i;
}
}
return -1;
}
bool CheckType(string config, char* type, char spliter) {
vector<string> types;
Split(config, spliter, types);
int len = types.size();
for (int i = 0;i < len;i++) {
if (strcmp(types[i].c_str(), type) == 0) {
return true;
}
}
return false;
}
int GetProcessTargets(bool debug, int att_cnt, tag_t* attachments, vector<tag_t>& targets, char* formType, char splitter) {
char* object_name = NULL, * object_type = NULL;
int ifail = ITK_ok;
WriteLog(debug, "Get Targets of Process: %d", att_cnt);
for (int i = 0;i < att_cnt;i++) {
ITKCALL(ifail = WSOM_ask_name2(attachments[i], &object_name));
ITKCALL(ifail = WSOM_ask_object_type2(attachments[i], &object_type));
WriteLog(debug, "%d. Target [%s], type: %s", i + 1, object_name, object_type);
//if (strcmp(object_type, TYPE_ITEM_PZJ.c_str()) == 0) {
if (CheckType(formType, object_type, splitter)) {
targets.push_back(attachments[i]);
}
DOFREE(object_name);
DOFREE(object_type);
}
return ITK_ok;
}
int findUser(bool debug, string userStr, tag_t* user_tag) {
int ind1 = userStr.find_first_of('(');
int ind2 = userStr.find_first_of(')');
WriteLog(debug, "Search User: %s", userStr.c_str());
if (ind1 != string::npos && ind2 != string::npos && ind1 < ind2) {
userStr = userStr.substr(ind1 + 1, ind2 - ind1 - 1);
WriteLog(debug, ">> User id: %s", userStr.c_str());
}
int ifail = ITK_ok;
ITKCALL(ifail = SA_find_user2(userStr.c_str(), user_tag));
return ifail;
}
int GetBomLinePropString(bool debug, tag_t line, char* propName, int errCode, char** attr_val) {
int attribute_id = 0, ifail = ITK_ok;
ITKCALL(ifail = BOM_line_look_up_attribute(propName, &attribute_id));
if (attribute_id == 0) {
WriteLog(debug, "BOMLine property not exist: %s", propName);
EMH_store_error_s2(EMH_severity_error, errCode, "BOMLine property not exist", propName);
return errCode;
}
else {
ITKCALL(ifail = BOM_line_ask_attribute_string(line, attribute_id, &*attr_val));
return ifail;
}
return ITK_ok;
}
int GetStringProp(tag_t obj, char* propName, char** attr_val) {
return AOM_ask_value_string(obj, propName, &*attr_val);
}
bool isRev(char* object_type) {
if (((strstr(object_type, "Revision") != NULL) || (strstr(object_type, "revision") != NULL))
&& (strstr(object_type, "Master") == NULL) && (strstr(object_type, "master") == NULL)
&& (strstr(object_type, "BOM") == NULL) && (strstr(object_type, "bom") == NULL) && (strstr(object_type, "Bom") == NULL)) {
return true;
}
return false;
}
int GetBomView(tag_t rev_tag, const char* viewtype, tag_t* bomView, tag_t* bomBVR, bool debug)
{
WriteLog(debug, "Get BOM View: %s", viewtype);
int ifail = ITK_ok, bvr_count = 0;
tag_t* bvr_list = NULL, bom_view = NULLTAG, view_type = NULLTAG;
*bomBVR = NULLTAG;
*bomView = NULLTAG;
ITKCALL(ITEM_rev_list_bom_view_revs(rev_tag, &bvr_count, &bvr_list));
if (bvr_count > 0)
{
for (int 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));
WriteLog(debug, "Find View: %s", view_type_name);
if (tc_strcmp(view_type_name, viewtype) == 0)
{
*bomBVR = bvr_list[i];
*bomView = bom_view;
}
DOFREE(view_type_name);
}
}
//else {
// WriteLog(debug, "??óD?òμ?bvr?aê???DD?¨");
// tag_t bv = NULLTAG, bvr = NULLTAG, item_tag = NULLTAG;
// int bvCnt = 0;
// tag_t* bvTags = NULL;
// ITKCALL(ifail = ITEM_ask_item_of_rev(rev_tag, &item_tag));
// tag_t tWindow = NULLTAG;
// ITKCALL(BOM_create_window(&tWindow));
// tag_t tTopLine = NULLTAG;
// ITKCALL(BOM_set_window_top_line(tWindow, item_tag, NULLTAG, NULLTAG, &tTopLine));
// //2é?ò?-BOMêóí?
// ITKCALL(ifail=ITEM_list_bom_views(item_tag, &bvCnt, &bvTags));
// if (bvCnt > 0) {
// WriteLog(debug, "???óò???úBOMêóí?£o%d", bvCnt);
// bv = bvTags[0];
// }
// ITKCALL(AOM_lock(item_tag));
// if (bv == NULLTAG) {
// ITKCALL(ifail=PS_create_bom_view(NULLTAG, "", "", item_tag, &bv));
// if (ifail != ITK_ok) {
// ITKCALL(AOM_unlock(item_tag));
// return ifail;
// }
// ITKCALL(AOM_save(bv));
// }
// ITKCALL(ifail=PS_create_bvr(bv, "", "", false, rev_tag, &bvr));
// if (ifail != ITK_ok) {
// ITKCALL(AOM_unlock(item_tag));
// return ifail;
// }
// ITKCALL(AOM_save(bvr));
// ITKCALL(AOM_save(bv));
// ITKCALL(AOM_save(item_tag));
// tag_t tChildLine = NULLTAG;
// ITKCALL(BOM_save_window(tWindow));
// ITKCALL(BOM_close_window(tWindow));
// ITKCALL(AOM_unlock(item_tag));
// *bomBVR = bvr;
// *bomView = bv;
// WriteLog(debug, "bvrD??¨íê3é");
// DOFREE(bvTags);
//}
DOFREE(bvr_list);
return ifail;
}
bool propExist(bool debug, tag_t obj, const char* propName) {
tag_t clTag = NULLTAG, * superClass = NULL;
char* clName = NULL;
int ifail = ITK_ok, cnt = 0;
logical exists = false;
ITKCALL(ifail = POM_class_of_instance(obj, &clTag));
if (ifail != ITK_ok) { return false; }
ITKCALL(ifail = POM_name_of_class(clTag, &clName));
if (ifail != ITK_ok) { return false; }
WriteLog(debug, ">> [%s] Check Property: %s", clName, propName);
ITKCALL(ifail = POM_attr_exists(propName, clName, &exists));
if (ifail != ITK_ok) { return false; }
DOFREE(clName);
if (exists) {
//WriteLog(debug,"ê?D???ú");
return exists;
}
ITKCALL(ifail = POM_superclasses_of_class(clTag, &cnt, &superClass));
for (int i = 0;i < cnt;i++) {
ITKCALL(ifail = POM_name_of_class(superClass[i], &clName));
if (ifail != ITK_ok) { return false; }
WriteLog(debug, ">> [%s] Check Property: %s", clName, propName);
ITKCALL(ifail = POM_attr_exists(propName, clName, &exists));
DOFREE(clName);
if (exists) {
//WriteLog(debug, "ê?D???ú");
return exists;
}
}
WriteLog(debug, "Property not exist");
return exists;
}
char* G2U(const char* gb2312)
{
int len = MultiByteToWideChar(CP_ACP, 0, gb2312, -1, NULL, 0);
wchar_t* wstr = new wchar_t[len + 1];
memset(wstr, 0, len + 1);
MultiByteToWideChar(CP_ACP, 0, gb2312, -1, wstr, len);
len = WideCharToMultiByte(CP_UTF8, 0, wstr, -1, NULL, 0, NULL, NULL);
char* str = new char[len + 1];
memset(str, 0, len + 1);
WideCharToMultiByte(CP_UTF8, 0, wstr, -1, str, len, NULL, NULL);
if (wstr) delete[] wstr;
return str;
}
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));
ITKCALL(ifail = PREF_ask_char_values_at_location(preference, scope, &num, &values));
if (ifail != ITK_ok) {
return ifail;
}
for (i = 0; i < num; i++)
{
pref_vec.push_back(values[i]);
}
DOFREE(values);
//ITKCALL(ifail = PREF_set_search_scope(old_scope));
return ifail;
}
int getPrefStrings2(const char* preference, TC_preference_search_scope_t scope, char splitter, 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));
ITKCALL(ifail = PREF_ask_char_values_at_location(preference, scope, &num, &values));
if (ifail != ITK_ok) {
return ifail;
}
for (i = 0; i < num; i++)
{
vector<string> split;
Split(values[i], splitter, split);
int size = split.size();
for (j = 0;j < size;j++) {
pref_vec.push_back(split[j]);
}
/*for each (string val in split) {
pref_vec.push_back(val);
}*/
}
DOFREE(values);
//ITKCALL(ifail = PREF_set_search_scope(old_scope));
return ifail;
}
//μ?3?êy?Y?ˉ???t
int export_dataset_file(bool debug, tag_t dataset, const char* ref_name, const char* ext, char** filename, char** original_name)
{
int ifail = ITK_ok;
tag_t ref_object = NULLTAG,
datasettype = NULLTAG,
new_ds = NULLTAG,
tool = NULLTAG,
folder_tag = NULLTAG,
spec_dataset_rev = NULLTAG;
AE_reference_type_t reference_type;
tag_t new_file_tag = NULLTAG;
IMF_file_t file_descriptor;
char* target_ds_name = NULL;
char* new_file_name;
WSOM_ask_name2(dataset, &target_ds_name);
WriteLog(debug, "Download file from dataset %s", target_ds_name);
DOFREE(target_ds_name);
*filename = (char*)MEM_alloc(sizeof(char) * 512);
*original_name = (char*)MEM_alloc(sizeof(char) * 512);
strcpy(*filename, "");
AE_ask_dataset_latest_rev(dataset, &spec_dataset_rev);
AE_ask_dataset_named_ref2(dataset, ref_name, &reference_type, &ref_object);
if (ref_object == NULLTAG)
{
WriteLog(debug, "File ref not exist");
return 1;
}
if (reference_type == AE_PART_OF)
{
char* pathname2 = NULL;
IMF_ask_file_pathname2(ref_object, SS_WNT_MACHINE, &pathname2);
DOFREE(pathname2);
char* origin_file_name2 = NULL;
IMF_ask_original_file_name2(ref_object, &origin_file_name2);
strcpy(*original_name, origin_file_name2);
DOFREE(origin_file_name2);
char new_ds_name[WSO_name_size_c + 1] = "";
char* new_file_name = USER_new_file_name(new_ds_name, ref_name, ext, 0);
char* temp_dir = getenv("TEMP");
char temp_file[SS_MAXPATHLEN] = "";
strcpy(temp_file, temp_dir);
//strcat(temp_file, "\\tc_");
//strcat(temp_file, userId);
strcat(temp_file, "\\");
strcat(temp_file, new_file_name);
WriteLog(debug, "Temp path: %s", temp_file);
if ((_access(temp_file, 0)) != -1) {
if (!remove(temp_file)) {
remove(temp_file);
}
}
IMF_export_file(ref_object, temp_file);
strcpy(*filename, temp_file);
return ITK_ok;
}
return -1;
}

@ -0,0 +1,88 @@
#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 <tchar.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 <time.h>
#include <ae/ae.h>
#include <stdio.h>
#include <ctype.h>
#include <string.h>
#include <string>
#include <iostream>
#include <iterator>
#include <map>
#include <vector>
#include <sstream>
#include <fstream>
#include <res\reservation.h>
#ifdef WIN32
#include <io.h>
#include <direct.h>
#else
#include <unistd.h>
#endif
#define DOFREE(obj) \
{ \
if(obj) \
{ \
MEM_free(obj); \
obj = NULL; \
} \
}
extern "C" int POM_AM__set_application_bypass(logical bypass);
using namespace std;
void WriteLog(logical debug, const char* format, ...);
void set_bypass(logical bypass);
char* G2U(const char* gb2312);
int getPrefStrings(const char* preference, TC_preference_search_scope_t scope, vector<string>& pref_vec);
int export_dataset_file(bool debug, tag_t dataset, const char* ref_name, const char* ext, char** filename, char** original_name);
int GetBomView(tag_t rev_tag, const char* viewtype, tag_t* bomView, tag_t* bomBVR, bool debug);
int GetBomLinePropString(bool debug, tag_t line, char* propName, int errCode, char** attr_val);
void Split(string strArg, char spliter, vector<string>& ans);
void Split(string strArg, string spliter, vector<string>& ans);
int getPrefStrings2(const char* preference, TC_preference_search_scope_t scope, char splitter, vector<string>& pref_vec);
int import_dataset_file(tag_t dataset, const char* ref_name, char* ext, char* fullfilename, char* original_name);
int import_dataset_file_binary(tag_t dataset, const char* ref_name, char* ext, char* fullfilename, char* original_name);
int readError(bool debug, char* errFilePath, int errCode);
void deleteFile(bool debug, char* path);
bool CheckType(string config, char* type, char spliter);
bool propExist(bool debug, tag_t obj, const char* propName);
bool isRev(char* object_type);
int GetProcessTargets(bool debug, int att_cnt, tag_t* attachments, vector<tag_t>& targets, char* formType, char splitter);
bool inArray(vector<string> types, string type);
int getIndexInArray(vector<string> types, string type);
int findUser(bool debug, string userStr, tag_t* user_tag);
bool isType(tag_t item, char* type);
void initUserDir(char* userId);
int CreateUserFile(logical debug, const char* FunctionName, char* userId, char** fullname, FILE** file);
int WriteToFile(logical debug, FILE* file, const char* format, ...);

@ -0,0 +1,169 @@
// cd9_TreeAndListCodeNode
#define TreeAndListCodeNode_uid "uid" // Integer 节点序号
#define TreeAndListCodeNode_isContainsChildren "isContainsChildren" // Integer 节点序号
#define TreeAndListCodeNode_node_index "cd9_node_index" // Integer 节点序号
#define TreeAndListCodeNode_node_type "cd9_node_type"// String 节点名称
#define TreeAndListCodeNode_node_name "cd9_node_name"// String 节点名称
#define TreeAndListCodeNode_node_value "cd9_node_value" // String 节点值
#define TreeAndListCodeNode_node_desc "cd9_node_desc" // String 节点描述
#define TreeAndListCodeNode_is_root "cd9_is_root"// boolean 是否是根节点
#define TreeAndListCodeNode_code_style "cd9_code_style" // String 编码格式
#define TreeAndListCodeNode_code_length "cd9_code_length" // int 编码长度
#define TreeAndListCodeNode_rule_node "cd9_rule_node" // String 编码格式
#define TreeAndListCodeNode_reference_nodes "cd9_reference_nodes" // 引用的节点
#define TreeAndListCodeNode_is_lock "cd9_is_lock"// boolean 是否锁定
#define TreeAndListCodeNode_create_date "cd9_create_date"// Date 创建日期
#define TreeAndListCodeNode_last_revise_date "cd9_last_revise_date"// Date 最后修改日期
#define TreeAndListCodeNode_create_user "cd9_create_user"// TypeReference 创建者
#define TreeAndListCodeNode_last_revise_user "cd9_last_revise_user"// TypeReference 最后修改者
#define TreeAndListCodeNode_seq_begin_value "cd9_seq_begin_value" // Integer 流水码初始值
#define TreeAndListCodeNode_seq_max_value "cd9_seq_max_value" // Integer 流水码最大值
#define TreeAndListCodeNode_seq_length "cd9_seq_length" // Integer 流水码长度
#define TreeAndListCodeNode_isDefaultSelected "cd9_isDefaultSelected" // boolean是否默认选中
#define TreeAndListCodeNode_icsID "cd9_icsID" //对应的分类ID
// Cd9_CodeRelation
#define CodeRelation_parent_nodes "cd9_parent_nodes" // TypeReference 父节点
#define CodeRelation_current_node "cd9_current_node" // TypeReference 当前节点
#define CodeRelation_children_nodes "cd9_children_nodes" // TypeReference 子节点
#define CodeRelation_create_date "cd9_create_date"// Date 创建日期
#define CodeRelation_create_user "cd9_create_user"// TypeReference 创建者
// Cd9_ClassificationCodeNode
#define ClassificationCodeNode_node_index "cd9_node_index" // Integer 节点序号
#define ClassificationCodeNode_node_name "cd9_node_name"// String 节点名称
#define ClassificationCodeNode_segment "cd9_segment"// String 所含码段
#define ClassificationCodeNode_create_date "cd9_create_date"// Date 创建日期
#define ClassificationCodeNode_last_revise_date "cd9_last_revise_date"// Date 最后修改日期
#define ClassificationCodeNode_create_user "cd9_create_user"// TypeReference 创建者
#define ClassificationCodeNode_last_revise_user "cd9_last_revise_user"// TypeReference 最后修改者
#define ClassificationCodeNode_grant_users "cd9_grant_users"// TypeReference 授权用户
#define ClassificationCodeNode_grant_roles "cd9_grant_roles"// TypeReference 授权角色
#define ClassificationCodeNode_grant_groups "cd9_grant_groups"// TypeReference 授权组
// Cd9_CodeSequence
#define CodeSequence_seq_node_index "cd9_seq_node_index" // string 流水码码段名称
#define CodeSequence_seq_node_name "cd9_seq_node_name" // Integer 流水码初始值
#define CodeSequence_seq_begin_value "cd9_seq_begin_value" // Integer 流水码初始值
#define CodeSequence_seq_max_value "cd9_seq_max_value" // Integer 流水码最大值
#define CodeSequence_seq_length "cd9_seq_length" // Integer 流水码长度
#define CodeSequence_seq_step "cd9_seq_step" // Integer 流水码步长
#define CodeSequence_seq_exclude_num "cd9_seq_exclude_num" // String 流水码不包含数字
#define CodeSequence_is_lock "cd9_is_lock"// boolean 是否锁定
#define CodeSequence_create_date "cd9_create_date"// Date 创建日期
#define CodeSequence_last_revise_date "cd9_last_revise_date"// Date 最后修改日期
#define CodeSequence_create_user "cd9_create_user"// TypeReference 创建者
#define CodeSequence_last_revise_user "cd9_last_revise_user"// TypeReference 最后修改者
// Cd9_CodeCounter
#define CodeCounter_index "cd9_index"
#define CodeCounter_name "cd9_name"
#define CodeCounter_recycleID "cd9_recycleID"
#define CodeCounter_isUsed "cd9_isUsed"
#define CodeCounter_createDate "cd9_createDate"
#define CodeCounter_createUser "cd9_createUser"
#define CodeCounter_last_revise_date "cd9_last_revise_date"// Date 最后修改日期
#define CodeCounter_last_revise_user "cd9_last_revise_user"
// Item
#define Item_codeDesc "cd9_codeDesc"
#define Item_codePattern "cd9_codePattern"
#define Item_codeID "cd9_codeID"
#define Item_codeRuleName "cd9_codeRuleName"
// cd9_TreeAndListCodeNode
#define TreeAndListCodeNode_uid "uid" // Integer 节点序号
#define TreeAndListCodeNode_isContainsChildren "isContainsChildren" // Integer 节点序号
#define TreeAndListCodeNode_node_index "cd9_node_index" // Integer 节点序号
#define TreeAndListCodeNode_node_type "cd9_node_type"// String 节点名称
#define TreeAndListCodeNode_node_name "cd9_node_name"// String 节点名称
#define TreeAndListCodeNode_node_value "cd9_node_value" // String 节点值
#define TreeAndListCodeNode_node_desc "cd9_node_desc" // String 节点描述
#define TreeAndListCodeNode_is_root "cd9_is_root"// boolean 是否是根节点
#define TreeAndListCodeNode_code_style "cd9_code_style" // String 编码格式
#define TreeAndListCodeNode_code_length "cd9_code_length" // int 编码长度
#define TreeAndListCodeNode_rule_node "cd9_rule_node" // String 编码格式
#define TreeAndListCodeNode_reference_nodes "cd9_reference_nodes" // 引用的节点
#define TreeAndListCodeNode_is_lock "cd9_is_lock"// boolean 是否锁定
#define TreeAndListCodeNode_create_date "cd9_create_date"// Date 创建日期
#define TreeAndListCodeNode_last_revise_date "cd9_last_revise_date"// Date 最后修改日期
#define TreeAndListCodeNode_create_user "cd9_create_user"// TypeReference 创建者
#define TreeAndListCodeNode_last_revise_user "cd9_last_revise_user"// TypeReference 最后修改者
#define TreeAndListCodeNode_seq_begin_value "cd9_seq_begin_value" // Integer 流水码初始值
#define TreeAndListCodeNode_seq_max_value "cd9_seq_max_value" // Integer 流水码最大值
#define TreeAndListCodeNode_seq_length "cd9_seq_length" // Integer 流水码长度
#define TreeAndListCodeNode_isDefaultSelected "cd9_isDefaultSelected" // boolean是否默认选中
#define TreeAndListCodeNode_icsID "cd9_icsID" //对应的分类ID
// Cd9_CodeRelation
#define CodeRelation_parent_nodes "cd9_parent_nodes" // TypeReference 父节点
#define CodeRelation_current_node "cd9_current_node" // TypeReference 当前节点
#define CodeRelation_children_nodes "cd9_children_nodes" // TypeReference 子节点
#define CodeRelation_create_date "cd9_create_date"// Date 创建日期
#define CodeRelation_create_user "cd9_create_user"// TypeReference 创建者
// Cd9_ClassificationCodeNode
#define ClassificationCodeNode_node_index "cd9_node_index" // Integer 节点序号
#define ClassificationCodeNode_node_name "cd9_node_name"// String 节点名称
#define ClassificationCodeNode_segment "cd9_segment"// String 所含码段
#define ClassificationCodeNode_create_date "cd9_create_date"// Date 创建日期
#define ClassificationCodeNode_last_revise_date "cd9_last_revise_date"// Date 最后修改日期
#define ClassificationCodeNode_create_user "cd9_create_user"// TypeReference 创建者
#define ClassificationCodeNode_last_revise_user "cd9_last_revise_user"// TypeReference 最后修改者
#define ClassificationCodeNode_grant_users "cd9_grant_users"// TypeReference 授权用户
#define ClassificationCodeNode_grant_roles "cd9_grant_roles"// TypeReference 授权角色
#define ClassificationCodeNode_grant_groups "cd9_grant_groups"// TypeReference 授权组
// Cd9_CodeSequence
#define CodeSequence_seq_node_index "cd9_seq_node_index" // string 流水码码段名称
#define CodeSequence_seq_node_name "cd9_seq_node_name" // Integer 流水码初始值
#define CodeSequence_seq_begin_value "cd9_seq_begin_value" // Integer 流水码初始值
#define CodeSequence_seq_max_value "cd9_seq_max_value" // Integer 流水码最大值
#define CodeSequence_seq_length "cd9_seq_length" // Integer 流水码长度
#define CodeSequence_seq_step "cd9_seq_step" // Integer 流水码步长
#define CodeSequence_seq_exclude_num "cd9_seq_exclude_num" // String 流水码不包含数字
#define CodeSequence_is_lock "cd9_is_lock"// boolean 是否锁定
#define CodeSequence_create_date "cd9_create_date"// Date 创建日期
#define CodeSequence_last_revise_date "cd9_last_revise_date"// Date 最后修改日期
#define CodeSequence_create_user "cd9_create_user"// TypeReference 创建者
#define CodeSequence_last_revise_user "cd9_last_revise_user"// TypeReference 最后修改者
// Cd9_CodeCounter
#define CodeCounter_index "cd9_index"
#define CodeCounter_name "cd9_name"
#define CodeCounter_recycleID "cd9_recycleID"
#define CodeCounter_isUsed "cd9_isUsed"
#define CodeCounter_createDate "cd9_createDate"
#define CodeCounter_createUser "cd9_createUser"
#define CodeCounter_last_revise_date "cd9_last_revise_date"// Date 最后修改日期
#define CodeCounter_last_revise_user "cd9_last_revise_user"
// Item
#define Item_codeDesc "cd9_codeDesc"
#define Item_codePattern "cd9_codePattern"
#define Item_codeID "cd9_codeID"
#define Item_codeRuleName "cd9_codeRuleName"
#pragma once

@ -0,0 +1,18 @@
## 1. 规则处理程序CONNOR-check-owner
功能:仅对象所有者可以发起流程
```text
参数:
-alert: 提示的内容
```
## 2. 规则处理程序CONNOR-check-release
功能:检查目标下的所有版本类型下的关系中,特定类型对象是否发布
```text
参数:
-alert: 提示的内容
-check: 关系和检查类型格式“关系1=类型1;类型2|关系2=类型3;类型4;类型5|关系3=类型6”
```

@ -0,0 +1,31 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.30002.166
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "NX12_Connor_ITK_QF", "Connor_NX\Connor_NX.vcxproj", "{B66C17FA-78C8-443E-8239-6E8744560AD7}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{B66C17FA-78C8-443E-8239-6E8744560AD7}.Debug|x64.ActiveCfg = Release|x64
{B66C17FA-78C8-443E-8239-6E8744560AD7}.Debug|x64.Build.0 = Release|x64
{B66C17FA-78C8-443E-8239-6E8744560AD7}.Debug|x86.ActiveCfg = Debug|Win32
{B66C17FA-78C8-443E-8239-6E8744560AD7}.Debug|x86.Build.0 = Debug|Win32
{B66C17FA-78C8-443E-8239-6E8744560AD7}.Release|x64.ActiveCfg = Release|x64
{B66C17FA-78C8-443E-8239-6E8744560AD7}.Release|x64.Build.0 = Release|x64
{B66C17FA-78C8-443E-8239-6E8744560AD7}.Release|x86.ActiveCfg = Release|Win32
{B66C17FA-78C8-443E-8239-6E8744560AD7}.Release|x86.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {860AF573-225E-4004-AED7-10B6AE5AA6DE}
EndGlobalSection
EndGlobal

@ -0,0 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="lib" path="lib/commons-io-2.6.jar"/>
<classpathentry kind="lib" path="lib/jfxrt.jar"/>
<classpathentry kind="lib" path="lib/jfxswt.jar"/>
<classpathentry kind="lib" path="lib/NXOpen.jar"/>
<classpathentry kind="lib" path="lib/NXOpenUF.jar"/>
<classpathentry kind="lib" path="lib/NXOpenUI.jar"/>
<classpathentry kind="lib" path="jsonlib/commons-beanutils-1.7.0.jar"/>
<classpathentry kind="lib" path="jsonlib/commons-collections-3.2.jar"/>
<classpathentry kind="lib" path="jsonlib/commons-lang-2.4.jar"/>
<classpathentry kind="lib" path="jsonlib/commons-logging-1.1.jar"/>
<classpathentry kind="lib" path="jsonlib/ezmorph-1.0.4.jar"/>
<classpathentry kind="lib" path="jsonlib/jdom.jar"/>
<classpathentry kind="lib" path="jsonlib/json-lib-2.2.2-jdk15.jar"/>
<classpathentry kind="lib" path="jsonlib/json-lib-2.2.3-jdk13.jar"/>
<classpathentry kind="lib" path="lib/axis.jar"/>
<classpathentry kind="lib" path="lib/commons-discovery-0.2.jar"/>
<classpathentry kind="lib" path="lib/org.apache.commons.logging_1.2.0.v20180409-1502.jar"/>
<classpathentry kind="lib" path="lib/saaj.jar"/>
<classpathentry kind="lib" path="jsonlib/javax.wsdl_1.6.2.v201012040545.jar"/>
<classpathentry kind="lib" path="lib/jaxrpc.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>

@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>NX_Connor_QF</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jem.workbench.JavaEMFNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>

@ -0,0 +1,10 @@
eclipse.preferences.version=1
encoding//src/org/tempuri/ErpWebService.java=UTF-8
encoding//src/org/tempuri/ErpWebServiceLocator.java=UTF-8
encoding//src/org/tempuri/ErpWebServiceSoap.java=UTF-8
encoding//src/org/tempuri/ErpWebServiceSoapStub.java=UTF-8
encoding//src/service/KWebService.java=UTF-8
encoding//src/service/KWebServicePortBindingStub.java=UTF-8
encoding//src/service/KWebServiceService.java=UTF-8
encoding//src/service/KWebServiceServiceLocator.java=UTF-8
encoding/TopDownDesignUI.dlx=UTF-8

@ -0,0 +1,15 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning
org.eclipse.jdt.core.compiler.release=disabled
org.eclipse.jdt.core.compiler.source=1.8

@ -0,0 +1,102 @@
# 一、NX集成配置
## 1. 安装
1. 解压文件 `ConnorNX.rar` 到NX安装目录%UGII_BASE_DIR%\ConnorNX`
2. 在NX安装目录找到文件%UGII_BASE_DIR%\UGII\menus\custom_dirs.dat` ,新增行%UGII_BASE_DIR%\ConnorNX`
3. 将文件 connor_nx_itk.dll 拷贝到TC目录`$TC_ROOT\bin`并修改首选项TC_customization_libraries新增行`connor_nx_itk`
## 2. 签名
需要对`Connor_NXOpen.jar`文件进行签名使用CMD执行命令
```text
%UGII_BASE_DIR%\NXBIN\SignJar.bat %UGII_BASE_DIR%\ConnorNX\Application\Connor_NXOpen.jar
```
## 3. NX 目录配置
`%UGII_BASE_DIR%\ConnorNX\Startup` 目录中包含两个文件`ConnorNX.men`和`ConnorNX.rtb`
1. 在`ConnorNX.men`定义按钮
```text
BUTTON 命令ID
LABEL 按钮文本
ACTIONS Connor_NXOpen.jar
```
2. 将按钮添加到`ConnorNX.rtb`
```text
BUTTON 命令ID
RIBBON_STYLE SMALL_IMAGE_AND_TEXT
```
## 4. 命令ID
**编码器:**`autocode`
**模块化设计:**`top-down-design#首选项名称`
> 模块化设计命令ID中首选项配置为多值、站点。
>
> 1. 第一行填写模板对象ID。模板对象最新版本要求发布版本下以“规范”关系添加图纸简图数据集命名分别为“二维简图.bmp”和“三维简图.bmp”
> 2. 第二行开始配置图纸属性,格式“显示名称=属性名称[=下拉值1;下拉值2;下拉值3...]”
>
> 示例:
>
> ```text
> C3F000001138
> 高度=gaodu=30;50;80;180
> 导柱间距1=jj1=1700;1800;1900
> 导柱间距2=jj2
> 导柱直径=zj=80;90;100
> 机架高度=gd
> ```
>
> 配置首选项:**Connor_NXBomClone**,多值,站点
>
> 格式:
>
> ```text
> 第一行:需要检查的版本属性名称
> 第二行:需要检查的版本属性值,匹配时进行克隆操作
> 第三行:模板版本下规范关系的三维数据集名称
> 第四行:模板版本下规范关系的二维数据集名称
> 第五行:固定内容,表示申请新编码的输入参数 “&;&6&;&1&;&999999&;&1&;&”。配置释义“&;&编码长度&;&起始流水&;&最大流水&;&步长&;&exclude”
> ```
>
> 示例:
>
> ```text
> object_desc
> 是
> 三维简图.bmp
> 二维简图.bmp
> &;&6&;&1&;&999999&;&1&;&
> ```
# 二、NX签名配置
## 1. 安装
1. 解压`NX签名.rar`文件到目录`%UGII_BASE_DIR%\NXBIN`
2. 将文件 connor_nx_itk.dll 拷贝到TC目录`$TC_ROOT\bin`并修改首选项TC_customization_libraries新增行`connor_nx_itk`
## 2. 签名
需要对`NX12_Open_CS_Wizard1.exe`文件进行签名使用CMD执行命令
```text
%UGII_BASE_DIR%\NXBIN\SignDotNet.exe %UGII_BASE_DIR%\NXBIN\NX12_Open_CS_Wizard1.exe
```
## 3. 首选项
配置首选项:**Connor_Sign_NX_EXE_Path**,单值,站点。
值填写`NX12_Open_CS_Wizard1.exe`文件路径
示例:`%UGII_BASE_DIR%\NXBIN\NX12_Open_CS_Wizard1.exe`

@ -0,0 +1,77 @@
注:以下配置中,中括号表示选配内容,配置时不要带中括号
# 集成配置
1. 修改文件“NX安装目录\UGII\menus\custom_dirs.dat” ,新增行“$UGII_BASE_DIR\ConnorNX”
2. 解压集成文件到NX安装目录
# NXOPEN命令参数
输入操作参数格式:
```text
命令ID
参数1
参数2
...
```
## 编码器
命令ID“autocode”
## Top-Down Design
命令ID 1"top-down-design" 界面使用javafx绘制任何时间都可以使用
命令ID 2"top-down-design-nx" 界面使用nx block styler绘制需要“TopDownDesignUI.dlx”只有在工作部件打开时可以正常打开
参数:
1. 首选项名称,写在第二行
示例:
```text
top-down design
01
```
首选项格式:
1. 第一行填写模板对象ID。模板对象最新版本要求发布版本下以“规范”关系添加图纸简图数据集命名分别为“二维简图.bmp”和“三维简图.bmp”
2. 第二行开始配置图纸属性,格式“显示名称=属性名称[=下拉值1;下拉值2;下拉值3...]”。"top-down design nx"命令最多支持配置21个属性如需更多可修改TopDownDesignUI.dlx文件
示例:
```text
C3F000001138
高度=gaodu=30;50;80;180
导柱间距1=jj1=1700;1800;1900
导柱间距2=jj2
导柱直径=zj=80;90;100
机架高度=gd
```
配置首选项Connor_NXBomClone多值站点
格式:
```text
第一行:需要检查的版本属性名称
第二行:需要检查的版本属性值,匹配时进行克隆操作
第三行:三维数据集名称
第四行:二维数据集名称
第五行:固定内容,表示申请新编码的输入参数 “&;&6&;&1&;&999999&;&1&;&”。配置释义“&;&编码长度&;&起始流水&;&最大流水&;&步长&;&exclude”
```
示例:
```text
object_desc
clone
三维简图.bmp
二维简图.bmp
&;&6&;&1&;&999999&;&1&;&
```

File diff suppressed because one or more lines are too long

@ -0,0 +1,91 @@
package nx_connor;
import com.sun.javafx.util.Logging;
import javafx.application.Application;
import javafx.application.Platform;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.image.Image;
import javafx.stage.Stage;
import sun.util.logging.PlatformLogger.Level;
public abstract class KFXPanel extends Application {
static {
Platform.setImplicitExit(false);
Logging.getCSSLogger().setLevel(Level.OFF);
}
public KFXPanel(Stage dialog) throws Exception {
setParentDialog(dialog);
initUI();
}
public KFXPanel(Stage dialog, Class<?> c, String css) throws Exception {
setParentDialog(dialog);
this.cssForm = c.getResource(css).toExternalForm();
initUI();
}
protected Scene scene;
protected Parent root;
protected String cssForm;
protected Stage parentDialog;
public void setParentDialog(Stage dialog) {
this.parentDialog = dialog;
if(dialog!=null) {
dialog.getIcons().add(new Image(KMain.class.getResourceAsStream("teamcenter_app_128.gif")));
}
}
public Stage getParentDialog() {
return this.parentDialog;
}
public Parent getRoot() {
return root;
}
public Scene getScene() {
if (scene == null) {
scene = new Scene(root);
scene.setFill(null);
}
return scene;
}
public abstract Object getController();
protected void initUI() throws Exception {
FXMLLoader fxmlLoader = new FXMLLoader();
String resource = this.getClass().getSimpleName() + ".fxml";
// System.out.println("Load Resource: "+resource);
fxmlLoader.setLocation(this.getClass().getResource(resource));
fxmlLoader.setController(getController());
root = fxmlLoader.load();
// controller = fxmlLoader.getController();
// primaryStage.initStyle(StageStyle.TRANSPARENT);
if (cssForm != null) {
root.getStylesheets().add(cssForm);
}
}
@Override
public void start(Stage primaryStage) throws Exception {
initUI();
primaryStage.setScene(getScene());
primaryStage.show();
}
/**
* Run as javafx application to test ui
*
* @param args
*/
// public static void main(String[] args) {
// launch(args);
// }
}

@ -0,0 +1,120 @@
package nx_connor;
import java.util.Arrays;
import nx_connor.autcocode.AutoCode;
import nx_connor.bomcopy.BomCopy;
import nx_connor.bomcopy2.BomCopy2;
import nx_connor.util.KUtil;
import nxopen.NXException;
import nxopen.NXMessageBox.DialogType;
import nxopen.Session;
import nxopen.SessionFactory;
import nxopen.UFSession;
import nxopen.UI;
public class KMain {
public static Session theSession = null;
public static UI theUI = null;
public static UFSession theUFSession = null;
public static final String APP_PATH;
public static final String SPLIT_SECTION = "&SECTION&";
public static final String SPLIT_PROP_STR = "&PROP&";
public static final String SPLIT_PROP_NAME_VALUE = "&=&";
public static final String SPLITTER = "&;&";
public static final String COMMAND_TOP_DOWN_DESIGN_NX = "TOP-DOWN-DESIGN-NX";
public static final String COMMAND_TOP_DOWN_DESIGN_FX = "TOP-DOWN-DESIGN";
public static final String COMMAND_AUTOCODE = "AUTOCODE";
public static final int INPUTCODE_GetPrefValue = 0;
public static final int INPUTCODE_Parse_NX_Template_By_ID = 1;
public static final int INPUTCODE_Read_NX_Image_By_ID = 2;
public static final int INPUTCODE_Download_Dataset_By_UID = 3;
public static final int INPUTCODE_GET_ALL_SUB_TYPES = 4;
public static final int INPUTCODE_SEARCH_AUTOCODE_NODE = 5;
public static final int INPUTCODE_GET_UID = 6;
public static final int INPUTCODE_SEARCH_AUTOCODE_SEGMENT = 7;
public static final int INPUTCODE_SEARCH_AUTOCODE_USER = 8;
public static final int INPUTCODE_GET_TREE_AND_LIST_STRING_VALUE = 9;
public static final int INPUTCODE_GET_NEW_REV_ID = 10;
public static final int INPUTCODE_GET_LOGICAL_PROP_VALUE = 11;
public static final int INPUTCODE_SEARCH_TREE_OR_LIST_NODE = 12;
public static final int INPUTCODE_GET_TREE_AND_LIST_STRING_VALUES = 13;
public static final int INPUTCODE_SEARCH_PARENT_TREE_OR_LIST_NODE = 14;
public static final int INPUTCODE_ICS_GET_ATTRIBUTES = 15;
// public static final int INPUTCODE_ICS_ATTR_IS_REFERENCE_ATTRIBUTE = 16;
public static final int INPUTCODE_ICS_ATTR_ASK_PROPERTY = 17;
public static final int INPUTCODE_ICS_ATTR_ASK_KEYLOV = 18;
public static final int INPUTCODE_GET_DISPLAY_PROP_VALUE = 19;
public static final int INPUTCODE_FIND_LOV_BY_NAME = 20;
public static final int INPUTCODE_GET_REFERENCE_PROP_VALUE = 21;
public static final int INPUTCODE_QUERY_PART_NO = 22;
public static final int INPUTCODE_DELETE_RECYCLE_ID = 23;
public static final int INPUTCODE_ITEM_EXIST = 24;
public static final int INPUTCODE_ITEM_CREATE = 25;
public static final int INPUTCODE_ADD_TO_NEWSTUFF = 26;
public static final int INPUTCODE_GET_CLASSIFICATION_ID = 27;
public static final int INPUTCODE_SEND_ITEM_TO_CLASSIFICATION = 28;
public static final int INPUTCODE_GET_ITEMTYPE_BY_ID = 29;
public static final int INPUTCODE_GET_REVUID_BY_ID = 30;
public static final int INPUTCODE_ITEM_UPDATE = 31;
public static final int INPUTCODE_READ_NX_TEMPLATE_BOM = 32;
public static final int INPUTCODE_GET_CLONE_INFO = 33;
public static final int INPUTCODE_GET_LATEST_ITEM_REVISION = 34;
public static final int INPUTCODE_GRANT_PRIVILEGE = 35;
public static final int INPUTCODE_GET_UOM_TAGS = 36;
public static final int INPUTCODE_UPDATE_UOM = 37;
public static final int INPUTCODE_GET_REFERENCE_PROP_VALUE_ARRAY = 38;
public static final int INPUTCODE_ICS_ATTR_ASK_METRIC_UNIT = 39;
static {
//APP_PATH = KMain.class.getProtectionDomain().getCodeSource().getLocation().getPath();
String path = KMain.class.getProtectionDomain().getCodeSource()
.getLocation().getPath();
APP_PATH = path.substring(1, path.lastIndexOf('/')+1);
}
public static void main(String[] args) throws NXException, java.rmi.RemoteException {
theSession = (Session) SessionFactory.get("Session");
theUI = (UI) SessionFactory.get("UI");
theUFSession = (UFSession) SessionFactory.get("UFSession");
KUtil.LOG("---------------------------------------------------------------------");
KUtil.LOG("NX12_Connor");
KUtil.LOG("Args: \n- "+Arrays.toString(args));
KUtil.LOG("---------------------------------------------------------------------");
int argCnt = args == null ? 0 : args.length;
if (argCnt == 0) {
return;
}else if(argCnt==1) {
args = args[0].split("#");
}
String commandName = args[0].toUpperCase();
try {
switch (commandName) {
case COMMAND_TOP_DOWN_DESIGN_NX:
BomCopy.copyFromTemplate(args, false);
break;
case COMMAND_TOP_DOWN_DESIGN_FX:
BomCopy2.copyFromTemplate(args);
break;
case COMMAND_AUTOCODE:
AutoCode.runAutoCode(args);
break;
default:
KUtil.LOG("Unknown Command: " + commandName);
break;
}
}
catch (Exception ex) {
KUtil.LOGERROR(ex);
theUI.nxmessageBox().show("´íÎó", DialogType.ERROR, ex.getMessage());
}
KUtil.LOG("---------------------------------------------------------------------");
KUtil.LOG("NX12_Connor Complete");
KUtil.LOG("---------------------------------------------------------------------");
}
}

@ -0,0 +1,43 @@
package nx_connor.autcocode;
import javafx.application.Platform;
import javafx.embed.swing.JFXPanel;
import javafx.stage.Stage;
import nx_connor.util.KUtil;
import nxopen.NXMessageBox.DialogType;
public class AutoCode {
public static void runAutoCode(String[] args) throws Exception{
new JFXPanel();
Platform.runLater(()->{
Stage stage = new Stage();
stage.setTitle("±àÂëÆ÷");
try {
stage.setScene(new AutoCodeDialog(stage).getScene());
stage.show();
} catch (Exception e) {
e.printStackTrace();
KUtil.LOGERROR(e);
KUtil.showNXMessage("´íÎó", DialogType.ERROR, e.getMessage());
}
});
// JFrame frame = new JFrame("ç¼ç <C3A7>å™");
// JFXPanel panel = new JFXPanel();
// panel.setScene(new AutoCodeDialog(frame).getScene());
// frame.setContentPane(panel);
// frame.setSize(new Dimension(1200, 800));
// frame.setLocationRelativeTo(null);
// frame.setAlwaysOnTop(true);
// frame.setVisible(true);
}
public static void main(String[] args) {
try {
runAutoCode(args);
} catch (Exception e) {
e.printStackTrace();
}
}
}

@ -0,0 +1,137 @@
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.scene.effect.*?>
<?import javafx.geometry.*?>
<?import javafx.scene.control.*?>
<?import java.lang.*?>
<?import javafx.scene.layout.*?>
<?import javafx.scene.layout.BorderPane?>
<StackPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="800.0" prefWidth="1200.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1">
<children>
<SplitPane dividerPositions="0.25, 0.7" prefHeight="160.0" prefWidth="200.0">
<items>
<AnchorPane prefHeight="200.0" prefWidth="200.0">
<children>
<TreeView fx:id="treeView" prefHeight="200.0" prefWidth="200.0" style="-fx-background-insets: 0;" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0" />
</children>
</AnchorPane>
<AnchorPane prefHeight="200.0" prefWidth="200.0">
<children>
<TabPane prefHeight="200.0" prefWidth="200.0" tabClosingPolicy="UNAVAILABLE" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<tabs>
<Tab text="编码树">
<content>
<TreeTableView fx:id="treeTableView" prefHeight="200.0" prefWidth="200.0">
<columnResizePolicy>
<TreeTableView fx:constant="CONSTRAINED_RESIZE_POLICY" />
</columnResizePolicy>
<columns>
<TreeTableColumn fx:id="treeTableCol_Name" minWidth="150.0" prefWidth="185.0" text="码段名称" />
<TreeTableColumn fx:id="treeTableCol_Value" minWidth="120.0" prefWidth="49.0" text="码值" />
<TreeTableColumn fx:id="treeTableCol_Note" minWidth="80.0" prefWidth="84.0" text="备注" />
</columns>
</TreeTableView>
</content>
</Tab>
</tabs>
</TabPane>
</children>
</AnchorPane>
<GridPane>
<children>
<Label text="特征码:" />
<Label text="特征码长度" GridPane.rowIndex="2" />
<Label text="版本:" GridPane.rowIndex="5" />
<Label text="名称:" GridPane.rowIndex="7" />
<TextField fx:id="tf_FeatureCode" editable="false" GridPane.rowIndex="1" />
<TextField fx:id="tf_FeatureCodeLength" editable="false" GridPane.rowIndex="3" />
<TextField fx:id="tf_RevisionID" editable="false" GridPane.rowIndex="6" />
<TextField fx:id="tf_Name" GridPane.rowIndex="8" />
<TabPane prefHeight="200.0" prefWidth="200.0" tabClosingPolicy="UNAVAILABLE" GridPane.rowIndex="11">
<tabs>
<Tab text="对象属性">
<content>
<ScrollPane fitToHeight="true" fitToWidth="true" layoutX="-14.0" layoutY="-6.0" prefHeight="200.0" prefWidth="200.0">
<content>
<GridPane fx:id="gridPane_ObjectProps" hgap="10.0" vgap="10.0">
<columnConstraints>
<ColumnConstraints hgrow="NEVER" minWidth="10.0" />
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
</columnConstraints>
<rowConstraints>
<RowConstraints minHeight="10.0" vgrow="NEVER" />
</rowConstraints>
<padding>
<Insets bottom="8.0" left="8.0" right="8.0" top="8.0" />
</padding>
</GridPane>
</content>
</ScrollPane>
</content>
</Tab>
<Tab text="分类属性">
<content>
<ScrollPane fitToHeight="true" fitToWidth="true" layoutX="-23.0" prefHeight="200.0" prefWidth="200.0">
<content>
<GridPane fx:id="gridPane_ClassProps" hgap="10.0" vgap="10.0">
<columnConstraints>
<ColumnConstraints hgrow="NEVER" minWidth="10.0" />
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
<ColumnConstraints hgrow="NEVER" minWidth="10.0" />
</columnConstraints>
<rowConstraints>
<RowConstraints minHeight="10.0" vgrow="NEVER" />
</rowConstraints>
<padding>
<Insets bottom="8.0" left="8.0" right="8.0" top="8.0" />
</padding>
</GridPane>
</content>
</ScrollPane>
</content>
</Tab>
</tabs>
<GridPane.margin>
<Insets bottom="5.0" top="5.0" />
</GridPane.margin>
</TabPane>
<CheckBox fx:id="cb_FeatureCode" mnemonicParsing="false" visible="false" GridPane.rowIndex="4" />
<FlowPane alignment="TOP_RIGHT" hgap="10.0" prefHeight="200.0" prefWidth="200.0" GridPane.rowIndex="12">
<children>
<Button mnemonicParsing="false" onAction="#createBtnClicked" text=" 新建 " />
<Button mnemonicParsing="false" onAction="#cancelBtnClicked" text=" 取消 " />
</children>
</FlowPane>
</children>
<columnConstraints>
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
</columnConstraints>
<padding>
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0" />
</padding>
<rowConstraints>
<RowConstraints minHeight="10.0" vgrow="NEVER" />
<RowConstraints minHeight="10.0" vgrow="NEVER" />
<RowConstraints minHeight="10.0" vgrow="NEVER" />
<RowConstraints minHeight="10.0" vgrow="NEVER" />
<RowConstraints minHeight="0.0" prefHeight="0.0" vgrow="NEVER" />
<RowConstraints minHeight="10.0" vgrow="NEVER" />
<RowConstraints minHeight="10.0" vgrow="NEVER" />
<RowConstraints minHeight="10.0" vgrow="NEVER" />
<RowConstraints minHeight="10.0" vgrow="NEVER" />
<RowConstraints minHeight="10.0" vgrow="NEVER" />
<RowConstraints minHeight="10.0" vgrow="NEVER" />
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="ALWAYS" />
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="NEVER" />
</rowConstraints>
</GridPane>
</items>
</SplitPane>
<AnchorPane fx:id="cover" prefHeight="200.0" prefWidth="200.0" visible="false">
<children>
<ProgressIndicator fx:id="progressBar" prefHeight="35.0" prefWidth="35.0" AnchorPane.bottomAnchor="7.0" AnchorPane.leftAnchor="7.0" />
</children>
</AnchorPane>
</children>
</StackPane>

@ -0,0 +1,17 @@
package nx_connor.autcocode;
import javafx.stage.Stage;
import nx_connor.KFXPanel;
public class AutoCodeDialog extends KFXPanel {
public AutoCodeDialog(Stage dialog) throws Exception {
super(dialog);
}
@Override
public Object getController() {
return new AutoCodeDialogController(this);
}
}

@ -0,0 +1,361 @@
package nx_connor.autcocode;
import java.net.URL;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.ResourceBundle;
import javafx.application.Platform;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.control.Alert.AlertType;
import javafx.scene.control.CheckBox;
import javafx.scene.control.ComboBox;
import javafx.scene.control.TextField;
import javafx.scene.control.TreeItem;
import javafx.scene.control.TreeTableColumn;
import javafx.scene.control.TreeTableView;
import javafx.scene.control.TreeView;
import javafx.scene.layout.AnchorPane;
import javafx.scene.layout.GridPane;
import nx_connor.KMain;
import nx_connor.autcocode.bean.AutoCodeTreeBean;
import nx_connor.autcocode.bean.AutoCodeTreeTableBean;
import nx_connor.autcocode.bean.TCComponent;
import nx_connor.autcocode.controller.AutoCodeConfigController;
import nx_connor.autcocode.controller.AutoCodeItemTypeController;
import nx_connor.autcocode.controller.AutoCodePropController;
import nx_connor.autcocode.controller.AutoCodeTreeTableViewController;
import nx_connor.autcocode.controller.AutoCodeTreeViewController;
import nx_connor.util.KUtil;
import nxopen.BasePart;
import nxopen.INXObject;
import nxopen.Session.MarkVisibility;
import nxopen.TaggedObject;
import nxopen.assemblies.Component;
import nxopen.assemblies.ComponentAssembly;
import nxopen.pdm.DatabaseAttributeManager;
public class AutoCodeDialogController implements Initializable {
@FXML
public AnchorPane cover;
@FXML
public TreeView<AutoCodeTreeBean> treeView;
@FXML
public TreeTableView<AutoCodeTreeTableBean> treeTableView;
@FXML
public TreeTableColumn<AutoCodeTreeTableBean, String> treeTableCol_Name;
@FXML
public TreeTableColumn<AutoCodeTreeTableBean, String> treeTableCol_Value;
@FXML
public TreeTableColumn<AutoCodeTreeTableBean, String> treeTableCol_Note;
// @FXML
// public ListView<AutoCodeListBean> listView;
@FXML
public TextField tf_FeatureCode;
@FXML
public TextField tf_FeatureCodeLength;
@FXML
public CheckBox cb_FeatureCode;
@FXML
public TextField tf_RevisionID;
@FXML
public TextField tf_Name;
// @FXML
// public ComboBox<TCComponent> cb_Unit;
@FXML
public GridPane gridPane_ObjectProps;
@FXML
public GridPane gridPane_ClassProps;
public AutoCodeDialog dialog;
public String userUid;
public String roleUid;
public String groupUid;
public TCComponent currentUser;
public TCComponent currentRole;
public TCComponent currentGroup;
protected AutoCodePropController autoCodePropController;
public AutoCodeConfigController autoCodeConfigController;
protected AutoCodeTreeViewController autoCodeTreeViewController;
protected AutoCodeTreeTableViewController autoCodeTreeTableViewController;
protected String showItemType = "";
protected boolean isTypeFilter = false;
public AutoCodeItemTypeController autoCodeItemTypeController;
public AutoCodeTreeBean selectedAutoCodeTreeNode;
public TreeItem<AutoCodeTreeBean> selectedAutoCodeTreeItem;
public List<String> filterType = new ArrayList<String>();
public TCComponent selectedPartRev;
public String selectedItemType = "Item";
private BasePart basePart;
public String oldItemId;
public String getSelectedItemType() {
return selectedItemType;
}
public void setSelectedItemType(String selectedItemType) {
if (!KUtil.isEmpty(selectedItemType)) {
this.selectedItemType = selectedItemType;
}
}
public AutoCodeDialogController(AutoCodeDialog autoCodeDialog) {
this.dialog = autoCodeDialog;
}
public void createBtnClicked() {
new Thread(new Runnable() {
@Override
public void run() {
setProgressVisible(true);
Boolean hasErr = false;
try {
long t = new Date().getTime();
if(oldItemId ==null || oldItemId.isEmpty()) {
oldItemId = getOldItemId();
}
KUtil.LOG("获取到的oldItemId为 "+oldItemId);
autoCodePropController.doCreate(oldItemId);
KUtil.printDuration("创建对象用时", t);
// NXOpen.PartCollection.WorkComponentOption;
// Part work = KMain.theSession.parts().work();
// basePart = KMain.theSession.parts().work();
KUtil.LOG("Base Part: " + basePart);
if (basePart != null) { // 刷新tc数据
KUtil.LOG(">> " + basePart.journalIdentifier());
boolean TCIN_mode = KMain.theUFSession.UF().isUgmanagerActive();
if (TCIN_mode) {
BasePart workPart = basePart;
DatabaseAttributeManager theDatabaseAttributeManager = workPart.pdmpart()
.newDatabaseAttributeManager();
int markId1 = KMain.theSession.setUndoMark(MarkVisibility.VISIBLE,
"Force Reload Attributes from Teamcenter");
theDatabaseAttributeManager.loadAttributes(true);
theDatabaseAttributeManager.refreshAttributes();
theDatabaseAttributeManager.storeAttributes();
KUtil.LOG("Database Attributes have been reloaded.");
KMain.theSession.updateManager().doUpdate(markId1);
KUtil.LOG("markId1 have been doUpdate.");
KMain.theSession.updateManager().doInterpartUpdate(markId1);
KUtil.LOG("markId1 have been doInterpartUpdate.");
KUtil.LOG(">> " + basePart.journalIdentifier());
} else {
KUtil.LOG("This only works in NX Manager (TCIN) mode.");
}
}
} catch (Exception e) {
e.printStackTrace();
hasErr = true;
Err(e);
}
setProgressVisible(false);
if (basePart != null && !hasErr) {
Platform.runLater(() -> {
dialog.getParentDialog().close();
});
}
}
}).start();
}
public String getOldItemId() throws Exception {
TaggedObject obj = KMain.theUI.selectionManager().getSelectedTaggedObject(0);
INXObject part = null;
if (obj instanceof Component) {
part = ((Component) obj).prototype();
this.basePart = (BasePart) ((Component) obj).prototype();
} else if (obj instanceof ComponentAssembly) {
part = ((ComponentAssembly) obj).owningPart();
this.basePart = ((ComponentAssembly) obj).owningPart();
}
if (part != null) {
try {
String id = part.journalIdentifier();
KUtil.LOG("getOldItemId ===> " + id);
if (!KUtil.isEmpty(id) && id.startsWith("@DB/")) {
return id.split("/")[1];
}
} catch (Exception e) {
e.printStackTrace();
KUtil.LOGERROR(e);
Err(e);
}
}
return "";
}
public void cancelBtnClicked() {
dialog.getParentDialog().close();
}
protected void initAutoCodeData() throws Exception {
int selectCnt = KMain.theUI.selectionManager().getNumSelectedObjects();
KUtil.LOG("选择数量:" + selectCnt);
for (int i = 0; i < selectCnt; i++) {
TaggedObject obj = KMain.theUI.selectionManager().getSelectedTaggedObject(i);
KUtil.LOG((i + 1) + ". " + obj + " | " + obj.getClass());
INXObject part = null;
if (obj instanceof Component) {
part = ((Component) obj).prototype();
this.basePart = (BasePart) ((Component) obj).prototype();
} else if (obj instanceof ComponentAssembly) {
part = ((ComponentAssembly) obj).owningPart();
this.basePart = ((ComponentAssembly) obj).owningPart();
}
if (part != null) {
try {
String id = part.journalIdentifier();
KUtil.LOG(">> Part:" + id);
if (!KUtil.isEmpty(id) && id.startsWith("@DB/")) {
String idStr = id.split("/")[1];
String type = KUtil.callITK(KMain.INPUTCODE_GET_ITEMTYPE_BY_ID, idStr);
if (!filterType.contains(type) && !KUtil.isEmpty(type)) {
filterType.add(type);
}
String uid = KUtil.callITK(KMain.INPUTCODE_GET_REVUID_BY_ID, id.substring(4));
this.selectedPartRev = new TCComponent(uid);
oldItemId = idStr;
break; // 只选择一个
}
} catch (Exception e) {
e.printStackTrace();
KUtil.LOGERROR(e);
Err(e);
}
}
}
KUtil.LOG("过滤类型:" + filterType);
this.userUid = KUtil.callITK(KMain.INPUTCODE_GET_UID, "user");
if (KUtil.isEmpty(userUid)) {
throw new Exception("获取用户UID失败");
}
this.currentUser = new TCComponent(userUid);
this.roleUid = KUtil.callITK(KMain.INPUTCODE_GET_UID, "role");
if (KUtil.isEmpty(roleUid)) {
throw new Exception("获取角色UID失败");
}
this.currentRole = new TCComponent(roleUid);
this.groupUid = KUtil.callITK(KMain.INPUTCODE_GET_UID, "group");
if (KUtil.isEmpty(groupUid)) {
throw new Exception("获取组UID失败");
}
this.currentGroup = new TCComponent(groupUid);
this.userUid += "AAAAAAAAAAAAA";
this.roleUid += "AAAAAAAAAAAAA";
this.groupUid += "AAAAAAAAAAAAA";
this.autoCodePropController = new AutoCodePropController(this);
this.autoCodeConfigController = new AutoCodeConfigController();
this.autoCodeItemTypeController = new AutoCodeItemTypeController(this);
this.autoCodeTreeViewController = new AutoCodeTreeViewController(this);
this.autoCodeTreeTableViewController = new AutoCodeTreeTableViewController(this);
// 提取属性
String uomValue = null;
TCComponent selectedUom = null;
if (this.selectedPartRev != null) {
TCComponent item = selectedPartRev.getReferenceListProperty("items_tag").get(0);
uomValue = item.getProperty("uom_tag");
}
try {
KUtil.LOG("selectedPartRev itemId " + selectedPartRev.getProperty("item_id"));
} catch (Exception e) {
// TODO Auto-generated catch block
KUtil.LOG("selectedPartRev itemId " + e.getMessage());
}
if (KUtil.isEmpty(uomValue)) {
uomValue = "PCS";
}
// 单位
String resp = KUtil.callITK(KMain.INPUTCODE_GET_UOM_TAGS, "");
TCComponent[] uomTags = KUtil.getOutputComponent(resp);
int uomCnt = KUtil.getLen(uomTags);
for (int i = 0; i < uomCnt; i++) {
TCComponent uom = uomTags[i];
uom.setObjectString(uom.getProperty("symbol"));
if (uomValue != null && uomValue.equals(uom.toString())) {
selectedUom = uom;
}
}
// this.cb_Unit.getItems().addAll(uomTags);
// if (selectedUom != null) {
// final TCComponent selectedUomF = selectedUom;
// Platform.runLater(() -> {
// this.cb_Unit.getSelectionModel().select(selectedUomF);
// });
// }
}
@Override
public void initialize(URL var1, ResourceBundle var2) {
treeTableCol_Name.setCellValueFactory(p -> p.getValue() == null ? null : p.getValue().getValue().name);
treeTableCol_Value.setCellValueFactory(p -> p.getValue() == null ? null : p.getValue().getValue().value);
treeTableCol_Note.setCellValueFactory(p -> p.getValue() == null ? null : p.getValue().getValue().note);
new Thread(new Runnable() {
@Override
public void run() {
setProgressVisible(true);
try {
initAutoCodeData();
} catch (Exception e) {
e.printStackTrace();
Err(e);
}
setProgressVisible(false);
Platform.runLater(() -> {
treeView.getRoot().setExpanded(true);
});
}
}).start();
}
public void Err(Exception e) {
KUtil.LOGERROR(e);
KUtil.showFXMessage(dialog.getParentDialog(), "错误", AlertType.ERROR, e.getMessage());
}
public void setProgressVisible(boolean visible) {
if (cover != null) {
Platform.runLater(new Runnable() {
@Override
public void run() {
cover.setVisible(visible);
}
});
try {
Thread.sleep(10);
} catch (Exception e) {
e.printStackTrace();
}
}
}
public void showAutoCodeList(TreeItem<AutoCodeTreeBean> newValue) throws Exception {
KUtil.LOG("Select AutoCode Tree Node: " + newValue);
if (newValue == null || newValue.getValue() == null) {
return;
}
autoCodePropController.initClassificationMouseClick();
this.selectedAutoCodeTreeNode = newValue.getValue();
this.selectedAutoCodeTreeItem = newValue;
autoCodeTreeTableViewController.loadAutoCodeTreeTable(newValue);
}
public void showAutoCodeProp(TreeItem<AutoCodeTreeTableBean> newValue) throws Exception {
KUtil.LOG("Select AutoCode TreeTable Node: " + newValue);
if (newValue == null || newValue.getValue() == null) {
return;
}
autoCodePropController.initClassificationMouseClick();
autoCodePropController.loadAutoCodeProp(newValue);
}
}

@ -0,0 +1,8 @@
package nx_connor.autcocode.bean;
public abstract class AbstractAutoCodeBean {
public PackCodeNodeInfo packCodeNodeInfo;
public AbstractAutoCodeBean parentTreeData;
}

@ -0,0 +1,5 @@
package nx_connor.autcocode.bean;
public class AutoCodeListBean {
}

@ -0,0 +1,59 @@
package nx_connor.autcocode.bean;
import javafx.scene.image.Image;
import nx_connor.autcocode.manager.AutoCodeManagerPropertyName;
import nx_connor.util.KUtil;
public class AutoCodeTreeBean extends AbstractAutoCodeBean{
private Image image;
public Image getImage() {
return image;
}
public AutoCodeTreeBean(PackCodeNodeInfo packCodeNodeInfo) {
this.packCodeNodeInfo = packCodeNodeInfo;
this.image = KUtil.getImageByType(packCodeNodeInfo.getNode_type());
if(packCodeNodeInfo.is_lock) {
this.image = KUtil.getImageByType(AutoCodeManagerPropertyName.LockName);
}
}
public AutoCodeTreeBean(TCComponent tcComponent, String nodeName, String nodeType) throws Exception {
this.image = KUtil.getImageByType(nodeType);
if ((tcComponent != null)
&& (tcComponent.getLogicalProperty(AutoCodeManagerPropertyName.TreeAndListCodeNode_is_lock))) {
this.image = KUtil.getImageByType(AutoCodeManagerPropertyName.LockName);
}
this.packCodeNodeInfo = new PackCodeNodeInfo();
packCodeNodeInfo.setNode_name(nodeName);
packCodeNodeInfo.setNodeComponent(tcComponent);
packCodeNodeInfo.setNode_type(nodeType);
}
public AutoCodeTreeBean(TCComponent tccomponent, String displayTypeName, String realTypeName,
String node_type) {
this.image = KUtil.getImageByType(AutoCodeManagerPropertyName.ComponentName);
PackCodeNodeInfo packCodeNodeInfo = new PackCodeNodeInfo();
packCodeNodeInfo.setNode_name(displayTypeName);
packCodeNodeInfo.setRealTypeName(realTypeName);
packCodeNodeInfo.setNodeComponent(tccomponent);
packCodeNodeInfo.setNode_type(node_type);
this.packCodeNodeInfo = packCodeNodeInfo;
}
@Override
public String toString() {
return packCodeNodeInfo == null ? "null"
: packCodeNodeInfo.getNode_name() + (KUtil.isEmpty(packCodeNodeInfo.getRealTypeName()) ? ""
: (" (" + packCodeNodeInfo.getRealTypeName() + ")"));
}
public void setParentTreeData(AutoCodeTreeBean parentTreeData) {
this.parentTreeData = parentTreeData;
}
}

@ -0,0 +1,39 @@
package nx_connor.autcocode.bean;
import javafx.beans.property.SimpleStringProperty;
import javafx.beans.property.StringProperty;
import javafx.scene.image.Image;
import nx_connor.autcocode.manager.AutoCodeManagerPropertyName;
import nx_connor.util.KUtil;
public class AutoCodeTreeTableBean extends AbstractAutoCodeBean{
public StringProperty name = new SimpleStringProperty("1");
public StringProperty value = new SimpleStringProperty("2");
public StringProperty note = new SimpleStringProperty("3");
private Image image;
public Image getImage() {
return image;
}
public AutoCodeTreeTableBean(String name, String value, String note) {
super();
this.name.setValue(name);
this.value.setValue(value);
this.note.setValue(note);
}
public AutoCodeTreeTableBean(AbstractAutoCodeBean segmentNode, PackCodeNodeInfo packCodeNodeInfo) {
this.packCodeNodeInfo = packCodeNodeInfo;
this.parentTreeData = segmentNode;
this.image = KUtil.getImageByType(packCodeNodeInfo.getNode_type());
if (packCodeNodeInfo.is_lock) {
this.image = KUtil.getImageByType(AutoCodeManagerPropertyName.LockName);
}
this.name.setValue(packCodeNodeInfo.getNode_name());
this.value.setValue(packCodeNodeInfo.getNode_value());
this.note.setValue(packCodeNodeInfo.getNode_desc());
}
}

@ -0,0 +1,57 @@
package nx_connor.autcocode.bean;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
public class CNClassPropBean {
// ICSFormate
public int propID;
public String propDisName;
public String relValue;
public String displayValue;
public int attrType;
public boolean isLov;
public HashMap<String, String> lovMapping;
public List<String> keyList;
public int intsize = 0;
public int floatsize = 0;
public String formate;
public CNClassPropBean(ICSAdminClassAttribute icsAttr) throws Exception{
this.propID = icsAttr.getAttributeId();
this.propDisName = icsAttr.getName();
ICSFormat format1 = icsAttr.getFormat1();
ICSFormat format2 = icsAttr.getFormat2();
this.formate = format2.getDisplayString();
if (format1.isReal()) {
floatsize = format2.getFlagB();
intsize = format2.getFlagC();
}
this.attrType = format1.getType();
ICSKeyLov lov1 = format1.getKeyLov();
lov1 = (lov1 == null ? format2.getKeyLov() : lov1);
lovMapping = new HashMap<>();
keyList = new ArrayList<>();
if (lov1 != null) {
this.isLov = true;
String[] keys = lov1.getKeys();
for (String key : keys) {
String value = lov1.getValueOfKey(key);
lovMapping.put(value, key);
keyList.add(value);
}
} else {
this.isLov = false;
}
}
@Override
public String toString() {
return propDisName + ":";
}
}

@ -0,0 +1,31 @@
package nx_connor.autcocode.bean;
public class ClassProperty {
private int propertyID;
private String value;
public ClassProperty() {
}
public ClassProperty(int propertyID, String value) {
this.propertyID = propertyID;
this.value = value;
}
public int getPropertyID() {
return propertyID;
}
public void setPropertyID(int propertyID) {
this.propertyID = propertyID;
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
}

@ -0,0 +1,52 @@
package nx_connor.autcocode.bean;
import nx_connor.KMain;
import nx_connor.util.KUtil;
public class ICSAdminClassAttribute {
public int propID;
public ICSAdminClassAttribute(int propID) {
super();
this.propID = propID;
}
@Override
public boolean equals(Object obj) {
if (obj == this) {
return true;
}
if (obj != null && (obj instanceof ICSAdminClassAttribute)) {
return propID == ((ICSAdminClassAttribute) obj).propID;
}
return super.equals(obj);
}
public boolean isReferenceAttribute() throws Exception {
return "ÐͺŹæ¸ñ".equals(getName());
// String resp = KUtil.callITK(KMain.INPUTCODE_ICS_ATTR_IS_REFERENCE_ATTRIBUTE, propID + "");
// return "true".equalsIgnoreCase(resp);
}
public int getAttributeId() {
return propID;
}
public String getName() throws Exception {
return KUtil.callITK(KMain.INPUTCODE_ICS_ATTR_ASK_PROPERTY, propID + KMain.SPLITTER + "NAME");
}
public String getMetricUnit(String classId) throws Exception {
return KUtil.callITK(KMain.INPUTCODE_ICS_ATTR_ASK_METRIC_UNIT, classId + KMain.SPLITTER + propID);
}
public ICSFormat getFormat1() throws Exception {
return new ICSFormat(KUtil.callITK(KMain.INPUTCODE_ICS_ATTR_ASK_PROPERTY, propID + KMain.SPLITTER + "FORMAT1"));
}
public ICSFormat getFormat2() throws Exception {
return new ICSFormat(KUtil.callITK(KMain.INPUTCODE_ICS_ATTR_ASK_PROPERTY, propID + KMain.SPLITTER + "FORMAT2"));
}
}

@ -0,0 +1,153 @@
package nx_connor.autcocode.bean;
public class ICSFormat {
private int m_format;
private ICSKeyLov m_lov;
private int m_formatType = -99;
public static final int UNDEFINED = -99;
public static final int LIST = -1;
public static final int STRING = 0;
public static final int INTEGER = 1;
public static final int REAL = 2;
public static final int DATE = 3;
public static final int TIMERANGE = 4;
public static final int SEARCH = 1;
public static final int STORE = 2;
public static final int READ = 3;
public static final int SEARCH_READ = 4;
public static final int MIN_DATE_FORMAT = 30000;
public static final int MAX_DATE_FORMAT = 30014;
public ICSFormat(String var1) throws Exception {
this.m_format = Integer.parseInt(var1);
if (this.m_format < 0) {
this.m_lov = ICSKeyLov.getICSKeyLov(this.m_format);
// if (this.m_lov == null) {
// this.m_lov = new ICSKeyLov();
// }
}
}
public ICSKeyLov getKeyLov() {
return this.m_lov;
}
public boolean isString() {
return this.m_format > 0 && this.m_format / 10000 == 0;
}
public boolean isInteger() {
return this.m_format > 0 && this.m_format / 10000 == 1;
}
public boolean isDate() {
return this.m_format > 0 && this.m_format / 10000 == 3;
}
public boolean isTimeRange() {
return this.m_format > 0 && this.m_format / 10000 == 4;
}
public boolean isList() {
return this.m_format < 0;
}
public boolean isReal() {
return this.m_format > 0 && this.m_format / 10000 == 2;
}
public int getType() {
if (this.isList()) {
this.m_formatType = -1;
} else if (this.isString()) {
this.m_formatType = 0;
} else if (this.isInteger()) {
this.m_formatType = 1;
} else if (this.isReal()) {
this.m_formatType = 2;
} else if (this.isDate()) {
this.m_formatType = 3;
} else if (this.isTimeRange()) {
this.m_formatType = 4;
} else {
this.m_formatType = -99;
}
return this.m_formatType;
}
public int getSize() {
return this.m_format < 0 ? 30 : this.m_format % 100;
}
public int getFlagA() {
return this.m_format < 0 ? 0 : this.m_format % 10000 / 1000;
}
public int getFlagB() {
return this.m_format < 0 ? 0 : this.m_format % 1000 / 100;
}
public int getFlagC() {
if (this.m_format < 0) {
return 0;
} else {
byte var1 = 0;
byte var2 = 0;
if (this.getFlagA() > 0) {
var1 = 1;
}
if (this.m_formatType == 2) {
var2 = 1;
}
return this.getSize() - this.getFlagB() - var1 - var2;
}
}
public String getDisplayString() {
if (this.m_format < 0) {
this.m_formatType = -1;
return "POPUP(" + this.m_format + ")";
} else if (this.m_format == 0) {
return "";
} else {
int var1;
if (this.m_format > 0 && this.m_format < 10000) {
var1 = this.getSize();
this.m_formatType = 0;
if (var1 == 99) {
var1 = 256;
}
return "STRING(" + var1 + ")";
} else if (this.m_format >= 10000 && this.m_format < 20000) {
this.m_formatType = 1;
var1 = this.getSize();
if (this.getFlagA() > 0) {
--var1;
}
return "INTEGER(" + var1 + ")";
} else if (this.m_format >= 20000 && this.m_format < 30000) {
this.m_formatType = 2;
var1 = this.getFlagB();
int var2 = this.getFlagC();
return "REAL(" + var2 + "." + var1 + ")";
} else if (this.m_format >= 30000 && this.m_format < 40000) {
this.m_formatType = 3;
var1 = this.getSize();
return "DATE(" + var1 + ")";
} else if (this.m_format >= 40000) {
this.m_formatType = 4;
var1 = this.getSize();
return "TIME RANGE(" + var1 + ")";
} else {
return "Invalid Format";
}
}
}
}

@ -0,0 +1,64 @@
package nx_connor.autcocode.bean;
import java.util.ArrayList;
import java.util.List;
import nx_connor.KMain;
import nx_connor.util.KUtil;
public class ICSKeyLov {
public String[] keys;
public String[] values;
public ICSKeyLov(String[] keys, String[] values) {
this.keys = keys;
this.values = values;
}
public static ICSKeyLov getICSKeyLov(int m_format) throws Exception{
String keylovStr = KUtil.callITK(KMain.INPUTCODE_ICS_ATTR_ASK_KEYLOV, ""+m_format);
if(KUtil.isEmpty(keylovStr)) {
return null;
}
String[] split = keylovStr.split(KMain.SPLITTER);
int len = KUtil.getLen(split);
List<String> k = new ArrayList<String>();
List<String> v = new ArrayList<String>();
for(int i=0;i<len;i++) {
String[] ss = split[i].split("=");
if(KUtil.getLen(ss)!=2) {
continue;
}
String key = ss[0];
String value = ss[1];
if(!KUtil.isEmpty(key)&&!k.contains(key)) {
k.add(key);
v.add(value);
}
}
return new ICSKeyLov(k.toArray(new String[] {}), v.toArray(new String[] {}));
}
public String[] getKeys() {
return this.keys;
}
public String[] getValues() {
return this.values;
}
public String getValueOfKey(String key) {
int len = KUtil.getLen(keys);
for(int i=0;i<len;i++){
if(keys[i].equals(key)) {
return values[i];
}
}
return null;
}
}

@ -0,0 +1,122 @@
package nx_connor.autcocode.bean;
public class PackCodeNodeInfo {
private TCComponent nodeComponent;
private String realTypeName;
private String node_name = "";
private String node_type = "";
public String node_value = "";
public String node_desc = "";
public String code_style = "";
public String rule_node = "";
// boolean
public boolean is_root=false;
public boolean is_lock=false;
public boolean isDefaultSelected=false;
public boolean isContainsChildren=false;
// date
public String create_date = "";
public String last_revise_date = "";
// user
public String create_user = "";
public String last_revise_user = "";
public TCComponent getNodeComponent() {
return nodeComponent;
}
public void setNodeComponent(TCComponent nodeComponent) {
this.nodeComponent = nodeComponent;
}
public String getRealTypeName() {
return realTypeName;
}
public void setRealTypeName(String realTypeName) {
this.realTypeName = realTypeName;
}
public String getNode_name() {
return node_name;
}
public void setNode_name(String node_name) {
this.node_name = node_name;
}
public String getNode_type() {
return node_type;
}
public void setNode_type(String node_type) {
this.node_type = node_type;
}
public String getNode_value() {
return node_value;
}
public void setNode_value(String node_value) {
this.node_value = node_value;
}
public String getNode_desc() {
return node_desc;
}
public void setNode_desc(String node_desc) {
this.node_desc = node_desc;
}
public String getCode_style() {
return code_style;
}
public void setCode_style(String code_style) {
this.code_style = code_style;
}
public String getRule_node() {
return rule_node;
}
public void setRule_node(String rule_node) {
this.rule_node = rule_node;
}
public boolean isIs_root() {
return is_root;
}
public void setIs_root(boolean is_root) {
this.is_root = is_root;
}
public boolean isIs_lock() {
return is_lock;
}
public void setIs_lock(boolean is_lock) {
this.is_lock = is_lock;
}
public boolean isDefaultSelected() {
return isDefaultSelected;
}
public void setDefaultSelected(boolean isDefaultSelected) {
this.isDefaultSelected = isDefaultSelected;
}
public boolean isContainsChildren() {
return isContainsChildren;
}
public void setContainsChildren(boolean isContainsChildren) {
this.isContainsChildren = isContainsChildren;
}
public String getCreate_date() {
return create_date;
}
public void setCreate_date(String create_date) {
this.create_date = create_date;
}
public String getLast_revise_date() {
return last_revise_date;
}
public void setLast_revise_date(String last_revise_date) {
this.last_revise_date = last_revise_date;
}
public String getCreate_user() {
return create_user;
}
public void setCreate_user(String create_user) {
this.create_user = create_user;
}
public String getLast_revise_user() {
return last_revise_user;
}
public void setLast_revise_user(String last_revise_user) {
this.last_revise_user = last_revise_user;
}
}

@ -0,0 +1,105 @@
package nx_connor.autcocode.bean;
import java.util.ArrayList;
import java.util.List;
import nx_connor.KMain;
import nx_connor.util.KUtil;
public class TCComponent {
public String uid;
private String objectString;
public TCComponent(String uid) {
super();
this.uid = uid;
this.objectString = uid;
}
public boolean getLogicalProperty(String propName) throws Exception {
if (KUtil.isEmpty(propName) || KUtil.isEmpty(uid)) {
return false;
}
return "true".equalsIgnoreCase(
KUtil.callITK(KMain.INPUTCODE_GET_LOGICAL_PROP_VALUE, uid + KMain.SPLITTER + propName));
}
public void setObjectString(String objectString) {
this.objectString = objectString;
}
@Override
public String toString() {
return objectString;
}
// @Override
// public int compareTo(TCComponent o) {
// if(o==null) {
// return 1;
// }
// return uid.compareTo(o.uid);
// }
@Override
public boolean equals(Object obj) {
if (obj == this) {
return true;
}
if (obj != null && (obj instanceof TCComponent)) {
if (uid == null) {
return ((TCComponent) obj).uid == null;
} else {
return uid.equals(((TCComponent) obj).uid);
}
}
return super.equals(obj);
}
public String getProperty(String propName) throws Exception {
if(KUtil.isEmpty(propName)) {
return "";
}
return KUtil.callITK(KMain.INPUTCODE_GET_DISPLAY_PROP_VALUE, uid + KMain.SPLITTER + propName);
}
public String[] getProperties(String[] propNames) throws Exception {
int len = KUtil.getLen(propNames);
String[] values = new String[len];
for (int i = 0; i < len; i++) {
values[i] = KUtil.callITK(KMain.INPUTCODE_GET_DISPLAY_PROP_VALUE, uid + KMain.SPLITTER + propNames[i]);
}
return values;
}
public TCComponent getReferenceProperty(String propName) throws Exception {
String uid = KUtil.callITK(KMain.INPUTCODE_GET_REFERENCE_PROP_VALUE, this.uid + KMain.SPLITTER + propName);
if (!KUtil.isEmpty(uid)) {
return new TCComponent(uid);
}
return null;
}
public List<TCComponent> getReferenceListProperty(String propName) throws Exception {
String resp = KUtil.callITK(KMain.INPUTCODE_GET_REFERENCE_PROP_VALUE_ARRAY, this.uid + KMain.SPLITTER + propName);
String[] uids = KUtil.isEmpty(resp)?null:resp.split(KMain.SPLITTER);
int uidCnt = KUtil.getLen(uids);
List<TCComponent> res = new ArrayList<TCComponent>();
for(int i=0; i<uidCnt; i++) {
String uid = uids[i];
if(!KUtil.isEmpty(uid)) {
res.add(new TCComponent(uid));
}
}
return res;
}
public TCComponent getLatestItemRevision() throws Exception {
String uid = KUtil.callITK(KMain.INPUTCODE_GET_LATEST_ITEM_REVISION, this.uid);
if (!KUtil.isEmpty(uid)) {
return new TCComponent(uid);
}
return null;
}
}

@ -0,0 +1,48 @@
package nx_connor.autcocode.bean;
import java.util.ArrayList;
import java.util.List;
import nx_connor.KMain;
import nx_connor.util.KUtil;
public class TCComponentListOfValues {
public String[] realValues;
public String[] displayValues;
public TCComponentListOfValues(String[] realValues, String[] displayValues) {
this.realValues = realValues;
this.displayValues = displayValues;
}
public static TCComponentListOfValues findLOVByName(String lovName) throws Exception{
String str = KUtil.callITK(KMain.INPUTCODE_FIND_LOV_BY_NAME, lovName);
if(KUtil.isEmpty(str)) {
return null;
}
List<String> realValues = new ArrayList<String>();
List<String> displayValues = new ArrayList<String>();
String[] split = str.split(KMain.SPLITTER);
int len = KUtil.getLen(split);
for(int i=0;i<len;i++) {
String s = split[i];
int ind = s.indexOf('=');
if(ind<1) {
continue;
}
String realValue = s.substring(0, ind);
String displayValue = s.substring(ind+1);
if(!realValues.contains(realValue)) {
realValues.add(realValue);
displayValues.add(displayValue);
}
}
if(realValues.size()>0) {
return new TCComponentListOfValues(realValues.toArray(new String[] {}), displayValues.toArray(new String[] {}));
}
return null;
}
}

@ -0,0 +1,88 @@
package nx_connor.autcocode.controller;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import nx_connor.KMain;
import nx_connor.autcocode.xmlutil.CNCompontent;
import nx_connor.autcocode.xmlutil.CNPart;
import nx_connor.autcocode.xmlutil.CNPartList;
import nx_connor.autcocode.xmlutil.CNProperty;
import nx_connor.autcocode.xmlutil.CNXmlUtil;
import nx_connor.util.KUtil;
public class AutoCodeConfigController {
public static final String PREF_CNPARTLIST = "Autocode_OptionFile_option"; // QKa9EIUaZUQMmD
public static final String PREF_SEQUENCEMAP = "LP_sequenceMapping";
public CNPartList cnPartList;
public HashMap<String, Integer> connor_SequenceNameMapping = new HashMap<String, Integer>();
public List<String> connor_PatterValueList = new ArrayList<String>();
public AutoCodeConfigController() {
readConfigs();
}
protected void readConfigs() {
// readSequenceMap();
readCNPartList();
}
protected void readSequenceMap() {
KUtil.LOG("LOAD SEQUENCE MAP");
try {
String prefValStr = KUtil.callITK(KMain.INPUTCODE_GetPrefValue, PREF_SEQUENCEMAP);
if (KUtil.isEmpty(prefValStr)) {
return;
}
String[] patternNames = prefValStr.split(KMain.SPLITTER);
int len = patternNames.length;
for (int i = 0; i < len; i++) {
String patternNameString = patternNames[i];
System.out.println(">> " + patternNameString);
String[] patterNamesStrings = patternNameString.split("@");
if (patterNamesStrings != null && patterNamesStrings.length == 2) {
Integer index = 1;
try {
index = Integer.parseInt(patterNamesStrings[1]);
this.connor_SequenceNameMapping.put(patterNamesStrings[0], index);
} catch (Exception var15) {
var15.printStackTrace();
KUtil.LOGERROR(var15);
}
}
}
} catch (Exception e) {
e.printStackTrace();
KUtil.LOGERROR(e);
}
}
protected void readCNPartList() {
KUtil.LOG("LOAD CNPARTLIST");
try {
String puid = KUtil.callITK(KMain.INPUTCODE_GetPrefValue, PREF_CNPARTLIST);
if (KUtil.isEmpty(puid)) {
return;
}
String filePath = KUtil.dowloadFileByUID(puid, "XMLRendering", "xml");
// String filePath = KUtil.callITK(KMain.INPUTCODE_Download_Dataset_By_UID,
// puid + KMain.SPLITTER + "XMLRendering" + KMain.SPLITTER + "xml");
this.cnPartList = (CNPartList) CNXmlUtil.xmlToBean(filePath, CNPartList.class);
List<CNPart> partList = cnPartList.getPartList();
for (int i = 0; i < partList.size(); i++) {
KUtil.LOG(partList.get(i).getType());
for (CNCompontent comp : partList.get(i).getCompontentList()) {
KUtil.LOG(comp.getType() + " - " + comp.getCompententType());
for (CNProperty prop : comp.getPropertyList()) {
KUtil.LOG(">> " + prop.getDisplayName());
}
}
}
} catch (Exception e) {
e.printStackTrace();
KUtil.LOGERROR(e);
}
}
}

@ -0,0 +1,80 @@
package nx_connor.autcocode.controller;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import nx_connor.KMain;
import nx_connor.autcocode.AutoCodeDialogController;
import nx_connor.autcocode.bean.AutoCodeTreeBean;
import nx_connor.autcocode.bean.TCComponent;
import nx_connor.autcocode.manager.AutoCodeManagerPropertyName;
import nx_connor.util.KUtil;
public class AutoCodeItemTypeController {
protected AutoCodeDialogController dialogController;
public AutoCodeItemTypeController(AutoCodeDialogController autoCodeDialogController) {
this.dialogController = autoCodeDialogController;
}
public List<AutoCodeTreeBean> getAllTypes(String[] typeNames, String[] excludeTypeNames) throws Exception {
List<AutoCodeTreeBean> res = new ArrayList<AutoCodeTreeBean>();
int len = typeNames == null ? 0 : typeNames.length;
List<String> addedTypes = new ArrayList<String>();
for (int i = 0; i < len; i++) {
String typeName = typeNames[i];
if (KUtil.isEmpty(typeName)) {
continue;
}
StringBuilder input = new StringBuilder();
input.append(typeName);
int excludeCnt = excludeTypeNames == null ? 0 : excludeTypeNames.length;
// for (int j = 0; j < excludeCnt; j++) {
// input.append(KMain.SPLITTER).append(excludeTypeNames[j]);
// }
String output = KUtil.callITK(KMain.INPUTCODE_GET_ALL_SUB_TYPES, input.toString());
if (KUtil.isEmpty(output)) {
continue;
}
String[] split = output.split(KMain.SPLITTER);
int cnt = split.length;
for (int j = 0; j < cnt; j++) {
String[] typeNameSplit = split[j].split("=");
if (typeNameSplit.length != 2) {
continue;
}
String name = typeNameSplit[0];
if (addedTypes.contains(name) || name.contains("0")) { // Fnd0 Mfg0
continue;
}
addedTypes.add(name);
String disName = typeNameSplit[1];
AutoCodeTreeBean bean = new AutoCodeTreeBean(null, disName, name, AutoCodeManagerPropertyName.ItemName);
TCComponent[] comps = searchAutoCodeNode(bean);
if (comps != null && comps.length > 0) {
res.add(bean);
}
}
}
return res;
}
public TCComponent[] searchAutoCodeSegment(AutoCodeTreeBean bean) throws Exception {
HashMap<String, String> map = new HashMap<String, String>();
String nodeName = bean.packCodeNodeInfo.getNode_name();
map.put(AutoCodeManagerPropertyName.ClassificationCodeNode_node_name, nodeName);
return KUtil.searchComponentFromITK(KMain.INPUTCODE_SEARCH_AUTOCODE_SEGMENT, map);
}
public TCComponent[] searchAutoCodeNode(AutoCodeTreeBean bean) throws Exception {
HashMap<String, String> map = new HashMap<String, String>();
String nodeName = bean.packCodeNodeInfo.getNode_name();
map.put(AutoCodeManagerPropertyName.ClassificationCodeNode_node_name, nodeName);
map.put(AutoCodeManagerPropertyName.ClassificationCodeNode_grant_groups, dialogController.groupUid);
map.put(AutoCodeManagerPropertyName.ClassificationCodeNode_grant_roles, dialogController.roleUid);
map.put(AutoCodeManagerPropertyName.ClassificationCodeNode_grant_users, dialogController.userUid);
return KUtil.searchComponentFromITK(KMain.INPUTCODE_SEARCH_AUTOCODE_NODE, map);
}
}

@ -0,0 +1,380 @@
package nx_connor.autcocode.controller;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import javafx.application.Platform;
import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue;
import javafx.scene.control.TreeItem;
import javafx.scene.control.TreeTableView;
import javafx.scene.image.ImageView;
import nx_connor.KMain;
import nx_connor.autcocode.AutoCodeDialogController;
import nx_connor.autcocode.bean.AbstractAutoCodeBean;
import nx_connor.autcocode.bean.AutoCodeTreeBean;
import nx_connor.autcocode.bean.AutoCodeTreeTableBean;
import nx_connor.autcocode.bean.PackCodeNodeInfo;
import nx_connor.autcocode.bean.TCComponent;
import nx_connor.autcocode.manager.AutoCodeManagerPropertyName;
import nx_connor.util.KUtil;
public class AutoCodeTreeTableViewController {
private AutoCodeDialogController dialogController;
protected String showItemType = "";
protected boolean isFilterType = false;
protected TreeTableView<AutoCodeTreeTableBean> treeTableView;
public AutoCodeTreeTableViewController(AutoCodeDialogController autoCodeDialogController) throws Exception {
this.dialogController = autoCodeDialogController;
this.treeTableView = dialogController.treeTableView;
initTree();
}
protected void initTree() throws Exception {
Platform.runLater(() -> {
AutoCodeTreeTableBean rootBean = new AutoCodeTreeTableBean("root", "", "");
TreeItem<AutoCodeTreeTableBean> root;
dialogController.treeTableView.setRoot(root = getTreeItem(rootBean, false));
dialogController.treeTableView.setShowRoot(false);
root.setExpanded(true);
});
// 选择监听
dialogController.treeTableView.getSelectionModel().selectedItemProperty()
.addListener(new ChangeListener<TreeItem<AutoCodeTreeTableBean>>() {
@Override
public void changed(ObservableValue<? extends TreeItem<AutoCodeTreeTableBean>> arg0,
TreeItem<AutoCodeTreeTableBean> arg1, TreeItem<AutoCodeTreeTableBean> newValue) {
if (newValue == null) {
return;
}
new Thread(() -> {
dialogController.setProgressVisible(true);
try {
dialogController.showAutoCodeProp(newValue);
} catch (Exception e) {
e.printStackTrace();
dialogController.Err(e);
}
dialogController.setProgressVisible(false);
}).start();
}
});
}
public TreeItem<AutoCodeTreeTableBean> getTreeItem(AutoCodeTreeTableBean child, boolean needExpand) {
ImageView image = child.getImage() == null ? null : new ImageView(child.getImage());
TreeItem<AutoCodeTreeTableBean> treeItem = new TreeItem<AutoCodeTreeTableBean>(child, image);
if (!needExpand) {
return treeItem;
}
treeItem.expandedProperty().addListener(new ChangeListener<Boolean>() {
@Override
public void changed(ObservableValue<? extends Boolean> arg0, Boolean oldValue, Boolean newValue) {
if (!newValue) {
return;
}
new Thread(new Runnable() {
@Override
public void run() {
try {
expandNode(treeItem);
} catch (Exception e) {
e.printStackTrace();
dialogController.Err(e);
}
}
}).start();
}
});
treeItem.getChildren().add(new TreeItem<AutoCodeTreeTableBean>(null));
return treeItem;
}
protected void expandNode(TreeItem<AutoCodeTreeTableBean> treeItem) throws Exception {
KUtil.LOG("展开节点:" + treeItem);
if (treeItem == null) {
return;
}
if(treeItem.getChildren().size()!=1||treeItem.getChildren().get(0).getValue()!=null) {
return;
}
treeItem.getChildren().clear();
AbstractAutoCodeBean segmentNode = treeItem.getValue();
if (segmentNode == null) {
return;
}
TCComponent autoCodeDataComponent = segmentNode.packCodeNodeInfo.getNodeComponent();
HashMap<String, String> hashMap = new HashMap<String, String>();
String parentStr = "";
parentStr = getParentStr(segmentNode, parentStr);
if (autoCodeDataComponent != null) {
hashMap.put(AutoCodeManagerPropertyName.CodeRelation_current_node, autoCodeDataComponent.uid);
hashMap.put(AutoCodeManagerPropertyName.CodeRelation_parent_node, parentStr);
} else {
hashMap.put(AutoCodeManagerPropertyName.CodeRelation_parent_node, "");
hashMap.put(AutoCodeManagerPropertyName.CodeRelation_current_node, "");
}
String parentStr2 = "";
if (autoCodeDataComponent != null) {
if (parentStr.trim().length() == 0) {
parentStr2 = autoCodeDataComponent.uid;
} else {
parentStr2 = parentStr + "," + autoCodeDataComponent.uid;
}
} else {
parentStr2 = parentStr;
}
List<PackCodeNodeInfo> packCodeNodeInfos = searchTreeORListNodeInfos(hashMap, parentStr2,
AutoCodeManagerPropertyName.searchTreeAndListCodeNodePropNames);
int nodeCnt = packCodeNodeInfos == null ? 0 : packCodeNodeInfos.size();
String realTypeName = segmentNode.packCodeNodeInfo.getRealTypeName();
KUtil.LOG("找到节点数量:" + nodeCnt);
for (int i = 0; i < nodeCnt; i++) {
PackCodeNodeInfo packCodeNodeInfo = packCodeNodeInfos.get(i);
packCodeNodeInfo.setRealTypeName(realTypeName);
KUtil.LOG(">> " + packCodeNodeInfo.getNode_name());
Platform.runLater(() -> {
AutoCodeTreeTableBean bean = new AutoCodeTreeTableBean(segmentNode, packCodeNodeInfo);
treeItem.getChildren().add(getTreeItem(bean, bean.packCodeNodeInfo.isContainsChildren));
});
}
Platform.runLater(() -> {
treeTableView.refresh();
});
// initTreeOrListMouseClick();
// AbstractTreeData selectedData = treeViewOperation.getSelectedTreeNode(treeView.treeViewer);
// if (selectedData == null) {
// return;
// }
// if (selectedData.getPackCodeNodeInfo().getNodeComponent() == null) {
// return;
// }
// if ((selectedData.getPackCodeNodeInfo().is_lock)) {
// return;
// }
// String currentNodeDesc = "";
// String currentNodeValue = "";
// String name = "";
// // 得到编码相关信息
// getCodeInfo(selectedData);
//
// KUtil.LOG(">>>>>>>><<<<<<<");
// getClassANDPropertyInfo(selectedData);
//
// name = selectedData.getPackCodeNodeInfo().getNode_name();
// icoTreeData = selectedData;
// currentNodeValue = replaceSpecialValue(selectedData.getPackCodeNodeInfo().node_value);
// if (currentNodeValue.length() > 0) {
// currentNodeDesc = currentNodeValue + "::" + selectedData.getPackCodeNodeInfo().getNode_name();
// }
// if (currentNodeValue.trim().length() > 0) {
// pattern = pattern + " " + currentNodeValue + " ";
// }
// if (currentNodeDesc.trim().length() > 0) {
// codeDesc = codeDesc + currentNodeDesc;
// }
// if (!TCPreferenceUitl.isTrueTCPreferenceValue(session, origin_isItemNameTextDefaultNull)) {
// nameText.setText(name);
// selectName = name;
// KUtil.LOG("1----------------" + name);
// String itemTypeString = tccomponentitemtype.getType();
// } else {
// nameText.setText("");
// }
// getFinalPattern();
// idText.setText(finalPattern);
// setIDPatternTextIsCanEdit();
// idLengthText.setText(String.valueOf(idText.getText().replace(" ", "").trim().length()));
// DescText.setText(codeDesc);
// setMidComposite();
}
public void loadAutoCodeTreeTable(TreeItem<AutoCodeTreeBean> autoCodeTreeItem) throws Exception {
AutoCodeTreeBean autoCodeTreeNode = autoCodeTreeItem.getValue();
TCComponent selectedSegmentTCComponent = autoCodeTreeNode.packCodeNodeInfo.getNodeComponent();
if (selectedSegmentTCComponent == null) {
return;
}
Platform.runLater(() -> {
treeTableView.getRoot().getChildren().clear();
});
if (selectedSegmentTCComponent.getLogicalProperty(AutoCodeManagerPropertyName.TreeAndListCodeNode_is_lock)) {
return;
}
if ((autoCodeTreeNode.packCodeNodeInfo.getNode_type().equals(AutoCodeManagerPropertyName.TreeName))
|| (autoCodeTreeNode.packCodeNodeInfo.getNode_type().equals(AutoCodeManagerPropertyName.ListName))) {
String realType = autoCodeTreeNode.packCodeNodeInfo.getRealTypeName();
KUtil.LOG("Select Type: " + realType);
dialogController.setSelectedItemType(realType);
}
// 加载编码树
if (autoCodeTreeNode.packCodeNodeInfo.getNode_type().equals(AutoCodeManagerPropertyName.TreeName)) {
setTreeNodes(autoCodeTreeItem);
}
}
protected void setTreeNodes(TreeItem<AutoCodeTreeBean> autoCodeTreeItem) throws Exception {
AutoCodeTreeBean segmentNode = autoCodeTreeItem.getValue();
if (segmentNode == null) {
return;
}
TCComponent autoCodeDataComponent = segmentNode.packCodeNodeInfo.getNodeComponent();
HashMap<String, String> hashMap = new HashMap<String, String>();
String parentStr = "";
parentStr = getParentStr(segmentNode, parentStr);
if (autoCodeDataComponent != null) {
hashMap.put(AutoCodeManagerPropertyName.CodeRelation_current_node, autoCodeDataComponent.uid);
hashMap.put(AutoCodeManagerPropertyName.CodeRelation_parent_node, parentStr);
} else {
hashMap.put(AutoCodeManagerPropertyName.CodeRelation_parent_node, "");
hashMap.put(AutoCodeManagerPropertyName.CodeRelation_current_node, "");
}
String parentStr2 = "";
if (autoCodeDataComponent != null) {
if (parentStr.trim().length() == 0) {
parentStr2 = autoCodeDataComponent.uid;
} else {
parentStr2 = parentStr + "," + autoCodeDataComponent.uid;
}
} else {
parentStr2 = parentStr;
}
List<PackCodeNodeInfo> packCodeNodeInfos = searchTreeORListNodeInfos(hashMap, parentStr2,
AutoCodeManagerPropertyName.searchTreeAndListCodeNodePropNames);
int nodeCnt = packCodeNodeInfos == null ? 0 : packCodeNodeInfos.size();
String realTypeName = segmentNode.packCodeNodeInfo.getRealTypeName();
for (int i = 0; i < nodeCnt; i++) {
PackCodeNodeInfo packCodeNodeInfo = packCodeNodeInfos.get(i);
packCodeNodeInfo.setRealTypeName(realTypeName);
Platform.runLater(() -> {
AutoCodeTreeTableBean bean = new AutoCodeTreeTableBean(segmentNode, packCodeNodeInfo);
treeTableView.getRoot().getChildren().add(getTreeItem(bean, bean.packCodeNodeInfo.isContainsChildren));
});
}
}
private List<PackCodeNodeInfo> searchTreeORListNodeInfos(HashMap<String, String> hashMap, String parentString,
String[] returnPropertyNames) throws Exception {
List<PackCodeNodeInfo> packCodeNodeInfos = new ArrayList<PackCodeNodeInfo>();
TCComponent[] searchTCcomponents = KUtil.searchComponentFromITK(KMain.INPUTCODE_SEARCH_TREE_OR_LIST_NODE,
hashMap);
packCodeNodeInfos = getTreeORListNodeInfos(searchTCcomponents, parentString, returnPropertyNames);
return packCodeNodeInfos;
}
public String[] getTreeAndListStringValues(TCComponent[] components, String[] propNames, String parentString)
throws Exception {
StringBuilder inputStr = new StringBuilder();
inputStr.append(parentString);
int compCnt = KUtil.getLen(components);
for (int i = 0; i < compCnt; i++) {
inputStr.append(KMain.SPLITTER);
inputStr.append(components[i].uid);
}
inputStr.append(KMain.SPLITTER);
inputStr.append(KMain.SPLIT_SECTION);
int paramCnt = KUtil.getLen(propNames);
for (int i = 0; i < paramCnt; i++) {
inputStr.append(KMain.SPLITTER);
inputStr.append(propNames[i]);
}
String returnValues = KUtil.callITK(KMain.INPUTCODE_GET_TREE_AND_LIST_STRING_VALUES, inputStr.toString());
return returnValues.split("@@");
}
private String getStringValue(String value) {
if ((value == null) || (value.equalsIgnoreCase("null"))) {
return "";
} else {
return value;
}
}
private List<PackCodeNodeInfo> getTreeORListNodeInfos(TCComponent[] searchTCcomponents, String parentString,
String[] returnPropertyNames) throws Exception {
List<PackCodeNodeInfo> packCodeNodeInfos = new ArrayList<PackCodeNodeInfo>();
if (searchTCcomponents != null && searchTCcomponents.length > 0) {
String[] stringValues = getTreeAndListStringValues(searchTCcomponents, returnPropertyNames, parentString);
if (stringValues == null) {
return null;
}
for (int i = 0; i < stringValues.length; i++) {
String[] values = stringValues[i].split("&&");
PackCodeNodeInfo packCodeNodeInfo = new PackCodeNodeInfo();
if ((values != null) && (values.length > 0)) {
if (returnPropertyNames.equals(AutoCodeManagerPropertyName.searchTreeAndListCodeNodePropNames)) {
packCodeNodeInfo.setNodeComponent(searchTCcomponents[i]);
packCodeNodeInfo.setNode_name(getStringValue(values[0]));
packCodeNodeInfo.setNode_type(getStringValue(values[1]));
packCodeNodeInfo.setNode_value(getStringValue(values[2]));
packCodeNodeInfo.setNode_desc(getStringValue(values[3]));
packCodeNodeInfo.setCode_style(getStringValue(values[4]));
packCodeNodeInfo.setRule_node(getStringValue(values[5]));
if (values[6].equalsIgnoreCase("yes")) {
packCodeNodeInfo.setIs_root(true);
}
if (values[7].equalsIgnoreCase("yes")) {
packCodeNodeInfo.setIs_lock(true);
}
if (values[8].equalsIgnoreCase("yes")) {
packCodeNodeInfo.setDefaultSelected(true);
}
packCodeNodeInfo.setCreate_date(getStringValue(values[9]));
packCodeNodeInfo.setLast_revise_date(getStringValue(values[10]));
packCodeNodeInfo.setCreate_user(getStringValue(values[11]));
packCodeNodeInfo.setLast_revise_user(getStringValue(values[12]));
if (values[13].equalsIgnoreCase("yes")) {
packCodeNodeInfo.setContainsChildren(true);
}
} else {
packCodeNodeInfo.setNodeComponent(searchTCcomponents[i]);
packCodeNodeInfo.setNode_name(getStringValue(values[0]));
packCodeNodeInfo.setNode_type(getStringValue(values[1]));
if (values[2].equalsIgnoreCase("yes")) {
packCodeNodeInfo.setIs_root(true);
}
if (values[3].equalsIgnoreCase("yes")) {
packCodeNodeInfo.setIs_lock(true);
}
if (values[4].equalsIgnoreCase("yes")) {
packCodeNodeInfo.setContainsChildren(true);
}
}
packCodeNodeInfos.add(packCodeNodeInfo);
}
}
}
return packCodeNodeInfos;
}
public String getParentStr(AbstractAutoCodeBean treeData, String parentStr) {
// KUtil.LOG("i am in getParentStr == " + parentStr);
if (treeData != null) {
AbstractAutoCodeBean parentData = treeData.parentTreeData;
if ((parentData != null) && ((parentData.packCodeNodeInfo.getNodeComponent() != null))) {
// KUtil.LOG("parentData.getPackCodeNodeInfo() " +
// parentData.packCodeNodeInfo.getNode_name());
if (parentData.packCodeNodeInfo.getNodeComponent() != null) {
// KUtil.LOG("i am not null");
}
if (parentStr.length() > 0) {
parentStr = parentData.packCodeNodeInfo.getNodeComponent().uid + "," + parentStr;
} else {
parentStr = parentData.packCodeNodeInfo.getNodeComponent().uid;
}
parentStr = getParentStr(parentData, parentStr);
// KUtil.LOG("parentStr AAA === " + parentStr);
}
} else {
// KUtil.LOG(" treeDtae =null");
}
if (parentStr.toString().endsWith(",")) {
parentStr = parentStr.substring(0, parentStr.length() - 1).toString();
}
return parentStr;
}
}

@ -0,0 +1,339 @@
package nx_connor.autcocode.controller;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import javafx.application.Platform;
import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue;
import javafx.scene.control.Alert.AlertType;
import javafx.scene.control.TreeItem;
import javafx.scene.image.ImageView;
import nx_connor.KMain;
import nx_connor.autcocode.AutoCodeDialogController;
import nx_connor.autcocode.bean.AutoCodeTreeBean;
import nx_connor.autcocode.bean.PackCodeNodeInfo;
import nx_connor.autcocode.bean.TCComponent;
import nx_connor.autcocode.manager.AutoCodeConstants;
import nx_connor.autcocode.manager.AutoCodeManagerPropertyName;
import nx_connor.util.KUtil;
public class AutoCodeTreeViewController {
private AutoCodeDialogController dialogController;
protected String showItemType = "";
protected boolean isFilterType = false;
public AutoCodeTreeViewController(AutoCodeDialogController autoCodeDialogController) throws Exception {
this.dialogController = autoCodeDialogController;
initTree();
}
protected void initTree() throws Exception {
AutoCodeTreeBean rootBean = new AutoCodeTreeBean(null, "编码分类", AutoCodeManagerPropertyName.ComponentName);
Platform.runLater(()->{
dialogController.treeView.setRoot(getTreeItem(rootBean, true));
});
// 选择监听
dialogController.treeView.getSelectionModel().selectedItemProperty()
.addListener(new ChangeListener<TreeItem<AutoCodeTreeBean>>() {
@Override
public void changed(ObservableValue<? extends TreeItem<AutoCodeTreeBean>> arg0,
TreeItem<AutoCodeTreeBean> arg1, TreeItem<AutoCodeTreeBean> newValue) {
if (newValue == null) {
return;
}
new Thread(() -> {
dialogController.setProgressVisible(true);
try {
dialogController.showAutoCodeList(newValue);
} catch (Exception e) {
e.printStackTrace();
dialogController.Err(e);
}
dialogController.setProgressVisible(false);
}).start();
}
});
}
public TreeItem<AutoCodeTreeBean> getTreeItem(AutoCodeTreeBean child, boolean needExpand) {
ImageView image = child.getImage() == null ? null : new ImageView(child.getImage());
TreeItem<AutoCodeTreeBean> treeItem = new TreeItem<AutoCodeTreeBean>(child, image);
if (!needExpand) {
return treeItem;
}
treeItem.expandedProperty().addListener(new ChangeListener<Boolean>() {
@Override
public void changed(ObservableValue<? extends Boolean> arg0, Boolean oldValue, Boolean newValue) {
if (!newValue) {
return;
}
new Thread(new Runnable() {
@Override
public void run() {
expandNode(treeItem);
}
}).start();
}
});
treeItem.getChildren().add(new TreeItem<AutoCodeTreeBean>(null));
return treeItem;
}
public void expandNode(TreeItem<AutoCodeTreeBean> treeItem) {
if (treeItem == null) {
return;
}
if (treeItem.getChildren().size() != 1 || treeItem.getChildren().get(0).getValue() != null) {
return;
}
AutoCodeTreeBean bean = treeItem.getValue();
long timeStart = System.nanoTime();
dialogController.setProgressVisible(true);
try {
KUtil.LOG("Expand Node: " + treeItem.getValue());
Platform.runLater(() -> {
treeItem.getChildren().clear();
});
String nodeType = bean.packCodeNodeInfo.getNode_type();
if (AutoCodeManagerPropertyName.ComponentName.equals(nodeType)) {
expandTopNode(treeItem);
} else if (AutoCodeManagerPropertyName.ItemName.equals(nodeType)) {
expandItemNode(treeItem);
}
} catch (Exception e) {
e.printStackTrace();
KUtil.LOGERROR(e);
KUtil.showFXMessage(dialogController.dialog.getParentDialog(), "加载节点失败", AlertType.ERROR, e.getMessage());
}
long timeEnd = System.nanoTime();
KUtil.LOG("Load Node Time: " + treeItem.getValue() + " -> " + (timeEnd - timeStart) / 1000000);
dialogController.setProgressVisible(false);
}
protected void expandItemNode(TreeItem<AutoCodeTreeBean> treeItem) throws Exception {
boolean isShow = false;
AutoCodeTreeBean bean = treeItem.getValue();
HashMap<String, String> map = new HashMap<String, String>();
map.put(AutoCodeManagerPropertyName.ClassificationCodeNode_node_name, bean.packCodeNodeInfo.getNode_name());
TCComponent[] tcComponents = KUtil.searchComponentFromITK(KMain.INPUTCODE_SEARCH_AUTOCODE_SEGMENT, map);
if (tcComponents == null || tcComponents.length == 0) {
return;
}
List<TCComponent> showSegments = new ArrayList<TCComponent>();
map.put(AutoCodeManagerPropertyName.ClassificationCodeNode_segment, "");
TCComponent[] userComponents = KUtil.searchComponentFromITK(KMain.INPUTCODE_SEARCH_AUTOCODE_USER, map);
String parentGroupUid = KUtil.callITK(KMain.INPUTCODE_GET_UID, "parentgroup");
TCComponent parentGroup = KUtil.isEmpty(parentGroupUid) ? null : new TCComponent(parentGroupUid);
int userComponentsCount = KUtil.getLen(userComponents);
for (int i = 0; i < userComponentsCount; i++) {
TCComponent u = userComponents[i];
if (u.equals(dialogController.currentUser) || u.equals(dialogController.currentGroup)
|| u.equals(dialogController.currentRole)) {
isShow = true;
break;
}
if (u.equals(parentGroup)) {
isShow = true;
break;
}
}
if (!isShow) {
int tcComponentsCount = KUtil.getLen(tcComponents);
for (int i = 0; i < tcComponentsCount; i++) {
isShow = false;
TCComponent cc = tcComponents[i];
if (cc == null) {
continue;
}
String segmentName = cc.uid;
HashMap<String, String> ccMap = new HashMap<String, String>();
ccMap.put(AutoCodeManagerPropertyName.ClassificationCodeNode_node_name,
bean.packCodeNodeInfo.getNode_name());
ccMap.put(AutoCodeManagerPropertyName.ClassificationCodeNode_segment, segmentName);
TCComponent[] ccUserComponents = KUtil.searchComponentFromITK(KMain.INPUTCODE_SEARCH_AUTOCODE_USER,
ccMap);
int ccUserCount = KUtil.getLen(ccUserComponents);
if (ccUserCount == 0) {
continue;
}
for (int j = 0; j < ccUserCount; j++) {
TCComponent u = ccUserComponents[j];
if (u == null) {
continue;
}
if (u.equals(dialogController.currentUser) || u.equals(dialogController.currentGroup)
|| u.equals(dialogController.currentRole)) {
isShow = true;
break;
}
if (u.equals(parentGroup)) {
isShow = true;
break;
}
}
if (isShow) {
showSegments.add(cc);
}
}
} else {
int tcComponentsCount = KUtil.getLen(tcComponents);
for (int i = 0; i < tcComponentsCount; i++) {
TCComponent cc = tcComponents[i];
if (cc != null) {
showSegments.add(cc);
}
}
}
int segCnt = showSegments.size();
if (segCnt == 0) {
return;
}
String realTypeName = bean.packCodeNodeInfo.getRealTypeName();
for (int i = 0; i < segCnt; i++) {
TCComponent seg = showSegments.get(i);
PackCodeNodeInfo packCodeNodeInfo = getTreeAndListStringValue(seg,
AutoCodeManagerPropertyName.searchTreeAndListCodeNodePropNames);
packCodeNodeInfo.setRealTypeName(realTypeName);
AutoCodeTreeBean childBean = new AutoCodeTreeBean(packCodeNodeInfo);
if (!packCodeNodeInfo.is_root) {
continue;
} else {
setParentTreeNode(bean, childBean);
}
Platform.runLater(() -> {
treeItem.getChildren().add(getTreeItem(childBean, packCodeNodeInfo.isContainsChildren));
});
}
}
private void setParentTreeNode(AutoCodeTreeBean parentBean, AutoCodeTreeBean childBean) throws Exception {
TCComponent[] tccomponents = null;
HashMap<String, String> hashMap = new HashMap<String, String>();
if (childBean.packCodeNodeInfo.getNodeComponent() != null) {
hashMap.put(AutoCodeManagerPropertyName.CodeRelation_current_node,
childBean.packCodeNodeInfo.getNodeComponent().uid);
tccomponents = KUtil.searchComponentFromITK(KMain.INPUTCODE_SEARCH_PARENT_TREE_OR_LIST_NODE, hashMap);
} else {
tccomponents = null;
}
if (tccomponents != null && tccomponents.length > 0) {
AutoCodeTreeBean childrenNode2 = childBean;
for (int k = tccomponents.length - 1; k >= 0; k--) {
if (tccomponents[k] == null) {
continue;
}
PackCodeNodeInfo packCodeNodeInfo = getTreeAndListStringValue(
tccomponents[k], AutoCodeManagerPropertyName.searchTreeAndListCodeNodePropNames);
AutoCodeTreeBean treeData = new AutoCodeTreeBean(packCodeNodeInfo);
childrenNode2.setParentTreeData(treeData);
childrenNode2 = treeData;
}
childrenNode2.setParentTreeData(parentBean);
}
}
private String getStringValue(String value) {
if ((value == null) || (value.equalsIgnoreCase("null"))) {
return "";
} else {
return value;
}
}
protected PackCodeNodeInfo getTreeAndListStringValue(TCComponent seg, String[] propNames) throws Exception {
PackCodeNodeInfo packCodeNodeInfo = new PackCodeNodeInfo();
StringBuilder inputStr = new StringBuilder();
inputStr.append(seg.uid);
int paramCnt = KUtil.getLen(propNames);
for (int i = 0; i < paramCnt; i++) {
inputStr.append(KMain.SPLITTER);
inputStr.append(propNames[i]);
}
String returnValues = KUtil.callITK(KMain.INPUTCODE_GET_TREE_AND_LIST_STRING_VALUE, inputStr.toString());
String[] values = KUtil.isEmpty(returnValues) ? null : returnValues.split("&&");
if ((values != null) && (values.length > 0)) {
if (propNames.equals(AutoCodeManagerPropertyName.searchTreeAndListCodeNodePropNames)) {
packCodeNodeInfo.setNodeComponent(seg);
packCodeNodeInfo.setNode_name(getStringValue(values[0]));
packCodeNodeInfo.setNode_type(getStringValue(values[1]));
packCodeNodeInfo.setNode_value(getStringValue(values[2]));
packCodeNodeInfo.setNode_desc(getStringValue(values[3]));
packCodeNodeInfo.setCode_style(getStringValue(values[4]));
packCodeNodeInfo.setRule_node(getStringValue(values[5]));
if (values[6].equalsIgnoreCase("yes")) {
packCodeNodeInfo.setIs_root(true);
}
if (values[7].equalsIgnoreCase("yes")) {
packCodeNodeInfo.setIs_lock(true);
}
if (values[8].equalsIgnoreCase("yes")) {
packCodeNodeInfo.setDefaultSelected(true);
}
packCodeNodeInfo.setCreate_date(getStringValue(values[9]));
packCodeNodeInfo.setLast_revise_date(getStringValue(values[10]));
packCodeNodeInfo.setCreate_user(getStringValue(values[11]));
packCodeNodeInfo.setLast_revise_user(getStringValue(values[12]));
if (values[13].equalsIgnoreCase("yes")) {
packCodeNodeInfo.setContainsChildren(true);
}
} else {
packCodeNodeInfo.setNodeComponent(seg);
packCodeNodeInfo.setNode_name(getStringValue(values[0]));
packCodeNodeInfo.setNode_type(getStringValue(values[1]));
if (values[2].equalsIgnoreCase("yes")) {
packCodeNodeInfo.setIs_root(true);
}
if (values[3].equalsIgnoreCase("yes")) {
packCodeNodeInfo.setIs_lock(true);
}
if (values[4].equalsIgnoreCase("yes")) {
packCodeNodeInfo.setContainsChildren(true);
}
}
}
return packCodeNodeInfo;
}
protected void expandTopNode(TreeItem<AutoCodeTreeBean> topNode) throws Exception {
String prefValueStr = KUtil.callITK(KMain.INPUTCODE_GetPrefValue, "Connor_load_only_item_types");
String[] itemTypeNames;
if (!KUtil.isEmpty(prefValueStr)) {
itemTypeNames = prefValueStr.split(KMain.SPLITTER);
} else {
itemTypeNames = AutoCodeConstants.as1;
}
// String prefValStr = KUtil.callITK(KMain.INPUTCODE_GetPrefValue, PREF_SEQUENCEMAP); //AutoCodeConstants.as2
List<AutoCodeTreeBean> allTypes = dialogController.autoCodeItemTypeController.getAllTypes(itemTypeNames,
AutoCodeConstants.as2);
int size = allTypes == null ? 0 : allTypes.size();
List<Integer> remove = new ArrayList<Integer>();
if(dialogController.filterType.size()>0) {
for(int i=0;i<size;i++) {
String typeName = allTypes.get(i).packCodeNodeInfo.getRealTypeName();
if(!dialogController.filterType.contains(typeName)) {
remove.add(i);
}
}
}
KUtil.LOG("过滤类型:"+remove);
int removeCnt = remove.size();
for(int i=removeCnt-1;i>=0;i--) {
allTypes.remove(remove.get(i).intValue());
}
int size2 = allTypes.size();
Platform.runLater(() -> {
for (int i = 0; i < size2; i++) {
topNode.getChildren().add(getTreeItem(allTypes.get(i), true));
}
if(size2==1) {
topNode.getChildren().get(0).setExpanded(true);
}
});
}
}

@ -0,0 +1,63 @@
/**
* @author tyl
* @Action ini
* 2011-3-15
*/
package nx_connor.autcocode.controller;
import nx_connor.KMain;
import nx_connor.util.KUtil;
public class GetCodeNumber {
public static void delete_recycleID(String itemID) throws Exception {
// Object[] params = { counterName, itemID };
if ((itemID == null) || (itemID.length() == 0)) {
return;
}
itemID = itemID.replace(" ", "").trim();
KUtil.callITK(KMain.INPUTCODE_DELETE_RECYCLE_ID, itemID);
}
/**
* @param patternCode
* @param codeLength
* @param startIndex
* @param endIndex
* @param increaseStep
* @return
* @throws ServiceException
*/
public static String getCodeNumber(String patternCode, int codeLength, int startIndex, int maxValue,
int increaseStep, String excludeStr) throws Exception {
if (maxValue == startIndex) {
return String.valueOf(maxValue);
}
if (startIndex < 1) {
startIndex = 1;
}
if (maxValue < startIndex) {
return String.valueOf(startIndex);
}
codeLength = String.valueOf(maxValue).length();
StringBuilder input = new StringBuilder();
input.append(patternCode.replace(" ", "").trim());
input.append(KMain.SPLITTER);
input.append(codeLength);
input.append(KMain.SPLITTER);
input.append(startIndex);
input.append(KMain.SPLITTER);
input.append(maxValue);
input.append(KMain.SPLITTER);
input.append(increaseStep);
input.append(KMain.SPLITTER);
input.append(excludeStr);
// String[] params = { patternCode.replace(" ", "").trim(), codeLength, startIndex, maxValue, increaseStep,
// excludeStr };
return KUtil.callITK(KMain.INPUTCODE_QUERY_PART_NO, input.toString());
// String str = "";
// str = (String) userService.call("queryPartNo", params);
// return str;
}
}

@ -0,0 +1,33 @@
package nx_connor.autcocode.manager;
public interface AutoCodeConstants {
// AutoCode
public static final String AutoCode_APPLICATION_ID = "cn.com.origin.autocode";
public static final String AutoCodeCodeView_ID = "cn.com.origin.autocode.views.AutoCodeView";
public static final String AutoCodeCodeView_Name = "编码规则";
public static final String AutoCodeItemTypeView_ID = "cn.com.origin.autocode.views.AutoCodeItemTypeView";
public static final String AutoCodeItemTypeView_Name = "零组件";
public static final String AutoCodeGroupView_ID = "cn.com.origin.autocode.views.AutoCodeGroupView";
public static final String AutoCodeGroupView_Name = "人员指派";
public static final String AutoCodeSegmentView_ID = "cn.com.origin.autocodemanager.views.AutoCodeSegmentView";
public static final String AutoCodeSegmentView_Name = "编码规则";
public static final String as1[] = { "Item" ,"Part","Design"};//
// public static final String as2[] = { "Part", "Design", "PSSignal", "PSConnection", "Schedule", "ScheduleTask", "Architecture", "AllocationMap", "CAEItem", "CAEBCItem", "CAEConnItem", "CAELoadItem", "MEOP", "MEProcess", "MEWorkarea", "MEContext", "MEGenericBOP", "MEProductBOP",
// "Vendor", "BidPackage", "SwDesignComp", "PhysicalPart", "ChangeItem", "ParmDef", "ParmDefBCD", "ParmDefBitDef", "ParmDefBool", "ParmDefDate", "ParmDefDbl", "ParmDefHex", "ParmDefInt", "ParmDefSED", "ParmDefStr", "ParmGrpVal", "CalParm", "ParmGrpDef" };
// public static final String as1[] = { "Item", "Drawing" };"Part", "Design",
public static final String as2[] = { "EngChange", "PSSignal" }; //, "BidPackage", "SwDesignComp", "PhysicalPart", "ChangeItem", "ParmDef", "ParmDefBCD", "ParmDefBitDef", "ParmDefBool", "ParmDefDate", "ParmDefDbl", "ParmDefHex", "ParmDefInt", "ParmDefSED", "ParmDefStr", "ParmGrpVal", "CalParm", "ParmGrpDef"
// , "PSConnection", "Schedule", "ScheduleTask", "Architecture", "AllocationMap", "CAEItem", "CAEBCItem", "CAEConnItem", "CAELoadItem", "MEOP", "MEProcess", "MEWorkarea", "MEContext", "MEGenericBOP", "MEProductBOP",
// "Vendor"
// public static final String startWithTypes[]={"SJ3_"};
// public static final String startWithTypes[] = {};
}

@ -0,0 +1,43 @@
package nx_connor.autcocode.manager;
public interface AutoCodeManagerImageKey {
public static final String ICONSPATH = "icons/";
public static final String HOME_IMAGE = ICONSPATH + "home_data.png";
public static final String CODE_IMAGE = ICONSPATH + "code_16.png";
public static final String CODEGROUP_IMAGE = ICONSPATH + "folder_16.png";
public static final String NODEVALUE_IMAGE = ICONSPATH + "nodevalue_16.png";
public static final String CODENODE_IMAGE = ICONSPATH + "codenode_16.png";
public static final String TREE_IMAGE = ICONSPATH + "tree_16.png";
public static final String TREENODE_IMAGE = ICONSPATH + "treenode_16.png";
public static final String LIST_IMAGE = ICONSPATH + "list_16.png";
public static final String LISTNODE_IMAGE = ICONSPATH + "listproperty_16.png";
public static final String LISTVALUE_IMAGE = ICONSPATH + "listvalue_16.png";
public static final String OK_IMAGE = ICONSPATH + "ok_16.png";
public static final String CLOSE_IMAGE = ICONSPATH + "close_16.png";
public static final String IMPORT_IMAGE = ICONSPATH + "import_16.png";
public static final String EXPORT_IMAGE = ICONSPATH + "export_16.png";
public static final String ORGANIZATION_IMAGE = ICONSPATH + "organization_16.png";
public static final String GROUP_IMAGE = ICONSPATH + "group_16.png";
public static final String ROLE_IMAGE = ICONSPATH + "role_16.png";
public static final String PERSON_IMAGE = ICONSPATH + "person_16.png";
public static final String ITEM_IMAGE = ICONSPATH + "item_16.png";
public static final String LOCK_IMAGE = ICONSPATH + "lock_16.png";
public static final String UNLOCK_IMAGE = ICONSPATH + "unlock_16.png";
public static final String EDIT_IMAGE = ICONSPATH + "edit_16.png";
public static final String REMOVE_IMAGE = ICONSPATH + "remove_16.png";
public static final String DELETE_IMAGE = ICONSPATH + "delete_16.png";
public static final String SEQ_IMAGE = ICONSPATH + "seq_16.png";
public static final String ADD_IMAGE = ICONSPATH + "add.png";
}

@ -0,0 +1,151 @@
package nx_connor.autcocode.manager;
public interface AutoCodeManagerPropertyName {
// Cd9_TreeAndListCodeNode
public final static String TreeAndListCodeNode_isContainsChildren = "isContainsChildren" ;// 是否包含子节点
public final static String TreeAndListCodeNode_uid = "uid" ;// uid
public final static String TreeAndListCodeNode_node_index = "cd9_node_index"; // Integer 节点序号
public final static String TreeAndListCodeNode_node_type = "cd9_node_type";// String 节点名称
public final static String TreeAndListCodeNode_node_name = "cd9_node_name";// String 节点名称
public final static String TreeAndListCodeNode_node_value = "cd9_node_value"; // String 节点值
public final static String TreeAndListCodeNode_node_desc = "cd9_node_desc"; // String 节点描述
public final static String TreeAndListCodeNode_code_style = "cd9_code_style"; // String 编码格式
public final static String TreeAndListCodeNode_code_length = "cd9_code_length"; // int 编码长度
public final static String TreeAndListCodeNode_is_root = "cd9_is_root";// boolean 是否是根节点
public final static String TreeAndListCodeNode_rule_node = "cd9_rule_node";// boolean 是否是根节点
public final static String TreeAndListCodeNode_reference_nodes = "cd9_reference_nodes"; // 引用的节点
public final static String TreeAndListCodeNode_is_lock = "cd9_is_lock";// boolean 是否锁定
public final static String TreeAndListCodeNode_create_date = "cd9_create_date";// Date 创建日期
public final static String TreeAndListCodeNode_last_revise_date = "cd9_last_revise_date";// Date 最后修改日期
public final static String TreeAndListCodeNode_create_user = "cd9_create_user";// TypeReference 创建者
public final static String TreeAndListCodeNode_last_revise_user = "cd9_last_revise_user";// TypeReference 最后修改者
public final static String TreeAndListCodeNode_seq_begin_value = "cd9_seq_begin_value"; // Integer 流水码初始值
public final static String TreeAndListCodeNode_seq_max_value = "cd9_seq_max_value"; // Integer 流水码最大值
public final static String TreeAndListCodeNode_seq_length = "cd9_seq_length"; // Integer 流水码长度
public final static String TreeAndListCodeNode_isDefaultSelected = "cd9_isDefaultSelected"; // boolean 是否为默认选中(针对列表)
String[] searchTreeAndListCodeNodePropNames = {
AutoCodeManagerPropertyName.TreeAndListCodeNode_node_name,
AutoCodeManagerPropertyName.TreeAndListCodeNode_node_type,
AutoCodeManagerPropertyName.TreeAndListCodeNode_node_value,
AutoCodeManagerPropertyName.TreeAndListCodeNode_node_desc,
AutoCodeManagerPropertyName.TreeAndListCodeNode_code_style,
AutoCodeManagerPropertyName.TreeAndListCodeNode_rule_node,
AutoCodeManagerPropertyName.TreeAndListCodeNode_is_root,
AutoCodeManagerPropertyName.TreeAndListCodeNode_is_lock,
AutoCodeManagerPropertyName.TreeAndListCodeNode_isDefaultSelected,
AutoCodeManagerPropertyName.TreeAndListCodeNode_create_date,
AutoCodeManagerPropertyName.TreeAndListCodeNode_last_revise_date,
AutoCodeManagerPropertyName.TreeAndListCodeNode_create_user,
AutoCodeManagerPropertyName.TreeAndListCodeNode_last_revise_user,
AutoCodeManagerPropertyName.TreeAndListCodeNode_isContainsChildren
};
String[] searchSegmentPropNames = {
AutoCodeManagerPropertyName.TreeAndListCodeNode_node_name,
AutoCodeManagerPropertyName.TreeAndListCodeNode_node_type,
AutoCodeManagerPropertyName.TreeAndListCodeNode_is_root,
AutoCodeManagerPropertyName.TreeAndListCodeNode_is_lock,
AutoCodeManagerPropertyName.TreeAndListCodeNode_isContainsChildren
};
// Cd9_CodeRelation
public final static String CodeRelation_parent_node = "cd9_parent_nodes"; // TypeReference 父节点
public final static String CodeRelation_current_node = "cd9_current_node"; // TypeReference 当前节点
public final static String CodeRelation_children_nodes = "cd9_children_nodes"; // TypeReference 子节点
public final static String CodeRelation_create_date = "cd9_create_date";// Date 创建日期
public final static String CodeRelation_create_user = "cd9_create_user";// TypeReference 创建者
// Cd9_ClassificationCodeNode
public final static String ClassificationCodeNode_node_index = "cd9_node_index"; // Integer 节点序号
public final static String ClassificationCodeNode_node_name = "cd9_node_name";// String 节点名称
public final static String ClassificationCodeNode_segment = "cd9_segment";// String 所含码段
public final static String ClassificationCodeNode_create_date = "cd9_create_date";// Date 创建日期
public final static String ClassificationCodeNode_last_revise_date = "cd9_last_revise_date";// Date 最后修改日期
public final static String ClassificationCodeNode_create_user = "cd9_create_user";// TypeReference 创建者
public final static String ClassificationCodeNode_last_revise_user = "cd9_last_revise_user";// TypeReference 最后修改者
public final static String ClassificationCodeNode_grant_users = "cd9_grant_users";// TypeReference 授权用户
public final static String ClassificationCodeNode_grant_roles = "cd9_grant_roles";// TypeReference 授权角色
public final static String ClassificationCodeNode_grant_groups = "cd9_grant_groups";// TypeReference 授权组
// type
public final static String ItemName = "item";
public final static String RootNodeName = "root";
public final static String TreeName = "tree";
public final static String ListName = "list";
public final static String CodeGroupName = "codeGroup";
public final static String TreeNodeName = "treeNode";
public final static String ListPropertyNodeName = "listPropertyNode";
public final static String ListPropertyValueNodeName = "listPropertyValueNode";
public final static String ComponentName = "component";
public final static String OrganizationName = "organization";
public final static String SegmentName = "segment";
public final static String GroupName = "group";
public final static String RoleName = "role";
public final static String UserName = "user";
public final static String LockName = "lock";
public final static String AddChildrenTreeNodeName = "AddChildrenTreeNode";
public final static String AddTreeNodeName = "AddTreeNode";
public final static String AddRuleRootNodeName = "AddRuleRootNode";
public final static String AddRuleGroupNodeName = "AddRuleGroupNode";
// Item
public final static String Item_Desc = "object_desc";
public final static String Item_generateID = "cd9_generateID";
public final static String Item_codeDesc = "cd9_codeDesc";
public final static String Item_isLock = "cd9_isLock";
public final static String Item_codePattern = "cd9_codePattern";
public final static String Item_codeRuleName = "cd9_codeRuleName";
public final static String Item_codeID = "cd9_codeID";
public final static String Item_codeStyle = "cd9_codeStyle";
public final static String Item_uom_tag = "uom_tag";
// Item Revision
public final static String ItemRevision_isLock = "cd9_isLock";
// codeStyle
public final static String Code_seq = "[L]";
public final static String Code_pattern = "[T]";
public final static String Code_year2 = "[YY]";
public final static String Code_year4 = "[YYYY]";
public final static String Code_mouth2 = "[MM]";
public final static String Code_mouth1 = "[M]";
public final static String Code_date2 = "[DD]";
public final static String Code_date1 = "[D]";
// Cd9_CodeCounter
public final static String CodeCounter_index = "cd9_index";
public final static String CodeCounter_name = "cd9_name";
public final static String CodeCounter_recycleID = "cd9_recycleID";
public final static String CodeCounter_isUsed = "cd9_isUsed";
public final static String CodeCounter_createDate = "cd9_createDate";
public final static String CodeCounter_createUser = "cd9_createUser";
public final static String CodeCounter_last_revise_date = "cd9_last_revise_date";// Date 最后修改日期
public final static String CodeCounter_last_revise_user = "cd9_last_revise_user";
// Cd9_CodeNextID
public final static String Counter_name = "cd9_name";
public final static String Counter_nextID = "cd9_nextID";
// 有关导入导出
public final static String CodeClassfication = "CodeClassfication";
public final static String CodeTree = "CodeTree";
public final static String CodeListName = "CodeListName";
public final static String CodeListValue = "CodeListValue";
// public final static String[] TreeAndListCodeNode_Titles = { "层号", "类型", "名称", "码值", "备注", "编码样式", "编码长度", "流水码初始值", "流水码最大值", "是否为根节点", "是否锁定", "创建日期", "最后修改日期", "创建者", "最后修改者" };
public final static String[] TreeAndListCodeNode_Titles = { "层号", "类型", "名称", "码值", "备注", "是否为默认值", "编码样式", "编码长度", "流水码初始值", "流水码最大值", "是否为根节点", "是否锁定", "创建日期", "最后修改日期", "创建者", "最后修改者" };
public final static String[] ClassificationCodeNode_Titles = { "层号", "类型", "名称", "码值", "备注", "编码格式", "是否为根节点", "是否锁定", "创建日期", "最后修改日期", "创建者", "最后修改者" };
public final static String[] CodeSequence_Titles = { "层号", "名称", "初始值", "最大值", "长度", "步长", "不包含数字", "是否锁定", "创建日期", "最后修改日期", "创建者", "最后修改者" };
}

@ -0,0 +1,34 @@
package nx_connor.autcocode.manager;
/**
* @author river
*
*/
public interface AutoCodeManangerConstants {
// autocodemannager
public static final String AutoCodeMananger_APPLICATION_ID = "cn.com.origin.autocodemanager";
public static final String AutoCodeManagerView_ID = "cn.com.origin.autocodemanager.views.AutoCodeSegmentView";
public static final String AutoCodeManagerView_Name = "编码管理";
public static final String AutoCodeManagerTreeCodeView_ID = "cn.com.origin.autocodemanager.views.AutoCodeTreeCodeView";
public static final String AutoCodeManagerTreeCodeView_Name = "编码树";
public static final String AutoCodeManagerListCodeView_ID = "cn.com.origin.autocodemanager.views.AutoCodeListCodeView";
public static final String AutoCodeManagerListCodeView_Name = "列表";
// public static final String AutoCodeTreeCodeView_ID = "cn.com.origin.autocodemanager.views.AutoCodeTreeCodeView";
// public static final String AutoCodeTreeCodeView_Name = "编码树";
// public static final String AutoCodeListCodeView_ID = "cn.com.origin.autocodemanager.views.AutoCodeListCodeView";
// public static final String AutoCodeListCodeView_Name = "列表";
public static final String AutoCodeManangerShowNoneView_Name = "";
public static final String AutoCodeManangerShowNoneView_ID = "cn.com.origin.autocodemanager.views.ShowNoneView";
public static final String AutoCodeStyleView_ID = "cn.com.origin.autocodemanager.views.AutoCodeStyleView";
public static final String AutoCodeStyleView_Name = "样式设置";
public static final String AutoCodeManagerGroupView_ID = "cn.com.origin.autocodemanager.views.AutoCodeGroupView";
public static final String AutoCodeTestView_ID = "cn.com.origin.autocodemanager.views.AutoCodeTestView";
public static final String AutoCodeTestView_Name = "编码验证";
}

@ -0,0 +1,70 @@
package nx_connor.autcocode.manager;
import java.awt.Graphics;
import java.awt.image.BufferedImage;
import java.awt.image.ImageObserver;
import java.io.InputStream;
import java.util.HashMap;
import java.util.Map;
import javax.swing.ImageIcon;
import javafx.scene.image.Image;
public class CacheImage {
private final Map<String, Image> imageMap = new HashMap<String, Image>();
private static CacheImage INSTANCE;
private CacheImage() {
}
// 单例模式获得CacheImage实例
public static CacheImage getINSTANCE() {
if (INSTANCE == null)
INSTANCE = new CacheImage();
return INSTANCE;
}
// 获得图像
public Image getImage(String applicationID,String imageName) {
if (imageName == null)
return null;
Image image = null;
if(imageMap.containsKey(imageName)) {
image = (Image) imageMap.get(imageName);
}else{
InputStream ss = CacheImage.class.getResourceAsStream(imageName);
if(ss!=null) {
image = new Image(ss);
}
imageMap.put(imageName, image);
}
return image;
}
// 释放图像资源
public void dispose() {
// Iterator iterator = imageMap.values().iterator();
// while (iterator.hasNext())
// ((Image) iterator.next()).dispose();
// imageMap.clear();
}
/**
* change ImageIcon to BufferedImage
* @param icon
* @return
*/
public static BufferedImage getBufferedImage(ImageIcon icon){
int width = icon.getIconWidth();
int height = icon.getIconHeight();
ImageObserver observer = icon.getImageObserver();
BufferedImage bufferedImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
Graphics gc = bufferedImage.createGraphics();
gc.drawImage(icon.getImage(), 0, 0, observer);
return bufferedImage;
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 332 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 699 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 681 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 454 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 726 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 906 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 672 B

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save