commit 6f98b1f6fe26d04024aa17cb20a37be9009b7fa1 Author: hongcj Date: Tue Jun 10 16:31:24 2025 +0800 first commit diff --git a/.classpath b/.classpath new file mode 100644 index 0000000..730cdc0 --- /dev/null +++ b/.classpath @@ -0,0 +1,31 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..73f69e0 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,8 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml +# Editor-based HTTP Client requests +/httpRequests/ diff --git a/.idea/encodings.xml b/.idea/encodings.xml new file mode 100644 index 0000000..6e8e052 --- /dev/null +++ b/.idea/encodings.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..ba93b15 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..b8b2d91 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..35eb1dd --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.project b/.project new file mode 100644 index 0000000..9ec7d54 --- /dev/null +++ b/.project @@ -0,0 +1,17 @@ + + + com.connor.signoff.soa + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..205164d --- /dev/null +++ b/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,8 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 +org.eclipse.jdt.core.compiler.compliance=1.6 +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.release=disabled +org.eclipse.jdt.core.compiler.source=1.6 diff --git a/ReadMe.txt b/ReadMe.txt new file mode 100644 index 0000000..59fa444 --- /dev/null +++ b/ReadMe.txt @@ -0,0 +1,96 @@ +This sample demonstrates the basic functionality of the Teamcenter Services. +The project can be built with Java SDK 1.7.0, from the command line using Ant(1.7.0), or from +the Eclipse IDE (3.8). + +Before running the sample application, you must have a Teamcenter Web Tier server +and Pool Manager up and running. + +From the Command line + +Prerequisite :- You need to have Ant set up. The Ant bin folder needs to be in your +PATH and ANT_HOME variable pointing to the Ant home directory. + +1. Build the application using Ant + >ant -buildfile build.xml + +2. Execute the client application + On Windows: + >RunMe http://localhost:7001/tc + On Unix platform: + >./RunMe.sh http://localhost:7001/tc + + Substitute the URI of the Teamcenter Web Tier server + In case of running in TCCS mode,instead of http://hostname:port/tc use tccs:// + +From the Eclipse IDE +1. Add ClassPath variable for the root location of the soa_client folder + Open the Preferences dialog (Window --> Preferences ... ) + Select the ClassPath Variable tab ( Java --> Build Path --> ClassPath Variables) + Add the variable 'TEAMCENTER_SERVICES_HOME', set it to the root path of the 'soa_client' folder + +2. Import the project + Open the Import dialog ( File --> Import... ) + Select Existing Project into Workspace (General --> Existing Projects into Workspace ) + Click Next, then browse to .../soa_client/java/sample, select Finish + +3. Compile the project + If the IDE is not configured to Build Automatically, force a build of the project + +4. Execute the client application + Open the Debug/Run dialog ( Run --> Debug ...) + Select the HelloTeamcenter Java Application + The launch is configured to connect to the server on http://localhost:7001/tc. To change this URI, either + Go to the Arguments tab in Run configuration and change value in VM Args + or + Change the value of "org.eclipse.jdt.launching.VM_ARGUMENTS" in HelloTeamcenter.launch file . + +Running in TCCS mode +1. To run in TCCS mode, ensure that TCCS and its configuration files are installed and TCCS is + already running. + +2. Set the FMS_HOME to correct value and ensure TCCS native libs are in PATH on Windows or LD_LIBRARY_PATH on Unix platforms. + +3. Use tccs:// (TCCS protocol and environment name) as the + host URI instead of http://hostname:port/tc + + + The source file Hello.java has the main function for the application. This is the + best place to start browsing the code. There are several classes prefixed with + the name AppX (AppXCredentialManager). These classes are implementations of + Teamcenter Services framework interfaces. Each client application is responsible + for providing an implementation to these interfaces: + + CredentialManager Used by the framework to re-authenticate as user. + ExceptionHandler Provide a mechanism for the client application to + handle low level exception in the communication framework. + PartialErrorListener Optional listener for notification when a service operation + has returned partial errors. + ModelEventListener Optional listener for notification when a service operation + has returned ModelObject with updated property values, + or when objects have been deleted from the database. + + + The remaining classes in this sample use a few service operations to demonstrate some + basic features of Teamcenter Services. + + Session This class shows how to establish a session with the + Teamcenter Server using the SessionService login and + logout methods. A session must be established before + any other service operation are called. + HomeFolder This class lists the contents of the user's home folder + Query This class performs a simple query. + DataManagement This class creates, revises, and deletes a set of Items + + Each of these examples performs the same basic steps + 1. Construct the desired service stub. + 2. Gather the data for the operation's input arguments, + 3. Call the service operation + 4. Process the results. + + A few of the service operations will make use of the ModelEventListener. + Under normal circumstances the ExeptionHandler and PartialErrorListner will not + be called. + + + + diff --git a/bin/.gitignore b/bin/.gitignore new file mode 100644 index 0000000..c2d9872 --- /dev/null +++ b/bin/.gitignore @@ -0,0 +1 @@ +/com/ diff --git a/bin/log4j.properties b/bin/log4j.properties new file mode 100644 index 0000000..1bab40f --- /dev/null +++ b/bin/log4j.properties @@ -0,0 +1,40 @@ +#================================================== +# +# @@ +# +#================================================== + +# ============================================================================ # +# Set the Logging for the entire Web Application. # +# The Level can be DEBUG, INFO, WARN, ERROR, FATAL, or OFF # +# There are two predefined Appenders, TheConsole and AppLogFile # +# ============================================================================ # +log4j.rootLogger = WARN, TheConsole +#log4j.logger.org.apache.commons.httpclient = WARN, TheConsole + + +# ============================================================================ # +# The "TheConsole" Appender will write the log message to the console # +# (System.out) with the pattern specified below # +# ============================================================================ # +log4j.appender.TheConsole = org.apache.log4j.ConsoleAppender +log4j.appender.TheConsole.layout = org.apache.log4j.PatternLayout +log4j.appender.TheConsole.layout.ConversionPattern = %d{MM-dd HH:mm:ss} %x %-5p %c - %m%n + + +# ============================================================================ # +# The "AppLogFile" Appender will write the log message to a log file # +# with the pattern and other attributes specified below. # +# ============================================================================ # +log4j.appender.AppLogFile = org.apache.log4j.RollingFileAppender +log4j.appender.AppLogFile.layout = org.apache.log4j.PatternLayout +log4j.appender.AppLogFile.layout.ConversionPattern = %d{MM-dd HH:mm:ss} %x %-5p %c - %m%n +log4j.appender.AppLogFile.MaxBackupIndex = 1 +log4j.appender.AppLogFile.MaxFileSize = 10MB +log4j.appender.AppLogFile.Append = false +log4j.appender.AppLogFile.File = SoaSampleServices.log + + + + + diff --git a/build.xml b/build.xml new file mode 100644 index 0000000..1ff6a9d --- /dev/null +++ b/build.xml @@ -0,0 +1,136 @@ + + + Build file to build SOA Tests. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @echo off + + if ""%1""==""-h"" goto Help + if ""%1""==""-help"" goto Help + if ""%1""==""?"" goto Help + + SET APP_CP=${app.cp} + + + "${java.home}\bin\java" -cp %APP_CP% -Dhost=%1% com.teamcenter.hello.Hello + + goto Exit + + :Help + echo Usage: RunMe [http://server:port/tc] + echo Will default to http://localhost:7001/tc if no argument is given. + + :Exit + + + + + + + + + + + + if [ "$1" = "-h" ] || [ "$1" = "-help" ] || [ "$1" = "?" ]|| [ $# -ne 1 ] + then + echo "Usage: ./RunMe.sh [http://server:port/tc]" + echo "Will default to http://localhost:7001/tc if no argument is given." + else + + export APP_CP=${app.cp} + "${java.home}/bin/java" -cp $APP_CP -Dhost=$1 com.teamcenter.hello.Hello + fi + + + + + + + + + diff --git a/com.connor.signoff.soa.iml b/com.connor.signoff.soa.iml new file mode 100644 index 0000000..c1b7957 --- /dev/null +++ b/com.connor.signoff.soa.iml @@ -0,0 +1,267 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/hs_err_pid5892.log b/hs_err_pid5892.log new file mode 100644 index 0000000..16f2461 --- /dev/null +++ b/hs_err_pid5892.log @@ -0,0 +1,334 @@ +# +# A fatal error has been detected by the Java Runtime Environment: +# +# EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x000000006022df5b, pid=5892, tid=8992 +# +# JRE version: 7.0_21-b11 +# Java VM: Java HotSpot(TM) 64-Bit Server VM (23.21-b01 mixed mode windows-amd64 compressed oops) +# Problematic frame: +# V [jvm.dll+0x11df5b] +# +# Failed to write core dump. Minidumps are not enabled by default on client versions of Windows +# +# If you would like to submit a bug report, please visit: +# http://bugreport.sun.com/bugreport/crash.jsp +# + +--------------- T H R E A D --------------- + +Current thread (0x000000000c5aa000): JavaThread "JDWP Transport Listener: dt_socket" daemon [_thread_in_vm, id=8992, stack(0x000000000db30000,0x000000000dc30000)] + +siginfo: ExceptionCode=0xc0000005, reading address 0xffffffffffffffff + +Registers: +RAX=0x000000000dc2f201, RBX=0x000000000c5aa000, RCX=0x72412f6c00000000, RDX=0x000000000c5aa000 +RSP=0x000000000dc2f240, RBP=0x72412f6c00000000, RSI=0x000000000dc2f358, RDI=0x0000000001829f30 +R8 =0x000000000dc2f358, R9 =0x0000000000000001, R10=0x0000000000008000, R11=0x000000000dc2f190 +R12=0x0000000000000000, R13=0x0000000000000000, R14=0x0000000000000000, R15=0x0000000000000000 +RIP=0x000000006022df5b, EFLAGS=0x0000000000010206 + +Top of Stack: (sp=0x000000000dc2f240) +0x000000000dc2f240: 000000000c5aa000 000000000c5a2520 +0x000000000dc2f250: 000000000dc2f308 00000000603b5699 +0x000000000dc2f260: 000000000c5aa000 00000000603d1062 +0x000000000dc2f270: 0000000000000000 000000000c5aa000 +0x000000000dc2f280: 000000000c5abbd8 0000000060a2264e +0x000000000dc2f290: 000000000c5aa000 0000000000000000 +0x000000000dc2f2a0: 0000000000000000 0000000000000000 +0x000000000dc2f2b0: 72412f6c00000000 0000000060a21745 +0x000000000dc2f2c0: 000000000dc2f358 000000000dc2f330 +0x000000000dc2f2d0: 0000000000000001 000000000c5abbd8 +0x000000000dc2f2e0: 72412f6c00000000 0000000060a053b3 +0x000000000dc2f2f0: 000000000dc2f420 0000000000000001 +0x000000000dc2f300: 0000000000000001 000000000c5abbd8 +0x000000000dc2f310: 0000000000000009 0000000000000000 +0x000000000dc2f320: 0000000000000000 0000000000000000 +0x000000000dc2f330: 0000000000000001 0000000060a05571 + +Instructions: (pc=0x000000006022df5b) +0x000000006022df3b: 48 8b 5c 24 30 48 89 47 18 48 83 c4 20 5f c3 cc +0x000000006022df4b: cc cc cc cc cc 40 53 48 83 ec 20 48 85 c9 74 54 +0x000000006022df5b: 48 8b 19 48 85 db 74 4c 48 b8 fe fe fe fe fe fe +0x000000006022df6b: fe fe 48 3b d8 74 3d 80 3d ff fd 58 00 00 74 15 + + +Register to memory mapping: + +RAX=0x000000000dc2f201 is pointing into the stack for thread: 0x000000000c5aa000 +RBX=0x000000000c5aa000 is a thread +RCX=0x72412f6c00000000 is an unknown value +RDX=0x000000000c5aa000 is a thread +RSP=0x000000000dc2f240 is pointing into the stack for thread: 0x000000000c5aa000 +RBP=0x72412f6c00000000 is an unknown value +RSI=0x000000000dc2f358 is pointing into the stack for thread: 0x000000000c5aa000 +RDI=0x0000000001829f30 is an unknown value +R8 =0x000000000dc2f358 is pointing into the stack for thread: 0x000000000c5aa000 +R9 =0x0000000000000001 is an unknown value +R10=0x0000000000008000 is an unknown value +R11=0x000000000dc2f190 is pointing into the stack for thread: 0x000000000c5aa000 +R12=0x0000000000000000 is an unknown value +R13=0x0000000000000000 is an unknown value +R14=0x0000000000000000 is an unknown value +R15=0x0000000000000000 is an unknown value + + +Stack: [0x000000000db30000,0x000000000dc30000], sp=0x000000000dc2f240, free space=1020k +Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code) +V [jvm.dll+0x11df5b] + +[error occurred during error reporting (printing native stack), id 0xc0000005] + + +--------------- P R O C E S S --------------- + +Java Threads: ( => current thread ) + 0x000000000ef6e800 JavaThread "MultiThreadedHttpConnectionManager cleanup" daemon [_thread_blocked, id=8416, stack(0x000000000ff00000,0x0000000010000000)] + 0x000000000ef6d800 JavaThread "MultiThreadedHttpConnectionManager cleanup" daemon [_thread_blocked, id=11000, stack(0x000000000fe00000,0x000000000ff00000)] + 0x000000000df61800 JavaThread "Service Thread" daemon [_thread_blocked, id=4068, stack(0x000000000e430000,0x000000000e530000)] + 0x000000000df5f000 JavaThread "C2 CompilerThread1" daemon [_thread_blocked, id=8200, stack(0x000000000e330000,0x000000000e430000)] + 0x000000000df5e800 JavaThread "C2 CompilerThread0" daemon [_thread_blocked, id=12156, stack(0x000000000e230000,0x000000000e330000)] + 0x000000000c5ba800 JavaThread "JDWP Command Reader" daemon [_thread_in_native, id=10624, stack(0x000000000dd30000,0x000000000de30000)] + 0x000000000c5b9000 JavaThread "JDWP Event Helper Thread" daemon [_thread_blocked, id=5212, stack(0x000000000dc30000,0x000000000dd30000)] +=>0x000000000c5aa000 JavaThread "JDWP Transport Listener: dt_socket" daemon [_thread_in_vm, id=8992, stack(0x000000000db30000,0x000000000dc30000)] + 0x000000000c5a3000 JavaThread "Attach Listener" daemon [_thread_blocked, id=8208, stack(0x000000000da30000,0x000000000db30000)] + 0x000000000c5a0000 JavaThread "Signal Dispatcher" daemon [_thread_blocked, id=11148, stack(0x000000000d930000,0x000000000da30000)] + 0x000000000c519000 JavaThread "Finalizer" daemon [_thread_blocked, id=6264, stack(0x000000000d830000,0x000000000d930000)] + 0x000000000c510000 JavaThread "Reference Handler" daemon [_thread_blocked, id=1004, stack(0x000000000d730000,0x000000000d830000)] + 0x000000000182e000 JavaThread "main" [_thread_blocked, id=8160, stack(0x0000000003360000,0x0000000003460000)] + +Other Threads: + 0x000000000c507800 VMThread [stack: 0x000000000d630000,0x000000000d730000] [id=6952] + 0x000000000dfa7000 WatcherThread [stack: 0x000000000e530000,0x000000000e630000] [id=13228] + +VM state:not at safepoint (normal execution) + +VM Mutex/Monitor currently owned by a thread: None + +Heap + PSYoungGen total 134912K, used 134891K [0x00000007d5d60000, 0x00000007de660000, 0x0000000800000000) + eden space 129536K, 100% used [0x00000007d5d60000,0x00000007ddbe0000,0x00000007ddbe0000) + from space 5376K, 99% used [0x00000007de120000,0x00000007de65ae50,0x00000007de660000) + to space 5376K, 0% used [0x00000007ddbe0000,0x00000007ddbe0000,0x00000007de120000) + ParOldGen total 86400K, used 11627K [0x0000000781800000, 0x0000000786c60000, 0x00000007d5d60000) + object space 86400K, 13% used [0x0000000781800000,0x000000078235ad20,0x0000000786c60000) + PSPermGen total 27776K, used 27663K [0x000000077c600000, 0x000000077e120000, 0x0000000781800000) + object space 27776K, 99% used [0x000000077c600000,0x000000077e103e48,0x000000077e120000) + +Card table byte_map: [0x0000000006720000,0x0000000006b40000] byte_map_base: 0x0000000002b3d000 + +Polling page: 0x0000000001320000 + +Code Cache [0x0000000003660000, 0x0000000003910000, 0x0000000006660000) + total_blobs=910 nmethods=593 adapters=275 free_code_cache=46458Kb largest_free_block=47531840 + +Compilation events (10 events): +Event: 28.155 Thread 0x000000000df5e800 611 java.lang.String::trim (77 bytes) +Event: 28.157 Thread 0x000000000df5e800 nmethod 611 0x00000000038f5cd0 code [0x00000000038f5e20, 0x00000000038f5fa8] +Event: 28.462 Thread 0x000000000df5f000 612 org.apache.xerces.impl.XMLScanner::normalizeWhitespace (56 bytes) +Event: 28.464 Thread 0x000000000df5e800 613 java.lang.Integer:: (10 bytes) +Event: 28.465 Thread 0x000000000df5e800 nmethod 613 0x00000000038f5ad0 code [0x00000000038f5c00, 0x00000000038f5c58] +Event: 28.465 Thread 0x000000000df5f000 nmethod 612 0x00000000038f5650 code [0x00000000038f57a0, 0x00000000038f59b8] +Event: 48.192 Thread 0x000000000df5e800 614 sun.util.calendar.ZoneInfo::getTransitionIndex (156 bytes) +Event: 48.198 Thread 0x000000000df5f000 615 java.util.regex.Matcher::reset (83 bytes) +Event: 48.200 Thread 0x000000000df5e800 nmethod 614 0x00000000038fba90 code [0x00000000038fbbe0, 0x00000000038fc158] +Event: 48.201 Thread 0x000000000df5f000 nmethod 615 0x00000000038f51d0 code [0x00000000038f5320, 0x00000000038f54e8] + +GC Heap History (8 events): +Event: 1.727 GC heap before +{Heap before GC invocations=1 (full 0): + PSYoungGen total 37760K, used 32384K [0x00000007d5d60000, 0x00000007d8780000, 0x0000000800000000) + eden space 32384K, 100% used [0x00000007d5d60000,0x00000007d7d00000,0x00000007d7d00000) + from space 5376K, 0% used [0x00000007d8240000,0x00000007d8240000,0x00000007d8780000) + to space 5376K, 0% used [0x00000007d7d00000,0x00000007d7d00000,0x00000007d8240000) + ParOldGen total 86400K, used 0K [0x0000000781800000, 0x0000000786c60000, 0x00000007d5d60000) + object space 86400K, 0% used [0x0000000781800000,0x0000000781800000,0x0000000786c60000) + PSPermGen total 21248K, used 9474K [0x000000077c600000, 0x000000077dac0000, 0x0000000781800000) + object space 21248K, 44% used [0x000000077c600000,0x000000077cf40818,0x000000077dac0000) +Event: 1.755 GC heap after +Heap after GC invocations=1 (full 0): + PSYoungGen total 37760K, used 3371K [0x00000007d5d60000, 0x00000007da720000, 0x0000000800000000) + eden space 32384K, 0% used [0x00000007d5d60000,0x00000007d5d60000,0x00000007d7d00000) + from space 5376K, 62% used [0x00000007d7d00000,0x00000007d804ae10,0x00000007d8240000) + to space 5376K, 0% used [0x00000007da1e0000,0x00000007da1e0000,0x00000007da720000) + ParOldGen total 86400K, used 8K [0x0000000781800000, 0x0000000786c60000, 0x00000007d5d60000) + object space 86400K, 0% used [0x0000000781800000,0x0000000781802000,0x0000000786c60000) + PSPermGen total 21248K, used 9474K [0x000000077c600000, 0x000000077dac0000, 0x0000000781800000) + object space 21248K, 44% used [0x000000077c600000,0x000000077cf40818,0x000000077dac0000) +} +Event: 2.566 GC heap before +{Heap before GC invocations=2 (full 0): + PSYoungGen total 37760K, used 35755K [0x00000007d5d60000, 0x00000007da720000, 0x0000000800000000) + eden space 32384K, 100% used [0x00000007d5d60000,0x00000007d7d00000,0x00000007d7d00000) + from space 5376K, 62% used [0x00000007d7d00000,0x00000007d804ae10,0x00000007d8240000) + to space 5376K, 0% used [0x00000007da1e0000,0x00000007da1e0000,0x00000007da720000) + ParOldGen total 86400K, used 8K [0x0000000781800000, 0x0000000786c60000, 0x00000007d5d60000) + object space 86400K, 0% used [0x0000000781800000,0x0000000781802000,0x0000000786c60000) + PSPermGen total 21248K, used 13155K [0x000000077c600000, 0x000000077dac0000, 0x0000000781800000) + object space 21248K, 61% used [0x000000077c600000,0x000000077d2d8c68,0x000000077dac0000) +Event: 2.581 GC heap after +Heap after GC invocations=2 (full 0): + PSYoungGen total 70144K, used 4171K [0x00000007d5d60000, 0x00000007da720000, 0x0000000800000000) + eden space 64768K, 0% used [0x00000007d5d60000,0x00000007d5d60000,0x00000007d9ca0000) + from space 5376K, 77% used [0x00000007da1e0000,0x00000007da5f2e60,0x00000007da720000) + to space 5376K, 0% used [0x00000007d9ca0000,0x00000007d9ca0000,0x00000007da1e0000) + ParOldGen total 86400K, used 16K [0x0000000781800000, 0x0000000786c60000, 0x00000007d5d60000) + object space 86400K, 0% used [0x0000000781800000,0x0000000781804000,0x0000000786c60000) + PSPermGen total 21248K, used 13155K [0x000000077c600000, 0x000000077dac0000, 0x0000000781800000) + object space 21248K, 61% used [0x000000077c600000,0x000000077d2d8c68,0x000000077dac0000) +} +Event: 4.278 GC heap before +{Heap before GC invocations=3 (full 0): + PSYoungGen total 70144K, used 68939K [0x00000007d5d60000, 0x00000007da720000, 0x0000000800000000) + eden space 64768K, 100% used [0x00000007d5d60000,0x00000007d9ca0000,0x00000007d9ca0000) + from space 5376K, 77% used [0x00000007da1e0000,0x00000007da5f2e60,0x00000007da720000) + to space 5376K, 0% used [0x00000007d9ca0000,0x00000007d9ca0000,0x00000007da1e0000) + ParOldGen total 86400K, used 16K [0x0000000781800000, 0x0000000786c60000, 0x00000007d5d60000) + object space 86400K, 0% used [0x0000000781800000,0x0000000781804000,0x0000000786c60000) + PSPermGen total 21248K, used 20830K [0x000000077c600000, 0x000000077dac0000, 0x0000000781800000) + object space 21248K, 98% used [0x000000077c600000,0x000000077da57be8,0x000000077dac0000) +Event: 4.294 GC heap after +Heap after GC invocations=3 (full 0): + PSYoungGen total 70144K, used 5355K [0x00000007d5d60000, 0x00000007de660000, 0x0000000800000000) + eden space 64768K, 0% used [0x00000007d5d60000,0x00000007d5d60000,0x00000007d9ca0000) + from space 5376K, 99% used [0x00000007d9ca0000,0x00000007da1dae80,0x00000007da1e0000) + to space 5376K, 0% used [0x00000007de120000,0x00000007de120000,0x00000007de660000) + ParOldGen total 86400K, used 3393K [0x0000000781800000, 0x0000000786c60000, 0x00000007d5d60000) + object space 86400K, 3% used [0x0000000781800000,0x0000000781b506a8,0x0000000786c60000) + PSPermGen total 21248K, used 20830K [0x000000077c600000, 0x000000077dac0000, 0x0000000781800000) + object space 21248K, 98% used [0x000000077c600000,0x000000077da57be8,0x000000077dac0000) +} +Event: 6.591 GC heap before +{Heap before GC invocations=4 (full 0): + PSYoungGen total 70144K, used 70123K [0x00000007d5d60000, 0x00000007de660000, 0x0000000800000000) + eden space 64768K, 100% used [0x00000007d5d60000,0x00000007d9ca0000,0x00000007d9ca0000) + from space 5376K, 99% used [0x00000007d9ca0000,0x00000007da1dae80,0x00000007da1e0000) + to space 5376K, 0% used [0x00000007de120000,0x00000007de120000,0x00000007de660000) + ParOldGen total 86400K, used 3393K [0x0000000781800000, 0x0000000786c60000, 0x00000007d5d60000) + object space 86400K, 3% used [0x0000000781800000,0x0000000781b506a8,0x0000000786c60000) + PSPermGen total 24128K, used 24047K [0x000000077c600000, 0x000000077dd90000, 0x0000000781800000) + object space 24128K, 99% used [0x000000077c600000,0x000000077dd7bf20,0x000000077dd90000) +Event: 6.610 GC heap after +Heap after GC invocations=4 (full 0): + PSYoungGen total 134912K, used 5355K [0x00000007d5d60000, 0x00000007de660000, 0x0000000800000000) + eden space 129536K, 0% used [0x00000007d5d60000,0x00000007d5d60000,0x00000007ddbe0000) + from space 5376K, 99% used [0x00000007de120000,0x00000007de65ae50,0x00000007de660000) + to space 5376K, 0% used [0x00000007ddbe0000,0x00000007ddbe0000,0x00000007de120000) + ParOldGen total 86400K, used 11627K [0x0000000781800000, 0x0000000786c60000, 0x00000007d5d60000) + object space 86400K, 13% used [0x0000000781800000,0x000000078235ad20,0x0000000786c60000) + PSPermGen total 24128K, used 24047K [0x000000077c600000, 0x000000077dd90000, 0x0000000781800000) + object space 24128K, 99% used [0x000000077c600000,0x000000077dd7bf20,0x000000077dd90000) +} + +Deoptimization events (10 events): +Event: 14.481 Thread 0x000000000182e000 Uncommon trap -83 fr.pc 0x0000000003791218 +Event: 14.495 Thread 0x000000000182e000 Uncommon trap -34 fr.pc 0x00000000037e9c30 +Event: 14.499 Thread 0x000000000182e000 Uncommon trap -83 fr.pc 0x00000000038a42a4 +Event: 14.666 Thread 0x000000000182e000 Uncommon trap -75 fr.pc 0x00000000038befdc +Event: 19.355 Thread 0x000000000182e000 Uncommon trap -42 fr.pc 0x00000000037bb4dc +Event: 19.355 Thread 0x000000000182e000 Uncommon trap -42 fr.pc 0x00000000037bb4dc +Event: 19.356 Thread 0x000000000182e000 Uncommon trap -42 fr.pc 0x00000000037bb4dc +Event: 19.356 Thread 0x000000000182e000 Uncommon trap -42 fr.pc 0x00000000037bb4dc +Event: 24.077 Thread 0x000000000182e000 Uncommon trap -12 fr.pc 0x00000000038de438 +Event: 48.123 Thread 0x000000000182e000 Uncommon trap -83 fr.pc 0x00000000038e3238 + +Internal exceptions (10 events): +Event: 48.099 Thread 0x000000000182e000 Threw 0x00000007dd932d18 at C:\jdk7u2_64p\jdk7u21\hotspot\src\share\vm\prims\jvm.cpp:1166 +Event: 48.099 Thread 0x000000000182e000 Threw 0x00000007dd9393b0 at C:\jdk7u2_64p\jdk7u21\hotspot\src\share\vm\prims\jvm.cpp:1166 +Event: 48.102 Thread 0x000000000182e000 Threw 0x00000007dd9556f0 at C:\jdk7u2_64p\jdk7u21\hotspot\src\share\vm\prims\jvm.cpp:1166 +Event: 48.120 Thread 0x000000000182e000 Threw 0x00000007dd973960 at C:\jdk7u2_64p\jdk7u21\hotspot\src\share\vm\prims\jvm.cpp:1166 +Event: 48.121 Thread 0x000000000182e000 Threw 0x00000007dd987d68 at C:\jdk7u2_64p\jdk7u21\hotspot\src\share\vm\prims\jvm.cpp:1166 +Event: 48.172 Thread 0x000000000182e000 Threw 0x00000007dd9a4d68 at C:\jdk7u2_64p\jdk7u21\hotspot\src\share\vm\prims\jvm.cpp:1166 +Event: 48.174 Thread 0x000000000182e000 Threw 0x00000007dd9abd70 at C:\jdk7u2_64p\jdk7u21\hotspot\src\share\vm\prims\jvm.cpp:1166 +Event: 48.174 Thread 0x000000000182e000 Threw 0x00000007dd9b1128 at C:\jdk7u2_64p\jdk7u21\hotspot\src\share\vm\prims\jvm.cpp:1166 +Event: 48.175 Thread 0x000000000182e000 Threw 0x00000007dd9b7d08 at C:\jdk7u2_64p\jdk7u21\hotspot\src\share\vm\prims\jvm.cpp:1166 +Event: 48.176 Thread 0x000000000182e000 Threw 0x00000007dd9bea38 at C:\jdk7u2_64p\jdk7u21\hotspot\src\share\vm\prims\jvm.cpp:1166 + +Events (10 events): +Event: 105.125 Executing VM operation: GetCurrentLocation +Event: 105.125 Executing VM operation: GetCurrentLocation done +Event: 105.125 Executing VM operation: EnterInterpOnlyMode +Event: 105.125 Executing VM operation: EnterInterpOnlyMode done +Event: 105.125 Executing VM operation: ChangeSingleStep +Event: 105.125 Executing VM operation: ChangeSingleStep done +Event: 105.125 Executing VM operation: ChangeSingleStep +Event: 105.125 Executing VM operation: ChangeSingleStep done +Event: 105.150 Executing VM operation: RedefineClasses +Event: 105.157 Executing VM operation: RedefineClasses done + + +Dynamic libraries: +0x00007ff622130000 - 0x00007ff622163000 D:\TC\Java\jdk1.7.0_21\bin\javaw.exe +0x00007ffb537f0000 - 0x00007ffb539e8000 C:\WINDOWS\SYSTEM32\ntdll.dll +0x00007ffb51e70000 - 0x00007ffb51f2f000 C:\WINDOWS\System32\KERNEL32.DLL +0x00007ffb51450000 - 0x00007ffb51746000 C:\WINDOWS\System32\KERNELBASE.dll +0x00007ffb51980000 - 0x00007ffb51a2f000 C:\WINDOWS\System32\ADVAPI32.dll +0x00007ffb53710000 - 0x00007ffb537ae000 C:\WINDOWS\System32\msvcrt.dll +0x00007ffb52920000 - 0x00007ffb529bc000 C:\WINDOWS\System32\sechost.dll +0x00007ffb51850000 - 0x00007ffb51976000 C:\WINDOWS\System32\RPCRT4.dll +0x00007ffb52000000 - 0x00007ffb5219d000 C:\WINDOWS\System32\USER32.dll +0x00007ffb50ed0000 - 0x00007ffb50ef2000 C:\WINDOWS\System32\win32u.dll +0x00007ffb51e20000 - 0x00007ffb51e4c000 C:\WINDOWS\System32\GDI32.dll +0x00007ffb510e0000 - 0x00007ffb511f5000 C:\WINDOWS\System32\gdi32full.dll +0x00007ffb513b0000 - 0x00007ffb5144d000 C:\WINDOWS\System32\msvcp_win.dll +0x00007ffb51200000 - 0x00007ffb51300000 C:\WINDOWS\System32\ucrtbase.dll +0x00007ffb3f670000 - 0x00007ffb3f90a000 C:\WINDOWS\WinSxS\amd64_microsoft.windows.common-controls_6595b64144ccf1df_6.0.19041.1110_none_60b5254171f9507e\COMCTL32.dll +0x00007ffb52810000 - 0x00007ffb52840000 C:\WINDOWS\System32\IMM32.DLL +0x0000000060d20000 - 0x0000000060df1000 D:\TC\Java\jdk1.7.0_21\jre\bin\msvcr100.dll +0x0000000060110000 - 0x0000000060831000 D:\TC\Java\jdk1.7.0_21\jre\bin\server\jvm.dll +0x00007ffb52910000 - 0x00007ffb52918000 C:\WINDOWS\System32\PSAPI.DLL +0x00007ffb3f320000 - 0x00007ffb3f347000 C:\WINDOWS\SYSTEM32\WINMM.dll +0x00007ffb370c0000 - 0x00007ffb370c9000 C:\WINDOWS\SYSTEM32\WSOCK32.dll +0x00007ffb52840000 - 0x00007ffb528ab000 C:\WINDOWS\System32\WS2_32.dll +0x0000000060a70000 - 0x0000000060a7f000 D:\TC\Java\jdk1.7.0_21\jre\bin\verify.dll +0x0000000060a40000 - 0x0000000060a68000 D:\TC\Java\jdk1.7.0_21\jre\bin\java.dll +0x0000000060a00000 - 0x0000000060a35000 D:\TC\Java\jdk1.7.0_21\jre\bin\jdwp.dll +0x00000000609f0000 - 0x00000000609f8000 D:\TC\Java\jdk1.7.0_21\jre\bin\npt.dll +0x0000000059650000 - 0x0000000059673000 D:\TC\Java\jdk1.7.0_21\jre\bin\instrument.dll +0x00000000609d0000 - 0x00000000609e5000 D:\TC\Java\jdk1.7.0_21\jre\bin\zip.dll +0x00000000609c0000 - 0x00000000609c9000 D:\TC\Java\jdk1.7.0_21\jre\bin\dt_socket.dll +0x00007ffb38db0000 - 0x00007ffb38dc7000 C:\WINDOWS\system32\napinsp.dll +0x00007ffb38d90000 - 0x00007ffb38dab000 C:\WINDOWS\system32\pnrpnsp.dll +0x00007ffb38d70000 - 0x00007ffb38d85000 C:\WINDOWS\system32\wshbth.dll +0x00007ffb49b10000 - 0x00007ffb49b2d000 C:\WINDOWS\system32\NLAapi.dll +0x00007ffb50300000 - 0x00007ffb5033c000 C:\WINDOWS\SYSTEM32\IPHLPAPI.DLL +0x00007ffb50680000 - 0x00007ffb506ea000 C:\WINDOWS\System32\mswsock.dll +0x00007ffb50340000 - 0x00007ffb5040a000 C:\WINDOWS\SYSTEM32\DNSAPI.dll +0x00007ffb529c0000 - 0x00007ffb529c8000 C:\WINDOWS\System32\NSI.dll +0x00007ffb38d50000 - 0x00007ffb38d62000 C:\WINDOWS\System32\winrnr.dll +0x00007ffb418d0000 - 0x00007ffb41952000 C:\WINDOWS\System32\fwpuclnt.dll +0x00007ffb51060000 - 0x00007ffb51087000 C:\WINDOWS\System32\bcrypt.dll +0x00007ffb41820000 - 0x00007ffb4182a000 C:\Windows\System32\rasadhlp.dll +0x00000000609a0000 - 0x00000000609b9000 D:\TC\Java\jdk1.7.0_21\jre\bin\net.dll +0x000000005ffe0000 - 0x000000005fff1000 D:\TC\Java\jdk1.7.0_21\jre\bin\nio.dll +0x0000000060990000 - 0x000000006099b000 D:\TC\Java\jdk1.7.0_21\jre\bin\management.dll +0x00007ffb4ffe0000 - 0x00007ffb50013000 C:\WINDOWS\SYSTEM32\ntmarta.dll +0x00007ffb473e0000 - 0x00007ffb475c4000 C:\WINDOWS\SYSTEM32\dbghelp.dll +0x00007ffb517c0000 - 0x00007ffb51842000 C:\WINDOWS\System32\bcryptPrimitives.dll + +VM Arguments: +jvm_args: -agentlib:jdwp=transport=dt_socket,suspend=y,address=localhost:15832 -javaagent:D:\eclipse\configuration\org.eclipse.osgi\424\0\.cp\lib\javaagent-shaded.jar -Dfile.encoding=GBK +java_command: com.teamcenter.hello.caxaPropertyHandler +Launcher Type: SUN_STANDARD + +Environment Variables: +CLASSPATH=.;\lib\dt.jar;\lib\tools.jar +PATH=D:\TC\Java\jdk1.7.0_21\jre\bin;D:/eclipse//plugins/org.eclipse.justj.openjdk.hotspot.jre.full.win32.x86_64_17.0.6.v20230204-1729/jre/bin/server;D:/eclipse//plugins/org.eclipse.justj.openjdk.hotspot.jre.full.win32.x86_64_17.0.6.v20230204-1729/jre/bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\WINDOWS\System32\OpenSSH\;"D:\TC \Java\jdk1.7.0_21\bin;D:\TC\Java\jre7\bin";C:\Program Files\Microsoft SQL Server\150\Tools\Binn\;C:\Program Files\Microsoft\Web Platform Installer\;C:\Program Files (x86)\Microsoft ASP.NET\ASP.NET Web Pages\v1.0\;C:\Program Files\Microsoft SQL Server\110\Tools\Binn\;C:\Program Files (x86)\Windows Kits\8.0\Windows Performance Toolkit\;D:\software\VisualSVN\bin;D:\TortoiseSVN\bin;C:\Users\HX\AppData\Local\Microsoft\WindowsApps;C:\WINDOWS\system32; +USERNAME=HX +OS=Windows_NT +PROCESSOR_IDENTIFIER=Intel64 Family 6 Model 142 Stepping 9, GenuineIntel + + + +--------------- S Y S T E M --------------- + +OS: Windows 8 , 64 bit Build 9200 + +CPU:total 4 (2 cores per cpu, 2 threads per core) family 6 model 142 stepping 9, cmov, cx8, fxsr, mmx, sse, sse2, sse3, ssse3, sse4.1, sse4.2, popcnt, avx, avx2, ht, tsc, tscinvbit + +Memory: 4k page, physical 8289204k(1915604k free), swap 14646164k(1577180k free) + +vm_info: Java HotSpot(TM) 64-Bit Server VM (23.21-b01) for windows-amd64 JRE (1.7.0_21-b11), built on Apr 4 2013 08:11:28 by "java_re" with unknown MS VC++:1600 + +time: Tue Jul 11 17:09:03 2023 +elapsed time: 105 seconds + diff --git a/lib/commons-codec.jar b/lib/commons-codec.jar new file mode 100644 index 0000000..957b675 Binary files /dev/null and b/lib/commons-codec.jar differ diff --git a/lib/commons-httpclient-3.1.jar b/lib/commons-httpclient-3.1.jar new file mode 100644 index 0000000..7c59774 Binary files /dev/null and b/lib/commons-httpclient-3.1.jar differ diff --git a/lib/commons-logging-1.1.jar b/lib/commons-logging-1.1.jar new file mode 100644 index 0000000..2ff9bbd Binary files /dev/null and b/lib/commons-logging-1.1.jar differ diff --git a/lib/commons-net-3.6.jar b/lib/commons-net-3.6.jar new file mode 100644 index 0000000..4537623 Binary files /dev/null and b/lib/commons-net-3.6.jar differ diff --git a/lib/dom4j-1.6.1.jar b/lib/dom4j-1.6.1.jar new file mode 100644 index 0000000..c8c4dbb Binary files /dev/null and b/lib/dom4j-1.6.1.jar differ diff --git a/lib/fccclient.jar b/lib/fccclient.jar new file mode 100644 index 0000000..2847997 Binary files /dev/null and b/lib/fccclient.jar differ diff --git a/lib/fscclient.jar b/lib/fscclient.jar new file mode 100644 index 0000000..1749048 Binary files /dev/null and b/lib/fscclient.jar differ diff --git a/lib/iText-5.0.2.jar b/lib/iText-5.0.2.jar new file mode 100644 index 0000000..ed95653 Binary files /dev/null and b/lib/iText-5.0.2.jar differ diff --git a/lib/log4j-1.2.13.jar b/lib/log4j-1.2.13.jar new file mode 100644 index 0000000..dde9972 Binary files /dev/null and b/lib/log4j-1.2.13.jar differ diff --git a/lib/org.apache.commons.lang_2.3.0.v200803061910.jar b/lib/org.apache.commons.lang_2.3.0.v200803061910.jar new file mode 100644 index 0000000..3f10af7 Binary files /dev/null and b/lib/org.apache.commons.lang_2.3.0.v200803061910.jar differ diff --git a/lib/resolver.jar b/lib/resolver.jar new file mode 100644 index 0000000..073d789 Binary files /dev/null and b/lib/resolver.jar differ diff --git a/lib/tcmemjavabinding.jar b/lib/tcmemjavabinding.jar new file mode 100644 index 0000000..081244b Binary files /dev/null and b/lib/tcmemjavabinding.jar differ diff --git a/lib/tcserverjavabinding.jar b/lib/tcserverjavabinding.jar new file mode 100644 index 0000000..ffe3bd1 Binary files /dev/null and b/lib/tcserverjavabinding.jar differ diff --git a/lib/xercesImpl.jar b/lib/xercesImpl.jar new file mode 100644 index 0000000..33990e8 Binary files /dev/null and b/lib/xercesImpl.jar differ diff --git a/lib/xml-apis.jar b/lib/xml-apis.jar new file mode 100644 index 0000000..b338fb6 Binary files /dev/null and b/lib/xml-apis.jar differ diff --git a/sign.config b/sign.config new file mode 100644 index 0000000..42f4da0 --- /dev/null +++ b/sign.config @@ -0,0 +1,4 @@ + +CompanyName=HX + +WAITPDF=100 \ No newline at end of file diff --git a/sign.xml b/sign.xml new file mode 100644 index 0000000..82be7b4 --- /dev/null +++ b/sign.xml @@ -0,0 +1,164 @@ + + + + + + + + + + + + + + <Attribute Type="String" Name="是否更新签字" Value="是"/> + <Attribute Type="String" Name="产品名称" Value="QT23007前车门后托架铝型材"/> + <Attribute Type="String" Name="产品型号" Value="QT23007209901"/> + <Attribute Type="String" Name="更改版次1" Value="B01"/> + <Attribute Type="String" Name="设计人员" Value=""/> + <Attribute Type="String" Name="设计日期" Value=""/> + <Attribute Type="String" Name="设计日期1" Value=""/> + <Attribute Type="String" Name="审核人员" Value=""/> + <Attribute Type="String" Name="审核日期" Value=""/> + <Attribute Type="String" Name="工艺人员" Value=""/> + <Attribute Type="String" Name="材料名称" Value=""/> + <Attribute Type="String" Name="材料厚度" Value=""/> + <Attribute Type="String" Name="样件标记" Value=""/> + <Attribute Type="String" Name="试生产标记" Value=""/> + <Attribute Type="String" Name="生产标记" Value=""/> + <Attribute Type="String" Name="工艺审核日期" Value=""/> + <Attribute Type="String" Name="标准化人员" Value=""/> + <Attribute Type="String" Name="标准化审核日期" Value=""/> + <Attribute Type="String" Name="批准人员" Value=""/> + <Attribute Type="String" Name="批准日期" Value=""/> + <Attribute Type="String" Name="重量" Value=""/> + <Attribute Type="String" Name="创建日期" Value=""/> + <Attribute Type="String" Name="更改类别" Value=""/> + <Attribute Type="String" Name="零部件图号" Value=""/> + <Attribute Type="String" Name="零部件名称" Value=""/> + <Attribute Type="String" Name="计划部人员" Value=""/> + <Attribute Type="String" Name="计划部日期" Value=""/> + <Attribute Type="String" Name="制造部人员" Value=""/> + <Attribute Type="String" Name="制造部日期" Value=""/> + <Attribute Type="String" Name="品质部人员" Value=""/> + <Attribute Type="String" Name="品质部日期" Value=""/> + <Attribute Type="String" Name="编号" Value=""/> + <Attribute Type="String" Name="编制人员" Value=""/> + <Attribute Type="String" Name="编制日期" Value=""/> + <Attribute Type="String" Name="审核人员" Value=""/> + <Attribute Type="String" Name="审核日期" Value=""/> + <Attribute Type="String" Name="批准人员1" Value=""/> + <Attribute Type="String" Name="批准日期1" Value=""/> + <Attribute Type="String" Name="批准人员2" Value=""/> + <Attribute Type="String" Name="批准日期2" Value=""/> + <Attribute Type="String" Name="更改原因" Value=""/> + <Attribute Type="String" Name="图纸" Value=""/> + <Attribute Type="String" Name="图纸说明" Value=""/> + <Attribute Type="String" Name="发客户图纸" Value=""/> + <Attribute Type="String" Name="同系列产品" Value=""/> + <Attribute Type="String" Name="工艺" Value=""/> + <Attribute Type="String" Name="激光打印" Value=""/> + <Attribute Type="String" Name="外协加工图" Value=""/> + <Attribute Type="String" Name="MES数据库" Value=""/> + <Attribute Type="String" Name="作业指导书" Value=""/> + <Attribute Type="String" Name="模具" Value=""/> + <Attribute Type="String" Name="条码系统" Value=""/> + <Attribute Type="String" Name="DFMEA" Value=""/> + <Attribute Type="String" Name="PFMEA" Value=""/> + <Attribute Type="String" Name="控制计划" Value=""/> + <Attribute Type="String" Name="技术部ERP" Value=""/> + <Attribute Type="String" Name="计划部ERP" Value=""/> + <Attribute Type="String" Name="品质检具或封样" Value=""/> + <Attribute Type="String" Name="设备参数调整" Value=""/> + <Attribute Type="String" Name="品质称重防错维护" Value=""/> + <Attribute Type="String" Name="品质检查基准书" Value=""/> + <Attribute Type="String" Name="包装" Value=""/> + <Attribute Type="String" Name="工艺图编号" Value="QT23007209901"/> + <Attribute Type="String" Name="工序名称" Value="QT23007前车门后托架铝型材"/> + <Attribute Type="String" Name="技术编制人员" Value=""/> + <Attribute Type="String" Name="技术编制日期" Value=""/> + <Attribute Type="String" Name="技术审核人员" Value=""/> + <Attribute Type="String" Name="技术审核日期" Value=""/> + <Attribute Type="String" Name="品质编制人员" Value=""/> + <Attribute Type="String" Name="品质编制日期" Value=""/> + <Attribute Type="String" Name="品质审核人员" Value=""/> + <Attribute Type="String" Name="品质审核日期" Value=""/> + <Attribute Type="String" Name="品质批准人员" Value=""/> + <Attribute Type="String" Name="品质批准日期" Value=""/> + <Attribute Type="String" Name="技术批准人员" Value=""/> + <Attribute Type="String" Name="技术批准日期" Value=""/> + + <Attribute Type="String" Name="更改文件名1" Value=""/> + <Attribute Type="String" Name="日期1" Value=""/> + <Attribute Type="String" Name="签字1" Value=""/> + + <Attribute Type="String" Name="更改版次" Value="B04"/> + <Attribute Type="String" Name="更改文件号" Value=""/> + <Attribute Type="String" Name="日期" Value="2023.07.19"/> + <Attribute Type="String" Name="签字" Value=""/> + + <Attribute Type="String" Name="模具1" Value=""/> + <Attribute Type="String" Name="模具2" Value=""/> + <Attribute Type="String" Name="模具3" Value=""/> + <Attribute Type="String" Name="模具4" Value=""/> + <Attribute Type="String" Name="模具5" Value=""/> + <Attribute Type="String" Name="模具6" Value=""/> + <Attribute Type="String" Name="模具7" Value=""/> + <Attribute Type="String" Name="模具8" Value=""/> + <Attribute Type="String" Name="检具1" Value=""/> + <Attribute Type="String" Name="检具2" Value=""/> + <Attribute Type="String" Name="检具3" Value=""/> + <Attribute Type="String" Name="检具4" Value=""/> + <Attribute Type="String" Name="检具5" Value=""/> + <Attribute Type="String" Name="检具6" Value=""/> + <Attribute Type="String" Name="检具7" Value=""/> + <Attribute Type="String" Name="检具8" Value=""/> + <Attribute Type="String" Name="检具9" Value=""/> + <Attribute Type="String" Name="检具10" Value=""/> + <Attribute Type="String" Name="检具11" Value=""/> + <Attribute Type="String" Name="检具12" Value=""/> + <Attribute Type="String" Name="签章" Value=""/> + <Attribute Type="String" Name="件号" Value="QT23007209901"/> + + <Attribute Type="String" Name="材料" Value="6060 T6"/> + <Attribute Type="String" Name="图纸名称" Value="零件图"/> + <Attribute Type="String" Name="设计" Value="杨郝"/> + <Attribute Type="String" Name="校对" Value="杨郝"/> + <Attribute Type="String" Name="审核" Value="杨郝"/> + <Attribute Type="String" Name="批准" Value=""/> + <Attribute Type="String" Name="日期" Value=""/> + + <Attribute Type="String" Name="外发图纸" Value=""/> + <Attribute Type="String" Name="激光打印区图纸" Value=""/> + <Attribute Type="String" Name="ERP" Value=""/> + <Attribute Type="String" Name="检具或封样同步调整" Value=""/> + <Attribute Type="String" Name="外协加工图纸" Value=""/> + + + \ No newline at end of file diff --git a/skz.png b/skz.png new file mode 100644 index 0000000..5f716b3 Binary files /dev/null and b/skz.png differ diff --git a/src/com/connor/signoff/soa/handler/DataManagement.java b/src/com/connor/signoff/soa/handler/DataManagement.java new file mode 100644 index 0000000..5687f67 --- /dev/null +++ b/src/com/connor/signoff/soa/handler/DataManagement.java @@ -0,0 +1,388 @@ +//================================================== +// +// Copyright 2012 Siemens Product Lifecycle Management Software Inc. All Rights Reserved. +// +//================================================== + +package com.connor.signoff.soa.handler; + +import java.math.BigInteger; +import java.util.HashMap; +import java.util.Map; + +import com.teamcenter.clientx.AppXSession; +import com.teamcenter.schemas.soa._2006_03.exceptions.ServiceException; + +// Include the Data Management Service Interface +import com.teamcenter.services.strong.core.DataManagementService; + +// Input and output structures for the service operations +// Note: the different namespace from the service interface +import com.teamcenter.services.strong.core._2006_03.DataManagement.CreateItemsOutput; +import com.teamcenter.services.strong.core._2006_03.DataManagement.CreateItemsResponse; +import com.teamcenter.services.strong.core._2006_03.DataManagement.ExtendedAttributes; +import com.teamcenter.services.strong.core._2006_03.DataManagement.GenerateItemIdsAndInitialRevisionIdsProperties; +import com.teamcenter.services.strong.core._2006_03.DataManagement.GenerateItemIdsAndInitialRevisionIdsResponse; +import com.teamcenter.services.strong.core._2006_03.DataManagement.GenerateRevisionIdsProperties; +import com.teamcenter.services.strong.core._2006_03.DataManagement.GenerateRevisionIdsResponse; +import com.teamcenter.services.strong.core._2006_03.DataManagement.ItemIdsAndInitialRevisionIds; +import com.teamcenter.services.strong.core._2006_03.DataManagement.ItemProperties; +import com.teamcenter.services.strong.core._2006_03.DataManagement.RevisionIds; +import com.teamcenter.services.strong.core._2007_01.DataManagement.CreateOrUpdateFormsResponse; +import com.teamcenter.services.strong.core._2007_01.DataManagement.FormAttributesInfo; +import com.teamcenter.services.strong.core._2007_01.DataManagement.FormInfo; +import com.teamcenter.services.strong.core._2007_01.DataManagement.GetItemCreationRelatedInfoResponse; +import com.teamcenter.services.strong.core._2008_06.DataManagement.ReviseInfo; +import com.teamcenter.services.strong.core._2008_06.DataManagement.ReviseResponse2; +import com.teamcenter.soa.client.model.ModelObject; +import com.teamcenter.soa.client.model.Property; +import com.teamcenter.soa.client.model.ServiceData; +import com.teamcenter.soa.client.model.strong.Item; +import com.teamcenter.soa.client.model.strong.ItemRevision; +import com.teamcenter.soa.exceptions.NotLoadedException; + +/** + * Perform different operations in the DataManagementService + * + */ +public class DataManagement +{ + + /** + * Perform a sequence of data management operations: Create Items, Revise + * the Items, and Delete the Items + * + */ + public void createReviseAndDelete() + { + try + { + int numberOfItems = 3; + + // Reserve Item IDs and Create Items with those IDs + ItemIdsAndInitialRevisionIds[] itemIds = generateItemIds(numberOfItems, "Item"); + CreateItemsOutput[] newItems = createItems(itemIds, "Item"); + + // Copy the Item and ItemRevision to separate arrays for further + // processing + Item[] items = new Item[newItems.length]; + ItemRevision[] itemRevs = new ItemRevision[newItems.length]; + for (int i = 0; i < items.length; i++) + { + items[i] = newItems[i].item; + itemRevs[i] = newItems[i].itemRev; + } + + // Reserve revision IDs and revise the Items + Map allRevIds = generateRevisionIds(items); + reviseItems(allRevIds, itemRevs); + + // Delete all objects created + deleteItems(items); + } + catch (ServiceException e) + { + System.out.println(e.getMessage()); + } + + } + + /** + * Reserve a number Item and Revision IDs + * + * @param numberOfIds Number of IDs to generate + * @param type Type of IDs to generate + * + * @return An array of Item and Revision IDs. The size of the array is equal + * to the input numberOfIds + * + * @throws ServiceException If any partial errors are returned + */ + public ItemIdsAndInitialRevisionIds[] generateItemIds(int numberOfIds, String type) + throws ServiceException + { + // Get the service stub + DataManagementService dmService = DataManagementService.getService(AppXSession.getConnection()); + + GenerateItemIdsAndInitialRevisionIdsProperties[] properties = new GenerateItemIdsAndInitialRevisionIdsProperties[1]; + GenerateItemIdsAndInitialRevisionIdsProperties property = new GenerateItemIdsAndInitialRevisionIdsProperties(); + + property.count = numberOfIds; + property.itemType = type; + property.item = null; // Not used + properties[0] = property; + + // ***************************** + // Execute the service operation + // ***************************** + GenerateItemIdsAndInitialRevisionIdsResponse response = dmService.generateItemIdsAndInitialRevisionIds(properties); + + + + // The AppXPartialErrorListener is logging the partial errors returned + // In this simple example if any partial errors occur we will throw a + // ServiceException + if (response.serviceData.sizeOfPartialErrors() > 0) + throw new ServiceException( "DataManagementService.generateItemIdsAndInitialRevisionIds returned a partial error."); + + // The return is a map of ItemIdsAndInitialRevisionIds keyed on the + // 0-based index of requested IDs. Since we only asked for IDs for one + // data type, the map key is '0' + BigInteger bIkey = new BigInteger("0"); + + @SuppressWarnings("unchecked") + Map allNewIds = response.outputItemIdsAndInitialRevisionIds; + ItemIdsAndInitialRevisionIds[] myNewIds = allNewIds.get(bIkey); + + return myNewIds; + } + + /** + * Create Items + * + * @param itemIds Array of Item and Revision IDs + * @param itemType Type of item to create + * + * @return Set of Items and ItemRevisions + * + * @throws ServiceException If any partial errors are returned + */ + @SuppressWarnings("unchecked") + public CreateItemsOutput[] createItems(ItemIdsAndInitialRevisionIds[] itemIds, String itemType) + throws ServiceException + { + // Get the service stub + DataManagementService dmService = DataManagementService.getService(AppXSession.getConnection()); + // Populate form type + GetItemCreationRelatedInfoResponse relatedResponse = dmService.getItemCreationRelatedInfo(itemType, null); + String[] formTypes = new String[0]; + if ( relatedResponse.serviceData.sizeOfPartialErrors() > 0) + throw new ServiceException( "DataManagementService.getItemCretionRelatedInfo returned a partial error."); + + formTypes = new String[relatedResponse.formAttrs.length]; + for ( int i = 0; i < relatedResponse.formAttrs.length; i++ ) + { + FormAttributesInfo attrInfo = relatedResponse.formAttrs[i]; + formTypes[i] = attrInfo.formType; + } + + ItemProperties[] itemProps = new ItemProperties[itemIds.length]; + for (int i = 0; i < itemIds.length; i++) + { + // Create form in cache for form property population + ModelObject[] forms = createForms(itemIds[i].newItemId, formTypes[0], + itemIds[i].newRevId, formTypes[1], + null, false); + ItemProperties itemProperty = new ItemProperties(); + + itemProperty.clientId = "AppX-Test"; + itemProperty.itemId = itemIds[i].newItemId; + itemProperty.revId = itemIds[i].newRevId; + itemProperty.name = "AppX-Test"; + itemProperty.type = itemType; + itemProperty.description = "Test Item for the SOA AppX sample application."; + itemProperty.uom = ""; + + // Retrieve one of form attribute value from Item master form. + ServiceData serviceData = dmService.getProperties(forms, new String[]{"project_id"}); + if ( serviceData.sizeOfPartialErrors() > 0) + throw new ServiceException( "DataManagementService.getProperties returned a partial error."); + Property property = null; + try + { + property= forms[0].getPropertyObject("project_id"); + } + catch ( NotLoadedException ex){} + + + // Only if value is null, we set new value + if ( property == null || property.getStringValue() == null || property.getStringValue().length() == 0) + { + itemProperty.extendedAttributes = new ExtendedAttributes[1]; + ExtendedAttributes theExtendedAttr = new ExtendedAttributes(); + theExtendedAttr.attributes = new HashMap(); + theExtendedAttr.objectType = formTypes[0]; + theExtendedAttr.attributes.put("project_id", "project_id"); + itemProperty.extendedAttributes[0] = theExtendedAttr; + } + itemProps[i] = itemProperty; + } + + + // ***************************** + // Execute the service operation + // ***************************** + CreateItemsResponse response = dmService.createItems(itemProps, null, ""); + // before control is returned the ChangedHandler will be called with + // newly created Item and ItemRevisions + + + + // The AppXPartialErrorListener is logging the partial errors returned + // In this simple example if any partial errors occur we will throw a + // ServiceException + if (response.serviceData.sizeOfPartialErrors() > 0) + throw new ServiceException( "DataManagementService.createItems returned a partial error."); + + return response.output; + } + + /** + * Reserve Revision IDs + * + * @param items Array of Items to reserve IDs for + * + * @return Map of RevisionIds + * + * @throws ServiceException If any partial errors are returned + */ + @SuppressWarnings("unchecked") + public Map generateRevisionIds(Item[] items) throws ServiceException + { + // Get the service stub + DataManagementService dmService = DataManagementService.getService(AppXSession.getConnection()); + + GenerateRevisionIdsResponse response = null; + GenerateRevisionIdsProperties[] input = null; + input = new GenerateRevisionIdsProperties[items.length]; + for (int i = 0; i < items.length; i++) + { + GenerateRevisionIdsProperties property = new GenerateRevisionIdsProperties(); + property.item = items[i]; + property.itemType = ""; + input[i] = property; + } + + // ***************************** + // Execute the service operation + // ***************************** + response = dmService.generateRevisionIds(input); + + // The AppXPartialErrorListener is logging the partial errors returned + // In this simple example if any partial errors occur we will throw a + // ServiceException + if (response.serviceData.sizeOfPartialErrors() > 0) + throw new ServiceException( "DataManagementService.generateRevisionIds returned a partial error."); + + return response.outputRevisionIds; + } + + /** + * Revise Items + * + * @param revisionIds Map of Revision IDs + * @param itemRevs Array of ItemRevisons + * + * @return Map of Old ItemRevsion(key) to new ItemRevision(value) + * + * @throws ServiceException If any partial errors are returned + */ + public void reviseItems(Map revisionIds, ItemRevision[] itemRevs) throws ServiceException + { + // Get the service stub + DataManagementService dmService = DataManagementService.getService(AppXSession.getConnection()); + ReviseInfo[] reviseInfo = new ReviseInfo[itemRevs.length]; + for (int i = 0; i < itemRevs.length; i++) + { + String key = Integer.toString(i); + BigInteger bIkey = new BigInteger(key); + RevisionIds rev = revisionIds.get(bIkey); + + reviseInfo[i] = new ReviseInfo(); + reviseInfo[i].baseItemRevision = itemRevs[i]; + reviseInfo[i].clientId = itemRevs[i].getUid()+ "--" + i; + reviseInfo[i].description = "describe testRevise"; + reviseInfo[i].name = "testRevise"; + reviseInfo[i].newRevId = rev.newRevId; + + } + + // ***************************** + // Execute the service operation + // ***************************** + ReviseResponse2 revised = dmService.revise2(reviseInfo); + // before control is returned the ChangedHandler will be called with + // newly created Item and ItemRevisions + + + + // The AppXPartialErrorListener is logging the partial errors returned + // In this simple example if any partial errors occur we will throw a + // ServiceException + if (revised.serviceData.sizeOfPartialErrors() > 0) + throw new ServiceException("DataManagementService.revise returned a partial error."); + + + } + + /** + * Delete the Items + * + * @param items Array of Items to delete + * + * @throws ServiceException If any partial errors are returned + */ + public void deleteItems(Item[] items) throws ServiceException + { + // Get the service stub + DataManagementService dmService = DataManagementService.getService(AppXSession.getConnection()); + + // ***************************** + // Execute the service operation + // ***************************** + ServiceData serviceData = dmService.deleteObjects(items); + + // The AppXPartialErrorListener is logging the partial errors returned + // In this simple example if any partial errors occur we will throw a + // ServiceException + if (serviceData.sizeOfPartialErrors() > 0) + throw new ServiceException("DataManagementService.deleteObjects returned a partial error."); + + } + + /** + * Create ItemMasterForm and ItemRevisionMasterForm + * + * @param IMFormName Name of ItemMasterForm + * @param IMFormType Type of ItemMasterForm + * @param IRMFormName Name of ItemRevisionMasterForm + * @param IRMFormType Type of ItemRevisionMasterForm + * @param parent The container object that two + * newly-created forms will be added into. + * @return ModelObject[] Array of forms + * + * @throws ServiceException If any partial errors are returned + */ + public ModelObject[] createForms ( String IMFormName, String IMFormType, + String IRMFormName, String IRMFormType, + ModelObject parent, boolean saveDB ) throws ServiceException + { + //Get the service stub + DataManagementService dmService = DataManagementService.getService(AppXSession.getConnection()); + FormInfo[] inputs = new FormInfo[2]; + inputs[0] = new FormInfo(); + inputs[0].clientId = "1"; + inputs[0].description=""; + inputs[0].name = IMFormName; + inputs[0].formType=IMFormType; + inputs[0].saveDB = saveDB; + inputs[0].parentObject = parent ; + inputs[1] = new FormInfo(); + inputs[1].clientId = "2"; + inputs[1].description=""; + inputs[1].name = IRMFormName; + inputs[1].formType=IRMFormType; + inputs[1].saveDB = saveDB; + inputs[1].parentObject = parent; + CreateOrUpdateFormsResponse response = dmService.createOrUpdateForms(inputs); + if ( response.serviceData.sizeOfPartialErrors() > 0) + throw new ServiceException("DataManagementService.createForms returned a partial error."); + ModelObject[] forms = new ModelObject [inputs.length]; + for (int i=0; i waitPdf) { + return null; + } + fs = waitOkOrErrFile(ftp, fileName, errorNamePrefix); + return fs; + } + /** + * Description: FTPϴļ + * + * @param ftpHost FTPhostname + * @param ftpUserName ˺ + * @param ftpPassword + * @param ftpPort ˿ + * @param ftpPath FTPļ· ʽ ftptest/aa + * @param fileName ftpļ + * @param in ļ + * @return ɹtrue򷵻false + */ + public static boolean deleteTxt( + String fileName, // Ҫصļ + String localPath// غ󱣴浽ص· + + ) { + + boolean success = false; + FTPClient ftp = new FTPClient(); + try { + int reply; + + ftp = getFTPClient(ftpHost, ftpUserName, ftpPassword, ftpPort); +// ftp.login("anonymous", null);// ½FTP + reply = ftp.getReplyCode(); + if (!FTPReply.isPositiveCompletion(reply)) { + ftp.disconnect(); + return success; + } + ftp.enterLocalPassiveMode();// 䣬ЩԴ˷ǽͻftp.listFiles()│ס +// System.out.println("aaa"); + boolean ftpchange = ftp.changeWorkingDirectory(ftpPath);// תƵFTPĿ¼ + fileName = fileName.replace(".exb", ".txt"); + ftp.setControlEncoding("GBK"); //FTP ֧ + fileName = convGBKToISO(fileName);//FTP ֧ + ftp.dele(fileName); + success=true; + + } catch (IOException e) { + e.printStackTrace(); + } finally { + if (ftp.isConnected()) { + try { + ftp.disconnect(); + } catch (IOException ioe) { + } + } + } + return success; + + } + public static boolean downFile( + String fileName, // Ҫصļ + String localPath// غ󱣴浽ص· + + ) { + boolean success = false; + FTPClient ftp = new FTPClient(); + try { + int reply; + ftp = getFTPClient(ftpHost, ftpUserName, ftpPassword, ftpPort); + reply = ftp.getReplyCode(); + if (!FTPReply.isPositiveCompletion(reply)) { + ftp.disconnect(); + return success; + } + ftp.enterLocalPassiveMode();// 䣬ЩԴ˷ǽͻftp.listFiles()│ס +// System.out.println("aaa"); + boolean ftpchange = ftp.changeWorkingDirectory(ftpPath);// תƵFTPĿ¼ +// System.out.println(ftpchange); +// FTPFile[] fs = ftp.listFiles(); + String errorName = ""; + if (fileName.toLowerCase().endsWith(".pdf")) { + errorName = fileName + ".err"; + } else if (fileName.toLowerCase().endsWith(".exb")) { + errorName = fileName + ".err"; + } + String okName= fileName + ".ok"; + File localFile = new File(localPath + "/" + fileName); + count = 0; + FTPFile[] fs = waitPdf(ftp, fileName, errorName,okName); + if (fs != null) { + + try { + Thread.sleep(500); + } catch (InterruptedException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + ftp.setControlEncoding("GBK"); + for (FTPFile ff : fs) { + // FTP֧ + String ffName = convISOtoGBK(ff.getName()); + if (ffName.equals(fileName)) { + OutputStream is = new FileOutputStream(localFile); + ftp.retrieveFile(ff.getName(), is); +// System.out.println("ccc" +ff.getName()+fileName); + is.close(); + break; + } + } + ftp.logout(); + success = true; + } else { + success = false; + } + } catch (IOException e) { + e.printStackTrace(); + } finally { + if (ftp.isConnected()) { + try { + ftp.disconnect(); + } catch (IOException ioe) { + } + } + } + return success; + } + public static FTPFile[] waitPdf(FTPClient ftp, String fileName, String errorName,String okName) { + FTPFile[] fs = null; + try { + + fs = ftp.listFiles(); + } catch (IOException e1) { + e1.printStackTrace(); + } + + for (FTPFile ff : fs) { + //2023.04.06ҵ.okΪɹ.errorΪʧܲ + //FTP֧ + String ffName = convISOtoGBK(ff.getName()); + if (ffName.equals(okName)) { + System.out.println("find the pdf..."); + return fs; + } else if (ffName.equals(errorName)) { + System.out.println("ת쳣"); + return null; + } + } + System.out.println("waitPdf---count:"+count); + System.out.println("waitPdf----waitPdf:"+waitPdf); + try { + Thread.sleep(1000); + count++; + } catch (InterruptedException e) { + e.printStackTrace(); + } + // ʱ˳ + if (count > waitPdf) { + return null; + } + fs = waitPdf(ftp, fileName, errorName,okName); + return fs; + } + /** + * ISOļתΪGBKʽ + * һFTPļwinϵͳ + * @param fileNameGBK + * @return + */ + public static String convISOtoGBK(String fileNameISO) { + String filenameGBK=""; + try { + filenameGBK = new String(fileNameISO.getBytes("iso-8859-1"),"GBK"); + } catch (UnsupportedEncodingException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return filenameGBK; + } + /** + * GBKļתΪISOʽ + * ļתΪFTPʶı + * @param fileNameGBK + * @return + */ + public static String convGBKToISO(String fileNameISO) { + String filenameISO=""; + try { + filenameISO = new String(fileNameISO.getBytes("GBK"),"iso-8859-1"); + } catch (UnsupportedEncodingException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return filenameISO; + } + /** + * ȡFTPClient + * + * @param ftpHost FTP + * @param ftpPassword FTP ¼ + * @param ftpUserName FTP¼û + * @param ftpPort FTP˿ ĬΪ21 + * @return + */ + public static FTPClient getFTPClient(String ftpHost, String ftpUserName, String ftpPassword, int ftpPort) { + FTPClient ftpClient = new FTPClient(); + try { + ftpClient = new FTPClient(); + ftpClient.connect(ftpHost, ftpPort);// FTP + ftpClient.login(ftpUserName, ftpPassword);// ½FTP +// ftpClient.login("anonymous", null);// ½FTP + if (!FTPReply.isPositiveCompletion(ftpClient.getReplyCode())) { + System.out.println("δӵFTPû"); + ftpClient.disconnect(); + } else { + System.out.println("FTPӳɹ"); + } + } catch (SocketException e) { + e.printStackTrace(); + System.out.println("FTPIPַܴȷá"); + } catch (IOException e) { + e.printStackTrace(); + System.out.println("FTPĶ˿ڴ,ȷá"); + } + return ftpClient; + } + /** + * ȡjarڵplugin· + * + * @param + * @return + */ + public static String getTCPlugin() { + String path2 = ""; + path2 = OpenDatasetSignoff.class.getProtectionDomain().getCodeSource().getLocation().getPath();// tcpluginsµjarľ· + path2 = path2.replace("%20", " "); + System.out.println("plugin·:" + path2); + File file = new File(path2); + try { + System.out.println("file.getParent:" + file.getParent()); + } catch (Exception e) { + e.printStackTrace(); + } + path2 = file.getParent() + "//"; + System.out.println("plugin·:" + path2); + return path2; + } + /** + * ȡļϢ + * + * @param ļ· + * @return + */ + public static Properties getProperties(String fileName) { + Properties properties = new Properties(); + try { + InputStream inputStream = new FileInputStream(fileName); + properties.load(inputStream); + } catch (IOException e) { + e.printStackTrace(); + } + return properties; + } +} diff --git a/src/com/connor/signoff/soa/handler/Hello.java b/src/com/connor/signoff/soa/handler/Hello.java new file mode 100644 index 0000000..db40349 --- /dev/null +++ b/src/com/connor/signoff/soa/handler/Hello.java @@ -0,0 +1,87 @@ +//================================================== +// +// Copyright 2012 Siemens Product Lifecycle Management Software Inc. All Rights Reserved. +// +//================================================== + +package com.connor.signoff.soa.handler; + +import com.teamcenter.clientx.AppXSession; +import com.teamcenter.soa.client.model.strong.User; + + + +/** + * This sample client application demonstrates some of the basic features of the + * Teamcenter Services framework and a few of the services. + * + * An instance of the Connection object is created with implementations of the + * ExceptionHandler, PartialErrorListener, ChangeListener, and DeleteListeners + * intefaces. This client application performs the following functions: + * 1. Establishes a session with the Teamcenter server + * 2. Display the contents of the Home Folder + * 3. Performs a simple query of the database + * 4. Create, revise, and delete an Item + * + */ +public class Hello +{ + + /** + * @param args -help or -h will print out a Usage statement + */ + public static void main(String[] args) + { + if (args.length > 0) + { + if (args[0].equals("-help") || args[0].equals("-h")) + { + System.out.println("usage: java [-Dhost=http://server:port/tc] com.teamcenter.hello.Hello"); + System.exit(0); + } + } + + // Get optional host information + String serverHost = "http://192.168.2.242:7001/tc"; + String host = System.getProperty("host"); + if (host != null && host.length() > 0) + { + serverHost = host; + } + + + + AppXSession session = new AppXSession(serverHost); + HomeFolder home = new HomeFolder(); + Query query = new Query(); + DataManagement dm = new DataManagement(); + + + + + + // Establish a session with the Teamcenter Server + User user = session.login(); + + // Using the User object returned from the login service request + // display the contents of the Home Folder + home.listHomeFolder(user); + + // Perform a simple query of the database + query.queryItems(); + + // Perform some basic data management functions + dm.createReviseAndDelete(); + + // Terminate the session with the Teamcenter server + session.logout(); + + } + + + + + + + +} diff --git a/src/com/connor/signoff/soa/handler/HomeFolder.java b/src/com/connor/signoff/soa/handler/HomeFolder.java new file mode 100644 index 0000000..e439b24 --- /dev/null +++ b/src/com/connor/signoff/soa/handler/HomeFolder.java @@ -0,0 +1,75 @@ +//================================================== +// +// Copyright 2012 Siemens Product Lifecycle Management Software Inc. All Rights Reserved. +// +//================================================== + +package com.connor.signoff.soa.handler; + +import com.teamcenter.clientx.AppXSession; +import com.teamcenter.services.strong.core.DataManagementService; +import com.teamcenter.soa.client.model.ModelObject; +import com.teamcenter.soa.client.model.strong.Folder; +import com.teamcenter.soa.client.model.strong.User; +import com.teamcenter.soa.client.model.strong.WorkspaceObject; +import com.teamcenter.soa.exceptions.NotLoadedException; + +public class HomeFolder +{ + + /** + * List the contents of the Home folder. + * + */ + public void listHomeFolder(User user) + { + Folder home = null; + WorkspaceObject[] contents = null; + + // Get the service stub + DataManagementService dmService = DataManagementService.getService(AppXSession.getConnection()); + + try + { + // User was a primary object returned from the login command + // the Object Property Policy should be configured to include the + // 'home_folder' property. However the actuall 'home_folder' object + // was a secondary object returned from the login request and + // therefore does not have any properties associated with it. We will need to + // get those properties explicitly with a 'getProperties' service request. + home = user.get_home_folder(); + } + catch (NotLoadedException e) + { + System.out.println(e.getMessage()); + System.out.println("The Object Property Policy ($TC_DATA/soa/policies/Default.xml) is not configured with this property."); + return; + } + + try + { + ModelObject[] objects = { home }; + String[] attributes = { "contents" }; + + // ***************************** + // Execute the service operation + // ***************************** + dmService.getProperties(objects, attributes); + + + // The above getProperties call returns a ServiceData object, but it + // just has pointers to the same object we passed into the method, so the + // input object have been updated with new property values + contents = home.get_contents(); + } + // This should never be thrown, since we just explicitly asked for this + // property + catch (NotLoadedException e){} + + System.out.println(""); + System.out.println("Home Folder:"); + AppXSession.printObjects( contents ); + + } + +} diff --git a/src/com/connor/signoff/soa/handler/JFomPdfBean.java b/src/com/connor/signoff/soa/handler/JFomPdfBean.java new file mode 100644 index 0000000..d2b90d8 --- /dev/null +++ b/src/com/connor/signoff/soa/handler/JFomPdfBean.java @@ -0,0 +1,41 @@ +package com.connor.signoff.soa.handler; + +public class JFomPdfBean { + private Float w = 0.0f; + private Float h = 0.0f; + private Float wi = 0.0f; + private Float hi = 0.0f; + + public Float getW() { + return w; + } + + public void setW(Float w) { + this.w = w; + } + + public Float getH() { + return h; + } + + public void setH(Float h) { + this.h = h; + } + + public Float getWi() { + return wi; + } + + public void setWi(Float wi) { + this.wi = wi; + } + + public Float getHi() { + return hi; + } + + public void setHi(Float hi) { + this.hi = hi; + } + +} diff --git a/src/com/connor/signoff/soa/handler/OpenDatasetSignoff.java b/src/com/connor/signoff/soa/handler/OpenDatasetSignoff.java new file mode 100644 index 0000000..14d05ab --- /dev/null +++ b/src/com/connor/signoff/soa/handler/OpenDatasetSignoff.java @@ -0,0 +1,1207 @@ +package com.connor.signoff.soa.handler; + +import java.io.InputStream; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; + +import java.io.IOException; + +import java.io.OutputStream; +import java.io.PrintWriter; +import java.io.UnsupportedEncodingException; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.net.MalformedURLException; +import java.net.SocketException; +import java.net.URISyntaxException; +import java.security.KeyManagementException; +import java.security.NoSuchAlgorithmException; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Date; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Properties; +import java.util.concurrent.TimeoutException; +import org.apache.commons.net.ftp.FTPClient; +import org.apache.commons.net.ftp.FTPFile; +import org.apache.commons.net.ftp.FTPReply; +import org.dom4j.Document; +import org.dom4j.DocumentException; +import org.dom4j.Element; +import org.dom4j.io.SAXReader; + +import com.itextpdf.text.BadElementException; +import com.itextpdf.text.Image; +import com.itextpdf.text.Rectangle; +import com.itextpdf.text.pdf.PdfContentByte; +import com.itextpdf.text.pdf.PdfGState; +import com.itextpdf.text.pdf.PdfReader; +import com.itextpdf.text.pdf.PdfStamper; +import com.teamcenter.clientx.AppXSession; +import com.teamcenter.services.strong.administration.PreferenceManagementRestBindingStub; +import com.teamcenter.services.strong.administration.PreferenceManagementService; +import com.teamcenter.services.strong.administration._2012_09.PreferenceManagement; +import com.teamcenter.services.strong.core.DataManagementService; +import com.teamcenter.soa.client.model.ModelObject; +import com.teamcenter.soa.client.model.strong.Dataset; +import com.teamcenter.soa.client.model.strong.User; +import com.teamcenter.soa.client.model.strong.WorkspaceObject; +//import com.teamcenter.rac.aif.AbstractAIFApplication; +//import com.teamcenter.rac.aif.kernel.AIFComponentContext; +//import com.teamcenter.rac.aifrcp.AIFUtility; +//import com.teamcenter.rac.ui.common.RACUIUtil; +//import com.teamcenter.rac.util.FileUtility; +//import com.teamcenter.rac.util.MessageBox; +//import com.teamcenter.soa.client.model.Property; +//import com.teamcenter.soa.client.model.strong.User; +//import com.teamcenter.soa.exceptions.NotLoadedException; + + +/** + * ̳ϵͳInterfaceDatasetAction࣬дpreProcessڴ ݼ ʱǰ + * + * @author hubing + * @version 1.0, 2015-01-6 + */ + +public class OpenDatasetSignoff{ + private static final boolean debug = false; + private static String exePath;//· + private static String[] refValues;//ӳ + private static AppXSession session; +// private static PreferenceManagementService tcp; +// private TCPreferenceService tcp; + // رݼʱ򴥷ǿͨ˷ʵִݼļԵǵı߰汾 + private int waitPdf = 0; + private int count = 0;// + + public static void main(String[] args) { + if (args.length > 0) { + if (args[0].equals("-help") || args[0].equals("-h")) { + System.out.println("usage: java [-Dhost=http://server:port/tc] com.teamcenter.hello.Hello"); + System.exit(0); + } + } + + // Get optional host information + String serverHost = "http://192.168.2.242:7001/tc"; + String host = System.getProperty("host"); + if (host != null && host.length() > 0) { + serverHost = host; + } + + session = new AppXSession(serverHost); +// HomeFolder home = new HomeFolder(); +// Query query = new Query(); +// DataManagement dm = new DataManagement(); + + // Establish a session with the Teamcenter Server + User user = session.login(); + + PreferenceManagementService tcp = PreferenceManagementService.getService(AppXSession.getConnection()); + String path = "C:\\Users\\HX\\eclipse-workspace\\"; + exePath = path;//.substring(1, path.indexOf("com.connor.signoff")).replace("/", "\\"); +// refValues = tcp.getStringArray(TCPreferenceService.TC_preference_site, "HxCaxaMapping"); + PreferenceManagement.GetPreferencesResponse getAttrMappingPreferencesResponse = tcp.getPreferences(new String[] {"HxCaxaMapping"}, true); + for(PreferenceManagement.CompletePreference completePreference : getAttrMappingPreferencesResponse.response) { + + if(completePreference.definition.name.equals("HxCaxaMapping")){ + refValues = completePreference.values.values; + } + } + FTPUtils.getConfigureInfomationg(tcp,""); + + + preProcess("hgiN5tO1I3go1D"); + + session.logout(); + + } + + + public static int preProcess(String datasetPuid) { + System.out.println("汾2023-04-12preProcess..."); + //ȡݼ + DataManagementService dataManagementService = DataManagementService.getService(AppXSession.getConnection()); + Dataset dataset = (Dataset) dataManagementService.loadObjects(new String[] {datasetPuid}).getPlainObject(0); + //ݼУ + if(!dataSetVerification(dataset)) {return 0;} + + //ִдCAXAɹע޸ +// openCad(); +// +// // ѾļҲҪжǷҪӳ + // caxaݼֻģ޸ʱ<=ʱ䣬pdf޸ʱ>ʱ,ֻ򿪣Ҫӳתpdf + boolean openDirect = false;// trueΪpdf +// openDirect = isCaxaDatasetRegen(tccomponentdataset, openDirect); + + if (openDirect) { + return 0; + } +// //ȡTCݼ· +// String exportedCaxaFilePath = TcUtils.getCaxaFile(arg1); +// +// if (openDirect && exportedCaxaFilePath != null) { +// if (debug) +// System.out.println("ǩ:" + exportedCaxaFilePath); +// //Ҫǩ +// }else { +// if (debug) +// System.out.println("ǩ:" + exportedCaxaFilePath); +// //Ҫǩ +// } +// +// if (exportedCaxaFilePath != null && (exportedCaxaFilePath.toLowerCase().endsWith(".exb") +// || exportedCaxaFilePath.toLowerCase().endsWith(".cxp"))) { +// try { +// +// hx_SetCAXAFileOrigin(tccomponentdataset, tcp, "",openDirect); +// +// } catch (Exception e) { +// e.printStackTrace(); +// MessageBox.post("Teamcenter쳣"+e.getMessage(), "", MessageBox.ERROR); +// } +// } +// //openCad(); + return 0; + } +// +// @Override +// public boolean postProcess(TCComponentDataset arg0, String arg1, int arg2) { +// System.out.println("PostProcess..."); +// System.out.println("PostProcess汾:2023-05-22..."); +// //ݼУ +// +// if(!dataSetVerification(arg0)) {return false;} +// File finalCaxa =TcUtils.getCaxaFile(arg1); +// +// openCad(); +// boolean openDirect = false;// trueΪpdf +// // caxaݼֻģ޸ʱ<=ʱ䣬pdf޸ʱ>ʱ,ֻ򿪣Ҫӳתpdf +// openDirect = isCaxaDatasetRegen(arg0, openDirect); +// if (openDirect) { +// deleteTempReadOnlyFile(arg1, finalCaxa); +// return false; +// } +// +// count = 0; +// //ȡеȴpdfתʱʱ +// loadWaitPdf(); +// TCComponentItemRevision rev = TcUtils.getReferenceRev(arg0); +// if (rev != null) { +// String addPdfPath = ""; +// try { +// if (debug) +// System.out.println("ܿ"); +// // ʱʩ ޸ʱͷʱС2ӣһӳ䣬תpdf +// String ftpCaxaName = ""; +// if (!openDirect) { +// ftpCaxaName = caxaProperty(rev, arg0, finalCaxa);// ӳתpdf +// } +// // ܿ +// addPdfPath = addSkz(addPdfPath, ftpCaxaName, rev); +// +// if (debug) +// System.out.println("ܿ"); +// +// if (addPdfPath.length() > 0) { +// if (debug) +// System.out.println("滻"); +// // 滻½ݼ +// ChangeDbomUtil.setByPass(true); +// replaceOrcreate(arg0, rev, session, addPdfPath); +// ChangeDbomUtil.setByPass(false); +// } +// +// } catch (Exception e) { +// // TODO Auto-generated catch block +// e.printStackTrace(); +// MessageBox.post("Teamcenter쳣"+e.getMessage(), "", MessageBox.ERROR); +// } +// }else if (rev == null) { +// MessageBox.post("ݼ汾pdfתʧ", "", MessageBox.INFORMATION); +// } +// +// //޸bugҪɾֻļ +// deleteTempReadOnlyFile(arg1, finalCaxa); +// return false; +// } + /** + * ݼУ + * @param dataset + * @param tccomponentdataset ݼ + * @return + */ + private static boolean dataSetVerification(Dataset dataset) { + //ûPDF +// if(TcUtils.checkPDF(dataset) == 1) {return false;} + + //жǷģݼǣ򷵻 +// if (judgeModel(dataset) == 1) {return false;} +// +// //ԭļǷ쳣 +// if(TcUtils.checkDatasetFileName(dataset) == 1) {return false;}; + + + return true; + + } +// /** +// * ɾTCжΪֻȻҪǩֵļ +// * @param tcTempDir +// * @param finalCaxa +// */ +// private void deleteTempReadOnlyFile(String tcTempDir, File finalCaxa) { +// File tempCacheFile; +// File[] allFiles; +// +// if(finalCaxa.exists()) { +// +// } +// // ֻ򿪣ҽcaxaǩֵ£ļ ᱨ +// boolean caxaReadOnly = !finalCaxa.canWrite(); +// if (caxaReadOnly) { +// tempCacheFile = new File(tcTempDir); +// allFiles = tempCacheFile.listFiles(); +// for (int i = allFiles.length - 1; i >= 0; i--) { +// allFiles[i].delete(); +// } +// } +// } +// +// +// +// /** +// * @param addPdfPath PDFǩ +// * @param ftpCaxaName +// * @param rev +// * @return +// * @throws Exception +// */ +// private String addSkz(String addPdfPath,String ftpCaxaName,TCComponent rev) throws Exception { +// String fileName=""; +// String item_id =""; +// String item_rev_id =""; +// String qianzhang = ""; +// item_id=rev.getProperty("item_id").trim(); +// item_rev_id=rev.getProperty("item_revision_id").trim(); +// item_id = TcUtils.newString(item_id); +// qianzhang = rev.getProperty("hx3_qianzhang").trim(); +// if(ftpCaxaName.length()>0) { +// fileName=ftpCaxaName.split(".exb")[0]; +// // ȡݼڵİ汾ƴӰ汾id͵ǰʱΪϴ +// boolean ss = false; +// //ӳpdfļ +// count = 0 ; +// boolean convertMark = FTPUtils.downFile(fileName + ".pdf", System.getenv("TEMP"));// pdf· +// if (convertMark == false) { +// if (count > waitPdf) { +// +// MessageBox.post("CAXAתPDFʱ,", "", MessageBox.INFORMATION); +// } else { +// +// MessageBox.post("CAXAתPDF쳣,", "", MessageBox.INFORMATION); +// } +// } else { +// // Ҫǩ +// String addSkzBeforePath=System.getenv("TEMP") + File.separator + fileName + ".pdf"; +// String addSkzAfterPath=""; +// if(FTPUtils.CompanyName.equals("HX")) { +// addSkzAfterPath=System.getenv("TEMP") + File.separator + item_id + item_rev_id + ".pdf"; +// String designType = rev.getType(); +// String[] imgPath = new String[1]; +// if(qianzhang.equals("ܿ") || qianzhang.equals("B") || qianzhang.isEmpty()) { +// +// exePath = exePath + "skz.png"; +// } +// else { +// exePath = exePath + "syz.png"; +// +// } +// +// imgPath[0] = exePath; +// System.out.println("ܿλ---------------" + imgPath[0]); +// addPdfMark(addSkzBeforePath,addSkzAfterPath, imgPath,designType); +// } +// +// File file = new File(addSkzBeforePath); +// if (file.exists()) { +// addPdfPath = addSkzBeforePath; +// } else { +// +// addPdfPath = addSkzAfterPath; +// } +// +// } +// } +// return addPdfPath; +// } +// +// +// +// /** +// * ǩֲȡǩֺPDF +// * @param rev +// * @param dataset +// * @param finalCaxa +// * @return +// * @throws Exception +// */ +// public String caxaProperty(TCComponentItemRevision rev, TCComponentDataset dataset,File finalCaxa) throws Exception { +// // Ҫݼ· +// +// if (dataset != null) { +// String fileOgiginName = ""; +// // аcxp, +// if (dataset.getProperty("object_name").contains(".cxp") +// || dataset.getProperty("object_name").contains(".CXP")) { +// return ""; +// } +// +// // TODO õԭļ +// TCComponent[] ref_list = dataset.getTCProperty("ref_list").getReferenceValueArray(); +// if (ref_list.length == 0) { +// return ""; +// } +// if (ref_list.length > 1) { +// return ""; +// } +// if (ref_list.length == 1) { +// fileOgiginName = ref_list[0].getProperty("original_file_name"); +// } +// +// // TODO Ⱥϴcaxaxmlļftpת +// String tempCaxaPath = ""; +// System.out.println("ʼtempCaxaPath"); +// System.out.println(dataset.getProperty("object_name")); +// tempCaxaPath = TcUtils.downLoadCaxaFile(dataset, rev, finalCaxa);// ļsystem temp·£Ϊǰʱ +// +// // пΪգ粻õʱ +// if (tempCaxaPath.trim().length() == 0) { +// return ""; +// } +// System.out.println(tempCaxaPath); +// System.out.println("tempCaxaPath caxaƵ·:" + tempCaxaPath); +// String tempCaxaPathName = tempCaxaPath.substring(tempCaxaPath.lastIndexOf("\\") + 1); +// second(new File(tempCaxaPath)); +// FileInputStream tempCaxaPathIn = new FileInputStream(new File(tempCaxaPath)); +// System.out.println("ʼϴtempCaxaPath:" + tempCaxaPathName); +// boolean tempCaxa = FTPUtils.uploadFile(tempCaxaPathName, tempCaxaPathIn); +// if (tempCaxa == false) { +// System.out.println("upload fail----------------"); +// return ""; +// } +// +// System.out.println("ϴcaxa"); +// boolean jump = hx_SetCAXAFile2(dataset, tcp, tempCaxaPathName.substring(0, tempCaxaPathName.length() - 4)); +// if (jump == false) { +// return ""; +// } +// second(new File(tempCaxaPath.replace(".exb", ".xml"))); +// +// FileInputStream tempXmlPathIn = new FileInputStream(new File(tempCaxaPath.replace(".exb", ".xml"))); +// System.out.println("ϴxml:" + tempCaxaPathName.replace(".exb", ".xml")); +// boolean tempXml = FTPUtils.uploadFile(tempCaxaPathName.replace(".exb", ".xml"), tempXmlPathIn); +// if (tempXml == false) { +// return ""; +// } +// // жǷokerrļ˵ӳɣ +// System.out.println("okerr"); +// boolean downResult = FTPUtils.downOkOrErrFile(tempCaxaPathName, System.getenv("TEMP")); +// // ʧܣһftpԱָļtxtshxλãȡʹõȱʡ壩Ȼ󵯳Դλ\ĵ +// if (downResult == false) { +// return ""; +// } +// // ɹ ɾftpϵͬtxt ȴpdf +// System.out.println("ɾļתpdf" + tempCaxaPathName.replace(".exb", ".txt")); +// boolean getPdf = FTPUtils.deleteTxt(tempCaxaPathName, System.getenv("TEMP")); +// if (getPdf) { +// return tempCaxaPathName; +// } +// } +// return ""; +// } +// +// +// + /** + * @param caxaDataset + * @param openDirect caxaݼֻģ޸ʱ<=ʱ䣬pdf޸ʱ>ʱ,ֻ򿪣Ҫӳתpdf + * @return true = ֱӴ_caxa || false = pdf + */ + private boolean isCaxaDatasetRegen(Dataset caxaDataset, boolean openDirect) { + try { + List whereReference = TcUtils.getWhereReference(new WorkspaceObject[] {caxaDataset}); + System.out.println(); + +// TCComponentItemRevision rev = (TCComponentItemRevision) caxaDataset.getReferenceProperty("item_revision"); +// if (!caxaDataset.okToModify()) { +// if (debug) +// System.out.println("ֻ======"); +// boolean isReleased = caxaDataset.getProperty("release_status_list").length()==0?false:true; +// if (!isReleased) { +// //޷״̬ +// openDirect = true; +// +// } else { +// +// if (debug) +// System.out.println("жϷʱ"); +// Date date_released = caxaDataset.getTCProperty("date_released").getDateValue(); +// Date last_mod_date = caxaDataset.getTCProperty("last_mod_date").getDateValue(); +// // ʱ֮ķ +// long diffMinutes = Math.abs((last_mod_date.getTime() - date_released.getTime()) / (60 * 1000)); +// if (diffMinutes < 2) { +// if (debug) +// System.out.println("޸ʱͷʱʱ2,PDF"); +// openDirect = false; +// } else { +// if (debug) +// System.out.println("޸ʱͷʱʱ2,PDF"); +// +// Map ecnValueMap = getECNValueMap(rev); +// +// if(ecnValueMap.size() != 0) { +// openDirect = false; +// }else { +// openDirect = true; +// } +// } +// } +// try { +// //תPDF +// +// String[] properties = session.getPropertyService().getProperties(rev, new String[] {"fnd0InProcess"}); +// +// if(properties.length != 0 && properties[0]!=null && "true".equals(properties[0])) { +// openDirect = false; +// } +// +// System.out.println(1); +// } catch (Exception e) { +// // TODO Auto-generated catch block +// e.printStackTrace(); +// } +// +// } else { +// if (debug) +// System.out.println("д======"); +// openDirect = false; +// } +// +// +// if(openDirect) { +// System.out.println("ǷֱӴͼֽжϽ=True"); +// }else { +// System.out.println("ֱӴͼֽжϽ=False"); +// } +// //ر߼TCѡHX_SignCAXAByChoice,ȷûǿת +// +// String forceOpenDirect = TcUtils.getTCPreference("HX_SignCAXAByChoice", session,TCPreferenceService.TC_preference_user); +// if (!forceOpenDirect.isEmpty()) { +// if (forceOpenDirect.equals("true")) { +// System.out.println("ǿִǩͼֽ:True"); +// openDirect = false; +// } else if (forceOpenDirect.equals("false")) { +// System.out.println("ǿִǩͼֽ:False"); +// openDirect = true; +// } else { +// System.out.println("ǿִǩͼֽ:"); +// } +// } +// +// //2023/05/26 HXCװͼתPDF +// if(rev!=null) { +// if("HXC".equals(FTPUtils.CompanyName) && "Hxc8gztuzhiRevision".equals(rev.getType())) { +// openDirect = true; +// } +// }else{ +// openDirect = true; +// } + } catch (Exception e) { + e.printStackTrace(); +// MessageBox.post("Teamcenter쳣"+e.getMessage(), "", MessageBox.ERROR); + } + return openDirect; + } +// +// private Map getECNValueMap(TCComponent rev) throws TCException { +// // 2019.11.254ӳ䣺İΣ汾ţļţ֪ͨıţǩ֣ϹԱڣ֪ͨڣգ +// // ֻһθļ¼ +// String dateString = ""; +// Map valueMap = new HashMap(); +// AIFComponentContext[] ecr = rev.whereReferenced(); +// for (int i = 0; i < ecr.length; i++) { +// TCComponent ecrRev = (TCComponent) ecr[i].getComponent(); +// System.out.println("ecrRev.getProperty:" + ecrRev.getProperty("object_type")); +// if (ecrRev.getProperty("object_type").equals("GCGGTZD Revision")) { +// // 뷢 +// if (ecrRev.getProperty("release_status_list").length() > 0) { +// String dateString2 = ecrRev.getProperty("creation_date"); +// String revType = rev.getProperty("object_type"); +// System.out.println("revType:" + revType); +// if (dateString.length() == 0) { +// dateString = dateString2; +// if (revType.equals("ZPT Revision") || revType.equals("LJT Revision") +// || revType.equals("WXT Revision")) { +// +// valueMap.put("İ1", rev.getProperty("item_revision_id")); +// valueMap.put("ļ1", ecrRev.getProperty("item_id")); +// valueMap.put("ǩ1", "ϹԱ"); +// valueMap.put("1", ecrRev.getProperty("creation_date").split(" ")[0]); +// } else if (revType.equals("GYT Revision")) { +// valueMap.put("İ", rev.getProperty("item_revision_id")); +// valueMap.put("ļ", ecrRev.getProperty("item_id")); +// valueMap.put("ǩ", "ϹԱ"); +// valueMap.put("", ecrRev.getProperty("creation_date").split(" ")[0]); +// +// } +// } else { +// if (dateString.compareTo(dateString2) < 0) { +// dateString = dateString2; +// if (revType.equals("ZPT Revision") || revType.equals("LJT Revision") +// || revType.equals("WXT Revision")) { +// +// valueMap.put("İ1", rev.getProperty("item_revision_id")); +// valueMap.put("ļ1", ecrRev.getProperty("item_id")); +// valueMap.put("ǩ1", "ϹԱ"); +// valueMap.put("1", ecrRev.getProperty("creation_date").split(" ")[0]); +// } else if (revType.equals("GYT Revision")) { +// valueMap.put("İ", rev.getProperty("item_revision_id")); +// valueMap.put("ļ", ecrRev.getProperty("item_id")); +// valueMap.put("ǩ", "ϹԱ"); +// valueMap.put("", ecrRev.getProperty("creation_date").split(" ")[0]); +// +// } +// } +// } +// } +// +// } +// } +// return valueMap; +// +// } +// +// // ȡеȴpdfתʱʱ +// private void loadWaitPdf() { +// Properties properties = new Properties(); +// InputStream is = null; +// is = getClass().getResourceAsStream("PDFInfo.properties"); +// try { +// properties.load(is); +// } catch (IOException e) { +// // TODO Auto-generated catch block +// e.printStackTrace(); +// MessageBox.post("PDFInfo.properties ȡ쳣"+e.getMessage(), "", MessageBox.ERROR); +// } +// waitPdf = Integer.valueOf(properties.getProperty("WAITPDF")); +// } +// +// /** +// * ȴļ +// * @param file +// */ +// public void second(File file) { +// if (!file.exists()) { +// System.out.println("second"); +// try { +// Thread.sleep(200); +// second(file); +// } catch (InterruptedException e) { +// e.printStackTrace(); +// MessageBox.post("쳣"+e.getMessage(), "", MessageBox.ERROR); +// } +// } else { +// System.out.println("cunzai"); +// try { +// Thread.sleep(200); +// } catch (InterruptedException e) { +// e.printStackTrace(); +// MessageBox.post("쳣"+e.getMessage(), "", MessageBox.ERROR); +// } +// } +// } +// +// +// /** +// * xmlӳļ +// * @param caxaDataset +// * @param tcp +// * @param xmlName +// * @return +// * @throws Exception +// */ +// public boolean hx_SetCAXAFile2(TCComponentDataset caxaDataset, TCPreferenceService tcp, String xmlName) +// throws Exception { +// TCComponentItemRevision rev = (TCComponentItemRevision) caxaDataset.getReferenceProperty("item_revision"); +// TCComponentForm revForm = (TCComponentForm) (rev.getReferenceListProperty("IMAN_master_form_rev"))[0]; +// TCComponentItem item = rev.getItem(); +// if (caxaDataset == null || rev == null || revForm == null || rev == null || item == null || refValues == null +// || refValues.length == 0) { +// return false; +// } +// File file = new File(System.getenv("TEMP") + "\\" + xmlName + ".xml"); +// Map valueMap = new HashMap(); +// String propName; +// int index; +// for (String refValue : refValues) { +// String[] valueS = refValue.split("="); +// +// String value = null; +// if (valueS == null || valueS.length != 2) { +// continue; +// } +// String[] propNameS = valueS[1].split("\\."); +// if (propNameS == null || propNameS.length != 2) { +// continue; +// } +// index = valueS[0].indexOf(':'); +// propName = valueS[0].substring(index + 1).trim(); +// switch (propNameS[0].toUpperCase()) { +// case "ITEM": +// value = TcUtils.hx_GetProp(item, propNameS[1]); +// +// break; +// case "REV": +// value = TcUtils.hx_GetProp(rev, propNameS[1]); +// break; +// case "REVMASTER": +// value = TcUtils.hx_GetProp(revForm, propNameS[1]); +// break; +// case "ITEMMASTER": +// break; +// default: +// break; +// } +// if (value == null || (valueMap.containsKey(propName) && value.length() == 0)) +// continue; +// valueMap.put(propName, value); +// } +// if (valueMap.size() != 0) { +// writeDoc(valueMap, file, xmlName); +// return true; +// }else { +// return false; +// } +// +// +// } +// +// +// +// +// +// public void replaceOrcreate(TCComponentDataset arg0, TCComponentItemRevision rev, TCSession session, +// String addPdfPath) throws Exception { +// // жϰ汾pdfݼƺcaxaͬо滻ûо½ +// TCComponentDataset dataset = null; +// TCComponent[] datasets = (TCComponent[]) rev.getTCProperty("IMAN_specification").getReferenceValueArray(); +//// datasets=(TCComponent[]) tempRev.getTCProperty("TC_Attaches").getReferenceValueArray(); +// String pdfName = ""; +// String caxaName = ""; +// for (int i = 0; i < datasets.length; i++) { +// if (datasets[i].getProperty("object_type").equals("PDF")) { +// pdfName = datasets[i].getProperty("object_name"); +// caxaName = arg0.getProperty("object_name"); +// if (pdfName.contains(".pdf") && caxaName.contains(".exb")) { +// pdfName = pdfName.substring(0, pdfName.lastIndexOf(".pdf")); +//// System.out.println(pdfName); +// caxaName = caxaName.substring(0, caxaName.lastIndexOf(".exb")); +//// System.out.println(pdfName); +// } +// } +// if (datasets[i].getProperty("object_type").equals("PDF") && caxaName.equals(pdfName)) { +// dataset = (TCComponentDataset) datasets[i]; +// } +// } +// +// if (dataset == null) { +// +// +// try { +// TCComponentDatasetType datasetType = (TCComponentDatasetType) session.getTypeComponent("Dataset"); +// dataset = datasetType.create(arg0.getProperty("object_name").replace(".exb", ".pdf"), "", "PDF"); +// rev.add("IMAN_specification", dataset); +// } catch (TCException e) { +// e.printStackTrace(); +// ChangeDbomUtil.setByPass(false); +// MessageBox.post("Teamcenter쳣"+e.getMessage(), "", MessageBox.ERROR); +// +// } +// +// } +// if (dataset == null) { +// MessageBox.post("ʧ", "", MessageBox.ERROR); +// } +// try { +// dataset.setFiles(new String[] { addPdfPath }, new String[] { "PDF_Reference" }); +// dataset.save(); +// arg0.setProperty("object_desc", "תʱ䣺"+new SimpleDateFormat("yyyy-MM-dd HH:mm").format(new Date())); +// } catch (Exception e) { +// TCComponentItemRevision tempRev = null; +// // õǰݼڰ汾 +// try { +// tempRev = (TCComponentItemRevision) dataset.getReferenceProperty("item_revision"); +// +// //String message = tempRev.getProperty("object_string") + "PDFͼֽӦ滻ʧܣϵԱ"; +// //޸⣺ֻģʽͼֽݼеıʾ쳣by Jimmy +// //ifError(tempRev, message); +// System.out.println("滻pdfʧܣ·"); +// } catch (TCException e1) { +// ChangeDbomUtil.setByPass(false); +// e1.printStackTrace(); +// MessageBox.post("Teamcenter쳣"+e1.getMessage(), "", MessageBox.ERROR); +// } +// } +// +// ChangeDbomUtil.setByPass(false); +// +// +// } +// +// +// +// +// +// +// /** +// * ȡPDFijߴͼƥ䲢ҪͼƬλ +// * +// * @param rectangle +// * @return +// */ +// public Float[] getSize(Rectangle rectangle) { +// Float[] sizef = new Float[2]; +// float toleft = rectangle.getLeft(); +// float tobottom = rectangle.getBottom(); +// float toright = rectangle.getRight(); +// float totop = rectangle.getTop(); +// +// JFomPdfBean bean = new JFomPdfBean(); +// bean.setH(toright - toleft);// PDFĿ +// bean.setW(totop - tobottom);// PDFĸ +// sizef[0] = bean.getH(); +// sizef[1] = bean.getW(); +// System.out.println("bean.getH------------>" + bean.getH()); +// System.out.println("bean.getW------------>" + bean.getW()); +// +// return sizef; +// } +// +// public String[] selectType(String Ax, String designType) { +// String[] type = null; +// switch (designType) { +// +// case "HX3_GYTRevision":// ͼ +// if (Ax.equals("A3")) { +// type = new String[1]; +// type[0] = Ax + "_GY"; +// } else if (Ax.equals("A2")) { +// type = new String[2]; +// type[0] = Ax + "_GY1"; +// type[1] = Ax + "_GY2"; +// } +// break; +// case "HX3_TYGY1Revision":// ͨù +// if (Ax.equals("A3")) { +// type = new String[1]; +// type[0] = Ax + "_TYGY"; +// } else if (Ax.equals("A2")) { +// type = new String[2]; +// type[0] = Ax + "_TYGY1"; +// type[1] = Ax + "_TYGY2"; +// } +// break; +// case "HX3_WXTRevision":// ƷͼЭӹͼHX3_WXTRevision ͼHX3_LJTRevision װͼHX3_ZPTRevision +// type = new String[1]; +// type[0] = Ax + "_PRODUCT"; +// break; +// case "HX3_DJTRevision":// ƷͼЭӹͼHX3_WXTRevision ͼHX3_LJTRevision +// // װͼHX3_ZPTRevisionͼͼHX3_DJTRevision +// type = new String[1]; +// type[0] = Ax + "_PRODUCT"; +// break; +// case "HX3_LJTRevision":// ƷͼЭӹͼHX3_WXTRevision ͼHX3_LJTRevision װͼHX3_ZPTRevision +// type = new String[1]; +// type[0] = Ax + "_PRODUCT"; +// break; +// case "HX3_ZPTRevision":// ƷͼЭӹͼHX3_WXTRevision ͼHX3_LJTRevision װͼHX3_ZPTRevision +// type = new String[1]; +// type[0] = Ax + "_PRODUCT"; +// break; +// case "HX3_GCGGTZDRevision":// ̸֪ͨ +// type = new String[1]; +// type[0] = Ax + "_ECN"; +// break; +// case "HX3_GZTRevision":// װͼ +// type = new String[2]; +// type[0] = Ax + "_GZT1"; +// type[1] = Ax + "_GZT2"; +// break; +// default: +// break; +// } +// +// return type; +// } +// +// public Image[] setPic(Image[] img, String[] sizeType, Properties properties, String markImagePath) +// throws BadElementException, MalformedURLException, IOException { +// // תString· +// img = new Image[sizeType.length]; +// for (int k = 0; k < sizeType.length; k++) { +// +// img[k] = Image.getInstance(markImagePath);// ȡͼƬʵ +// String str = properties.getProperty(sizeType[k]); +// if (str == null) { +// img[k].setAbsolutePosition(Float.valueOf(10), Float.valueOf(10)); +// } else { +// +// String[] values = str.split(","); +// img[k].setAbsolutePosition(Float.valueOf(values[0]), Float.valueOf(values[1]));// ˮӡ½ǵ +// } +// } +// return img; +// } +// +// public void addPdfMark(String InPdfFile, String temp, String[] markImagePath, String designType) throws Exception { +// boolean isModel = true; +// File pdffile = new File(temp); +// if (pdffile.exists()) { +// pdffile.delete(); +// } +// // +// Properties properties = new Properties(); +// InputStream is = null; +// is = getClass().getResourceAsStream("PDFInfo.properties"); +// properties.load(is); +// +// // PDF ļ +// PdfReader reader = new PdfReader(InPdfFile, "PDF".getBytes()); +// // PDF ļ +// PdfStamper stamp = new PdfStamper(reader, new FileOutputStream(temp)); +// // ˮӡͼƬ +// Image[] img = null; +// for (int j = 0; j < markImagePath.length; j++) { +//// img.scaleAbsolute(35, 20);// ͼƬ +//// float imgW = img.getScaledWidth();// ȡͼƬĿ +//// float imgH = img.getScaledHeight();// ȡͼƬĸ߶ +// // ȡPDFҳ +// int pageSize = reader.getNumberOfPages();// ȡļҳ +// for (int i = 1; i <= pageSize; i++) { +// Rectangle rectangle = reader.getPageSize(i); +// Float[] fposition = getSize(rectangle); +// System.out.println("fposition[0]=======" + fposition[0]); +// System.out.println("fposition[1]=======" + fposition[1]); +// boolean isSizeOk = false; +// String[] sizeType = null; +// // ˮӡIJλA0 +// if ((fposition[0] > 3300 && fposition[1] > 2300)) { +// isSizeOk = true; +// // ͨpdfڵİ汾ж +// System.out.println("ˮӡIJλA0"); +// sizeType = selectType("A0", designType); +// +// } +// // TODO ˮӡIJλA1 +// if ((fposition[0] > 2300 && fposition[1] > 1600) && isSizeOk == false) { +// isSizeOk = true; +// System.out.println("ˮӡIJλA1"); +// sizeType = selectType("A1", designType); +// } +// +// // TODO ˮӡIJλA2 +// if ((fposition[1] > 1100 && fposition[0] > 1600) && isSizeOk == false) { +// isSizeOk = true; +// System.out.println("ˮӡIJλA2"); +// sizeType = selectType("A2", designType); +// } +// // TODO ˮӡIJλA2 +// if ((fposition[0] > 1100 && fposition[1] > 1600) && isSizeOk == false) { +// isSizeOk = true; +// System.out.println("ˮӡIJλA2_GY"); +// sizeType = selectType("A2", designType); +// } +// // TODO ˮӡIJλA3 +// if ((fposition[0] > 1100 && fposition[1] > 800) && isSizeOk == false) { +// isSizeOk = true; +// System.out.println("ˮӡIJλA3"); +// sizeType = selectType("A3", designType); +// } +// +// // TODO ˮӡIJλA3 +// if ((fposition[1] > 1100 && fposition[0] > 800) && isSizeOk == false) { +// isSizeOk = true; +// System.out.println("ˮӡIJλA3H"); +// sizeType = selectType("A3H", designType); +// } +// +// // TODO ˮӡIJλA4 +// if ((fposition[1] > 800 && fposition[0] > 500) && isSizeOk == false) { +// isSizeOk = true; +// System.out.println("ˮӡIJλA4"); +// sizeType = selectType("A4", designType); +// } +// +// // ˮӡIJλA4 +// if ((fposition[0] > 800 && fposition[1] > 500) && isSizeOk == false) { +// isSizeOk = true; +// System.out.println("ˮӡIJλA4H "); +// sizeType = selectType("A4H", designType); +// } +// if (sizeType != null) { +// +// img = setPic(img, sizeType, properties, markImagePath[j]); +// } +// if (img == null || sizeType == null) { +// img = new Image[1]; +// img[0] = Image.getInstance(markImagePath[j]);// ȡͼƬʵ +// img[0].setAbsolutePosition(Float.valueOf(10), Float.valueOf(10)); +// /* +// * isModel=false; continue; +// */ +// } +// // PDFļвˮӡ +// PdfContentByte under = stamp.getOverContent(i);// stamp.getUnderContent(i); +// PdfGState gs = new PdfGState(); +// gs.setFillOpacity(1.0f);// ͸Ϊ0.2 +// under.setGState(gs); +// for (int k = 0; k < img.length; k++) { +// under.addImage(img[k]); +// +// } +// } +// } +// stamp.close();// ر +// reader.close();// ر +// File tempfile = new File(InPdfFile); +// if (tempfile.exists() && isModel == true) { +// // ɾԭļ +// tempfile.delete(); +// } +// +// } +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// /** +// * жݼǷΪģļ +// * @param tccomponentdataset +// * @return +// */ +// public int judgeModel(TCComponentDataset tccomponentdataset) { +// // жDzľļǾ˳ +// long start1 = System.currentTimeMillis(); +// try { +// TCComponentItemRevision rev = (TCComponentItemRevision) tccomponentdataset +// .getReferenceProperty("item_revision"); +// if (rev != null) { +// TCComponentItem item = rev.getItem(); +// AIFComponentContext[] folders = item.whereReferenced(); +// if (folders.length == 1) { +// if (folders[0].getComponent() instanceof TCComponentFolder) { +// +// TCComponentFolder folder = (TCComponentFolder) folders[0].getComponent(); +// AIFComponentContext[] folders2 = folder.whereReferenced(); +// if (folders2.length == 1) { +// if (folders2[0].getComponent() instanceof TCComponentFolder) { +// TCComponentFolder folder2 = (TCComponentFolder) folders2[0].getComponent(); +// String name = folder2.getProperty("object_name"); +// if (name.equals("ͼֽģ")) { +// return 1; +// } +// } +// } +// } +// } +// } else { +// return 0; +// } +// } catch (TCException e1) { +// e1.printStackTrace(); +// MessageBox.post("Teamcenter쳣"+e1.getMessage(), "", MessageBox.ERROR); +// } // +// long now1 = System.currentTimeMillis(); +// float time1 = (now1 - start1) / 1000.00f; +// System.out.println("judgeModelѺʱ" + time1 + ""); +// return 0; +// } +// +// +// +// +// +// /** +// * ЭCAXAݼǰ +// * +// * @param caxaDataset +// * @throws Exception +// */ +// public void hx_SetCAXAFileOrigin(TCComponentDataset caxaDataset, TCPreferenceService tcp, String type,boolean openDirect) +// throws Exception { +// long start1 = System.currentTimeMillis(); +// +// // õǰݼڰ汾󡢰汾 +// TCComponentItemRevision rev = (TCComponentItemRevision) caxaDataset.getReferenceProperty("item_revision"); +// System.out.println("-----------" + rev.getProperty("object_string")); +// TCComponentForm revForm = (TCComponentForm) (rev.getReferenceListProperty("IMAN_master_form_rev"))[0]; +// TCComponentItem item = rev.getItem(); +// // ȡcaxaļ +// File file = TcUtils.getCaxaDatasetFile(caxaDataset); +// if (rev == null || revForm == null || item == null || file == null || refValues == null +// || refValues.length == 0) { +// return; +// } +// +// Map valueMap = getValueMap(item, rev, revForm, openDirect); +// if (valueMap.size() != 0) { +// writeDoc(valueMap, file,null); +// } +// long now1 = System.currentTimeMillis(); +// float time1 = (now1 - start1) / 1000.00f; +// System.out.println("hx_SetCAXAFileѺʱ" + time1 + ""); +// } +// +// +// +// private Map getValueMap(TCComponent item,TCComponent rev,TCComponent revForm,boolean openDirect ) throws TCException { +// Map valueMap = new HashMap(); +// StringBuffer infoSB = new StringBuffer(); +// String propName; +// int index; +// for (String refValue : refValues) { +// String[] valueS = refValue.split("="); +// +// String value = null; +// if (valueS == null || valueS.length != 2) { +// continue; +// } +// String[] propNameS = valueS[1].split("\\."); +// if (propNameS == null || propNameS.length != 2) { +// continue; +// } +// index = valueS[0].indexOf(':'); +// propName = valueS[0].substring(index + 1).trim(); +// switch (propNameS[0].toUpperCase()) { +// case "ITEM": +// value = TcUtils.hx_GetProp(item, propNameS[1]); +// break; +// case "REV": +// value = TcUtils.hx_GetProp(rev, propNameS[1]); +// break; +// case "REVMASTER": +// value = TcUtils.hx_GetProp(revForm, propNameS[1]); +// break; +// case "ITEMMASTER": +// break; +// default: +// break; +// } +// if (value == null || (valueMap.containsKey(propName) && value.length() == 0)) +// continue; +// valueMap.put(propName, value); +// infoSB.append(valueS[0]).append("=").append(value).append("|"); +// } +// Map ecnValueMap = getECNValueMap(rev); +// for(String ecnValueSet :ecnValueMap.keySet()) { +// valueMap.put(ecnValueSet, ecnValueMap.get(ecnValueSet)); +// } +// +// valueMap.put("Ƿǩ",openDirect==true?"":""); +// System.out.println("valueMap:" + valueMap); +// return valueMap; +// } +// +// +// +// /** +// * дӳļ +// * @param valueMap ӳԼ +// * @param file xmlӳļ +// * @throws Exception +// */ +// private void writeDoc(Map valueMap,File file,String caxaFileName) throws Exception { +// SAXReader reader = new SAXReader(); +// Document doc = reader.read(new File(exePath + "sign.xml")); +// Element root = doc.getRootElement(); +// Element title = root.element("SignInfo").element("Title"); +// Element files = root.element("SignInfo").element("Files").element("File"); +// if(caxaFileName != null) { +// files.attribute("Path").setValue(FTPUtils.ftpPath +"\\"+ caxaFileName + ".exb"); +// } +// Element e; +// Iterator it = title.elementIterator(); +// while (it.hasNext()) { +// e = (Element) it.next(); +// String val = valueMap.get(e.attribute("Name").getValue()); +// if(debug)System.out.println("name:" + e.attribute("Name").getValue()); +// if(debug)System.out.println("val:" + val); +// if (val != null) +// e.attribute("Value").setValue(val); +// } +// PrintWriter pw = new PrintWriter(file, "UTF-8"); +// doc.write(pw); +// pw.close(); +// System.out.println("222"); +// +// } +// +// +// +// +// +// public void openCad() { +// +// String path = this.getClass().getProtectionDomain().getCodeSource().getLocation().getPath(); +//// System.out.println("·-----------------"+path); +// String exePath = path.substring(1, path.indexOf("com.connor.signoff")).replace("/", "\\"); +// exePath = exePath + "CADregedit.bat"; +// File file = new File(exePath); +// +// if (file != null && file.exists()) { +// System.out.println("ִдCAXAɹע޸:"+ exePath); +// Runtime rn = Runtime.getRuntime(); +// Process p = null; +// try { +// System.out.println("CALL CMD:" + exePath); +// p = rn.exec("cmd /c \"" + exePath + "\""); +// p.waitFor(); +// //滻ΪԱ +// //String command = "cmd /c start /wait runas /user:Administrator \"cmd /c \"" + exePath + "\"\""; +// //Runtime.getRuntime().exec(command); +// } catch (Exception e) { +// e.printStackTrace(); +// System.out.println("Error exec!"); +// } +// } else { +// System.out.println("" + exePath + "ļ"); +// } +// +// +// } + + + +} diff --git a/src/com/connor/signoff/soa/handler/PDFInfo.properties b/src/com/connor/signoff/soa/handler/PDFInfo.properties new file mode 100644 index 0000000..9f0f6ca --- /dev/null +++ b/src/com/connor/signoff/soa/handler/PDFInfo.properties @@ -0,0 +1,27 @@ +#A4 +A4_PRODUCT=82,747 +A4H_PRODUCT=60,500 +#A3 +#A3=37,753 +A3_PRODUCT=75,750 +A3H_PRODUCT=100,1100 +A3_ECN=62,762 +A3_GY=31,759 +A3_TYGY=29,759 +#A3=43,737 +#A2 +A2_PRODUCT=43,1077 +A2_GY1=54,1601 +A2_GY2=54,725 +A2_GZT1=12,706 +A2_GZT2=1035,979 +A2_TYGY1=54,1601 +A2_TYGY2=54,726 +#A1 +A1_PRODUCT=150,1580 +#A0 +A0_PRODUCT=150,2241 +A0_GZT1=12,2151 +A0_GZT2=1908,2151 + +WAITPDF=120 \ No newline at end of file diff --git a/src/com/connor/signoff/soa/handler/Query.java b/src/com/connor/signoff/soa/handler/Query.java new file mode 100644 index 0000000..8a1eda4 --- /dev/null +++ b/src/com/connor/signoff/soa/handler/Query.java @@ -0,0 +1,136 @@ +//================================================== +// +// Copyright 2012 Siemens Product Lifecycle Management Software Inc. All Rights Reserved. +// +//================================================== + +package com.connor.signoff.soa.handler; + + + +import com.teamcenter.clientx.AppXSession; +import com.teamcenter.schemas.soa._2006_03.exceptions.ServiceException; + +//Include the Saved Query Service Interface +import com.teamcenter.services.strong.query.SavedQueryService; + +// Input and output structures for the service operations +// Note: the different namespace from the service interface +import com.teamcenter.services.strong.query._2006_03.SavedQuery.GetSavedQueriesResponse; +import com.teamcenter.services.strong.query._2007_09.SavedQuery.SavedQueriesResponse; +import com.teamcenter.services.strong.query._2008_06.SavedQuery.QueryInput; +import com.teamcenter.services.strong.query._2007_09.SavedQuery.QueryResults; + +import com.teamcenter.services.strong.core.DataManagementService; + +import com.teamcenter.soa.client.model.ModelObject; +import com.teamcenter.soa.client.model.ServiceData; +import com.teamcenter.soa.client.model.strong.ImanQuery; + + +public class Query +{ + + /** + * Perform a simple query of the database + * + */ + public void queryItems() + { + + ImanQuery query = null; + + // Get the service stub. + SavedQueryService queryService = SavedQueryService.getService(AppXSession.getConnection()); + DataManagementService dmService= DataManagementService.getService(AppXSession.getConnection()); + try + { + + // ***************************** + // Execute the service operation + // ***************************** + GetSavedQueriesResponse savedQueries = queryService.getSavedQueries(); + + + if (savedQueries.queries.length == 0) + { + System.out.println("There are no saved queries in the system."); + return; + } + + // Find one called 'Item Name' + for (int i = 0; i < savedQueries.queries.length; i++) + { + + if (savedQueries.queries[i].name.equals("Item Name")) + { + query = savedQueries.queries[i].query; + break; + } + } + } + catch (ServiceException e) + { + System.out.println("GetSavedQueries service request failed."); + System.out.println(e.getMessage()); + return; + } + + if (query == null) + { + System.out.println("There is not an 'Item Name' query."); + return; + } + + try + { + //Search for all Items, returning a maximum of 25 objects + QueryInput savedQueryInput[] = new QueryInput[1]; + savedQueryInput[0] = new QueryInput(); + savedQueryInput[0].query = query; + savedQueryInput[0].maxNumToReturn = 25; + savedQueryInput[0].limitList = new ModelObject[0]; + savedQueryInput[0].entries = new String[]{"Item Name" }; + savedQueryInput[0].values = new String[1]; + savedQueryInput[0].values[0] = "*"; + + + //***************************** + //Execute the service operation + //***************************** + SavedQueriesResponse savedQueryResult = queryService.executeSavedQueries(savedQueryInput); + QueryResults found = savedQueryResult.arrayOfResults[0]; + + System.out.println(""); + System.out.println("Found Items:"); + + // Page through the results 10 at a time + for(int i=0; i< found.objectUIDS.length; i+=10) + { + int pageSize = (i+10 bomMap = null; + +// // ļӳ +// public static Map fileTypeMap = new HashMap(); +// static { +// fileTypeMap.put("xlsx", new String[] { "MSExcelX", "excel" }); +// fileTypeMap.put("xls", new String[] { "MSExcel", "excel" }); +// fileTypeMap.put("xlsm", new String[] { "MSExcelX", "excel" }); +// fileTypeMap.put("csv", new String[] { "MSExcelX", "excel" }); +// fileTypeMap.put("txt", new String[] { "Text", "Text" }); +// fileTypeMap.put("docx", new String[] { "MSWordX", "word" }); +// fileTypeMap.put("doc", new String[] { "MSWord", "word" }); +// fileTypeMap.put("pptx", new String[] { "MSPowerPointX", "powerpoint" }); +// fileTypeMap.put("ppt", new String[] { "MSPowerPoint", "powerpoint" }); +// fileTypeMap.put("pdf", new String[] { "PDF", "PDF_Reference" }); +// fileTypeMap.put("jpg", new String[] { "Image", "Image" }); +// fileTypeMap.put("jpeg", new String[] { "Image", "Image" }); +// fileTypeMap.put("png", new String[] { "Image", "Image" }); +// fileTypeMap.put("gif", new String[] { "Image", "Image" }); +// fileTypeMap.put("dwg", new String[] { "ACADDWG", "DWG" }); +// } +// +// public static String transRefId(String refId) { +// return refId.replaceAll("[|/\\:\\*\\?<>\\\\\"]", "_"); +// } +// +// public static void main(String[] args) { +// Float usercount = Float.parseFloat("3.83"); +// System.out.println(usercount); +// +// } +// +// // ItemID +// public static TCComponentItem findItemByItemId(String itemId, TCSession session) { +// TCComponentItem myQueryedItem = null; +// +// try { +// TCComponentItemType itemType = (TCComponentItemType) session.getTypeComponent("Item"); +// myQueryedItem = itemType.find(itemId); +// if (myQueryedItem != null) +// return myQueryedItem; +// +// } catch (TCException e) { +// e.printStackTrace(); +// } +// return null; +// } +// +// +// // ItemIDѯxxx;xxxx;yyyy +// public static TCComponentItem[] findItemByItemIds(String itemIds, TCSession session) { +// TCComponentItem[] myQueryedItem = null; +// +// try { +// TCComponentItemType itemType = (TCComponentItemType) session.getTypeComponent("Item"); +// myQueryedItem = itemType.findItems(itemIds); +// if (myQueryedItem != null) +// return myQueryedItem; +// +// } catch (TCException e) { +// e.printStackTrace(); +// } +// return null; +// } +// +// public static TCComponentItemRevision findItemRevisonByItemIdAndRevision(String itemId, String revNo, TCSession session) { +// try { +// TCComponentItem item = findItemByItemId(itemId, session); +// if (item == null) { +// return null; +// } +// return item.getLatestItemRevision().findRevision(revNo); +// } catch (TCException e) { +// e.printStackTrace(); +// } +// return null; +// } +// +// /** +// * tccomponent´ڴTCcomponent +// * @param tcComponent +// */ +//// public static void openComponent(TCComponent tcComponent) { +//// IApplicationDefService appDefService = AifrcpPlugin.getApplicationDefService(); +//// ApplicationDef appDef = appDefService.getApplicationDef("com.teamcenter.rac.ui.perspectives.navigatorPerspective"); +//// +//// if (appDef == null) { +//// appDef = appDefService.getApplicationDefByPerspectiveId("com.teamcenter.rac.ui.perspectives.navigatorPerspective"); +//// } +//// TCComponent[] comps = new TCComponent[] { tcComponent }; +//// appDef.openApplication(comps); +//// } +// public static void openComponent(TCComponent tcComponent) { +// IPerspectiveDefService iperspectivedefservice = (IPerspectiveDefService) OSGIUtil.getService(AifrcpPlugin.getDefault(), IPerspectiveDefService.class); +// String s = "com.teamcenter.rac.ui.perspectives.navigatorPerspective"; +// IPerspectiveDef iperspectivedef = iperspectivedefservice.findByLegacyAppId(s); +// TCComponent[] comps = new TCComponent[] { tcComponent }; +// iperspectivedef.openPerspective(comps); +// } +// +// +// public static void test(TCComponent tcComponent){ +// IPerspectiveDefService iperspectivedefservice = (IPerspectiveDefService) OSGIUtil.getService(AifrcpPlugin.getDefault(), IPerspectiveDefService.class); +// String s = "com.teamcenter.rac.ui.views.ActiveWorkspaceView.newView"; +// IPerspectiveDef iperspectivedef = iperspectivedefservice.findByLegacyAppId(s); +// TCComponent[] comps = new TCComponent[] { tcComponent }; +// iperspectivedef.openPerspective(comps); +// } +// +// /** +// * tccomponent´ڴTCcomponent +// * @param tcComponent +// */ +//// public static void openComponentToStructuerManager(TCComponent tcComponent) { +//// IApplicationDefService appDefService = AifrcpPlugin.getApplicationDefService(); +//// ApplicationDef appDef = appDefService.getApplicationDef("com.teamcenter.rac.pse.PSEApplication"); +//// TCComponent[] comps = new TCComponent[] { tcComponent }; +//// appDef.openApplication(comps); +//// } +// public static void openComponentToStructuerManager(TCComponent tcComponent) { +// IPerspectiveDefService iperspectivedefservice = (IPerspectiveDefService) OSGIUtil.getService(AifrcpPlugin.getDefault(), IPerspectiveDefService.class); +// String s = "com.teamcenter.rac.pse.PSEApplication"; +// IPerspectiveDef iperspectivedef = iperspectivedefservice.findByLegacyAppId(s); +// TCComponent[] comps = new TCComponent[] { tcComponent }; +// iperspectivedef.openPerspective(comps); +// } +// +// public static String printExecption(Throwable e) { +// StringBuffer output = new StringBuffer(); +// e.printStackTrace(); +// StackTraceElement[] stes = e.getStackTrace(); +// output.append("쳣:" + e.toString()); +// for (int i = 0; i < stes.length; i++) { +// StackTraceElement stackTraceElement = stes[i]; +// output.append("at " + stackTraceElement.getClassName() + "." + stackTraceElement.getMethodName() + "(" + stackTraceElement.getFileName() + ":" +// + stackTraceElement.getLineNumber() + ")"); +// } +// if (output.length() > 4000) { +// return output.substring(0, 4000); +// } +// return output.toString(); +// } +// +// public static void printTccompent(TCComponent tcComponent) { +// System.out.println("printf ......tccomponet.........begin"); +// System.out.println("class " + tcComponent.getClass()); +// try { +// if (tcComponent == null && tcComponent.getPropertyNames().length == 0) { +// return; +// } +// String[] values = tcComponent.getProperties(tcComponent.getPropertyNames()); +// int i = 0; +// for(String property : tcComponent.getPropertyNames()){ +// System.out.print("key: " + property); +// System.out.print(values[i]); +// i++; +// } +//// Iterator it = tcComponent.getProperties().keySet().iterator(); +//// while (it.hasNext()) { +//// String key = (String) it.next(); +//// System.out.print("key: " + key); +//// System.out.print(tcComponent.getProperties().get(key)); +//// } +// System.out.println(); +// } catch (TCException e) { +// e.printStackTrace(); +// } +// System.out.println("printf ......tccomponet.........end"); +// } +// +// public static TCComponentBOMViewRevision getBomViewRevision(TCComponentItemRevision componentItemRevision) throws Exception { +// AIFComponentContext[] contexts = componentItemRevision.getChildren(); +// for (AIFComponentContext componentContext : contexts) { +// String objecttype = componentContext.getComponent().getType();//getProperty("object_type"); +// if (objecttype.equals("BOMView Revision")) { +// return (TCComponentBOMViewRevision) componentContext.getComponent(); +// } +// } +// return null; +// } +// +// public static String[] getTCPreferenceArray(String key, TCSession session,int tcScope) { +// TCPreferenceService tcprefsvr = session.getPreferenceService(); +// if(tcScope == -1) { +// tcScope = TCPreferenceService.TC_preference_site; +// } +// return tcprefsvr.getStringArray(tcScope, key); +// } +// +// public static String getTCPreference(String key, TCSession session ,int tcScope) { +// TCPreferenceService tcprefsvr = session.getPreferenceService(); +// if(tcScope == -1) { +// tcScope = TCPreferenceService.TC_preference_site; +// } +// return tcprefsvr.getString(tcScope, key); +// } +// +// /** +// * ôλĻм +// * +// * @param display +// * 豸 +// * @param shell +// * ҪλõĴڶ +// */ +// public static void center(Display display, Shell shell) { +// Rectangle bounds = display.getPrimaryMonitor().getBounds(); +// Rectangle rect = shell.getBounds(); +// int x = bounds.x + (bounds.width - rect.width) / 2; +// int y = bounds.y + (bounds.height - rect.height) / 2; +// shell.setLocation(x, y); +// } +// +// /** +// * "TC_Generic_Architecture","ArchitectureRevision" +// * +// * @param comp +// * @param relation +// * @param type +// * @return +// * @throws TCException +// */ +// public static InterfaceAIFComponent getChildByRelation(TCComponent comp, String relation, String type) throws TCException { +// AIFComponentContext[] components = comp.getChildren(relation); +// for (AIFComponentContext componentContext : components) { +// if (type.equals(componentContext.getComponent().getType())) { +// return componentContext.getComponent(); +// } +// } +// return null; +// } +// +// /** +// * "TC_Generic_Architecture","ArchitectureRevision" +// * +// * @param comp +// * @param relation +// * @param type +// * @return +// * @throws Exception +// */ +// public static InterfaceAIFComponent getChildByRelationAndName(TCComponent comp, String relation, String type, String name) throws Exception { +// AIFComponentContext[] components = comp.getChildren(relation); +// for (AIFComponentContext componentContext : components) { +// if (type.equals(componentContext.getComponent().getType()) && name.equalsIgnoreCase(componentContext.getComponent().getProperty("object_name"))) { +// return componentContext.getComponent(); +// } +// } +// return null; +// } +// +// public static String getTCConfigRuleName(TCSession session) { +// TCPreferenceService tcprefsvr = session.getPreferenceService(); +// String TCConfigRuleName = ""; +// try { +// // TC_Output_BOM_RevConfig +// // TC_SendToSRM_Rev_Rule_OLD +// TCConfigRuleName = tcprefsvr.getString(TCPreferenceService.TC_preference_site, "TC_Output_BOM_RevConfig"); +// } catch (Exception e) { +// e.printStackTrace(); +// } +// return TCConfigRuleName; +// } +// +// public static String getTCConfigNewRuleName(TCSession session) { +// TCPreferenceService tcprefsvr = session.getPreferenceService(); +// String TCConfigRuleName = ""; +// try { +// // TC_Output_BOM_RevConfig +// // TC_SendToSRM_Rev_Rule_OLD +// TCConfigRuleName = tcprefsvr.getString(TCPreferenceService.TC_preference_site, "TC_SendToSRM_Rev_Rule_NEW"); +// } catch (Exception e) { +// e.printStackTrace(); +// } +// return TCConfigRuleName; +// } +// +// public static String getTCConfigOldRuleName(TCSession session) { +// TCPreferenceService tcprefsvr = session.getPreferenceService(); +// String TCConfigRuleName = ""; +// try { +// // TC_Output_BOM_RevConfig +// // TC_SendToSRM_Rev_Rule_OLD +// TCConfigRuleName = tcprefsvr.getString(TCPreferenceService.TC_preference_site, "TC_SendToSRM_Rev_Rule_OLD"); +// } catch (Exception e) { +// e.printStackTrace(); +// } +// return TCConfigRuleName; +// } +// +// public static String readTxt(String txtPath) { +// StringBuffer sb = new StringBuffer(); +// try { +// BufferedReader in = new BufferedReader(new FileReader(txtPath)); +// String line = null; +// while ((line = in.readLine()) != null) { +// sb.append(line); +// } +// return sb.toString(); +// } catch (Exception e) { +// e.printStackTrace(); +// return null; +// } +// } +// +// +// /** +// * ǩ +// * @throws TCException +// */ +// public static void signin(TCSession session, TCComponent component) throws TCException{ +// TCReservationService tcreservationservice = session.getReservationService(); +// if(component != null && tcreservationservice.isReserved(component)){ +// tcreservationservice.unreserve(component); +// } +// } +// +// +// +// /** +// * +// * @param itemID id +// * @param itemName +// * @param itemType_name +// * @param Revision 汾 +// * @param desc +// * @param compObj λãΪ򴴽newStaff£ +// * @return +// */ +// public static TCComponentItem createItem(String itemID, String itemName, String itemType_name, String Revision, String desc, InterfaceAIFComponent compObj, Shell shell) { +// AbstractAIFSession mysession = RACUIUtil.getTCSession(); +// TCSession imansession = (TCSession) mysession; +// String[] EntryVal = new String[1]; +// EntryVal[0] = itemID; +// if (mysession instanceof TCSession) { +// try { +// TCComponentItem myQueryedItem = null; +// TCComponentItemType itemType = (TCComponentItemType) imansession.getTypeComponent("Item"); +// if (itemName == null || itemName == "") +// itemName = itemID; +// myQueryedItem = itemType.create(itemID, Revision, itemType_name, itemName, desc, null); +// if (compObj instanceof TCComponentFolder) { +// TCComponent comp = (TCComponent) compObj; +// comp.add("contents", myQueryedItem); +// return myQueryedItem; +// } else if (compObj instanceof TCComponentBOMLine) { +// TCComponentBOMLine compbomline = (TCComponentBOMLine) compObj; +// compbomline.add(myQueryedItem, ""); +// } else { +// imansession.getUser().getNewStuffFolder().add("contents", myQueryedItem); +// return myQueryedItem; +// } +// +// return myQueryedItem; +// } catch (TCException e) { +// if(shell != null){ +// MessageBox.post(shell, "Itemʱ\nʾ:" + e.toString(), "ʾ", MessageBox.INFORMATION); +// }else{ +// MessageBox.post("Itemʱ\nʾ:" + e.toString(), "ʾ", MessageBox.INFORMATION); +// } +// e.printStackTrace(); +// return null; +// } +// } +// return null; +// } +// +// /** +// * ȡѡ +// */ +// public static InterfaceAIFComponent getSelectedObj(){ +// AbstractAIFUIApplication application = AIFUtility.getCurrentApplication(); +// InterfaceAIFComponent selectObj = application.getTargetComponent(); +// return selectObj; +// } +// +// /** +// * ȡѡ +// */ +// public static InterfaceAIFComponent[] getSelectedObjs(){ +// AbstractAIFUIApplication application = AIFUtility.getCurrentApplication(); +// InterfaceAIFComponent[] selectObj = application.getTargetComponents(); +// return selectObj; +// } +// +// /** +// * ȡѡеITEMѡж󷵻null +// */ +// public static TCComponentItem getSelectedItem(){ +// InterfaceAIFComponent selectObj = getSelectedObj(); +// if(selectObj == null){ +// return null; +// } +// if(selectObj instanceof TCComponentItem){ +// TCComponentItem item = (TCComponentItem) selectObj; +// return item; +// }else{ +// MessageBox.post("ѡеĶItem", "", MessageBox.ERROR); +// return null; +// } +// } +// +// /** +// * ȡѡеItemRevisionѡж󷵻null +// */ +// public static TCComponentItemRevision getSelectedItemRevision(){ +// InterfaceAIFComponent selectObj = getSelectedObj(); +// if(selectObj == null){ +// return null; +// } +// if(selectObj instanceof TCComponentItemRevision){ +// TCComponentItemRevision itemRev = (TCComponentItemRevision) selectObj; +// return itemRev; +// }else{ +// MessageBox.post("ѡеĶItemRevision", "", MessageBox.ERROR); +// return null; +// } +// } +// +// /** +// * ȡѡеBomlineѡж󷵻null +// */ +// public static TCComponentBOMLine getSelectedBomline(){ +// InterfaceAIFComponent selectObj = getSelectedObj(); +// if(selectObj == null){ +// return null; +// } +// if(selectObj instanceof TCComponentBOMLine){ +// TCComponentBOMLine bomline = (TCComponentBOMLine) selectObj; +// return bomline; +// }else{ +// MessageBox.post("ѡеĶBOMLine", "", MessageBox.ERROR); +// return null; +// } +// } +// +// /** +// * ȡbomwindow,ͨbomwinȡbomlineǵclose +// * TCComponentBOMLine bomline = bomWin.setWindowTopLine(null, newItem, null, null); +// * @throws TCException +// */ +// public static TCComponentBOMWindow getBomWin() throws TCException{ +// TCSession session = RACUIUtil.getTCSession(); +// TCComponentRevisionRuleType imancomponentrevisionruletype = (TCComponentRevisionRuleType) session.getTypeComponent("RevisionRule"); +// TCComponentRevisionRule imancomponentrevisionrule = imancomponentrevisionruletype.getDefaultRule(); +// TCComponentBOMWindowType imancomponentbomwindowtype = (TCComponentBOMWindowType) session.getTypeComponent("BOMWindow"); +// TCComponentBOMWindow bomWin = imancomponentbomwindowtype.create(imancomponentrevisionrule); +// return bomWin; +// } +// +// +// +// /** +// * ȡǰʱַ +// * @param type:TYPE_DATE_FORMATTYPE_DATE_TIME_FORMAT +// * @return ǰʱַĬϷyyyy-MM-dd HH:mm:ss +// */ +// public static String getDateString(String type){ +// if(type.equals(TYPE_DATE)){ +// return dateFormat.format(new Date()); +// }else if(type.equals(TYPE_DATE_TIME)){ +// return dateTimeFormat.format(new Date()); +// }else{ +// return dateTimeFormat.format(new Date()); +// } +// } +// +// /** +// * ͨ汾ȡ +// * @param revision +// * @return +// */ +// public static TCComponentForm getFormFromRev(TCComponentItemRevision revision){ +// TCComponentForm itemRevForm = null; +// if(revision != null){ +// AIFComponentContext[] itemRevForms = null; +// try { +// itemRevForms = revision.getChildren("IMAN_master_form_rev"); +// } catch (TCException e) { +// e.printStackTrace(); +// } +// if(itemRevForms.length > 0){ +// itemRevForm = (TCComponentForm) itemRevForms[0].getComponent(); +// } +// } +// return itemRevForm; +// } +// +// /** +// * ȡĿ¼ +// * @param pluginName +// * @throws IOException +// * @return ڸĿ¼ +// */ +// public static String getPluginRootPath(String pluginName) throws IOException{ +// String path =FileLocator.toFileURL(Platform.getBundle(pluginName).getEntry("")).getPath(); +// return path; +// } +// +// /** +// * ȡģݼľ· +// * @param type ͣexcel +// * @param refType ͹ϵMSExcelϵɲοϹϵ +// * @return +// * @throws TCException +// */ +// public static String getTcDateSetPath(String prefrenceName, String type, String refType, String groupName) throws TCException{ +// return getTcDateSet(prefrenceName, type, refType, groupName).getAbsolutePath(); +// } +// +// /** +// * ȡģݼ +// * @return +// * @throws TCException +// */ +// public static File getTcDateSet(String prefrenceName, String type, String refType, String groupName) throws TCException{ +// TCSession session = RACUIUtil.getTCSession(); +// //ȡݼ +// TCPreferenceService tcprefsvr = session.getPreferenceService(); +// String[] exportTemplate = tcprefsvr.getStringArray(TCPreferenceService.TC_preference_site, prefrenceName); +// String exportFileName = exportTemplate[0]; +// //ͨѯҵݼ +// TCComponentQueryType queryType = (TCComponentQueryType) session.getTypeComponent("ImanQuery"); +// TCComponentQuery orderByVehicleQuery = (TCComponentQuery) queryType.find("ݼ..."); +// TCQueryClause[] clauses = orderByVehicleQuery.describe(); +// +// String[] tmp_displayNames = new String[3]; +// String[] tmp_values = new String[3]; +// for (int i = 0; i < clauses.length; i++) { +// if (clauses[i].getAttributeName().equals("object_name")) { +// tmp_displayNames[0] = clauses[i].getUserEntryNameDisplay(); +// continue; +// } +// if (clauses[i].getAttributeName().equals("object_type")) { +// tmp_displayNames[1] = clauses[i].getUserEntryNameDisplay(); +// continue; +// } +// if (clauses[i].getAttributeName().equals("owning_group.name")){ +// tmp_displayNames[2] = clauses[i].getUserEntryNameDisplay(); +// continue; +// } +// } +// +// tmp_values[0] = exportFileName; +// tmp_values[1] = refType; +// tmp_values[2] = groupName; +// +// //ļʱ· +// TCComponent[] comps = orderByVehicleQuery.execute(tmp_displayNames, tmp_values); +// File[] file = null; +// for (TCComponent comp : comps) { +// TCComponentDataset dataSet = (TCComponentDataset) comp; +// file = dataSet.getFiles(type, System.getProperty("java.io.tmpdir")); +// } +// if(file == null || !file[0].exists()){ +// MessageBox.post("" + type + "ʱļʧ", "", MessageBox.ERROR); +// return null; +// }else{ +// return file[0]; +// } +// } +// +// /** +// * ǷѾݼ +// * @param dataSetType ݼͣMSExcel +// */ +// public static boolean checkHasDataSet(TCComponentItemRevision itemrev, String dataSetType){ +// TCComponent [] com = null; +// boolean hasDataSet = false; +// //ǷѾݼ +// try { +// com = itemrev.getRelatedComponents("IMAN_specification"); +// TCComponentDataset d = null; +// for (int n = 0; n < com.length; n++) { +// if(com[n].getClassType().equals("Dataset")){ +// d = (TCComponentDataset)com[n]; +// String name = d.getTCProperty("object_name").getStringValue(); +// String type = d.getTCProperty("object_type").getStringValue(); +// if(name.endsWith(itemrev.getItem().toDisplayString())&&type.equals(dataSetType)){ +// //MessageBox.post("Ѿݼֶɾɣ", "ʾ", MessageBox.INFORMATION); +// hasDataSet = true; +// } +// } +// } +// } catch (TCException e) { +// e.printStackTrace(); +// } +// return hasDataSet; +// } +// +// /** +// * ϴTCʱļItemrev +// * @param itemrev TC汾 +// * @param outputFilePathName ʱļ· +// * @param isDelFile Ƿɾʱļ +// * @param ref ϵĬIMAN_specification +// * @throws TCException +// */ +// public static void upload(TCComponentItemRevision itemrev, String outputFilePathName, boolean isDelFile, String ref) throws TCException{ +// if(StringUtils.isBlank(ref)){ +// ref = "IMAN_specification"; +// } +// TCComponentDatasetType datasetType; +// TCSession session = RACUIUtil.getTCSession(); +// TCComponentDataset dataset = null; +// datasetType = (TCComponentDatasetType)session.getTypeComponent("Dataset"); +// dataset =datasetType.create(itemrev.getItem().toDisplayString(), "", getDataSetTypeFromFileName(outputFilePathName)[0]); +// itemrev.add(ref, dataset); +// +// try { +// writeDateSet(dataset, outputFilePathName, itemrev, isDelFile); +// } catch (FileNotFoundException e) { +// e.printStackTrace(); +// } catch (IOException e) { +// e.printStackTrace(); +// } catch (Exception e) { +// e.printStackTrace(); +// } +// } +// +// /** +// * ͨļȫȡTCݼϵ +// * @return String[] 磺{ "MSExcelX", "excel" } +// */ +// public static String[] getDataSetTypeFromFileName(String fileName){ +// if(fileName.indexOf(".") < 0){ +// throw new RuntimeException("׺"); +// } +// String suffix = fileName.substring(fileName.lastIndexOf(".") + 1); +// if(!fileTypeMap.containsKey(suffix)){ +// throw new RuntimeException("׺" + suffix + "ϵ"); +// } +// return fileTypeMap.get(suffix); +// } +// +// /** +// * дݼ +// * @param dataset +// * @param outputFileName +// * @param itemrev +// * @param dataSetType +// * @param isDelFile +// * @throws IOException +// * @throws FileNotFoundException +// * @throws Exception +// * @throws TCException +// */ +// public static void writeDateSet(TCComponentDataset dataset, String outputFilePathName, TCComponentItemRevision itemrev, boolean isDelFile) throws IOException, FileNotFoundException, Exception, TCException { +// File output = new File(outputFilePathName); +// String dataSetType = getDataSetTypeFromFileName(outputFilePathName)[0]; +// String fileName = output.getName(); +// String path = output.getParent() + File.separator + itemrev.getItem().toDisplayString() + fileName.substring(fileName.lastIndexOf(".")); +// output.renameTo(new File(path)); +// File out = new File(path); +// String[] impfileNames = new String[]{out.getAbsolutePath()}; +// String[] nameRef = guessDatasetReferences(dataSetType, impfileNames); +// dataset.setFiles(impfileNames, nameRef); +// dataset.refresh(); +// dataset.lock(); +// dataset.save(); +// dataset.unlock(); +// if(output.exists() && isDelFile){ +// output.delete(); +// } +// } +// +// /** +// * ȡݼϵ +// * @param datasetType +// * @param files +// * @return +// * @throws Exception +// */ +// private static String[] guessDatasetReferences(String datasetType, String files[]) throws Exception { +// System.out.println((new StringBuilder("dataset type:")).append(datasetType).toString()); +// TCSession session = RACUIUtil.getTCSession(); +// TCComponentDatasetDefinitionType dsdefType = (TCComponentDatasetDefinitionType)session.getTypeComponent("DatasetType"); +// TCComponentDatasetDefinition dsdef = dsdefType.find(datasetType); +// NamedReferenceContext contexts[] = dsdef.getNamedReferenceContexts(); +// String refs[] = new String[files.length]; +// if (contexts.length == 1) { +// for (int i = 0; i < refs.length; i++) +// refs[i] = contexts[0].getNamedReference(); +// } +// if (contexts.length > 1) { +// for (int i = 0; i < files.length; i++) { +// String ext = ""; +// String fname = (new File(files[i])).getName(); +// int pos = fname.lastIndexOf('.'); +// if (pos >= 0) +// ext = fname.substring(pos); +// for (int j = 0; j < contexts.length; j++) { +// String pattern = contexts[j].getFileTemplate(); +// int pos1 = pattern.lastIndexOf('.'); +// if (pos1 < 0) +// continue; +// String re = pattern.substring(pos1); +// if (!ext.equalsIgnoreCase(re)) +// continue; +// refs[i] = contexts[j].getNamedReference(); +// break; +// } +// } +// } +// return refs; +// } +// /** +// * ȡTCݼ· +// * @param arg1 +// * @return +// */ +// public static String getCaxaFile(AEShell arg1) { +// File[] caxaFile = null; +// try { +// Method method = AEShell.class.getDeclaredMethod("askExportedFiles"); +// method.setAccessible(true); +// Object retData = method.invoke(arg1); +// caxaFile = (File[])retData; +// return caxaFile[0].getAbsolutePath(); +// } catch (SecurityException | IllegalAccessException | IllegalArgumentException | InvocationTargetException | NoSuchMethodException e) { +// // TODO Auto-generated catch block +// e.printStackTrace(); +// } +// return null; +// } +// /** +// * ȡTCݼ· +// * @param arg1 +// * @return +// */ +// public static File getCaxaFile(String arg1) { +// File finalCaxa = null; +// // bakȱļ +// File tempCacheFile = new File(arg1); +// File[] allFiles = tempCacheFile.listFiles(); +// for (int i = allFiles.length - 1; i >= 0; i--) { +// if (!allFiles[i].getAbsolutePath().toLowerCase().endsWith(".exb")) { +// allFiles[i].delete(); +// } else { +// finalCaxa = allFiles[i]; +// } +// } +// return finalCaxa; +// } +// public static String getFileName(TCComponentDataset tccomponentdataset) throws TCException { +// // TODO Auto-generated method stub +// TCComponent[] reList = tccomponentdataset.getRelatedComponents("ref_list"); +// if (reList == null || reList.length == 0) { +// return "0"; +// } else if (reList.length == 1) { +// return reList[0].getProperty("original_file_name"); +// } else if (reList.length > 1) { +// return "2"; +// } +// return null; +// } +// +// public static TCComponentItemRevision getReferenceRev(TCComponentDataset arg0) { +// int x = 0; +// TCComponentItemRevision targetrev = null; +// boolean workflow = false; +// try { +// AIFComponentContext[] revs = arg0.whereReferenced(); +// for (int i = 0; i < revs.length; i++) { +// if (revs[i].getComponent() instanceof TCComponentItemRevision) { +// TCComponentItemRevision rev = (TCComponentItemRevision) revs[i].getComponent(); +// TCComponent[] datasets = rev.getRelatedComponents("IMAN_specification"); +// for (int j = 0; j < datasets.length; j++) { +// if (datasets[j].getUid().equals(arg0.getUid())) { +// workflow = true; +// targetrev = rev; +// x++; +//// break; +// } +// } +// if (workflow == true) { +//// break; +// } +// +// } +// } +// } catch (TCException e1) { +// e1.printStackTrace(); +// } +// if (x > 1) { +// return null; +// } +// return targetrev; +// +// } +// +// /** +// * ļ +// * +// * @param comps +// * @return +// * @throws TCException +// * @throws IOException +// */ +// public static String downLoadCaxaFile(TCComponent comp,TCComponent rev,File finalCaxa) { +// if (comp == null) { +// return ""; +// } +// String tempPath = System.getenv("TEMP"); +// if (!tempPath.endsWith("\\")) { +// tempPath = tempPath + "\\"; +// } +// SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmssSSS"); +// String fileName = finalCaxa.getName(); +//// System.out.println("fileName:" + fileName); +// String fileDix = fileName.substring(fileName.lastIndexOf("."), fileName.length()); +// try { +// fileName = tempPath +rev.getProperty("item_id")+"-"+rev.getProperty("item_revision_id")+ sdf.format(new Date()) + fileDix; +// File dirFile = new File(fileName); +// FileUtility.copyFile(finalCaxa, dirFile); +// } catch (TCException e) { +// // TODO Auto-generated catch block +// e.printStackTrace(); +// } catch (IOException e) { +// // TODO Auto-generated catch block +// e.printStackTrace(); +// } +// +// return fileName; +// } +// +// /** +// * ȡTempµcaxaļ +// * @param caxaDataset caxaݼ +// * @return caxaļ +// * @throws TCException +// */ +// public static File getCaxaDatasetFile(TCComponentDataset caxaDataset) throws TCException { +// File file = null; +// String datasetName = null; +// TCComponentTcFile[] tcFiles = caxaDataset.getTcFiles(); +// // File file = null; +// if (tcFiles != null && tcFiles.length != 0) { +// +// datasetName = tcFiles[0].getStringProperty("object_string"); +// } +// datasetName = datasetName.substring(0, datasetName.lastIndexOf('.')); +// // ܴõļ.exbĺ׺Ҫ +// if (datasetName.endsWith(".exb") || datasetName.endsWith(".EXB")) { +// datasetName = datasetName.substring(0, datasetName.lastIndexOf('.')); +// } +// file = new File(System.getenv("TEMP") + "\\" + datasetName + ".xml"); +// if(file != null) { +// System.out.println("file:" + file); +// System.out.println(" datasetName =" + datasetName); +// // = caxaDataset.getStringProperty("object_name"); +// +// System.out.println("tcfile:" + tcFiles[0].getWorkingDir()); +// System.out.println("tcfile2:" + tcFiles[0]); +// } +// return file; +// } +// +// /** +// * ȡ +// * +// * @param comp +// * @return +// */ +// public static String hx_GetProp(TCComponent comp, String refInfo) { +// if (comp == null) { +// return null; +// } +// if (refInfo == null) { +// return null; +// } +// try { +// return comp.getProperty(refInfo); +// } catch (TCException e) { +// // TODO Auto-generated catch block +// e.printStackTrace(); +// } +// return ""; +// } + /** + * + * @param tccomponentdataset + * @param tccomponentdataset + * @return + */ + public static int checkPDF(Dataset tccomponentdataset) { + try { + if (tccomponentdataset.getTypeObject().getName().equals("PDF")) { + + if(tccomponentdataset == null){ + return 1; + } + DataManagementService dmService = DataManagementService.getService(AppXSession.getConnection()); + FileManagementUtility fmu = new FileManagementUtility(AppXSession.getConnection(), + null, + new String[] { "http://192.168.2.242:4544" }, + new String[] { "http://192.168.2.242:4544" }, + "D://TEMP//fcc_tmp"); + ModelObject[] objects = {tccomponentdataset}; + dmService.refreshObjects(objects); + dmService.getProperties(objects, new String[]{"ref_list"}); + objects = tccomponentdataset.get_ref_list(); + + GetFileResponse getFileResponse = fmu.getFiles(objects); + File[] fileinfovec = getFileResponse.getFiles(); +// outFile = fileinfovec[0]; + + // õļС + if (fileinfovec.length > 0) { + File file = fileinfovec[0]; + if (file.length() == 0) { +// MessageBox.post("ԭļǷٻߴСΪ0", "", MessageBox.INFORMATION); + return 1; + } + } + } + return 0; + } catch (Exception e1) { + + e1.printStackTrace(); + } + return 1; + } +// /** +// * ԭļǷ쳣 +// * @param tccomponentdataset ݼ +// * @return +// */ +// public static int checkDatasetFileName(TCComponentDataset tccomponentdataset) { +// String originalFileName = ""; +// try { +// originalFileName = TcUtils.getFileName(tccomponentdataset); +// if (originalFileName.equals("0") || originalFileName.equals("2")) { +// MessageBox.post("ԭļǷ쳣", "", MessageBox.INFORMATION); +// return 1; +// } +// } catch (TCException e1) { +// // TODO Auto-generated catch block +// e1.printStackTrace(); +// MessageBox.post("Teamcenter쳣"+e1.getMessage(), "", MessageBox.ERROR); +// } +// return 0; +// } +// public static String newString(String oldName) { +//// String newName=oldName; +// if (oldName.contains("/")) { +// System.out.println("bingo"); +// oldName = getNewName("/", oldName); +// } +// if (oldName.contains("*")) { +// oldName = getNewName("*", oldName); +// } +// if (oldName.contains("\\")) { +// oldName = getNewName("\\", oldName); +// } +// if (oldName.contains(":")) { +// oldName = getNewName(":", oldName); +// } +// if (oldName.contains("?")) { +// oldName = getNewName("?", oldName); +// } +// if (oldName.contains("\"")) { +// oldName = getNewName("\"", oldName); +// } +// if (oldName.contains("<")) { +// oldName = getNewName("<", oldName); +// } +// if (oldName.contains(">")) { +// oldName = getNewName(">", oldName); +// } +// if (oldName.contains("|")) { +// oldName = getNewName("|", oldName); +// } +// if (oldName.contains("")) { +// oldName = getNewName("", oldName); +// } +// if (oldName.contains("")) { +// oldName = getNewName("", oldName); +// } +// return oldName; +// } +// +// public static String getNewName(String illegalCharacter, String oldString) { +// if (illegalCharacter.equals("")) { +// oldString = oldString.replace(illegalCharacter, "("); +// } else if (illegalCharacter.equals("")) { +// oldString = oldString.replace(illegalCharacter, ")"); +// +// } else { +// +// oldString = oldString.replace(illegalCharacter, "--"); +// } +// return oldString; +// } + // Ӱϻȡ + public static List getWhereReference(WorkspaceObject[] obj){ + List list = new ArrayList(); + DataManagementService dataManagementService = DataManagementService.getService(AppXSession.getConnection()); + WhereReferencedResponse response = dataManagementService.whereReferenced(obj,1); + WhereReferencedInfo[] info = response.output[0].info; + for (int i = 0; i < info.length; i++) { + list.add(info[i].referencer); + } + return list; + } + public static void setByPass(boolean b) throws Exception { +// dataManagementService = DataManagementService.getService(AppXSession.getConnection()); +// queryService = SavedQueryService.getService(AppXSession.getConnection()); +// tcUser = ZwCADService.tcUser; + com.teamcenter.services.strong.core._2007_12.Session.StateNameValue[] propPairs = new com.teamcenter.services.strong.core._2007_12.Session.StateNameValue[1]; + propPairs[0] = new com.teamcenter.services.strong.core._2007_12.Session.StateNameValue(); + propPairs[0].name = new String("bypassFlag"); + propPairs[0].value = new String(Property.toBooleanString(b)); + ServiceData data = SessionService.getService(AppXSession.getConnection()).setUserSessionState(propPairs); +// checkPartialError(data); + } + public static void changeOwnershipModelObject(ModelObject user, String groupName, ModelObject[] modls) throws Exception + { + DataManagementService ser1 = DataManagementService.getService( AppXSession.getConnection() ); + //ModelObject user = findUser( userName ) ; + + if( user != null ) + { + System.out.println("................................owning user found.................................."); + + } else { + + + //The configured EPI-Owning-user is not found in Teamcenter. + + System.out.println("................ EPI-owning user not found ................"); + + throw new Exception("Change ownership service: 003.Change ownership service - The configured EPI-owning user is not found in Teamcenter."); + + } + ModelObject userGroup = null; + if(groupName!=""){ + userGroup = findGroup( groupName ) ; + }else{ + ser1.getProperties(new ModelObject[]{user},new String[]{"default_group"}); + userGroup = user.getPropertyObject("default_group").getModelObjectValue(); + } + + + if( userGroup != null ) + { + + System.out.println("................................owning group found.................................."); + + }else{ + + System.out.println("................ EPI-owning group not found ................"); + + throw new Exception("Change ownership service: 004.Change ownership service - The configured EPI-owning group is not found in Teamcenter."); + + } + + + + com.teamcenter.services.strong.core._2006_03.DataManagement.ObjectOwner[] ownerData = new com.teamcenter.services.strong.core._2006_03.DataManagement.ObjectOwner[modls.length]; + for(int i = 0 ; i 0){ + + throw new Exception("Change ownership service: 005.Change ownership service - "+returnData.getPartialError(0).getMessages()[0]); + + } + + } + public static ModelObject findGroup(String groupName) + { + + ImanQuery query = null; + + SavedQueryService queryService = SavedQueryService.getService(AppXSession.getConnection()); + + try + { + + SavedQuery.GetSavedQueriesResponse savedQueries = queryService.getSavedQueries(); + + if (savedQueries.queries.length == 0) + { + return null; + } + + for (int i = 0; i < savedQueries.queries.length; i++) + { + //__WEB_group -> Query in Query builder to find the group + + if (savedQueries.queries[i].name.equals("__WEB_group")) + { + query = savedQueries.queries[i].query; + break; + } + + } + + } + catch (ServiceException e) + { + + System.out.println(e.getMessage()); + return null; + } + + if (query == null) + { + System.out.println("__WEB_group query not found"); + return null; + } + try + { + + com.teamcenter.services.strong.query._2007_06.SavedQuery.SavedQueryInput savedQueryInput[] = new com.teamcenter.services.strong.query._2007_06.SavedQuery.SavedQueryInput[1]; + savedQueryInput[0] = new com.teamcenter.services.strong.query._2007_06.SavedQuery.SavedQueryInput(); + savedQueryInput[0].query = query; + savedQueryInput[0].maxNumToReturn = 25; + savedQueryInput[0].limitListCount = 0; + savedQueryInput[0].limitList = new ModelObject[0]; + savedQueryInput[0].entries = new String[]{"Name" };//Attribute in Query to search by + savedQueryInput[0].values = new String[1]; + savedQueryInput[0].values[0] = groupName;//Value for the search attribute + savedQueryInput[0].maxNumToInflate = 25; + + //Execute Query to find the Group + + com.teamcenter.services.strong.query._2007_06.SavedQuery.ExecuteSavedQueriesResponse savedQueryResult = queryService.executeSavedQueries(savedQueryInput); + + com.teamcenter.services.strong.query._2007_06.SavedQuery.SavedQueryResults found = savedQueryResult.arrayOfResults[0]; + + // System.out.println("Found Users:"); + + + ModelObject[] modelObjs = found.objects; + + return modelObjs[0];//Group object + + } + catch (Exception e) + { + + System.out.println(e.getMessage()); + + return null; + + } + + } +} diff --git a/src/com/connor/signoff/soa/handler/beifen b/src/com/connor/signoff/soa/handler/beifen new file mode 100644 index 0000000..c3bdfa7 --- /dev/null +++ b/src/com/connor/signoff/soa/handler/beifen @@ -0,0 +1,2510 @@ +package com.connor.signoff.soa.handler; +import java.io.BufferedReader; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.OutputStream; +import java.io.PrintWriter; +import java.io.UnsupportedEncodingException; +import java.lang.reflect.InvocationTargetException; +import java.net.MalformedURLException; +import java.net.SocketException; +import java.net.URISyntaxException; +import java.security.KeyManagementException; +import java.security.NoSuchAlgorithmException; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Date; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Properties; +import java.util.concurrent.TimeoutException; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import org.apache.commons.net.ftp.FTPClient; +import org.apache.commons.net.ftp.FTPFile; +import org.apache.commons.net.ftp.FTPReply; +import org.apache.log4j.Logger; +import org.apache.log4j.PropertyConfigurator; +import org.dom4j.Document; +import org.dom4j.Element; +import org.dom4j.io.SAXReader; +import com.itextpdf.text.BadElementException; +import com.itextpdf.text.Image; +import com.itextpdf.text.Rectangle; +import com.itextpdf.text.pdf.PdfContentByte; +import com.itextpdf.text.pdf.PdfGState; +import com.itextpdf.text.pdf.PdfReader; +import com.itextpdf.text.pdf.PdfStamper; +import com.teamcenter.clientx.AppXSession; +import com.teamcenter.services.strong.administration.PreferenceManagementService; +import com.teamcenter.services.strong.administration._2012_09.PreferenceManagement; +//import com.teamcenter.services.strong.administration._2012_09.PreferenceManagement; +import com.teamcenter.services.strong.administration.*; +import com.teamcenter.services.strong.core.DataManagementService; +import com.teamcenter.services.strong.core.SessionService; +import com.teamcenter.services.strong.core._2006_03.DataManagement.CreateDatasetsResponse; +import com.teamcenter.services.loose.core._2006_03.FileManagement; +import com.teamcenter.soa.client.FileManagementUtility; +import com.teamcenter.soa.client.GetFileResponse; +import com.teamcenter.soa.client.model.ModelObject; +import com.teamcenter.soa.client.model.Property; +import com.teamcenter.soa.client.model.ServiceData; +import com.teamcenter.soa.client.model.strong.Dataset; +import com.teamcenter.soa.client.model.strong.ImanFile; +import com.teamcenter.soa.client.model.strong.Item; +import com.teamcenter.soa.client.model.strong.ItemRevision; +import com.teamcenter.soa.client.model.strong.POM_system_class; +import com.teamcenter.soa.client.model.strong.ReleaseStatus; +import com.teamcenter.soa.client.model.strong.User; +import com.teamcenter.soa.client.model.strong.WorkspaceObject; +import com.teamcenter.soa.exceptions.NotLoadedException; +import com.teamcenter.services.strong.workflow._2007_06.Workflow.ReleaseStatusInput; +import com.teamcenter.services.strong.workflow._2007_06.Workflow.ReleaseStatusOption; +import com.teamcenter.services.strong.workflow._2007_06.Workflow.SetReleaseStatusResponse; +import com.teamcenter.services.strong.workflow.WorkflowService; +import com.teamcenter.services.strong.core._2007_01.DataManagement; +public class caxaPropertyHandler { + + public static boolean debug = true; + private static String fileName; + private static FTPClient ftpClient = null; + private static String exePath;//· + private static String[] refValues;//ӳ + private static AppXSession session; +// InterfaceAIFComponent[] targetComp; + private static String caxaInfo = ""; + private static Logger logger = null; + private static int waitPdf = 0; + + private static String releaseStatus; + + private static DataManagementService dmService; + private static FileManagementUtility fmu; + private static PreferenceManagementService tcp; + + private static boolean hasException = true; + private static String companyName; + private static String mainArgs[]; +// private static Stirng re + /** + * strERR = "" + */ +// private static String strERR = ""; +// +// /** +// * +// */ +// private static int monitorWorkCount = 0; +// +// public String traverseFolder(String path) { +// +// File file = new File(path); +// if (file.exists()) { +// File[] files = file.listFiles(); +// if (null == files || files.length == 0) { +// if (debug) +// System.out.println("ļǿյ!"); +// +// } else { +// for (File file2 : files) { +// if (file2.isDirectory()) { +// } else { +// if (file2.getAbsolutePath().toLowerCase().endsWith(".exb")) { +// if (debug) +// System.out.println("ļ:" + file2.getAbsolutePath()); +// return file2.getAbsolutePath(); +// } +// +// } +// } +// } +// } else { +// if (debug) +// System.out.println("ļ!"); +// } +// return ""; +// +// } + /** + * GBKļתΪISOʽ + * һwinϵͳϴļFTP + * @param fileNameGBK + * @return + */ + public static String convGBKtoISO(String fileNameGBK) { + String filenameISO=""; + try { + filenameISO = new String(fileNameGBK.getBytes("GBK"),"iso-8859-1"); + } catch (UnsupportedEncodingException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return filenameISO; + } +// + /** + * ISOļתΪGBKʽ + * һFTPļwinϵͳ + * @param fileNameGBK + * @return + */ + public static String convISOtoGBK(String fileNameISO) { + String filenameGBK=""; + try { + filenameGBK = new String(fileNameISO.getBytes("iso-8859-1"),"GBK"); + } catch (UnsupportedEncodingException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return filenameGBK; + } +// + /** + * ļ + * @param ref_list + * @param fileOgiginName + * + * @param comps + * @return + * @throws TCException + * @throws IOException + */ + public static String downLoadCaxaFile(File ref_list, String fileOgiginName, Dataset comp, ItemRevision rev) { + if (comp == null) { + return ""; + } + String value = ""; + String tempPath = System.getenv("TEMP"); + // MessageBox.post(" tempPath = + // "+tempPath,"INFO",MessageBox.INFORMATION); + if (tempPath == null) { + tempPath = ""; + } else if (!tempPath.endsWith("\\")) { + tempPath = tempPath + "\\"; + } + SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmssSSS"); + // for(TCComponent comp : comps){ + try { +// if (comp instanceof Dataset) { +// ModelObject[] objects = {comp}; +// dmService.refreshObjects(objects); +// dmService.getProperties(objects, new String[]{"ref_list"}); +// objects = comp.get_ref_list(); +// +// GetFileResponse getFileResponse = fmu.getFiles(objects); +// File[] tcFiles = getFileResponse.getFiles(); +//// TCComponentTcFile[] tcFiles = ((TCComponentDataset) comp).getTcFiles(); +// File file = null; +//// if(debug)System.out.println("tcFiles:" + tcFiles.length); +// if (tcFiles != null && tcFiles.length != 0) { +// file = tcFiles[0]; + dmService.getProperties(new ModelObject[] {rev}, new String[] {"item_id","item_revision_id"}); + String fileName = fileOgiginName; +// if(debug)System.out.println("fileName:" + fileName); + String fileDix = fileName.substring(fileName.lastIndexOf("."), fileName.length()); + String item_id = rev.getPropertyDisplayableValue("item_id"); + String item_revision_id = rev.getPropertyDisplayableValue("item_revision_id"); + String fileRealName =item_id + "-" + item_revision_id + sdf.format(new Date()) + fileDix; + Pattern pattern = Pattern.compile("[\\s\\\\/:\\*\\?\\\"<>\\|]"); + Matcher matcher = pattern.matcher(fileRealName); + + fileRealName= matcher.replaceAll(""); // ƥ䵽ķǷַԿ滻 + + fileName = tempPath +fileRealName; + + File newFile = new File(fileName); + ref_list.renameTo(newFile); +// +// File.copyFile(ref_list, dirFile); +// +// if (debug) +// System.out.println("111111111111"); + return fileName; +// } +// } + } catch (Exception e) { + e.printStackTrace(); + } + // } + return value; + } +// +// /** +// * ļ +// * +// * @param comps +// * @return +// * @throws TCException +// * @throws IOException +// */ +// public String downLoadFile(TCComponent comp) { +// if (comp == null) { +// return ""; +// } +// String value = ""; +// String tempPath = System.getenv("TEMP"); +// // MessageBox.post(" tempPath = +// // "+tempPath,"INFO",MessageBox.INFORMATION); +// if (tempPath == null) { +// tempPath = ""; +// } else if (!tempPath.endsWith("\\")) { +// tempPath = tempPath + "\\"; +// } +// SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmssSSS"); +// // for(TCComponent comp : comps){ +// try { +// if (comp instanceof TCComponentDataset) { +// TCComponentTcFile[] tcFiles = ((TCComponentDataset) comp).getTcFiles(); +// File file = null; +//// if(debug)System.out.println("tcFiles:" + tcFiles.length); +// if (tcFiles != null && tcFiles.length != 0) { +// file = tcFiles[0].getFmsFile(); +// String fileName = file.getName(); +//// if(debug)System.out.println("fileName:" + fileName); +// String fileDix = fileName.substring(fileName.lastIndexOf("."), fileName.length()); +// fileName = tempPath + sdf.format(new Date()) + fileDix; +// File dirFile = new File(fileName); +// +// FileUtility.copyFile(file, dirFile); +// +// if (debug) +// System.out.println("11111111111"); +// return fileName; +// } +// } +// } catch (TCException e) { +// e.printStackTrace(); +// } catch (IOException e) { +// e.printStackTrace(); +// } +// // } +// return value; +// } +// + public static void caxaToPdf(Dataset component) throws Exception { +// int messageCount=getMessage(); +// if(debug)System.out.println("ǰŶ===="+messageCount); +// property(component); + } + + public static void property(Dataset dataset,ItemRevision rev) { + String workDir = System.getenv("TEMP") + File.separator + "caxaBatch"; + File workDirFile = new File(workDir); + if (!workDirFile.exists()) { + workDirFile.mkdirs(); + } + + try { +// + String fileOgiginName = ""; + ModelObject[] objects = {dataset}; + dmService.refreshObjects(objects); + dmService.getProperties(objects, new String[]{"ref_list"}); + objects = dataset.get_ref_list(); + + GetFileResponse getFileResponse = fmu.getFiles(objects); + File[] ref_list = getFileResponse.getFiles(); + +// TCComponent[] ref_list = dataset.getTCProperty("ref_list").getReferenceValueArray(); + if (ref_list.length == 0) { +// logger.error("caxaʧ,û:id" + item_id + " 汾" + item_rev_id); + caxaInfo = caxaInfo + ";" + "caxaʧ,û";//:id" + item_id + " 汾" + item_rev_id; + return; + } + if (ref_list.length > 1) { +// logger.error("caxaʧ,1:id" + item_id + " 汾" + item_rev_id); + caxaInfo = caxaInfo + ";" + "caxaʧ,1";//:id" + item_id + " 汾" + item_rev_id; + return; + } + if (ref_list.length == 1) { +// fileOgiginName = ref_list[0].getProperty("original_file_name"); + dmService.getProperties(objects, new String[]{"original_file_name"}); + fileOgiginName = objects[0].getPropertyObject("original_file_name").getStringValue(); + } +// + // object_nameܺ/ַΪʧܡid+汾滻 + /* + * fileOgiginName=dataset.getProperty("object_name").endsWith(".exb")?dataset. + * getProperty("object_name"):dataset.getProperty("object_name")+".exb"; + * fileOgiginName=dataset.getProperty("object_name").endsWith(".EXB")?dataset. + * getProperty("object_name"):dataset.getProperty("object_name")+".exb"; + * fileOgiginName=dataset.getUid()+".exb"; + */ + // TODO Ⱥϴcaxaxmlļftpת + String tempCaxaPath = ""; +// if (debug) +// System.out.println("ʼ"); +// if (debug) +// System.out.println(dataset.getProperty("object_name")); + tempCaxaPath = downLoadCaxaFile(ref_list[0],fileOgiginName,dataset, rev);// ļtemp·£Ϊǰʱ +// + // пΪգ粻õʱ + if (tempCaxaPath.trim().length() == 0) { +// logger.error("caxaʧ:id" + item_id + " 汾" + item_rev_id); + caxaInfo = caxaInfo + ";" + "caxaʧ";//:id" + item_id + " 汾" + item_rev_id; + return; + } +// if (debug) +// System.out.println(tempCaxaPath); +// if (debug) +// System.out.println("caxa"); + File file = new File(tempCaxaPath); +// if(file.exists()) { +// //ر +// String fileName2=dataset.getRelatedComponents("ref_list")[0].getProperty("original_file_name"); +// if(debug)System.out.println("fileName2===="+fileName2); +// fileName2="D:\\caxaBackup\\"+fileName2; +// SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmssSSS"); +// fileName2=fileName2.substring(0,fileName2.lastIndexOf("."))+sdf.format(new Date())+fileName2.substring(fileName2.lastIndexOf(".")); +// File dirFile2 = new File(fileName2); +// +// try { +// FileUtility.copyFile(file, dirFile2); +// } catch (IOException e) { +// e.printStackTrace(); +// } +// // +// FileInputStream tempCaxaPathIn=null; +//// if(debug)System.out.println("desPathStr------------------"+desPathStr); +// try { +// tempCaxaPathIn = new FileInputStream(dirFile2); +//// in = new FileInputStream(new File(fileSS[0].getName())); +// } catch (FileNotFoundException e) { +// e.printStackTrace(); +// } +// fileName2=fileName2.substring(fileName2.lastIndexOf("\\")+1); +// boolean tempCaxa=uploadFile(ip,user,password,port,"\\caxaBackup",fileName2,tempCaxaPathIn); +// if(tempCaxa==false) { +// logger.error("caxaϴʧ:id"+item_id+" 汾"+item_rev_id); +// if(debug)System.out.println("upload fail----------------"); +// return; +// } +// } + +// if(debug)System.out.println("ص·-----------"+tempCaxaPath); + String tempCaxaPathName = tempCaxaPath.substring(tempCaxaPath.lastIndexOf("\\") + 1); + second(new File(tempCaxaPath)); + FileInputStream tempCaxaPathIn = null; +// if(debug)System.out.println("desPathStr------------------"+desPathStr); + try { + tempCaxaPathIn = new FileInputStream(new File(tempCaxaPath)); +// in = new FileInputStream(new File(fileSS[0].getName())); + } catch (FileNotFoundException e) { + e.printStackTrace(); + } + if (debug) + System.out.println("ʼϴcaxa"); + boolean tempCaxa = uploadFile(FTPUtils.ftpHost, FTPUtils.ftpUserName, FTPUtils.ftpPassword, FTPUtils.ftpPort, FTPUtils.ftpPath, tempCaxaPathName, tempCaxaPathIn); + if (tempCaxa == false) { +// logger.error("caxaϴʧ:id" + item_id + " 汾" + item_rev_id); + caxaInfo = caxaInfo + ";" + "caxaϴʧ";//:id" + item_id + " 汾" + item_rev_id; + if (debug) + System.out.println("upload fail----------------"); + return; + } +// +// if (debug) +// System.out.println("ϴcaxa"); +// TCPreferenceService tcp = dataset.getSession().getPreferenceService(); + boolean jump = hx_SetCAXAFile(dataset, + tempCaxaPathName.substring(0, tempCaxaPathName.length() - 4),fileOgiginName,rev); + if (jump == false) { + return; + } + second(new File(tempCaxaPath.replace(".exb", ".xml"))); + FileInputStream tempXmlPathIn = null; + try { + tempXmlPathIn = new FileInputStream(new File(tempCaxaPath.replace(".exb", ".xml"))); +// in = new FileInputStream(new File(fileSS[0].getName())); + } catch (FileNotFoundException e) { + e.printStackTrace(); + } + if (debug) + System.out.println("ϴxml"); + boolean tempXml = uploadFile(FTPUtils.ftpHost, FTPUtils.ftpUserName, FTPUtils.ftpPassword, FTPUtils.ftpPort, FTPUtils.ftpPath, + tempCaxaPathName.replace(".exb", ".xml"), tempXmlPathIn); + if (tempXml == false) { +// logger.error("xmlϴʧ:id" + item_id + " 汾" + item_rev_id); + caxaInfo = caxaInfo + ";" + "xmlϴʧ";//:id" + item_id + " 汾" + item_rev_id; + return; + } +// + // жǷokerrļ˵ӳɣ + if (debug) + System.out.println("okerr"); + waitOkOrErrFileCount = 0; + boolean downResult = downOkOrErrFile(FTPUtils.ftpHost,FTPUtils.ftpPort, FTPUtils.ftpUserName, FTPUtils.ftpPassword, FTPUtils.ftpPath, tempCaxaPathName, workDir); + // ʧܣһftpԱָļtxtshxλãȡʹõȱʡ壩Ȼ󵯳Դλ\ĵ + if (downResult == false) { + caxaInfo = caxaInfo + ";" + "ӳʧ";//:id" + item_id + " 汾" + item_rev_id; + return; + } + // ɹ ɾftpϵͬtxt ȴpdf + if (debug) + System.out.println("ɾ " + tempCaxaPathName.replace(".exb", ".txt")); + boolean getPdf = deleteTxt(FTPUtils.ftpHost,FTPUtils.ftpPort, FTPUtils.ftpUserName, FTPUtils.ftpPassword, FTPUtils.ftpPath,tempCaxaPathName, workDir); + if (!getPdf) { + caxaInfo = caxaInfo + ";" + "txtɾʧ";//:id" + item_id + " 汾" + item_rev_id; + return; + } +// + // 滻caxa + if (debug) + System.out.println("caxa"); + count = 0; + boolean downCaxa = downFile(FTPUtils.ftpHost,FTPUtils.ftpPort, FTPUtils.ftpUserName, FTPUtils.ftpPassword, FTPUtils.ftpPath, tempCaxaPathName, workDir); + if (downCaxa == false) { + if (debug) + System.out.println("caxaʧ"); + caxaInfo = caxaInfo + ";" + "caxaʧ";//:id" + item_id + " 汾" + item_rev_id; +// logger.error("caxaʧ:id" + item_id + " 汾" + item_rev_id); + return; + } + + if (new File(workDir + "\\" + fileOgiginName).exists()) { + new File(workDir + "\\" + fileOgiginName).delete(); + } + // пַܰ + boolean caxaFile = new File(workDir + "\\" + tempCaxaPathName) + .renameTo(new File(workDir + "\\" + fileOgiginName)); + if (caxaFile == false) { + caxaInfo = caxaInfo + ";" + "ʧ";//:id" + item_id + " 汾" + item_rev_id; +// logger.error("ʧ:id" + item_id + " 汾" + item_rev_id); + return; + } + if (debug) + System.out.println("滻"); + // 滻 +// try { +// TcUtils. +// ChangeDbomUtil.setByPass(true); +// } catch (TCException e2) { +// e2.printStackTrace(); +// } +// try { +// if(debug)System.out.println(tempCaxaPath); + TcUtils.setByPass(true); + //2023-11-15 liujb Ӳ start + File tcFileToFile = TCFileToFile(dataset); + File exbFile = new File("D:\\TEMP\\fcc_tmp"+ "\\" + fileOgiginName); + if (exbFile.exists()) { + exbFile.delete(); + } + boolean caxaFile2 = tcFileToFile.renameTo(exbFile); + String fileName = exbFile.getPath()+"@"+rev.getUid()+"#"+dataset.getUid()+"#"+releaseStatus; + File lockFile = new File(fileName); + + boolean createNewFile = lockFile.createNewFile(); + +// if(checkFile("CaxaToPDF.lock",new File(exePath))) { +// return true; +// } + updateDataSet(dataset, workDir + "\\" + fileOgiginName,"HX3_exb"); + exbFile.delete(); + lockFile.delete(); + TcUtils.setByPass(false); + //dataset.setFiles(new String[] { workDir + "\\" + fileOgiginName }, new String[] { "HX3_exb" }); +// sendMail("ɹ",item_id); +// } catch (Exception e) { +// e.printStackTrace(); +// +// try { +// if (debug) +// System.out.println("滻caxaʧܣ·"); +// ChangeDbomUtil.setByPass(false); +// } catch (TCException e2) { +// e2.printStackTrace(); +// } +// +// sendMail("滻caxaʧ:" + e.getLocalizedMessage() + e.getMessage(), item_id); +//// return;//ûǩݼͻ滻ʧ +// } + if (debug) + System.out.println("滻caxaɹ·id");//" + item_id + " 汾" + item_rev_id); +// logger.error("滻caxaɹ·id" + item_id + " 汾" + item_rev_id); +// try { +// ChangeDbomUtil.setByPass(false); +// } catch (TCException e2) { +// e2.printStackTrace(); +// } + // 滻pdf + if (debug) + System.out.println("ʼpdf"); + boolean sucess = downFile(FTPUtils.ftpHost,FTPUtils.ftpPort, FTPUtils.ftpUserName, FTPUtils.ftpPassword, FTPUtils.ftpPath, + tempCaxaPathName.replace(".exb", ".pdf"), workDir); + if (sucess == false) { + // TODO ־ + System.out.println(); +// logger.error("error:id:" + item_id + "汾:" + item_rev_id + "pdf쳣´"); +// continue; + } + + +// if (debug) +// System.out.println("·-----------------" + path); + // String exePath = path.substring(1, path.indexOf("com.connor.signoff")).replace("/", "\\"); + + +// if (debug) +// System.out.println("ܿλ---------------" + imgPath[0]); + boolean action = false; + String addPdfPath = ""; + try { + // if(debug)System.out.println("designType--------"+designType); + // if(debug)System.out.println(System.getenv("TEMP")+File.separator+fileName+".pdf"); + // if(debug)System.out.println(System.getenv("TEMP")+File.separator+oldName); + // action=addPdfMark(arg1+File.separator+fileName.replace(".exb", + // ".pdf"),arg1+File.separator+oldName+".pdf",imgPath, designType); + + // Ҫǩ + String item_id = rev.get_item_id(); + String item_rev_id = rev.get_item_revision_id(); + if("HX".equals(FTPUtils.CompanyName)) { + String designType = rev.getTypeObject().getName(); + String[] imgPath = new String[1]; + + String path = caxaPropertyHandler.class.getProtectionDomain().getCodeSource().getLocation().getPath(); + path = path.replace("%20", " "); + String exePath = new File(path).getParent() + "//"; + String qianzhang = rev.getPropertyDisplayableValue("hx3_qianzhang").trim(); + if(qianzhang.equals("ܿ") || qianzhang.equals("B") || qianzhang.isEmpty()) { + + exePath = exePath + "skz.png"; + } + else { + exePath = exePath + "syz.png"; + + } + + imgPath[0] = exePath; + item_id = newString(item_id); + + + action = addPdfMark(workDir + File.separator + tempCaxaPathName.replace(".exb", ".pdf"), + workDir + File.separator + item_id + item_rev_id + ".pdf", imgPath, designType); + } + // pdfߴ粻ģ壬ܿʧܣʱͰԭpdf滻ȥ + if (action == false) { + + addPdfPath = workDir + File.separator+tempCaxaPathName.replace(".exb", ".pdf");//workDir + File.separator + fileName.replace(".exb", ".pdf"); + + } else { + + addPdfPath = workDir + File.separator + item_id + item_rev_id + ".pdf"; + } + } catch (Exception e) { + // 3ʾͼƬ쳣 + String HXC_STATUS = "3"; + // refreshDataBase( HXC_STATUS, item_id_origin, item_revision_id_origin, rs_get, stmt, sdf0); + e.printStackTrace(); + addPdfPath = workDir + File.separator+tempCaxaPathName.replace(".exb", ".pdf"); + // continue; + } + + // Ҫǩ +// String designType = rev.getType(); +// String[] imgPath = new String[1]; +// +// String path = this.getClass().getProtectionDomain().getCodeSource().getLocation().getPath(); +// if (debug) +// System.out.println("·-----------------" + path); +// String exePath = path.substring(1, path.indexOf("com.connor.signoff")).replace("/", "\\"); +// String qianzhang = rev.getProperty("hx3_qianzhang").trim(); +// if(qianzhang.equals("ܿ") || qianzhang.equals("B") || qianzhang.isEmpty()) { +// +// exePath = exePath + "skz.png"; +// } +// else { +// exePath = exePath + "syz.png"; +// +// } +// +// imgPath[0] = exePath; +// if (debug) +// System.out.println("ܿλ---------------" + imgPath[0]); +// boolean action = false; + //String addPdfPath = ""; +// try { +// // if(debug)System.out.println("designType--------"+designType); +// // if(debug)System.out.println(System.getenv("TEMP")+File.separator+fileName+".pdf"); +// // if(debug)System.out.println(System.getenv("TEMP")+File.separator+oldName); +// // action=addPdfMark(arg1+File.separator+fileName.replace(".exb", +// // ".pdf"),arg1+File.separator+oldName+".pdf",imgPath, designType); +// +// item_id = newString(item_id); +// if("HX".equals(FTPUtils.CompanyName)) { +// +// action = addPdfMark(workDir + File.separator + tempCaxaPathName.replace(".exb", ".pdf"), +// workDir + File.separator + item_id + item_rev_id + ".pdf", imgPath, designType); +// } +// // pdfߴ粻ģ壬ܿʧܣʱͰԭpdf滻ȥ +// if (action == false) { + //addPdfPath = workDir + File.separator+tempCaxaPathName.replace(".exb", ".pdf");//workDir + File.separator + fileName.replace(".exb", ".pdf"); +// } else { +// +// addPdfPath = workDir + File.separator + item_id + item_rev_id + ".pdf"; +// } +// } catch (Exception e) { +// // 3ʾͼƬ쳣 +// String HXC_STATUS = "3"; +//// refreshDataBase( HXC_STATUS, item_id_origin, item_revision_id_origin, rs_get, stmt, sdf0); +// e.printStackTrace(); +// continue; +// } + // 滻½ݼ + replaceOrcreate(dataset, rev, addPdfPath); + System.out.println("addPdfPath:"+addPdfPath); + // ɾļµļ +// deleteDirectory(workDir); +// } +// } + + } catch (Exception e) { + e.printStackTrace(); + } + } + // + private static boolean deleteTxt(String url, // FTPhostname + int port, // FTP˿ + String username, // FTP¼˺ + String password, // FTP¼ + String remotePath, // FTPϵ· + String fileName, // Ҫصļ + String localPath// غ󱣴浽ص· + + ) { + + boolean success = false; + FTPClient ftp = new FTPClient(); + try { + int reply; + ftp.connect(url, port); + // Ĭ϶˿ڣʹftp.connect(url)ķʽֱFTP + ftp.login(username, password);// ¼ +// ftp.login("anonymous", null);// ½FTP + reply = ftp.getReplyCode(); + if (!FTPReply.isPositiveCompletion(reply)) { + ftp.disconnect(); + return success; + } + ftp.enterLocalPassiveMode();// 䣬ЩԴ˷ǽͻftp.listFiles()│ס +// if(debug)System.out.println("aaa"); + boolean ftpchange = ftp.changeWorkingDirectory(remotePath);// תƵFTPĿ¼ + fileName = fileName.replace(".exb", ".txt"); + ftp.setControlEncoding("GBK"); //FTP ֧ + fileName = convGBKtoISO(fileName);//FTP ֧ + int flag = ftp.dele(fileName); + success = true; + + } catch (IOException e) { + e.printStackTrace(); + } finally { + if (ftp.isConnected()) { + try { + ftp.disconnect(); + } catch (IOException ioe) { + } + } + } + return success; + + } +static int count = 0;// +// + public static FTPFile[] waitPdf(FTPClient ftp, String fileName, String errorName, String okName) { + FTPFile[] fs = null; + try { + + fs = ftp.listFiles(); + } catch (IOException e1) { + e1.printStackTrace(); + } + + for (FTPFile ff : fs) { + //2023.04.06ҵ.okΪɹ.errorΪʧܲ + //FTP֧ + String ffName = convISOtoGBK(ff.getName()); + if (ffName.equals(okName)) { + System.out.println("find the pdf..."); + return fs; + } else if (ffName.equals(errorName)) { + System.out.println("ת쳣"); + return null; + } + } + System.out.println("waitPdf---count:" + count); + System.out.println("waitPdf----waitPdf:" + waitPdf); + try { + Thread.sleep(1000); + count++; + } catch (InterruptedException e) { + e.printStackTrace(); + } + // ʱ˳ + if (count > waitPdf) { + return null; + } + fs = waitPdf(ftp, fileName, errorName, okName); + return fs; + } +// + public static boolean downOkOrErrFile(String url, // FTPhostname + int port, // FTP˿ + String username, // FTP¼˺ + String password, // FTP¼ + String remotePath, // FTPϵ· + String fileName, // Ҫصļ + String localPath// غ󱣴浽ص· + + ) { + boolean success = false; + FTPClient ftp = new FTPClient(); + try { + int reply; + ftp.connect(url, port); + // Ĭ϶˿ڣʹftp.connect(url)ķʽֱFTP + ftp.login(username, password);// ¼ +// ftp.login("anonymous", null);// ½FTP + reply = ftp.getReplyCode(); + if (!FTPReply.isPositiveCompletion(reply)) { + ftp.disconnect(); + return success; + } + ftp.enterLocalPassiveMode();// 䣬ЩԴ˷ǽͻftp.listFiles()│ס +// if(debug)System.out.println("aaa"); + boolean ftpchange = ftp.changeWorkingDirectory(remotePath);// תƵFTPĿ¼ +// if(debug)System.out.println(ftpchange); +// FTPFile[] fs = ftp.listFiles(); + String errorNamePrefix = ""; + if (fileName.toLowerCase().endsWith(".exb")) { + errorNamePrefix = fileName; + } + + FTPFile[] fs = waitOkOrErrFile(ftp, fileName, errorNamePrefix); + if (fs != null) { + success = true; + } else { + success = false; + } + } catch (IOException e) { + e.printStackTrace(); + } finally { + if (ftp.isConnected()) { + try { + ftp.disconnect(); + } catch (IOException ioe) { + } + } + } + return success; + } + +// + public static FTPFile[] waitOkOrErrFile(FTPClient ftp, String fileName, String errorNamePrefix) { + FTPFile[] fs = null; + try { + + fs = ftp.listFiles(); + } catch (IOException e1) { + e1.printStackTrace(); + } + + for (FTPFile ff : fs) { + // 2023.04.06ҵ.okΪɹ.errorΪʧܲ + // FTP֧ + String ffName = convISOtoGBK(ff.getName()); + if (ffName.equals(errorNamePrefix + ".ok")) { + System.out.println("ӳɹ..."); + return fs; + } else if (ffName.equals(errorNamePrefix + ".err")) { + System.out.println("ӳ쳣"); + return null; + } + } + if (debug) + System.out.println("waitOkOrErrFile---" + errorNamePrefix); + try { + Thread.sleep(1000); + waitOkOrErrFileCount++; + } catch (InterruptedException e) { + e.printStackTrace(); + } + // ʱ˳ + if (waitOkOrErrFileCount > waitPdf) { + return null; + } + fs = waitOkOrErrFile(ftp, fileName, errorNamePrefix); + return fs; + } +// + static int waitOkOrErrFileCount = 0; +// + /** + * ȡ + * + * @param comp + * @return + */ + public static String hx_GetProp(ModelObject comp, String refInfo) { + if (comp == null) { + return null; + } + if (refInfo == null) { + return null; + } + try { + dmService.getProperties(new ModelObject[] {comp}, new String[] {refInfo}); + return comp.getPropertyDisplayableValue(refInfo); +// return comp.getProperty(refInfo); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return ""; + } + + public static String toUpperCase(String input) { + if (input == null) { + return null; + } + + int length = input.length(); + StringBuilder result = new StringBuilder(length); + + for (int i = 0; i < length; i++) { + char c = input.charAt(i); + if (c >= 'a' && c <= 'z') { + // СдĸתΪдĸ + c = (char) (c - 32); + } + result.append(c); + } + + return result.toString(); + } +// + /** + * ЭCAXAݼǰ + * + * @param caxaDataset + * @param rev + * @throws TCException + */ + public static boolean hx_SetCAXAFile(Dataset caxaDataset, String xmlName,String datasetName, ItemRevision rev) + throws Exception { + try { + StringBuffer infoSB = new StringBuffer(); +// TCComponentItemRevision rev = null; +// TCComponentItem item = null; +// TCComponentForm revForm = null; +// TCComponentForm itemForm = null; + String path = caxaPropertyHandler.class.getProtectionDomain().getCodeSource().getLocation().getPath(); + path = path.replace("%20", " "); + String exePath = new File(path).getParent() + "//"; + + SAXReader reader = new SAXReader(); + Document doc = reader.read(new File(exePath + "sign.xml")); + Element root = doc.getRootElement(); + Element title = root.element("SignInfo").element("Title"); + Element files = root.element("SignInfo").element("Files").element("File"); +// files.attribute("Path").setValue("D:\\CAXAPROPERTY\\" + xmlName + ".exb"); + files.attribute("Path").setValue(FTPUtils.ftpPath + "\\" + xmlName + ".exb"); + String blockName = files.attributeValue("BlockName"); + Map valueMap = getECNValueMap(rev); +// String datasetName = null; +// if (caxaDataset == null) { +// return false; +// } +// TCComponentTcFile[] tcFiles = caxaDataset.getTcFiles(); +// // File file = null; +// if (tcFiles != null && tcFiles.length != 0) { +// +// datasetName = tcFiles[0].getStringProperty("object_string"); +// } + datasetName = datasetName.substring(0, datasetName.indexOf('.')); + File file = new File(System.getenv("TEMP") + "\\" + xmlName + ".xml"); +// rev = (TCComponentItemRevision) caxaDataset.getReferenceProperty("item_revision");// õǰݼڰ汾 +// +// if (rev == null) { +// return false; +// } +// try { + dmService.getProperties(new ModelObject[] {rev}, new String[] {"IMAN_master_form_rev"}); + ModelObject revForm = rev.get_IMAN_master_form_rev()[0]; +// revForm = (TCComponentForm) (rev.getReferenceListProperty("IMAN_master_form_rev"))[0]; +// } catch (Exception e1) { +// e1.printStackTrace(); +// return false; +// } + Item item = rev.get_items_tag(); + + String[] refValues = null;//tcp.getStringArray(TCPreferenceService.TC_preference_site, "HxCaxaMapping"); + + PreferenceManagement.GetPreferencesResponse getAttrMappingPreferencesResponse = tcp.getPreferences(new String[] {"HxCaxaMapping"}, true); + for(PreferenceManagement.CompletePreference completePreference : getAttrMappingPreferencesResponse.response) { + + if(completePreference.definition.name.equals("HxCaxaMapping")){ + refValues = completePreference.values.values; + } + } + + if (refValues == null || refValues.length == 0) { + + return false; + } +// if(debug)System.out.println("rev:" + rev); + String propName; + int index; +// Map> map = new HashMap<>();// ŶͶԼ + + + List itemPropList = new ArrayList(); + List itemRevPropList = new ArrayList(); + List itemRevMasterPropList = new ArrayList(); + for (String refValue : refValues) { + String[] valueS = refValue.split("="); + + String value = null; + if (valueS == null || valueS.length != 2) { + continue; + } + String[] propNameS = valueS[1].split("\\."); + if (propNameS == null || propNameS.length != 2) { + continue; + } + index = valueS[0].indexOf(':'); + propName = valueS[0].substring(index + 1).trim(); +// switch (toUpperCase(propNameS[0])) { +// case "ITEM": +// if(!itemPropList.contains(propNameS[1])) { +// +// itemPropList.add(propNameS[1]); +// } +//// value = hx_GetProp(item, propNameS[1]); +//// map = addToMap(map, item, propNameS[1]); +// +// break; +// case "REV": +// if(!itemRevPropList.contains(propNameS[1])) { +// +// itemRevPropList.add(propNameS[1]); +// } +//// value = hx_GetProp(rev, propNameS[1]); +//// map = addToMap(map, rev, propNameS[1]); +// break; +// case "REVMASTER": +// if(!itemRevMasterPropList.contains(propNameS[1])) { +// +// itemRevMasterPropList.add(propNameS[1]); +// } +//// value = hx_GetProp(revForm, propNameS[1]); +//// map = addToMap(map, revForm, propNameS[1]); +// break; +// case "ITEMMASTER": +// break; +// default: +// break; +// } + String propNameS0Upper = toUpperCase(propNameS[0]); + + if ("ITEM".equals(propNameS0Upper)) { + if (!itemPropList.contains(propNameS[1])) { + itemPropList.add(propNameS[1]); + } + // value = hx_GetProp(item, propNameS[1]); + // map = addToMap(map, item, propNameS[1]); + } else if ("REV".equals(propNameS0Upper)) { + if (!itemRevPropList.contains(propNameS[1])) { + itemRevPropList.add(propNameS[1]); + } + // value = hx_GetProp(rev, propNameS[1]); + // map = addToMap(map, rev, propNameS[1]); + } else if ("REVMASTER".equals(propNameS0Upper)) { + if (!itemRevMasterPropList.contains(propNameS[1])) { + itemRevMasterPropList.add(propNameS[1]); + } + // value = hx_GetProp(revForm, propNameS[1]); + // map = addToMap(map, revForm, propNameS[1]); + } else if ("ITEMMASTER".equals(propNameS0Upper)) { + // No action needed for "ITEMMASTER" + } else { + // Default case + } +// infoSB.append(valueS[0]).append("=").append(value).append("|"); + + } + if(itemPropList.size()!=0) { + String[] itemProps = itemPropList.toArray(new String[itemPropList.size()]); + dmService.getProperties(new ModelObject[] {item}, itemProps); + } + if(itemRevPropList.size()!=0) { + String[] itemRevProps = itemRevPropList.toArray(new String[itemRevPropList.size()]); + dmService.getProperties(new ModelObject[] {rev}, itemRevProps); + } + if(itemRevMasterPropList.size()!=0) { + String[] itemRevMasterProps = itemRevMasterPropList.toArray(new String[itemRevMasterPropList.size()]); + dmService.getProperties(new ModelObject[] {revForm}, itemRevMasterProps); + } + dmService.refreshObjects(new ModelObject[] {item,rev,revForm}); + for (String refValue : refValues) { + String[] valueS = refValue.split("="); + + String value = null; + if (valueS == null || valueS.length != 2) { + continue; + } + String[] propNameS = valueS[1].split("\\."); + if (propNameS == null || propNameS.length != 2) { + continue; + } + index = valueS[0].indexOf(':'); + propName = valueS[0].substring(index + 1).trim(); + if(propName.equals("Ա")) { + System.out.println(); + } + if(valueMap.containsKey(propName)) { + continue; + } + String propNameS0Upper = toUpperCase(propNameS[0]); + + if ("ITEM".equals(propNameS0Upper)) { + value = hx_GetProp(item, propNameS[1]); + // map = addToMap(map, item, propNameS[1]); + } else if ("REV".equals(propNameS0Upper)) { + boolean flag = false; + String[] propertyNames = rev.getPropertyNames(); + for (String prop : propertyNames) { + if (prop.equals(propNameS[1]) && !valueMap.containsKey(prop)) { + flag = true; + break; + } + } + if (flag) { + value = hx_GetProp(rev, propNameS[1]); + } + // map = addToMap(map, rev, propNameS[1]); + } else if ("REVMASTER".equals(propNameS0Upper)) { + boolean flag2 = false; + String[] propertyNames2 = revForm.getPropertyNames(); + for (String prop : propertyNames2) { + if (prop.equals(propNameS[1]) && !valueMap.containsKey(prop)) { + flag2 = true; + break; + } + } + if (flag2) { + value = hx_GetProp(revForm, propNameS[1]); + } + // map = addToMap(map, revForm, propNameS[1]); + } else if ("ITEMMASTER".equals(propNameS0Upper)) { + // No action needed for "ITEMMASTER" + } else { + // Default case + } +// switch (toUpperCase(propNameS[0])) { +// case "ITEM": +// value = hx_GetProp(item, propNameS[1]); +//// map = addToMap(map, item, propNameS[1]); +// +// break; +// case "REV": +// boolean flag = false; +// String[] propertyNames = rev.getPropertyNames(); +// for(String prop : propertyNames) { +// if(prop.equals(propNameS[1]) && !valueMap.containsKey(prop)) { +// flag = true; +// } +// } +// if(flag) { +// +//// value = hx_GetProp(revForm, propNameS[1]); +// value = hx_GetProp(rev, propNameS[1]); +// } +//// map = addToMap(map, rev, propNameS[1]); +// break; +// case "REVMASTER": +// boolean flag2 = false; +// String[] propertyNames2 = revForm.getPropertyNames(); +// for(String prop : propertyNames2) { +// if(prop.equals(propNameS[1]) && !valueMap.containsKey(prop)) { +// flag2 = true; +// } +// } +// if(flag2) { +// +// value = hx_GetProp(revForm, propNameS[1]); +// } +//// map = addToMap(map, revForm, propNameS[1]); +// break; +// case "ITEMMASTER": +// break; +// default: +// break; +// } + if (value == null || value.length() == 0) + continue; + valueMap.put(propName, value); + } +// for (Map.Entry> me : map.entrySet()) { +// TCComponent component = me.getKey(); +// List propList = me.getValue(); +// String[] proptring = propList.toArray(new String[propList.size()]); +// String[] values = component.getProperties(proptring); +// for (int i = 0; i < proptring.length; i++) { +// valueMap.put(proptring[i], values[i]); +// } +// +// } + + // files.attribute("Path").setValue(dir+"\\"+fileName); +// if(debug)System.out.println("valueMap:" + valueMap); + Element e; + Iterator it = title.elementIterator(); + while (it.hasNext()) { + e = (Element) it.next(); + String val = valueMap.get(e.attribute("Name").getValue()); +// if(debug)System.out.println("name:" + e.attribute("Name").getValue()); +// if(debug)System.out.println("val:" + val); + if (val != null) + e.attribute("Value").setValue(val); + } + PrintWriter pw = new PrintWriter(file, "UTF-8"); + doc.write(pw); + pw.close(); +// if(debug)System.out.println("222"); + } catch (Exception e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + return true; + + } +// +// private Map> addToMap(Map> map, TCComponent item, +// String propName) { +// if (map.containsKey(item)) { +// List list = map.get(item); +// list.add(propName); +// map.put(item, list); +// } else { +// List list = new ArrayList<>(); +// list.add(propName); +// map.put(item, list); +// } +// return map; +// } +// + public static void second(File file) { + if (!file.exists()) { + if (debug) + System.out.println("second"); + try { + Thread.sleep(200); + second(file); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } else { + if (debug) + System.out.println("cunzai"); + try { + Thread.sleep(200); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + } +// + /** + * ɾļ + * + * @param fileName Ҫɾļļ + * @return ļɾɹtrue򷵻false + */ + public static boolean deleteFile(String fileName) { + File file = new File(fileName); + // ļ·Ӧļڣһļֱɾ + if (file.exists() && file.isFile()) { + if (file.delete()) { +// if(debug)System.out.println("ɾļ" + fileName + "ɹ"); + return true; + } else { +// if(debug)System.out.println("ɾļ" + fileName + "ʧܣ"); + return false; + } + } else { +// if(debug)System.out.println("ɾļʧܣ" + fileName + "ڣ"); + return false; + } + } +// +// + /** + * ɾĿ¼Ŀ¼µļ + * + * @param dir ҪɾĿ¼ļ· + * @return Ŀ¼ɾɹtrue򷵻false + */ + public static boolean deleteDirectory(String dir) { + // dirļָβԶļָ + if (!dir.endsWith(File.separator)) + dir = dir + File.separator; + File dirFile = new File(dir); + // dirӦļڣ߲һĿ¼˳ + if ((!dirFile.exists()) || (!dirFile.isDirectory())) { +// if(debug)System.out.println("ɾĿ¼ʧܣ" + dir + "ڣ"); + return false; + } + boolean flag = true; + // ɾļеļĿ¼ + File[] files = dirFile.listFiles(); + for (int i = 0; i < files.length; i++) { + // ɾļ + if (files[i].isFile()) { + flag = deleteFile(files[i].getAbsolutePath()); + if (!flag) + break; + } + // ɾĿ¼ + else if (files[i].isDirectory()) { + flag = deleteDirectory(files[i].getAbsolutePath()); + if (!flag) + break; + } + } + if (!flag) { +// if(debug)System.out.println("ɾĿ¼ʧܣ"); + return false; + } + return true; + } +// + // ȡеȴpdfתʱʱ + private static void loadWaitPdf() { + Properties properties = new Properties(); + InputStream is = null; +// is = this.getClass().getResourceAsStream("PDFInfo.properties"); + is = caxaPropertyHandler.class.getResourceAsStream("PDFInfo.properties"); + try { + properties.load(is); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + waitPdf = Integer.valueOf(properties.getProperty("WAITPDF")); + System.out.println(); + } +// +// private void dealWithFolder(TCComponent tcComponent) throws TCException { +// if (tcComponent instanceof TCComponentFolder) { +// TCComponentFolder folder = (TCComponentFolder) tcComponent; +// TCComponent[] contents = null; +// try { +// contents = folder.getRelatedComponents("contents"); +// } catch (TCException e) { +// // TODO Auto-generated catch block +// e.printStackTrace(); +// } +// for (int j = 0; j < contents.length; j++) { +// TCComponent content = contents[j]; +// if (content instanceof TCComponentFolder) { +// dealWithFolder(content); +// } else if (content instanceof TCComponentItem) { +// TCComponentItemRevision rev = ((TCComponentItem) content).getLatestItemRevision(); +// caxaToPdf(rev, logger); +// } else if (content instanceof TCComponentItemRevision) { +// caxaToPdf((TCComponentItemRevision) content, logger); +// } +// } +// } +// +// } +// + /** + * ȡFTPClient + * + * @param ftpHost FTP + * @param ftpPassword FTP ¼ + * @param ftpUserName FTP¼û + * @param ftpPort FTP˿ ĬΪ21 + * @return + */ + public static FTPClient getFTPClient(String ftpHost, String ftpUserName, String ftpPassword, int ftpPort) { + FTPClient ftpClient = new FTPClient(); + try { + ftpClient = new FTPClient(); + ftpClient.connect(ftpHost, ftpPort);// FTP + ftpClient.login(ftpUserName, ftpPassword);// ½FTP +// ftpClient.login("anonymous", null);// ½FTP + if (!FTPReply.isPositiveCompletion(ftpClient.getReplyCode())) { + if (debug) + System.out.println("δӵFTPû"); + ftpClient.disconnect(); + } else { +// if(debug)System.out.println("FTPӳɹ"); + } + } catch (SocketException e) { + e.printStackTrace(); + if (debug) + System.out.println("FTPIPַܴȷá"); + } catch (IOException e) { + e.printStackTrace(); + if (debug) + System.out.println("FTPĶ˿ڴ,ȷá"); + } + return ftpClient; + } +// + /** + * Description: FTPϴļ + * + * @param ftpHost FTPhostname + * @param ftpUserName ˺ + * @param ftpPassword + * @param ftpPort ˿ + * @param ftpPath FTPļ· ʽ ftptest/aa + * @param fileName ftpļ + * @param in ļ + * @return ɹtrue򷵻false + */ + public static boolean uploadFile(String ftpHost, String ftpUserName, String ftpPassword, int ftpPort, String ftpPath, + String fileName, FileInputStream in) { + boolean success = false; + FTPClient ftpClient = null; + try { + int reply; + ftpClient = getFTPClient(ftpHost, ftpUserName, ftpPassword, ftpPort); + reply = ftpClient.getReplyCode(); + if (!FTPReply.isPositiveCompletion(reply)) { + ftpClient.disconnect(); + return success; + } + ftpClient.setFileType(FTPClient.BINARY_FILE_TYPE); + ftpClient.enterLocalPassiveMode(); + ftpClient.changeWorkingDirectory(ftpPath); + + ftpClient.setControlEncoding("GBK"); // FTP֧ + fileName = convGBKtoISO(fileName);// FTP֧ + ////fileName = convISOtoGBK(fileName);// FTP֧ + + boolean ff = ftpClient.storeFile(fileName, in); + String str = ftpClient.getReplyString(); + in.close(); + ftpClient.logout(); + success = true; + } catch (IOException e) { + e.printStackTrace(); + } finally { + if (ftpClient.isConnected()) { + try { + ftpClient.disconnect(); + } catch (IOException ioe) { + } + } + } +// if(debug)System.out.println("ϴ"); + return success; + } +// +// public String GetNowDate() { +// String temp_str = ""; +// Date dt = new Date(); +// // aaʾ硱硱 HHʾ24Сʱ hhʾ12Сʱ "yyyy-MM-ddHH:mm:ss aa" +// SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd-HH-mm"); +// temp_str = sdf.format(dt); +// return temp_str; +// } +// +// /* +// * ʵļĿ +// * +// * @param srcPathStr ԴļĵַϢ +// * +// * @param desPathStr ĿļĵַϢ +// */ +// private String copyFile(String srcPathStr, String desPathStr, String newName) { +// // 1.ȡԴļ +// String newFileName = newName + srcPathStr.substring(srcPathStr.lastIndexOf(".")); // Ŀļַ +//// if(debug)System.out.println(newFileName); +//// if(debug)System.out.println(File.separator); +// desPathStr = desPathStr + File.separator + newFileName; // Դļַ +//// if(debug)System.out.println(desPathStr); +// +// try { +// // 2. +// FileInputStream fis = new FileInputStream(srcPathStr); +// FileOutputStream fos = new FileOutputStream(desPathStr); +// +// // ˹ +// byte datas[] = new byte[1024 * 8]; +// // +// int len = 0; +// // ѭȡ +// while ((len = fis.read(datas)) != -1) { +// fos.write(datas, 0, len); +// } +// // 3.ͷԴ +// fis.close(); +// fis.close(); +// } catch (Exception e) { +// e.printStackTrace(); +// } +// return desPathStr; +// } +// + public static boolean downFile(String url, // FTPhostname + int port, // FTP˿ + String username, // FTP¼˺ + String password, // FTP¼ + String remotePath, // FTPϵ· + String fileName, // Ҫصļ + String localPath// غ󱣴浽ص· + + ) { + if (debug) + System.out.println(""); + boolean success = false; + FTPClient ftp = new FTPClient(); + try { + int reply; + ftp.connect(url, port); + // Ĭ϶˿ڣʹftp.connect(url)ķʽֱFTP + ftp.login(username, password);// ¼ +// ftp.login("anonymous", null);// ½FTP + reply = ftp.getReplyCode(); + if (!FTPReply.isPositiveCompletion(reply)) { + if (debug) + System.out.println("Ͽ"); + ftp.disconnect(); + return success; + } +// if(debug)System.out.println("aaa"); + ftp.changeWorkingDirectory(remotePath);// תƵFTPĿ¼ +// FTPFile[] fs = ftp.listFiles(); + int x = 0; + if (debug) + System.out.println("ȴpdf"); + String errorName = fileName + ".err"; + String okName = fileName + ".ok"; + FTPFile[] fs = waitPdf(ftp, fileName, errorName, okName); + try { + Thread.sleep(1000); + } catch (InterruptedException e) { + e.printStackTrace(); + } + if (fs == null) { + return false; + } + ftp.setControlEncoding("GBK"); + for (FTPFile ff : fs) { + // FTP֧ + String ffName = convISOtoGBK(ff.getName()); + if (ffName.equals(fileName)) { + if (debug) + System.out.println("ļ----------" + fileName); +// if(debug)System.out.println("dd"); + File localFile = new File(localPath + "/" + ffName); + OutputStream is = new FileOutputStream(localFile); + ftp.retrieveFile(ff.getName(), is); +// if(debug)System.out.println("ccc" +ff.getName()+fileName); + is.close(); + success = true; + break;//2023-04-12ѭ + } + } + ftp.logout(); + } catch (IOException e) { + e.printStackTrace(); + } finally { + if (ftp.isConnected()) { + try { + ftp.disconnect(); + } catch (IOException ioe) { + } + } + } + return success; + } +// + /** + * ȡPDFijߴͼƥ䲢ҪͼƬλ + * + * @param rectangle + * @return + */ + public static Float[] getSize(Rectangle rectangle) { + Float[] sizef = new Float[2]; + float toleft = rectangle.getLeft(); + float tobottom = rectangle.getBottom(); + float toright = rectangle.getRight(); + float totop = rectangle.getTop(); + + JFomPdfBean bean = new JFomPdfBean(); + bean.setH(toright - toleft);// PDFĿ + bean.setW(totop - tobottom);// PDFĸ + sizef[0] = bean.getH(); + sizef[1] = bean.getW(); +// if(debug)System.out.println("bean.getH------------>" + bean.getH()); +// if(debug)System.out.println("bean.getW------------>" + bean.getW()); + + return sizef; + } + + public static boolean addPdfMark(String InPdfFile, String temp, String[] markImagePath, String designType) + throws Exception { + File pdffile = new File(temp); + if (pdffile.exists()) { + pdffile.delete(); + } + // + Properties properties = new Properties(); + InputStream is = null; + is = caxaPropertyHandler.class.getResourceAsStream("PDFInfo.properties"); + properties.load(is); + System.out.println(2); + // PDF ļ + PdfReader reader = new PdfReader(InPdfFile, "PDF".getBytes()); + // PDF ļ + PdfStamper stamp = new PdfStamper(reader, new FileOutputStream(temp)); + // ˮӡͼƬ + Image[] img = null; + for (int j = 0; j < markImagePath.length; j++) { +// img.scaleAbsolute(35, 20);// ͼƬ +// float imgW = img.getScaledWidth();// ȡͼƬĿ +// float imgH = img.getScaledHeight();// ȡͼƬĸ߶ + // ȡPDFҳ + int pageSize = reader.getNumberOfPages();// ȡļҳ + for (int i = 1; i <= pageSize; i++) { + Rectangle rectangle = reader.getPageSize(i); + Float[] fposition = getSize(rectangle); +// if(debug)System.out.println("fposition[0]======="+fposition[0]); +// if(debug)System.out.println("fposition[1]======="+fposition[1]); + boolean isSizeOk = false; + // ˮӡIJλA0 + if ((fposition[0] > 3300 && fposition[1] > 2300)) { + isSizeOk = true; + // ͨpdfڵİ汾ж +// if(debug)System.out.println("ˮӡIJλA0"); + String[] sizeType = selectType("A0", designType); + if (sizeType == null || sizeType.length == 0) { + return false; + } + img = setPic(img, sizeType, properties, markImagePath[j]); + } + // TODO ˮӡIJλA1 + if ((fposition[0] > 2300 && fposition[1] > 1600) && isSizeOk == false) { + isSizeOk = true; +// if(debug)System.out.println("ˮӡIJλA1"); + String[] sizeType = selectType("A1", designType); + if (sizeType == null || sizeType.length == 0) { + return false; + } + + img = setPic(img, sizeType, properties, markImagePath[j]); + + } + + // TODO ˮӡIJλA2 + if ((fposition[1] > 1100 && fposition[0] > 1600) && isSizeOk == false) { + isSizeOk = true; +// if(debug)System.out.println("ˮӡIJλA2"); + String[] sizeType = selectType("A2", designType); + if (sizeType == null || sizeType.length == 0) { + return false; + } + img = setPic(img, sizeType, properties, markImagePath[j]); + } + // TODO ˮӡIJλA2 + if ((fposition[0] > 1100 && fposition[1] > 1600) && isSizeOk == false) { + isSizeOk = true; +// if(debug)System.out.println("ˮӡIJλA2_GY"); + String[] sizeType = selectType("A2", designType); + if (sizeType == null || sizeType.length == 0) { + return false; + } + img = setPic(img, sizeType, properties, markImagePath[j]); + } + // TODO ˮӡIJλA3 + if ((fposition[0] > 1100 && fposition[1] > 800) && isSizeOk == false) { + isSizeOk = true; +// if(debug)System.out.println("ˮӡIJλA3"); + String[] sizeType = selectType("A3", designType); + if (sizeType == null || sizeType.length == 0) { + return false; + } + img = setPic(img, sizeType, properties, markImagePath[j]); + } + // TODO ˮӡIJλA3H + if ((fposition[1] > 1100 && fposition[0] > 800) && isSizeOk == false) { + isSizeOk = true; +// if(debug)System.out.println("ˮӡIJλA3"); + String[] sizeType = selectType("A3H", designType); + if (sizeType == null || sizeType.length == 0) { + return false; + } + img = setPic(img, sizeType, properties, markImagePath[j]); + } + // TODO ˮӡIJλA4 + if ((fposition[1] > 800 && fposition[0] > 500) && isSizeOk == false) { + isSizeOk = true; +// if(debug)System.out.println("ˮӡIJλA4"); + String[] sizeType = selectType("A4", designType); + if (sizeType == null || sizeType.length == 0) { + return false; + } + img = setPic(img, sizeType, properties, markImagePath[j]); + } + // ˮӡIJλA4 + if ((fposition[0] > 800 && fposition[1] > 500) && isSizeOk == false) { + isSizeOk = true; +// if(debug)System.out.println("ˮӡIJλA4"); + String[] sizeType = selectType("A4H", designType); + if (sizeType == null || sizeType.length == 0) { + return false; + } + + img = setPic(img, sizeType, properties, markImagePath[j]); + System.out.println(); + } +// +// if (sizeType != null) { +// +// img = setPic(img, sizeType, properties, markImagePath[j]); +// } + if (img == null ) { + img = new Image[1]; + img[0] = Image.getInstance(markImagePath[j]);// ȡͼƬʵ + img[0].setAbsolutePosition(Float.valueOf(10), Float.valueOf(10)); + /* + * isModel=false; continue; + */ + } + if (img == null) { + return false; + } + + // PDFļвˮӡ + PdfContentByte under = stamp.getOverContent(i);// stamp.getUnderContent(i); + PdfGState gs = new PdfGState(); + gs.setFillOpacity(1.0f);// ͸Ϊ0.2 + under.setGState(gs); + for (int k = 0; k < img.length; k++) { + under.addImage(img[k]); + + } + } + } + stamp.close();// ر + reader.close();// ر + File tempfile = new File(InPdfFile); + if (tempfile.exists()) { + // ɾԭļ + tempfile.delete(); + } + return true; + } + + +// public static String[] selectType(String Ax, String designType) { +// String[] type = null; +// switch (designType) { +// +// case "HX3_GYTRevision":// ͼ +// if (Ax.equals("A3")) { +// type = new String[1]; +// type[0] = Ax + "_GY"; +// } else if (Ax.equals("A2")) { +// type = new String[2]; +// type[0] = Ax + "_GY1"; +// type[1] = Ax + "_GY2"; +// } +// break; +// case "HX3_TYGY1Revision":// ͨù +// if (Ax.equals("A3")) { +// type = new String[1]; +// type[0] = Ax + "_TYGY"; +// } else if (Ax.equals("A2")) { +// type = new String[2]; +// type[0] = Ax + "_TYGY1"; +// type[1] = Ax + "_TYGY2"; +// } +// break; +// case "HX3_WXTRevision":// ƷͼЭӹͼHX3_WXTRevision ͼHX3_LJTRevision װͼHX3_ZPTRevision +// type = new String[1]; +// type[0] = Ax + "_PRODUCT"; +// break; +// case "HX3_DJTRevision":// ƷͼЭӹͼHX3_WXTRevision ͼHX3_LJTRevision +// // װͼHX3_ZPTRevisionͼͼHX3_DJTRevision +// type = new String[1]; +// type[0] = Ax + "_PRODUCT"; +// break; +// case "HX3_LJTRevision":// ƷͼЭӹͼHX3_WXTRevision ͼHX3_LJTRevision װͼHX3_ZPTRevision +// type = new String[1]; +// type[0] = Ax + "_PRODUCT"; +// break; +// case "HX3_ZPTRevision":// ƷͼЭӹͼHX3_WXTRevision ͼHX3_LJTRevision װͼHX3_ZPTRevision +// type = new String[1]; +// type[0] = Ax + "_PRODUCT"; +// break; +// case "HX3_GCGGTZDRevision":// ̸֪ͨ +// type = new String[1]; +// type[0] = Ax + "_ECN"; +// break; +// case "HX3_GZTRevision":// װͼ +// type = new String[2]; +// type[0] = Ax + "_GZT1"; +// type[1] = Ax + "_GZT2"; +// break; +// default: +// break; +// } +// +// return type; +// } + public static String[] selectType(String Ax, String designType) { + String[] type = null; + + if ("HX3_GYTRevision".equals(designType)) { // ͼ + if (Ax.equals("A3")) { + type = new String[1]; + type[0] = Ax + "_GY"; + } else if (Ax.equals("A2")) { + type = new String[2]; + type[0] = Ax + "_GY1"; + type[1] = Ax + "_GY2"; + } + } else if ("HX3_TYGY1Revision".equals(designType)) { // ͨù + if (Ax.equals("A3")) { + type = new String[1]; + type[0] = Ax + "_TYGY"; + } else if (Ax.equals("A2")) { + type = new String[2]; + type[0] = Ax + "_TYGY1"; + type[1] = Ax + "_TYGY2"; + } + } else if ("HX3_WXTRevision".equals(designType)) { // ƷͼЭӹͼHX3_WXTRevision ͼHX3_LJTRevision װͼHX3_ZPTRevision + type = new String[1]; + type[0] = Ax + "_PRODUCT"; + } else if ("HX3_DJTRevision".equals(designType)) { // ƷͼЭӹͼHX3_WXTRevision ͼHX3_LJTRevision + // װͼHX3_ZPTRevisionͼͼHX3_DJTRevision + type = new String[1]; + type[0] = Ax + "_PRODUCT"; + } else if ("HX3_LJTRevision".equals(designType)) { // ƷͼЭӹͼHX3_WXTRevision ͼHX3_LJTRevision װͼHX3_ZPTRevision + type = new String[1]; + type[0] = Ax + "_PRODUCT"; + } else if ("HX3_ZPTRevision".equals(designType)) { // ƷͼЭӹͼHX3_WXTRevision ͼHX3_LJTRevision װͼHX3_ZPTRevision + type = new String[1]; + type[0] = Ax + "_PRODUCT"; + } else if ("HX3_GCGGTZDRevision".equals(designType)) { // ̸֪ͨ + type = new String[1]; + type[0] = Ax + "_ECN"; + } else if ("HX3_GZTRevision".equals(designType)) { // װͼ + type = new String[2]; + type[0] = Ax + "_GZT1"; + type[1] = Ax + "_GZT2"; + } + + return type; + } + + public static Image[] setPic(Image[] img, String[] sizeType, Properties properties, String markImagePath) + throws BadElementException, MalformedURLException, IOException { + // תString· + img = new Image[sizeType.length]; + for (int k = 0; k < sizeType.length; k++) { + + img[k] = Image.getInstance(markImagePath);// ȡͼƬʵ + String str = properties.getProperty(sizeType[k]); + if (str == null) { + return null; + } + String[] values = str.split(","); + img[k].setAbsolutePosition(Float.valueOf(values[0]), Float.valueOf(values[1]));// ˮӡ½ǵ + } + return img; + } +// + public static void replaceOrcreate(Dataset arg0, ItemRevision rev,String addPdfPath) { + // жϰ汾pdfݼƺcaxaͬо滻ûо½ + ModelObject[] datasets = null; + Dataset dataset = null; + try { + dmService.getProperties(new ModelObject[] {rev}, new String[] {"IMAN_specification"}); + datasets = rev.getPropertyObject("IMAN_specification").getModelObjectArrayValue();; + dmService.getProperties(datasets, new String[] {"object_name"}); +// datasets = TcUtils.getWhereReference(new WorkspaceObject[] {arg0}); +// datasets = (TCComponent[]) rev.getTCProperty("IMAN_specification").getReferenceValueArray(); + String pdfName = ""; + String caxaName = ""; + for (int i = 0; i < datasets.length; i++) { + if (datasets[i].getTypeObject().getName().equals("PDF")) { + pdfName = datasets[i].getPropertyDisplayableValue("object_name"); + caxaName = arg0.getPropertyDisplayableValue("object_name"); + if (pdfName.contains(".pdf") && caxaName.contains(".exb")) { + pdfName = pdfName.substring(0, pdfName.lastIndexOf(".pdf")); + if (debug) + System.out.println(pdfName); + caxaName = caxaName.substring(0, caxaName.lastIndexOf(".exb")); + if (debug) + System.out.println(pdfName); + } + } + if (datasets[i].getTypeObject().getName().equals("PDF") && caxaName.equals(pdfName)) { + dataset = (Dataset) datasets[i]; + } + } + System.out.println(); + } catch (Exception e1) { + e1.printStackTrace(); + } + + if (dataset == null) { + try { +// if(debug)System.out.println("·0"); + TcUtils.setByPass(true); + } catch (Exception e2) { + e2.printStackTrace(); + } + try { + dataset = createDataSet(rev,arg0.getPropertyDisplayableValue("object_name").replace(".exb", ".pdf"));//PDF_Reference + POM_system_class get_owning_user = rev.get_owning_user();//rev.getPropertyObject("").getModelObjectValue(); + TcUtils.changeOwnershipModelObject(get_owning_user, "",new ModelObject[] {dataset}); +// TCComponentDatasetType datasetType = (TCComponentDatasetType) session.getTypeComponent("Dataset"); +// dataset = datasetType.create(arg0.getProperty("object_name").replace(".exb", ".pdf"), "", "PDF"); +// rev.add("IMAN_specification", dataset); + + } catch (Exception e) { + e.printStackTrace(); + try { +// if(debug)System.out.println("·"); + TcUtils.setByPass(false); + } catch (Exception e2) { + e2.printStackTrace(); + } + } + } +// if (dataset == null) { +//// MessageBox.post("ʧ", "", MessageBox.ERROR); +//// return null; +// } + + try { + try { +// if(debug)System.out.println("·1"); + TcUtils.setByPass(true); + } catch (Exception e2) { + e2.printStackTrace(); + } + + try { + updateDataSet(dataset, addPdfPath, "PDF_Reference"); + //ӷ״̬ + ReleaseStatus[] get_release_status_list = dataset.get_release_status_list(); + if(get_release_status_list.length == 0) { + ReleaseStatusInput releaseStatusInput = new ReleaseStatusInput(); + ReleaseStatusOption releaseStatusOption = new ReleaseStatusOption(); + releaseStatusOption.newReleaseStatusTypeName = releaseStatus; + releaseStatusOption.operation = "Append"; + releaseStatusInput.objects = new WorkspaceObject[]{ (WorkspaceObject)dataset }; + releaseStatusInput.operations = new ReleaseStatusOption[] {releaseStatusOption}; + WorkflowService workflowService = WorkflowService.getService(AppXSession.getConnection()); + SetReleaseStatusResponse setReleaseStatus = workflowService.setReleaseStatus(new ReleaseStatusInput[] {releaseStatusInput}); + System.out.println(); + } + if(mainArgs.length >=5) { + //identiyʶ + if(mainArgs[4].contains(";")){ + String[] splitIdentity = mainArgs[4].split(";"); + Map propValueMap = new HashMap(); + DataManagement.VecStruct vec = new DataManagement.VecStruct(); + vec.stringVec = new String[] { splitIdentity[1]}; + propValueMap.put(splitIdentity[0], vec) ; + dmService.setProperties(new ModelObject[] {rev}, propValueMap); + } + + } + + //ж + POM_system_class rev_owning = rev.get_owning_user(); + POM_system_class dataset_owning = dataset.get_owning_user(); + if(!rev_owning.getUid().equals(dataset_owning.getUid())) { + TcUtils.changeOwnershipModelObject(rev_owning, "",new ModelObject[] {dataset}); + } +// dataset.setFiles(new String[] { addPdfPath }, new String[] { "PDF_Reference" }); + } catch (Exception e) { + e.printStackTrace(); + try { + if (debug) + System.out.println("滻pdfʧܣ·"); + TcUtils.setByPass(false); + } catch (Exception e2) { + e2.printStackTrace(); + } + } + + try { +// if(debug)System.out.println("滻pdfɹ·"); + TcUtils.setByPass(false); + } catch (Exception e2) { + e2.printStackTrace(); + } +// if(debug)System.out.println("end"); + } catch (Exception e) { + e.printStackTrace(); + } + } +// +// // pdfݼ +// public void RecreatePdf(TCComponentDataset arg0, TCComponentItemRevision rev) { +// // жϰ汾pdfݼƺcaxaͬо滻ûо½ +// TCComponent[] datasets = null; +// TCComponentDataset dataset = null; +// try { +// datasets = (TCComponent[]) rev.getTCProperty("IMAN_specification").getReferenceValueArray(); +// String pdfName = ""; +// String caxaName = ""; +// for (int i = 0; i < datasets.length; i++) { +// if (datasets[i].getProperty("object_type").equals("PDF")) { +// pdfName = datasets[i].getProperty("object_name"); +// caxaName = arg0.getProperty("object_name"); +// if (pdfName.contains(".pdf") && caxaName.contains(".exb")) { +// pdfName = pdfName.substring(0, pdfName.lastIndexOf(".pdf")); +// if (debug) +// System.out.println(pdfName); +// caxaName = caxaName.substring(0, caxaName.lastIndexOf(".exb")); +// if (debug) +// System.out.println(pdfName); +// } +// } +// if (datasets[i].getProperty("object_type").equals("PDF") && caxaName.equals(pdfName)) { +// dataset = (TCComponentDataset) datasets[i]; +// } +// } +// } catch (TCException e1) { +// e1.printStackTrace(); +// } +// +// if (dataset == null) { +// return; +// } else { +// +// try { +// try { +//// if(debug)System.out.println("·1"); +// ChangeDbomUtil.setByPass(true); +// } catch (TCException e2) { +// e2.printStackTrace(); +// } +// +// try { +// dataset.removeFiles("PDF_Reference"); +// if (debug) +// System.out.println("PDFԭɾ"); +//// dataset.setFiles(new String[] { addPdfPath}, new String[] { "PDF_Reference" }); +// } catch (Exception e) { +// e.printStackTrace(); +// try { +// if (debug) +// System.out.println("ɾpdfʧܣ·"); +// ChangeDbomUtil.setByPass(false); +// } catch (TCException e2) { +// e2.printStackTrace(); +// } +// } +// +// try { +//// if(debug)System.out.println("滻pdfɹ·"); +// ChangeDbomUtil.setByPass(false); +// } catch (TCException e2) { +// e2.printStackTrace(); +// } +//// if(debug)System.out.println("end"); +// } catch (Exception e) { +// e.printStackTrace(); +// } +// } +// +// } +// + public static String newString(String oldName) { +// String newName=oldName; + if (oldName.contains("/")) { + if (debug) + System.out.println("bingo"); + oldName = getNewName("/", oldName); + } + if (oldName.contains("*")) { + oldName = getNewName("*", oldName); + } + if (oldName.contains("\\")) { + oldName = getNewName("\\", oldName); + } + if (oldName.contains(":")) { + oldName = getNewName(":", oldName); + } + if (oldName.contains("?")) { + oldName = getNewName("?", oldName); + } + if (oldName.contains("\"")) { + oldName = getNewName("\"", oldName); + } + if (oldName.contains("<")) { + oldName = getNewName("<", oldName); + } + if (oldName.contains(">")) { + oldName = getNewName(">", oldName); + } + if (oldName.contains("|")) { + oldName = getNewName("|", oldName); + } + if (oldName.contains("")) { + oldName = getNewName("", oldName); + } + if (oldName.contains("")) { + oldName = getNewName("", oldName); + } + return oldName; + } +// + public static String getNewName(String illegalCharacter, String oldString) { + if (illegalCharacter.equals("")) { + oldString = oldString.replace(illegalCharacter, "("); + } else if (illegalCharacter.equals("")) { + oldString = oldString.replace(illegalCharacter, ")"); + + } else { + + oldString = oldString.replace(illegalCharacter, "--"); + } + return oldString; + } +// +// +// public void sendMail(String message, String title) throws TCException { +// TCComponentUserType userType = (TCComponentUserType) session.getTypeComponent("User"); +// TCComponentUser user = userType.find("admin"); +// TCComponent[] targetUser = new TCComponent[] { user }; +// try { +// TCComponentEnvelopeType type = (TCComponentEnvelopeType) session.getTypeComponent("Envelope"); +// TCComponentEnvelope envelope = type.create(title, message, ""); +// envelope.setProperty("object_name", "caxa" + title); +// envelope.addReceivers(targetUser); +// envelope.send(); +// } catch (TCException e) { +// e.printStackTrace(); +// } +// } + public static void main(String[] args) throws Exception { + mainArgs = args; + String serverHost = "http://10.10.10.35:8080/tc"; + String host = System.getProperty("host"); + if (host != null && host.length() > 0) { + serverHost = host; + } + + session = new AppXSession(serverHost); + User user = session.login(); + + dmService = DataManagementService.getService(AppXSession.getConnection()); + fmu = new FileManagementUtility(AppXSession.getConnection(), + null, + new String[] { "http://10.10.10.35:4544" }, + new String[] { "http://10.10.10.35:4544" }, + "D://TEMP//fcc_tmp"); + tcp = PreferenceManagementService.getService(AppXSession.getConnection()); + if(args.length!=5) { + tryAgain(); + } + + try { + while(write()) { + try { + int sec = new java.util.Random().nextInt(30); + System.out.println(""+sec+"s"); + Thread.sleep(1000*sec); // 1~10 + } catch (Exception e) { + + } + } + + FTPUtils.getConfigureInfomationg(tcp,args[3]); + + //ȡݼ +// DataManagementService dataManagementService = DataManagementService.getService(AppXSession.getConnection()); + + + String revPuids[] = args[0].split(","); + String puidss[] = args[1].split("\\|"); + for(int i = 0 ; i < revPuids.length ; i++) { + ItemRevision rev = null; + try { + rev = (ItemRevision) dmService.loadObjects(new String[] {revPuids[i]}).getPlainObject(0); + }catch(Exception for1) { + continue; + } +// dmService.getProperties(new ModelObject[] {rev}, new String[] {"hx3_identity"}); +// String identity = rev.getPropertyDisplayableValue("hx3_identity"); + // if(identity != null && "Y".equals(identity)) { + // System.out.println("תͼʶ"+identity); + // return; + // } + String puids[] = puidss[i].split(","); + for(String puid : puids) { + try { + + Dataset dataset = (Dataset) dmService.loadObjects(new String[] {puid}).getPlainObject(0); + releaseStatus = args[2]; + companyName = args[3]; + loadWaitPdf(); + property(dataset,rev); + }catch(Exception for2) { + continue; + } + } + } + + }catch (Exception e) { + e.printStackTrace(); + }finally { + //ɾļ + String path = caxaPropertyHandler.class.getProtectionDomain().getCodeSource().getLocation().getPath(); + path = path.replace("%20", " "); + String exePath = new File(path).getParent() + "//"; + if(checkFile("CaxaToPDF.lock",new File(exePath))) { + String fileName = "CaxaToPDF.lock"; + File lockFile = new File(exePath+ fileName); + lockFile.delete(); + } + //쳣 + if(hasException) { + tryAgain(); + } + } + + } + public static String consumeInputStream(InputStream is) throws IOException { + BufferedReader br = new BufferedReader(new InputStreamReader(is,"GBK")); + String s; + StringBuilder sb = new StringBuilder(); + while ((s = br.readLine()) != null) { + System.out.println(s); + sb.append(s); + } + return sb.toString(); + } + + private static void tryAgain() { + checkDir("D://TEMP//fcc_tmp"); + + } + private static void checkDir(String dir) { + + File[]files= new File(dir).listFiles(); + List exbFileList = new ArrayList(); + Map exbPuidMap = new HashMap(); + for(File file:files) + { + String fileName = file.getName(); + if(fileName.contains("@")) { + exbPuidMap.put(fileName.split("@")[0], fileName.split("@")[1]); + } + if(fileName.substring(fileName.length()-3, fileName.length()).equals("exb")) { + exbFileList.add(file); + } + System.out.println(fileName); + } + for(File exbFile : exbFileList) { + if(exbPuidMap.containsKey(exbFile.getName())) { + //ִ + String puid = exbPuidMap.get(exbFile.getName()); + File deleteFile = new File(exbFile.getPath()+"@"+puid); + try { + deleteFile.delete(); + ModelObject plainObject = dmService.loadObjects(new String[] {puid.split("#")[1]}).getPlainObject(0); + updateDataSet((Dataset) plainObject,exbFile.getPath(),"HX3_exb"); + +// Runtime runtime = Runtime.getRuntime(); //ȡRuntimeʵ +// String[] command = {"cmd", "/c", "start java -jar D:\\Siemens\\Teamcenter11\\portal\\plugins\\CaxaToPDF.jar \""+puid.split("#")[0]+"\" \""+puid.split("#")[1]+"\" \""+puid.split("#")[2]+"\" \""+puid.split("#")[3]+"\" \"Y\""}; +// Process process = runtime.exec(command); + String main_args[] = new String[] {puid.split("#")[0],puid.split("#")[1],puid.split("#")[2],puid.split("#")[3],"Y"}; + new caxaPropertyHandler().main(main_args); + } catch (Exception e) { + try { + deleteFile.createNewFile(); + } catch (IOException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + e.printStackTrace(); + } + + } + } + System.out.println(); + } + /** + * Ƿȴִ + * @return + * @throws IOException + */ + private static boolean write() throws IOException { + String path = caxaPropertyHandler.class.getProtectionDomain().getCodeSource().getLocation().getPath(); + path = path.replace("%20", " "); + String exePath = new File(path).getParent() + "//"; + if(checkFile("CaxaToPDF.lock",new File(exePath))) { + return true; + } + + String fileName = "CaxaToPDF.lock"; + File lockFile = new File(exePath+ fileName); + if (!lockFile.exists()) { + lockFile.createNewFile(); + } + System.out.println(); + return false; + } + + private static boolean checkFile(String filename,File dir) + { + + File[]files=dir.listFiles(); + for(File file:files) + { + + if(file.isFile() && filename.equals(file.getName())) //fileʱļļͬʱ; + { + return true; + } + } + return false; + } + + private static void writeTime() { + try { + int sec = new java.util.Random().nextInt(30); + System.out.println(""+sec+"s"); + Thread.sleep(1000*sec); // 1~10 + } catch (Exception e) { + System.out.println("Got an exception!"); + } + + +} + private static void updateDataSet(Dataset dataset, String filePath,String namedRef) throws Exception{ + +// try { + + + + //ȡãļ + dmService.getProperties(new ModelObject[]{dataset},new String[]{"ref_list"}); + int refListNum = dataset.get_ref_list().length; + ServiceData removeNamedReferenceFromDatasetServiceDate = null; + if(refListNum == 0 ){ + System.out.println("ݼã"); + } + else { + // + com.teamcenter.services.strong.core._2007_09.DataManagement.NamedReferenceInfo[] namedReferenceInfos = new com.teamcenter.services.strong.core._2007_09.DataManagement.NamedReferenceInfo[refListNum]; + for(int i = 0 ; i < refListNum ; i++ ){ + ModelObject[] get_ref_list = dataset.get_ref_list(); + ImanFile namedRefMobj = (ImanFile) dataset.get_ref_list()[i]; + dmService.refreshObjects(new ModelObject[] {namedRefMobj}); + dmService.getProperties(new ModelObject[]{namedRefMobj},new String[]{"file_ext"}); + String get_file_ext = namedRefMobj.get_file_ext(); + com.teamcenter.services.strong.core._2007_09.DataManagement.NamedReferenceInfo namedReferenceInfo= new com.teamcenter.services.strong.core._2007_09.DataManagement.NamedReferenceInfo(); + namedReferenceInfo.type = namedRef; + namedReferenceInfo.deleteTarget = true; + namedReferenceInfo.targetObject = namedRefMobj; + namedReferenceInfos[i] = namedReferenceInfo; + } + + //ɾ + com.teamcenter.services.strong.core._2007_09.DataManagement.RemoveNamedReferenceFromDatasetInfo[] removeNamedReferenceFromDatasets = new com.teamcenter.services.strong.core._2007_09.DataManagement.RemoveNamedReferenceFromDatasetInfo[1]; + com.teamcenter.services.strong.core._2007_09.DataManagement.RemoveNamedReferenceFromDatasetInfo removeNamedReferenceFromDataset = new com.teamcenter.services.strong.core._2007_09.DataManagement.RemoveNamedReferenceFromDatasetInfo(); + removeNamedReferenceFromDataset.dataset = dataset; + removeNamedReferenceFromDataset.nrInfo = namedReferenceInfos; + removeNamedReferenceFromDatasets[0] = removeNamedReferenceFromDataset; + removeNamedReferenceFromDatasetServiceDate = dmService.removeNamedReferenceFromDataset(removeNamedReferenceFromDatasets); + } + + if((removeNamedReferenceFromDatasetServiceDate != null + && removeNamedReferenceFromDatasetServiceDate.sizeOfDeletedObjects() > 0 ) + || refListNum == 0){ + System.out.println("ɾɹ"); + //µ + FileManagement.DatasetFileInfo fileInfo = new FileManagement.DatasetFileInfo(); + + fileInfo.allowReplace = false; +// fileInfo.clientId = fileInfo.toString(); + fileInfo.fileName = filePath; + fileInfo.isText = false; + fileInfo.namedReferencedName = namedRef; + + FileManagement.DatasetFileInfo[] fileInfos = { fileInfo }; + + FileManagement.GetDatasetWriteTicketsInputData inputData = new FileManagement.GetDatasetWriteTicketsInputData(); + inputData.dataset = dataset; + inputData.createNewVersion = false; + inputData.datasetFileInfos = fileInfos; + + FileManagement.GetDatasetWriteTicketsInputData[] inputs = { inputData }; + ServiceData putFilesServiceData = fmu.putFiles(inputs); +// fileManagementUtility.putFiles(inputs); + if(putFilesServiceData.sizeOfUpdatedObjects() > 0){ + System.out.println(""); + } + fmu.term(); + + + } else{ + String[] errMsg = removeNamedReferenceFromDatasetServiceDate.getPartialError(0).getMessages(); + System.out.println("ɾʧܣ"); + } +// throw new Exception("1"); +// } catch (Exception e) { +// e.printStackTrace(); +// } + + } + //TCFMSеļת + public static File TCFileToFile(Dataset dataset) throws Exception{ + if(dataset == null){ + return null; + } + File outFile = null; + String filename = ""; + + dmService.getProperties(new ModelObject[] { dataset}, new String[]{"ref_list"}); + ModelObject[] objects = dataset.get_ref_list(); + dmService.getProperties( objects, new String[]{"original_file_name"}); + filename = objects[0].getPropertyObject("original_file_name").getStringValue(); +// filename = CommonlyUtils.getNowDate()+ filename; + GetFileResponse getFileResponse = fmu.getFiles(objects); + File[] fileinfovec = getFileResponse.getFiles(); + outFile = fileinfovec[0]; +// nameMap.put(outFile.getName(),filename); + + return outFile; + } + /*** + * ݼ API + * @param targetMobj Ŀݼ + * @param datasetName ݼ + * @param filePath ļ· + */ + private static Dataset createDataSet(ModelObject targetMobj,String datasetName) { + + //ݼ + com.teamcenter.services.strong.core._2008_06.DataManagement.DatasetProperties2 datasetProperties2 = new com.teamcenter.services.strong.core._2008_06.DataManagement.DatasetProperties2(); + datasetProperties2.name = datasetName; + datasetProperties2.type ="PDF"; + datasetProperties2.clientId="PDF_1"; + datasetProperties2.container = targetMobj; + datasetProperties2.relationType = "IMAN_specification"; + CreateDatasetsResponse ceateDatasetsResponse = dmService.createDatasets2(new com.teamcenter.services.strong.core._2008_06.DataManagement.DatasetProperties2[]{datasetProperties2}); + Dataset dt = ceateDatasetsResponse.output[0].dataset; + return dt; +// // +// FileManagement.DatasetFileInfo fileInfo = new FileManagement.DatasetFileInfo(); +// fileInfo.allowReplace = false; +// fileInfo.fileName = filePath; +// fileInfo.isText = false; +// fileInfo.namedReferencedName = "HG8_dwg"; +// FileManagement.DatasetFileInfo[] fileInfos = { fileInfo }; +// +// //ݼ +// FileManagement.GetDatasetWriteTicketsInputData inputData = new FileManagement.GetDatasetWriteTicketsInputData(); +// inputData.dataset = dt; +// inputData.createNewVersion = false; +// inputData.datasetFileInfos = fileInfos; +// FileManagement.GetDatasetWriteTicketsInputData[] inputs = { inputData }; +// ServiceData response = fmu.putFiles(inputs); +// fmu.term(); + +// + } + // Ӱϻȡ + public static List getWhereReference(WorkspaceObject[] obj ,int number){ + List list = new ArrayList(); + DataManagement.WhereReferencedResponse response = dmService.whereReferenced(obj,number); + DataManagement.WhereReferencedInfo[] info = response.output[0].info; + for (int i = 0; i < info.length; i++) { + if(info[i].relation.equals("HX3_ggh")) { + list.add(info[i].referencer); + } + } + return list; + } + private static Map getECNValueMap(ItemRevision rev) throws Exception { + // 2019.11.254ӳ䣺İΣ汾ţļţ֪ͨıţǩ֣ϹԱڣ֪ͨڣգ + // ֻһθļ¼ + String dateString = ""; + Map valueMap = new HashMap(); + List ecr = getWhereReference(new WorkspaceObject[] {rev}, 1); +// AIFComponentContext[] ecr = rev.whereReferenced(); + for (int i = 0; i < ecr.size(); i++) { + if(ecr.get(i) instanceof ItemRevision) { + ItemRevision ecrRev = (ItemRevision) ecr.get(i); + dmService.getProperties(new ModelObject[] {ecrRev}, new String[] {"creation_date","item_id"}); + System.out.println("ecrRev.getProperty:" + ecrRev.getTypeObject().getName()); + System.out.println(); + if (ecrRev.getTypeObject().getName().equals("HX3_GCGGTZDRevision")) { + + SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); + String dateString2 = format.format(ecrRev.get_creation_date().getTime()) ; + String revType = rev.getTypeObject().getName(); + System.out.println("revType:" + revType); + if (dateString.length() == 0) { + dateString = dateString2; + if (revType.equals("HX3_ZPTRevision") || revType.equals("HX3_LJTRevision") + || revType.equals("HX3_WXTRevision") || revType.equals("HX3_DJTRevision") || revType.equals("HX3_TYGY1Revision")) { + + valueMap.put("İ1", rev.get_item_revision_id()); + valueMap.put("ļ1", ecrRev.get_item_id()); + valueMap.put("ǩ1", "ϹԱ"); + valueMap.put("1", format.format(ecrRev.get_creation_date().getTime())); + } else if (revType.equals("HX3_GYTRevision")) { + valueMap.put("İ", rev.get_item_revision_id()); + valueMap.put("ļ", ecrRev.get_item_id()); + valueMap.put("ǩ", "ϹԱ"); + valueMap.put("", format.format(ecrRev.get_creation_date().getTime())); + + } + } else { + if (dateString.compareTo(dateString2) < 0) { + dateString = dateString2; + if (revType.equals("HX3_ZPTRevision") || revType.equals("HX3_LJTRevision") + || revType.equals("HX3_WXTRevision")|| revType.equals("HX3_DJTRevision")|| revType.equals("HX3_TYGY1Revision")) { + + valueMap.put("İ1", rev.get_item_revision_id()); + valueMap.put("ļ1", ecrRev.get_item_id()); + valueMap.put("ǩ1", "ϹԱ"); + valueMap.put("1", format.format(ecrRev.get_creation_date().getTime())); + } else if (revType.equals("HX3_GYTRevision")) { + valueMap.put("İ", rev.get_item_revision_id()); + valueMap.put("ļ", ecrRev.get_item_id()); + valueMap.put("ǩ", "ϹԱ"); + valueMap.put("", format.format(ecrRev.get_creation_date().getTime())); + + } + } + } + } + + + } + + } + return valueMap; + + } +} diff --git a/src/com/connor/signoff/soa/handler/caxaPropertyHandler.java b/src/com/connor/signoff/soa/handler/caxaPropertyHandler.java new file mode 100644 index 0000000..220a483 --- /dev/null +++ b/src/com/connor/signoff/soa/handler/caxaPropertyHandler.java @@ -0,0 +1,2383 @@ +package com.connor.signoff.soa.handler; +import java.io.BufferedReader; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.OutputStream; +import java.io.PrintWriter; +import java.io.UnsupportedEncodingException; +import java.lang.reflect.InvocationTargetException; +import java.net.MalformedURLException; +import java.net.SocketException; +import java.net.URISyntaxException; +import java.net.URLDecoder; +import java.nio.file.Files; +import java.security.KeyManagementException; +import java.security.NoSuchAlgorithmException; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Date; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Properties; +import java.util.concurrent.TimeoutException; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import org.apache.commons.net.ftp.FTPClient; +import org.apache.commons.net.ftp.FTPFile; +import org.apache.commons.net.ftp.FTPReply; +import org.apache.log4j.Logger; +import org.apache.log4j.PropertyConfigurator; +import org.dom4j.Document; +import org.dom4j.Element; +import org.dom4j.io.SAXReader; +import com.itextpdf.text.BadElementException; +import com.itextpdf.text.Image; +import com.itextpdf.text.Rectangle; +import com.itextpdf.text.pdf.PdfContentByte; +import com.itextpdf.text.pdf.PdfGState; +import com.itextpdf.text.pdf.PdfReader; +import com.itextpdf.text.pdf.PdfStamper; +import com.teamcenter.clientx.AppXSession; +import com.teamcenter.services.strong.administration.PreferenceManagementService; +import com.teamcenter.services.strong.administration._2012_09.PreferenceManagement; +//import com.teamcenter.services.strong.administration._2012_09.PreferenceManagement; +import com.teamcenter.services.strong.administration.*; +import com.teamcenter.services.strong.core.DataManagementService; +import com.teamcenter.services.strong.core.SessionService; +import com.teamcenter.services.strong.core._2006_03.DataManagement.CreateDatasetsResponse; +import com.teamcenter.services.loose.core._2006_03.FileManagement; +import com.teamcenter.soa.client.FileManagementUtility; +import com.teamcenter.soa.client.GetFileResponse; +import com.teamcenter.soa.client.model.ModelObject; +import com.teamcenter.soa.client.model.Property; +import com.teamcenter.soa.client.model.ServiceData; +import com.teamcenter.soa.client.model.strong.Dataset; +import com.teamcenter.soa.client.model.strong.ImanFile; +import com.teamcenter.soa.client.model.strong.Item; +import com.teamcenter.soa.client.model.strong.ItemRevision; +import com.teamcenter.soa.client.model.strong.POM_system_class; +import com.teamcenter.soa.client.model.strong.ReleaseStatus; +import com.teamcenter.soa.client.model.strong.User; +import com.teamcenter.soa.client.model.strong.WorkspaceObject; +import com.teamcenter.soa.exceptions.NotLoadedException; +import com.teamcenter.services.strong.workflow._2007_06.Workflow.ReleaseStatusInput; +import com.teamcenter.services.strong.workflow._2007_06.Workflow.ReleaseStatusOption; +import com.teamcenter.services.strong.workflow._2007_06.Workflow.SetReleaseStatusResponse; +import com.teamcenter.services.strong.workflow.WorkflowService; +import com.teamcenter.services.strong.core._2007_01.DataManagement; +import com.teamcenter.services.strong.core._2007_01.Session; +public class caxaPropertyHandler { + + public static boolean debug = true; + private static String fileName; + private static FTPClient ftpClient = null; + private static String exePath;//· + private static String[] refValues;//ӳ + private static AppXSession session; +// InterfaceAIFComponent[] targetComp; + private static String caxaInfo = ""; + private static Logger logger = null; + private static int waitPdf = 0; + + private static String releaseStatus; + + private static DataManagementService dmService; + private static FileManagementUtility fmu; + private static PreferenceManagementService tcp; + + private static boolean hasException = true; + private static String companyName; + private static String mainArgs[]; +// private static Stirng re + /** + * strERR = "" + */ +// private static String strERR = ""; +// +// /** +// * +// */ +// private static int monitorWorkCount = 0; +// +// public String traverseFolder(String path) { +// +// File file = new File(path); +// if (file.exists()) { +// File[] files = file.listFiles(); +// if (null == files || files.length == 0) { +// if (debug) +// System.out.println("ļǿյ!"); +// +// } else { +// for (File file2 : files) { +// if (file2.isDirectory()) { +// } else { +// if (file2.getAbsolutePath().toLowerCase().endsWith(".exb")) { +// if (debug) +// System.out.println("ļ:" + file2.getAbsolutePath()); +// return file2.getAbsolutePath(); +// } +// +// } +// } +// } +// } else { +// if (debug) +// System.out.println("ļ!"); +// } +// return ""; +// +// } + /** + * GBKļתΪISOʽ + * һwinϵͳϴļFTP + * @param fileNameGBK + * @return + */ + public static String convGBKtoISO(String fileNameGBK) { + String filenameISO=""; + try { + filenameISO = new String(fileNameGBK.getBytes("GBK"),"iso-8859-1"); + } catch (UnsupportedEncodingException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return filenameISO; + } +// + /** + * ISOļתΪGBKʽ + * һFTPļwinϵͳ + * @param fileNameGBK + * @return + */ + public static String convISOtoGBK(String fileNameISO) { + String filenameGBK=""; + try { + filenameGBK = new String(fileNameISO.getBytes("iso-8859-1"),"GBK"); + } catch (UnsupportedEncodingException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return filenameGBK; + } +// + /** + * ļ + * @param ref_list + * @param fileOgiginName + * + * @param comps + * @return + * @throws TCException + * @throws IOException + */ + public static String downLoadCaxaFile(File ref_list, String fileOgiginName, Dataset comp, ItemRevision rev) { + if (comp == null) { + return ""; + } + String value = ""; + String tempPath = System.getenv("TEMP"); + // MessageBox.post(" tempPath = + // "+tempPath,"INFO",MessageBox.INFORMATION); + if (tempPath == null) { + tempPath = ""; + } else if (!tempPath.endsWith("\\")) { + tempPath = tempPath + "\\"; + } + SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmssSSS"); + // for(TCComponent comp : comps){ + try { +// if (comp instanceof Dataset) { +// ModelObject[] objects = {comp}; +// dmService.refreshObjects(objects); +// dmService.getProperties(objects, new String[]{"ref_list"}); +// objects = comp.get_ref_list(); +// +// GetFileResponse getFileResponse = fmu.getFiles(objects); +// File[] tcFiles = getFileResponse.getFiles(); +//// TCComponentTcFile[] tcFiles = ((TCComponentDataset) comp).getTcFiles(); +// File file = null; +//// if(debug)System.out.println("tcFiles:" + tcFiles.length); +// if (tcFiles != null && tcFiles.length != 0) { +// file = tcFiles[0]; + dmService.getProperties(new ModelObject[] {rev}, new String[] {"item_id","item_revision_id"}); + String fileName = fileOgiginName; +// if(debug)System.out.println("fileName:" + fileName); + String fileDix = fileName.substring(fileName.lastIndexOf("."), fileName.length()); + String item_id = rev.getPropertyDisplayableValue("item_id"); + String item_revision_id = rev.getPropertyDisplayableValue("item_revision_id"); + String fileRealName =item_id + "-" + item_revision_id + sdf.format(new Date()) + fileDix; + Pattern pattern = Pattern.compile("[\\s\\\\/:\\*\\?\\\"<>\\|]"); + Matcher matcher = pattern.matcher(fileRealName); + + fileRealName= matcher.replaceAll(""); // ƥ䵽ķǷַԿ滻 + + fileName = tempPath +fileRealName; + + File newFile = new File(fileName); + ref_list.renameTo(newFile); +// +// File.copyFile(ref_list, dirFile); +// +// if (debug) +// System.out.println("111111111111"); + return fileName; +// } +// } + } catch (Exception e) { + e.printStackTrace(); + } + // } + return value; + } +// +// /** +// * ļ +// * +// * @param comps +// * @return +// * @throws TCException +// * @throws IOException +// */ +// public String downLoadFile(TCComponent comp) { +// if (comp == null) { +// return ""; +// } +// String value = ""; +// String tempPath = System.getenv("TEMP"); +// // MessageBox.post(" tempPath = +// // "+tempPath,"INFO",MessageBox.INFORMATION); +// if (tempPath == null) { +// tempPath = ""; +// } else if (!tempPath.endsWith("\\")) { +// tempPath = tempPath + "\\"; +// } +// SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmssSSS"); +// // for(TCComponent comp : comps){ +// try { +// if (comp instanceof TCComponentDataset) { +// TCComponentTcFile[] tcFiles = ((TCComponentDataset) comp).getTcFiles(); +// File file = null; +//// if(debug)System.out.println("tcFiles:" + tcFiles.length); +// if (tcFiles != null && tcFiles.length != 0) { +// file = tcFiles[0].getFmsFile(); +// String fileName = file.getName(); +//// if(debug)System.out.println("fileName:" + fileName); +// String fileDix = fileName.substring(fileName.lastIndexOf("."), fileName.length()); +// fileName = tempPath + sdf.format(new Date()) + fileDix; +// File dirFile = new File(fileName); +// +// FileUtility.copyFile(file, dirFile); +// +// if (debug) +// System.out.println("11111111111"); +// return fileName; +// } +// } +// } catch (TCException e) { +// e.printStackTrace(); +// } catch (IOException e) { +// e.printStackTrace(); +// } +// // } +// return value; +// } +// + public static void caxaToPdf(Dataset component) throws Exception { +// int messageCount=getMessage(); +// if(debug)System.out.println("ǰŶ===="+messageCount); +// property(component); + } + + public static void property(Dataset dataset,ItemRevision rev) { + String workDir = System.getenv("TEMP") + File.separator + "caxaBatch"; + File workDirFile = new File(workDir); + if (!workDirFile.exists()) { + workDirFile.mkdirs(); + } + + try { + String fileOgiginName = ""; + ModelObject[] tempObjects = {dataset}; + dmService.refreshObjects(tempObjects); + dmService.getProperties(tempObjects, new String[]{"ref_list"}); + tempObjects = dataset.get_ref_list(); + + ModelObject exbRefFile = null; + dmService.getProperties(tempObjects, new String[]{"original_file_name","file_ext"}); + for(int i = 0;i < tempObjects.length;i++) { + fileOgiginName = tempObjects[i].getPropertyObject("original_file_name").getStringValue(); + String refExtString = tempObjects[i].getPropertyObject("file_ext").getStringValue(); + + if(refExtString.toLowerCase().equals("exb")) { + exbRefFile = tempObjects[i]; + break; + } + } + tempObjects = new ModelObject[] {exbRefFile}; + + GetFileResponse getFileResponse = fmu.getFiles(tempObjects); + File[] ref_lists = getFileResponse.getFiles(); + + + if (ref_lists.length == 0) { + caxaInfo = caxaInfo + ";" + "caxaʧ,û";//:id" + item_id + " 汾" + item_rev_id; + return; + } + File exbFile1 = ref_lists[0]; + + if (exbFile1 == null) { + caxaInfo = caxaInfo + ";" + "ûҵexbļ";//:id" + item_id + " 汾" + item_rev_id; + return; + } + + + + + // TODO Ⱥϴcaxaxmlļftpת + String tempCaxaPath = ""; + + tempCaxaPath = downLoadCaxaFile(exbFile1,fileOgiginName,dataset, rev);// ļtemp·£Ϊǰʱ +// + // пΪգ粻õʱ + if (tempCaxaPath.trim().length() == 0) { + caxaInfo = caxaInfo + ";" + "caxaʧ";//:id" + item_id + " 汾" + item_rev_id; + return; + } + + File file = new File(tempCaxaPath); + + String tempCaxaPathName = tempCaxaPath.substring(tempCaxaPath.lastIndexOf("\\") + 1); + second(new File(tempCaxaPath)); + FileInputStream tempCaxaPathIn = null; + + try { + tempCaxaPathIn = new FileInputStream(new File(tempCaxaPath)); + + } catch (FileNotFoundException e) { + e.printStackTrace(); + } + if (debug) + System.out.println("ʼϴcaxa"); + boolean tempCaxa = uploadFile(FTPUtils.ftpHost, FTPUtils.ftpUserName, FTPUtils.ftpPassword, FTPUtils.ftpPort, FTPUtils.ftpPath, tempCaxaPathName, tempCaxaPathIn); + if (tempCaxa == false) { + + caxaInfo = caxaInfo + ";" + "caxaϴʧ";//:id" + item_id + " 汾" + item_rev_id; + if (debug) + System.out.println("upload fail----------------"); + return; + } + + boolean jump = hx_SetCAXAFile(dataset, + tempCaxaPathName.substring(0, tempCaxaPathName.length() - 4),fileOgiginName,rev); + if (jump == false) { + return; + } + second(new File(tempCaxaPath.replace(".exb", ".xml"))); + FileInputStream tempXmlPathIn = null; + try { + tempXmlPathIn = new FileInputStream(new File(tempCaxaPath.replace(".exb", ".xml"))); + + } catch (FileNotFoundException e) { + e.printStackTrace(); + } + if (debug) + System.out.println("ϴxml"); + boolean tempXml = uploadFile(FTPUtils.ftpHost, FTPUtils.ftpUserName, FTPUtils.ftpPassword, FTPUtils.ftpPort, FTPUtils.ftpPath, + tempCaxaPathName.replace(".exb", ".xml"), tempXmlPathIn); + if (tempXml == false) { + caxaInfo = caxaInfo + ";" + "xmlϴʧ";//:id" + item_id + " 汾" + item_rev_id; + return; + } +// + // жǷokerrļ˵ӳɣ + if (debug) + System.out.println("okerr"); + waitOkOrErrFileCount = 0; + boolean downResult = downOkOrErrFile(FTPUtils.ftpHost,FTPUtils.ftpPort, FTPUtils.ftpUserName, FTPUtils.ftpPassword, FTPUtils.ftpPath, tempCaxaPathName, workDir); + // ʧܣһftpԱָļtxtshxλãȡʹõȱʡ壩Ȼ󵯳Դλ\ĵ + if (downResult == false) { + caxaInfo = caxaInfo + ";" + "ӳʧ";//:id" + item_id + " 汾" + item_rev_id; + return; + } + // ɹ ɾftpϵͬtxt ȴpdf + if (debug) + System.out.println("ɾ " + tempCaxaPathName.replace(".exb", ".txt")); + boolean getPdf = deleteTxt(FTPUtils.ftpHost,FTPUtils.ftpPort, FTPUtils.ftpUserName, FTPUtils.ftpPassword, FTPUtils.ftpPath,tempCaxaPathName, workDir); + if (!getPdf) { + caxaInfo = caxaInfo + ";" + "txtɾʧ";//:id" + item_id + " 汾" + item_rev_id; + return; + } +// + // 滻caxa + if (debug) + System.out.println("caxa"); + count = 0; + boolean downCaxa = downFile(FTPUtils.ftpHost,FTPUtils.ftpPort, FTPUtils.ftpUserName, FTPUtils.ftpPassword, FTPUtils.ftpPath, tempCaxaPathName, workDir); + if (downCaxa == false) { + if (debug) + System.out.println("caxaʧ"); + caxaInfo = caxaInfo + ";" + "caxaʧ";//:id" + item_id + " 汾" + item_rev_id; + return; + } + + if (new File(workDir + "\\" + fileOgiginName).exists()) { + new File(workDir + "\\" + fileOgiginName).delete(); + } + // пַܰ + boolean caxaFile = new File(workDir + "\\" + tempCaxaPathName) + .renameTo(new File(workDir + "\\" + fileOgiginName)); + if (caxaFile == false) { + caxaInfo = caxaInfo + ";" + "ʧ";//:id" + item_id + " 汾" + item_rev_id; + return; + } + if (debug) + System.out.println("滻"); + + TcUtils.setByPass(true); + //2023-11-15 liujb Ӳ start + File tcFileToFile = TCFileToFile(dataset); + File exbFile = new File("D:\\TEMP\\fcc_tmp"+ "\\" + fileOgiginName); + if (exbFile.exists()) { + exbFile.delete(); + } + boolean caxaFile2 = tcFileToFile.renameTo(exbFile); + String fileName = exbFile.getPath()+"@"+rev.getUid()+"#"+dataset.getUid()+"#"+releaseStatus; + File lockFile = new File(fileName); + + boolean createNewFile = lockFile.createNewFile(); + + updateDataSet(dataset, workDir + "\\" + fileOgiginName,"U2_EXB"); + exbFile.delete(); + lockFile.delete(); + TcUtils.setByPass(false); + + if (debug) + System.out.println("滻caxaɹ·id");//" + item_id + " 汾" + item_rev_id); + +// // 滻pdf +// if (debug) +// System.out.println("ʼpdf"); +// boolean sucess = downFile(FTPUtils.ftpHost,FTPUtils.ftpPort, FTPUtils.ftpUserName, FTPUtils.ftpPassword, FTPUtils.ftpPath, +// tempCaxaPathName.replace(".exb", ".pdf"), workDir); +// if (sucess == false) { +// // TODO ־ +// System.out.println(); +// +// } +// boolean action = false; +// String addPdfPath = ""; +// try { +// +// // Ҫǩ +// String item_id = rev.get_item_id(); +// String item_rev_id = rev.get_item_revision_id(); +// if("HX".equals(FTPUtils.CompanyName)) { +// String designType = rev.getTypeObject().getName(); +// String[] imgPath = new String[1]; +// +// String path = caxaPropertyHandler.class.getProtectionDomain().getCodeSource().getLocation().getPath(); +// path = path.replace("%20", " "); +// String exePath = new File(path).getParent() + "//"; +// String qianzhang = rev.getPropertyDisplayableValue("hx3_qianzhang").trim(); +// if(qianzhang.equals("ܿ") || qianzhang.equals("B") || qianzhang.isEmpty()) { +// +// exePath = exePath + "skz.png"; +// } +// else { +// exePath = exePath + "syz.png"; +// +// } +// +// imgPath[0] = exePath; +// item_id = newString(item_id); +// +// +// action = addPdfMark(workDir + File.separator + tempCaxaPathName.replace(".exb", ".pdf"), +// workDir + File.separator + item_id + item_rev_id + ".pdf", imgPath, designType); +// } +// // pdfߴ粻ģ壬ܿʧܣʱͰԭpdf滻ȥ +// if (action == false) { +// +// addPdfPath = workDir + File.separator+tempCaxaPathName.replace(".exb", ".pdf");//workDir + File.separator + fileName.replace(".exb", ".pdf"); +// +// } else { +// +// addPdfPath = workDir + File.separator + item_id + item_rev_id + ".pdf"; +// } +// } catch (Exception e) { +// // 3ʾͼƬ쳣 +// String HXC_STATUS = "3"; +// e.printStackTrace(); +// addPdfPath = workDir + File.separator+tempCaxaPathName.replace(".exb", ".pdf"); +// } +// +// // ñʾ + System.out.println("״̬תͼʶ"); + replaceOrcreate(dataset, rev); +// System.out.println("addPdfPath:"+addPdfPath); + + } catch (Exception e) { + e.printStackTrace(); + } + } + + private static boolean deleteTxt(String url, // FTPhostname + int port, // FTP˿ + String username, // FTP¼˺ + String password, // FTP¼ + String remotePath, // FTPϵ· + String fileName, // Ҫصļ + String localPath// غ󱣴浽ص· + + ) { + + boolean success = false; + FTPClient ftp = new FTPClient(); + try { + int reply; + ftp.connect(url, port); + // Ĭ϶˿ڣʹftp.connect(url)ķʽֱFTP + ftp.login(username, password);// ¼ +// ftp.login("anonymous", null);// ½FTP + reply = ftp.getReplyCode(); + if (!FTPReply.isPositiveCompletion(reply)) { + ftp.disconnect(); + return success; + } + ftp.enterLocalPassiveMode();// 䣬ЩԴ˷ǽͻftp.listFiles()│ס +// if(debug)System.out.println("aaa"); + boolean ftpchange = ftp.changeWorkingDirectory(remotePath);// תƵFTPĿ¼ + fileName = fileName.replace(".exb", ".txt"); + ftp.setControlEncoding("GBK"); //FTP ֧ + fileName = convGBKtoISO(fileName);//FTP ֧ + int flag = ftp.dele(fileName); + success = true; + + } catch (IOException e) { + e.printStackTrace(); + } finally { + if (ftp.isConnected()) { + try { + ftp.disconnect(); + } catch (IOException ioe) { + } + } + } + return success; + + } +static int count = 0;// +// + public static FTPFile[] waitPdf(FTPClient ftp, String fileName, String errorName, String okName) { + FTPFile[] fs = null; + try { + + fs = ftp.listFiles(); + } catch (IOException e1) { + e1.printStackTrace(); + } + + for (FTPFile ff : fs) { + //2023.04.06ҵ.okΪɹ.errorΪʧܲ + //FTP֧ + String ffName = convISOtoGBK(ff.getName()); + if (ffName.equals(okName)) { + System.out.println("find the pdf..."); + return fs; + } else if (ffName.equals(errorName)) { + System.out.println("ת쳣"); + return null; + } + } + System.out.println("waitPdf---count:" + count); + System.out.println("waitPdf----waitPdf:" + waitPdf); + try { + Thread.sleep(1000); + count++; + } catch (InterruptedException e) { + e.printStackTrace(); + } + // ʱ˳ + if (count > waitPdf) { + return null; + } + fs = waitPdf(ftp, fileName, errorName, okName); + return fs; + } +// + public static boolean downOkOrErrFile(String url, // FTPhostname + int port, // FTP˿ + String username, // FTP¼˺ + String password, // FTP¼ + String remotePath, // FTPϵ· + String fileName, // Ҫصļ + String localPath// غ󱣴浽ص· + + ) { + boolean success = false; + FTPClient ftp = new FTPClient(); + try { + int reply; + ftp.connect(url, port); + // Ĭ϶˿ڣʹftp.connect(url)ķʽֱFTP + ftp.login(username, password);// ¼ +// ftp.login("anonymous", null);// ½FTP + reply = ftp.getReplyCode(); + if (!FTPReply.isPositiveCompletion(reply)) { + ftp.disconnect(); + return success; + } + ftp.enterLocalPassiveMode();// 䣬ЩԴ˷ǽͻftp.listFiles()│ס +// if(debug)System.out.println("aaa"); + boolean ftpchange = ftp.changeWorkingDirectory(remotePath);// תƵFTPĿ¼ +// if(debug)System.out.println(ftpchange); +// FTPFile[] fs = ftp.listFiles(); + String errorNamePrefix = ""; + if (fileName.toLowerCase().endsWith(".exb")) { + errorNamePrefix = fileName; + } + + FTPFile[] fs = waitOkOrErrFile(ftp, fileName, errorNamePrefix); + if (fs != null) { + success = true; + } else { + success = false; + } + } catch (IOException e) { + e.printStackTrace(); + } finally { + if (ftp.isConnected()) { + try { + ftp.disconnect(); + } catch (IOException ioe) { + } + } + } + return success; + } + +// + public static FTPFile[] waitOkOrErrFile(FTPClient ftp, String fileName, String errorNamePrefix) { + FTPFile[] fs = null; + try { + + fs = ftp.listFiles(); + } catch (IOException e1) { + e1.printStackTrace(); + } + + for (FTPFile ff : fs) { + // 2023.04.06ҵ.okΪɹ.errorΪʧܲ + // FTP֧ + String ffName = convISOtoGBK(ff.getName()); + System.out.println("ffName:"+ffName); + System.out.println("errorNamePrefix:"+errorNamePrefix); + if (ffName.equals(errorNamePrefix + ".ok")) { + System.out.println("ӳɹ..."); + return fs; + } else if (ffName.equals(errorNamePrefix + ".err")) { + System.out.println("ӳ쳣"); + return null; + } + } + if (debug) + System.out.println("waitOkOrErrFile---" + errorNamePrefix); + try { + Thread.sleep(1000); + waitOkOrErrFileCount++; + } catch (InterruptedException e) { + e.printStackTrace(); + } + // ʱ˳ + if (waitOkOrErrFileCount > waitPdf) { + return null; + } + fs = waitOkOrErrFile(ftp, fileName, errorNamePrefix); + return fs; + } +// + static int waitOkOrErrFileCount = 0; +// + /** + * ȡ + * + * @param comp + * @return + */ + public static String hx_GetProp(ModelObject comp, String refInfo) { + if (comp == null) { + return null; + } + if (refInfo == null) { + return null; + } + try { + dmService.getProperties(new ModelObject[] {comp}, new String[] {refInfo}); + return comp.getPropertyDisplayableValue(refInfo); +// return comp.getProperty(refInfo); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return ""; + } + + public static String toUpperCase(String input) { + if (input == null) { + return null; + } + + int length = input.length(); + StringBuilder result = new StringBuilder(length); + + for (int i = 0; i < length; i++) { + char c = input.charAt(i); + if (c >= 'a' && c <= 'z') { + // СдĸתΪдĸ + c = (char) (c - 32); + } + result.append(c); + } + + return result.toString(); + } + + public static String getPrefValue(String prefName) { + SessionService sessionService = SessionService.getService(AppXSession.getConnection()); + Session.ScopedPreferenceNames preferenceNames = new Session.ScopedPreferenceNames(); + preferenceNames.names = new String[]{prefName}; + preferenceNames.scope = "site"; + com.teamcenter.services.strong.core._2010_04.Session.MultiPreferenceResponse2 resp = sessionService.getPreferences2(new Session.ScopedPreferenceNames[]{preferenceNames}); + com.teamcenter.services.strong.core._2010_04.Session.ReturnedPreferences2[] prefs = resp.preferences; + if (prefs == null || prefs.length == 0) { + return ("ѡ + prefName + "); + } + String[] values = prefs[0].values; + if (values == null || values.length == 0) { + return "ѡ + prefName + δ"; + } + return values[0]; + } +// + /** + * ЭCAXAݼǰ + * + * @param caxaDataset + * @param rev + * @throws TCException + */ + public static boolean hx_SetCAXAFile(Dataset caxaDataset, String xmlName,String datasetName, ItemRevision rev) + throws Exception { + try { + String forceOpenDirect = getPrefValue("PX_SignatureImagePath"); + + StringBuffer infoSB = new StringBuffer(); + String path = caxaPropertyHandler.class.getProtectionDomain().getCodeSource().getLocation().getPath(); + path = path.replace("%20", " "); + String exePath = new File(path).getParent() + "//"; + + SAXReader reader = new SAXReader(); + Document doc = reader.read(new File(exePath + "sign.xml")); + Element root = doc.getRootElement(); + Element title = root.element("SignInfo").element("Title"); + Element files = root.element("SignInfo").element("Files").element("File"); +// files.attribute("Path").setValue("D:\\CAXAPROPERTY\\" + xmlName + ".exb"); + files.attribute("Path").setValue(FTPUtils.ftpPath + "\\" + xmlName + ".exb"); + String blockName = files.attributeValue("BlockName"); + Map valueMap = getECNValueMap(rev); + + datasetName = datasetName.substring(0, datasetName.indexOf('.')); + File file = new File(System.getenv("TEMP") + "\\" + xmlName + ".xml"); + + dmService.getProperties(new ModelObject[] {rev}, new String[] {"IMAN_master_form_rev"}); + ModelObject revForm = rev.get_IMAN_master_form_rev()[0]; + + Item item = rev.get_items_tag(); + + List refValues = new ArrayList();//tcp.getStringArray(TCPreferenceService.TC_preference_site, "HxCaxaMapping"); + + //ȡļеǩϢ + // ·жȡļ + InputStream resourceAsStream = test.class.getResourceAsStream("signoff.properties"); + + // ȡļ + Properties properties = new Properties(); + try { + properties.load(resourceAsStream); + } catch (Exception e) { + System.out.println("öȡʧ"); + e.printStackTrace(); + return false; + } + + // ȡ + for (String key : properties.stringPropertyNames()) { + String value = properties.getProperty(key); + + // еתַUnicode + String decodedKey = URLDecoder.decode(key.replace("\\:", ":")); + String decodedValue = URLDecoder.decode(value); + + System.out.println("ֵ: " + decodedKey + "=" + decodedValue); + String frece = decodedKey + "=" + decodedValue; + refValues.add(frece); + } + + if (refValues == null || refValues.size() == 0) { + + return false; + } + String propName; + int index; + + + List itemPropList = new ArrayList(); + List itemRevPropList = new ArrayList(); + List itemRevMasterPropList = new ArrayList(); + for (String refValue : refValues) { + String[] valueS = refValue.split("="); + + String value = null; + if (valueS == null || valueS.length != 2) { + continue; + } + String[] propNameS = valueS[1].split("\\."); + if (propNameS == null || propNameS.length != 2) { + continue; + } + index = valueS[0].indexOf(':'); + propName = valueS[0].substring(index + 1).trim(); + String propNameS0Upper = toUpperCase(propNameS[0]); + + if ("ITEM".equals(propNameS0Upper)) { + if (!itemPropList.contains(propNameS[1])) { + itemPropList.add(propNameS[1]); + } + } else if ("REV".equals(propNameS0Upper)) { + if (!itemRevPropList.contains(propNameS[1])) { + itemRevPropList.add(propNameS[1]); + } + } else if ("REVMASTER".equals(propNameS0Upper)) { + if (!itemRevMasterPropList.contains(propNameS[1])) { + itemRevMasterPropList.add(propNameS[1]); + } + } else if ("ITEMMASTER".equals(propNameS0Upper)) { + } else { + } + + } + if(itemPropList.size()!=0) { + String[] itemProps = itemPropList.toArray(new String[itemPropList.size()]); + dmService.getProperties(new ModelObject[] {item}, itemProps); + } + if(itemRevPropList.size()!=0) { + String[] itemRevProps = itemRevPropList.toArray(new String[itemRevPropList.size()]); + dmService.getProperties(new ModelObject[] {rev}, itemRevProps); + } + if(itemRevMasterPropList.size()!=0) { + String[] itemRevMasterProps = itemRevMasterPropList.toArray(new String[itemRevMasterPropList.size()]); + dmService.getProperties(new ModelObject[] {revForm}, itemRevMasterProps); + } + dmService.refreshObjects(new ModelObject[] {item,rev,revForm}); + for (String refValue : refValues) { + String[] valueS = refValue.split("="); + + String value = null; + if (valueS == null || valueS.length != 2) { + continue; + } + String[] propNameS = valueS[1].split("\\."); + if (propNameS == null || propNameS.length != 2) { + continue; + } + index = valueS[0].indexOf(':'); + propName = valueS[0].substring(index + 1).trim(); + if(propName.equals("Ա")) { + System.out.println(); + } + if(valueMap.containsKey(propName)) { + continue; + } + String propNameS0Upper = toUpperCase(propNameS[0]); + + if ("ITEM".equals(propNameS0Upper)) { + value = hx_GetProp(item, propNameS[1]); + } else if ("REV".equals(propNameS0Upper)) { + boolean flag = false; + String[] propertyNames = rev.getPropertyNames(); + for (String prop : propertyNames) { + if (prop.equals(propNameS[1]) && !valueMap.containsKey(prop)) { + flag = true; + break; + } + } + if (flag) { + value = hx_GetProp(rev, propNameS[1]); + } + } else if ("REVMASTER".equals(propNameS0Upper)) { + boolean flag2 = false; + String[] propertyNames2 = revForm.getPropertyNames(); + for (String prop : propertyNames2) { + if (prop.equals(propNameS[1]) && !valueMap.containsKey(prop)) { + flag2 = true; + break; + } + } + if (flag2) { + value = hx_GetProp(revForm, propNameS[1]); + } + } else if ("ITEMMASTER".equals(propNameS0Upper)) { + } else { + } + + if (value == null || value.length() == 0) + continue; + valueMap.put(propName, value); + } + + Element e; + Iterator it = title.elementIterator(); + while (it.hasNext()) { + e = (Element) it.next(); + + String val = valueMap.get(e.attribute("Name").getValue()); + if (val != null) { + System.out.println("·" + forceOpenDirect + val + ".jpg"); + + String[] extensions = {".jpg", ".jpeg", ".png", ".PNG"}; + File sourceFile = null; + + // ҴڵԴļ + for (String ext : extensions) { + File f = new File(forceOpenDirect + val + ext); + if (f.exists()) { + sourceFile = f; + break; + } + } + + if (sourceFile != null) { + try { + // ʱĿ¼ѡ + File tempDir = new File(System.getProperty("java.io.tmpdir"), "caxa_images"); + if (!tempDir.exists()) { + tempDir.mkdirs(); + } + + // ȡԭʼչ + String originalExt = sourceFile.getName() + .substring(sourceFile.getName().lastIndexOf(".")); + + // һΨһʱļ + File tempFile = File.createTempFile("img_", originalExt, tempDir); + + // ļ + InputStream is = null; // ڴԴļжȡ + OutputStream os = null; // ڽдĿļ + try { + // ָԴļ + is = new FileInputStream(sourceFile); + // ָĿļ + os = new FileOutputStream(tempFile); + // һֽڻʱ洢ȡݣСΪ 1024 ֽ + byte[] buffer = new byte[1024]; + int length; // ڴ洢ÿζȡֽ + // ѭȡԴļݣֱļread() -1 + while ((length = is.read(buffer)) > 0) { + // ȡдĿļӻʼλÿʼд룬д볤Ϊȡֽ + os.write(buffer, 0, length); + } + } finally { + // رͷԴ + if (is != null) { + is.close(); + } + // رͷԴ + if (os != null) { + os.close(); + } + } +// Files.copy(sourceFile.toPath(), tempFile.toPath()); + + // XML Ϊ· + e.attribute("Type").setValue("Image"); + e.attribute("Value").setValue("W:\\"+tempFile.getName()); + + } catch (IOException ex) { + ex.printStackTrace(); + // ʱΪַ + e.attribute("Type").setValue("String"); + e.attribute("Value").setValue(val); + } + } else { + // ļڣΪַ + e.attribute("Type").setValue("String"); + e.attribute("Value").setValue(val); + } + } +// if (val != null) { +// System.out.println("·"+forceOpenDirect+val+".jpg"); +// +// +// if(new File(forceOpenDirect+val+".jpg").exists()) { +// e.attribute("Type").setValue("Image"); +// e.attribute("Value").setValue(forceOpenDirect+val+".jpg"); +// }else if(new File(forceOpenDirect+val+".jpeg").exists()) { +// e.attribute("Type").setValue("Image"); +// e.attribute("Value").setValue(forceOpenDirect+val+".jpeg"); +// }else if(new File(forceOpenDirect+val+".png").exists()) { +// e.attribute("Type").setValue("Image"); +// e.attribute("Value").setValue(forceOpenDirect+val+".png"); +// }else if(new File(forceOpenDirect+val+".PNG").exists()) { +// e.attribute("Type").setValue("Image"); +// e.attribute("Value").setValue(forceOpenDirect+val+".PNG"); +// }else { +// e.attribute("Type").setValue("String"); +// e.attribute("Value").setValue(val); +// } +// } + } + PrintWriter pw = new PrintWriter(file, "UTF-8"); + doc.write(pw); + pw.close(); + } catch (Exception e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + return true; + + } + + public static void second(File file) { + if (!file.exists()) { + if (debug) + System.out.println("second"); + try { + Thread.sleep(200); + second(file); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } else { + if (debug) + System.out.println("cunzai"); + try { + Thread.sleep(200); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + } +// + /** + * ɾļ + * + * @param fileName Ҫɾļļ + * @return ļɾɹtrue򷵻false + */ + public static boolean deleteFile(String fileName) { + File file = new File(fileName); + // ļ·Ӧļڣһļֱɾ + if (file.exists() && file.isFile()) { + if (file.delete()) { +// if(debug)System.out.println("ɾļ" + fileName + "ɹ"); + return true; + } else { +// if(debug)System.out.println("ɾļ" + fileName + "ʧܣ"); + return false; + } + } else { +// if(debug)System.out.println("ɾļʧܣ" + fileName + "ڣ"); + return false; + } + } +// +// + /** + * ɾĿ¼Ŀ¼µļ + * + * @param dir ҪɾĿ¼ļ· + * @return Ŀ¼ɾɹtrue򷵻false + */ + public static boolean deleteDirectory(String dir) { + // dirļָβԶļָ + if (!dir.endsWith(File.separator)) + dir = dir + File.separator; + File dirFile = new File(dir); + // dirӦļڣ߲һĿ¼˳ + if ((!dirFile.exists()) || (!dirFile.isDirectory())) { +// if(debug)System.out.println("ɾĿ¼ʧܣ" + dir + "ڣ"); + return false; + } + boolean flag = true; + // ɾļеļĿ¼ + File[] files = dirFile.listFiles(); + for (int i = 0; i < files.length; i++) { + // ɾļ + if (files[i].isFile()) { + flag = deleteFile(files[i].getAbsolutePath()); + if (!flag) + break; + } + // ɾĿ¼ + else if (files[i].isDirectory()) { + flag = deleteDirectory(files[i].getAbsolutePath()); + if (!flag) + break; + } + } + if (!flag) { +// if(debug)System.out.println("ɾĿ¼ʧܣ"); + return false; + } + return true; + } +// + // ȡеȴpdfתʱʱ + private static void loadWaitPdf() { + Properties properties = new Properties(); + InputStream is = null; +// is = this.getClass().getResourceAsStream("PDFInfo.properties"); + is = caxaPropertyHandler.class.getResourceAsStream("PDFInfo.properties"); + try { + properties.load(is); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + waitPdf = Integer.valueOf(properties.getProperty("WAITPDF")); + System.out.println(); + } +// +// private void dealWithFolder(TCComponent tcComponent) throws TCException { +// if (tcComponent instanceof TCComponentFolder) { +// TCComponentFolder folder = (TCComponentFolder) tcComponent; +// TCComponent[] contents = null; +// try { +// contents = folder.getRelatedComponents("contents"); +// } catch (TCException e) { +// // TODO Auto-generated catch block +// e.printStackTrace(); +// } +// for (int j = 0; j < contents.length; j++) { +// TCComponent content = contents[j]; +// if (content instanceof TCComponentFolder) { +// dealWithFolder(content); +// } else if (content instanceof TCComponentItem) { +// TCComponentItemRevision rev = ((TCComponentItem) content).getLatestItemRevision(); +// caxaToPdf(rev, logger); +// } else if (content instanceof TCComponentItemRevision) { +// caxaToPdf((TCComponentItemRevision) content, logger); +// } +// } +// } +// +// } +// + /** + * ȡFTPClient + * + * @param ftpHost FTP + * @param ftpPassword FTP ¼ + * @param ftpUserName FTP¼û + * @param ftpPort FTP˿ ĬΪ21 + * @return + */ + public static FTPClient getFTPClient(String ftpHost, String ftpUserName, String ftpPassword, int ftpPort) { + FTPClient ftpClient = new FTPClient(); + try { + ftpClient = new FTPClient(); + ftpClient.connect(ftpHost, ftpPort);// FTP + ftpClient.login(ftpUserName, ftpPassword);// ½FTP +// ftpClient.login("anonymous", null);// ½FTP + if (!FTPReply.isPositiveCompletion(ftpClient.getReplyCode())) { + if (debug) + System.out.println("δӵFTPû"); + ftpClient.disconnect(); + } else { +// if(debug)System.out.println("FTPӳɹ"); + } + } catch (SocketException e) { + e.printStackTrace(); + if (debug) + System.out.println("FTPIPַܴȷá"); + } catch (IOException e) { + e.printStackTrace(); + if (debug) + System.out.println("FTPĶ˿ڴ,ȷá"); + } + return ftpClient; + } +// + /** + * Description: FTPϴļ + * + * @param ftpHost FTPhostname + * @param ftpUserName ˺ + * @param ftpPassword + * @param ftpPort ˿ + * @param ftpPath FTPļ· ʽ ftptest/aa + * @param fileName ftpļ + * @param in ļ + * @return ɹtrue򷵻false + */ + public static boolean uploadFile(String ftpHost, String ftpUserName, String ftpPassword, int ftpPort, String ftpPath, + String fileName, FileInputStream in) { + boolean success = false; + FTPClient ftpClient = null; + try { + int reply; + ftpClient = getFTPClient(ftpHost, ftpUserName, ftpPassword, ftpPort); + reply = ftpClient.getReplyCode(); + if (!FTPReply.isPositiveCompletion(reply)) { + ftpClient.disconnect(); + return success; + } + ftpClient.setFileType(FTPClient.BINARY_FILE_TYPE); + ftpClient.enterLocalPassiveMode(); + ftpClient.changeWorkingDirectory(ftpPath); + + ftpClient.setControlEncoding("GBK"); // FTP֧ + fileName = convGBKtoISO(fileName);// FTP֧ + ////fileName = convISOtoGBK(fileName);// FTP֧ + + boolean ff = ftpClient.storeFile(fileName, in); + String str = ftpClient.getReplyString(); + in.close(); + ftpClient.logout(); + success = true; + } catch (IOException e) { + e.printStackTrace(); + } finally { + if (ftpClient.isConnected()) { + try { + ftpClient.disconnect(); + } catch (IOException ioe) { + } + } + } +// if(debug)System.out.println("ϴ"); + return success; + } +// +// public String GetNowDate() { +// String temp_str = ""; +// Date dt = new Date(); +// // aaʾ硱硱 HHʾ24Сʱ hhʾ12Сʱ "yyyy-MM-ddHH:mm:ss aa" +// SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd-HH-mm"); +// temp_str = sdf.format(dt); +// return temp_str; +// } +// +// /* +// * ʵļĿ +// * +// * @param srcPathStr ԴļĵַϢ +// * +// * @param desPathStr ĿļĵַϢ +// */ +// private String copyFile(String srcPathStr, String desPathStr, String newName) { +// // 1.ȡԴļ +// String newFileName = newName + srcPathStr.substring(srcPathStr.lastIndexOf(".")); // Ŀļַ +//// if(debug)System.out.println(newFileName); +//// if(debug)System.out.println(File.separator); +// desPathStr = desPathStr + File.separator + newFileName; // Դļַ +//// if(debug)System.out.println(desPathStr); +// +// try { +// // 2. +// FileInputStream fis = new FileInputStream(srcPathStr); +// FileOutputStream fos = new FileOutputStream(desPathStr); +// +// // ˹ +// byte datas[] = new byte[1024 * 8]; +// // +// int len = 0; +// // ѭȡ +// while ((len = fis.read(datas)) != -1) { +// fos.write(datas, 0, len); +// } +// // 3.ͷԴ +// fis.close(); +// fis.close(); +// } catch (Exception e) { +// e.printStackTrace(); +// } +// return desPathStr; +// } +// + public static boolean downFile(String url, // FTPhostname + int port, // FTP˿ + String username, // FTP¼˺ + String password, // FTP¼ + String remotePath, // FTPϵ· + String fileName, // Ҫصļ + String localPath// غ󱣴浽ص· + + ) { + if (debug) + System.out.println(""); + boolean success = false; + FTPClient ftp = new FTPClient(); + try { + int reply; + ftp.connect(url, port); + // Ĭ϶˿ڣʹftp.connect(url)ķʽֱFTP + ftp.login(username, password);// ¼ +// ftp.login("anonymous", null);// ½FTP + reply = ftp.getReplyCode(); + if (!FTPReply.isPositiveCompletion(reply)) { + if (debug) + System.out.println("Ͽ"); + ftp.disconnect(); + return success; + } +// if(debug)System.out.println("aaa"); + ftp.changeWorkingDirectory(remotePath);// תƵFTPĿ¼ +// FTPFile[] fs = ftp.listFiles(); + int x = 0; + if (debug) + System.out.println("ȴpdf"); + String errorName = fileName + ".err"; + String okName = fileName + ".ok"; + FTPFile[] fs = waitPdf(ftp, fileName, errorName, okName); + try { + Thread.sleep(1000); + } catch (InterruptedException e) { + e.printStackTrace(); + } + if (fs == null) { + return false; + } + ftp.setControlEncoding("GBK"); + for (FTPFile ff : fs) { + // FTP֧ + String ffName = convISOtoGBK(ff.getName()); + if (ffName.equals(fileName)) { + if (debug) + System.out.println("ļ----------" + fileName); +// if(debug)System.out.println("dd"); + File localFile = new File(localPath + "/" + ffName); + OutputStream is = new FileOutputStream(localFile); + ftp.retrieveFile(ff.getName(), is); +// if(debug)System.out.println("ccc" +ff.getName()+fileName); + is.close(); + success = true; + break;//2023-04-12ѭ + } + } + ftp.logout(); + } catch (IOException e) { + e.printStackTrace(); + } finally { + if (ftp.isConnected()) { + try { + ftp.disconnect(); + } catch (IOException ioe) { + } + } + } + return success; + } +// + /** + * ȡPDFijߴͼƥ䲢ҪͼƬλ + * + * @param rectangle + * @return + */ + public static Float[] getSize(Rectangle rectangle) { + Float[] sizef = new Float[2]; + float toleft = rectangle.getLeft(); + float tobottom = rectangle.getBottom(); + float toright = rectangle.getRight(); + float totop = rectangle.getTop(); + + JFomPdfBean bean = new JFomPdfBean(); + bean.setH(toright - toleft);// PDFĿ + bean.setW(totop - tobottom);// PDFĸ + sizef[0] = bean.getH(); + sizef[1] = bean.getW(); +// if(debug)System.out.println("bean.getH------------>" + bean.getH()); +// if(debug)System.out.println("bean.getW------------>" + bean.getW()); + + return sizef; + } + + public static boolean addPdfMark(String InPdfFile, String temp, String[] markImagePath, String designType) + throws Exception { + File pdffile = new File(temp); + if (pdffile.exists()) { + pdffile.delete(); + } + // + Properties properties = new Properties(); + InputStream is = null; + is = caxaPropertyHandler.class.getResourceAsStream("PDFInfo.properties"); + properties.load(is); + System.out.println(2); + // PDF ļ + PdfReader reader = new PdfReader(InPdfFile, "PDF".getBytes()); + // PDF ļ + PdfStamper stamp = new PdfStamper(reader, new FileOutputStream(temp)); + // ˮӡͼƬ + Image[] img = null; + for (int j = 0; j < markImagePath.length; j++) { +// img.scaleAbsolute(35, 20);// ͼƬ +// float imgW = img.getScaledWidth();// ȡͼƬĿ +// float imgH = img.getScaledHeight();// ȡͼƬĸ߶ + // ȡPDFҳ + int pageSize = reader.getNumberOfPages();// ȡļҳ + for (int i = 1; i <= pageSize; i++) { + Rectangle rectangle = reader.getPageSize(i); + Float[] fposition = getSize(rectangle); +// if(debug)System.out.println("fposition[0]======="+fposition[0]); +// if(debug)System.out.println("fposition[1]======="+fposition[1]); + boolean isSizeOk = false; + // ˮӡIJλA0 + if ((fposition[0] > 3300 && fposition[1] > 2300)) { + isSizeOk = true; + // ͨpdfڵİ汾ж +// if(debug)System.out.println("ˮӡIJλA0"); + String[] sizeType = selectType("A0", designType); + if (sizeType == null || sizeType.length == 0) { + return false; + } + img = setPic(img, sizeType, properties, markImagePath[j]); + } + // TODO ˮӡIJλA1 + if ((fposition[0] > 2300 && fposition[1] > 1600) && isSizeOk == false) { + isSizeOk = true; +// if(debug)System.out.println("ˮӡIJλA1"); + String[] sizeType = selectType("A1", designType); + if (sizeType == null || sizeType.length == 0) { + return false; + } + + img = setPic(img, sizeType, properties, markImagePath[j]); + + } + + // TODO ˮӡIJλA2 + if ((fposition[1] > 1100 && fposition[0] > 1600) && isSizeOk == false) { + isSizeOk = true; +// if(debug)System.out.println("ˮӡIJλA2"); + String[] sizeType = selectType("A2", designType); + if (sizeType == null || sizeType.length == 0) { + return false; + } + img = setPic(img, sizeType, properties, markImagePath[j]); + } + // TODO ˮӡIJλA2 + if ((fposition[0] > 1100 && fposition[1] > 1600) && isSizeOk == false) { + isSizeOk = true; +// if(debug)System.out.println("ˮӡIJλA2_GY"); + String[] sizeType = selectType("A2", designType); + if (sizeType == null || sizeType.length == 0) { + return false; + } + img = setPic(img, sizeType, properties, markImagePath[j]); + } + // TODO ˮӡIJλA3 + if ((fposition[0] > 1100 && fposition[1] > 800) && isSizeOk == false) { + isSizeOk = true; +// if(debug)System.out.println("ˮӡIJλA3"); + String[] sizeType = selectType("A3", designType); + if (sizeType == null || sizeType.length == 0) { + return false; + } + img = setPic(img, sizeType, properties, markImagePath[j]); + } + // TODO ˮӡIJλA3H + if ((fposition[1] > 1100 && fposition[0] > 800) && isSizeOk == false) { + isSizeOk = true; +// if(debug)System.out.println("ˮӡIJλA3"); + String[] sizeType = selectType("A3H", designType); + if (sizeType == null || sizeType.length == 0) { + return false; + } + img = setPic(img, sizeType, properties, markImagePath[j]); + } + // TODO ˮӡIJλA4 + if ((fposition[1] > 800 && fposition[0] > 500) && isSizeOk == false) { + isSizeOk = true; +// if(debug)System.out.println("ˮӡIJλA4"); + String[] sizeType = selectType("A4", designType); + if (sizeType == null || sizeType.length == 0) { + return false; + } + img = setPic(img, sizeType, properties, markImagePath[j]); + } + // ˮӡIJλA4 + if ((fposition[0] > 800 && fposition[1] > 500) && isSizeOk == false) { + isSizeOk = true; +// if(debug)System.out.println("ˮӡIJλA4"); + String[] sizeType = selectType("A4H", designType); + if (sizeType == null || sizeType.length == 0) { + return false; + } + + img = setPic(img, sizeType, properties, markImagePath[j]); + System.out.println(); + } +// +// if (sizeType != null) { +// +// img = setPic(img, sizeType, properties, markImagePath[j]); +// } + if (img == null ) { + img = new Image[1]; + img[0] = Image.getInstance(markImagePath[j]);// ȡͼƬʵ + img[0].setAbsolutePosition(Float.valueOf(10), Float.valueOf(10)); + /* + * isModel=false; continue; + */ + } + if (img == null) { + return false; + } + + // PDFļвˮӡ + PdfContentByte under = stamp.getOverContent(i);// stamp.getUnderContent(i); + PdfGState gs = new PdfGState(); + gs.setFillOpacity(1.0f);// ͸Ϊ0.2 + under.setGState(gs); + for (int k = 0; k < img.length; k++) { + under.addImage(img[k]); + + } + } + } + stamp.close();// ر + reader.close();// ر + File tempfile = new File(InPdfFile); + if (tempfile.exists()) { + // ɾԭļ + tempfile.delete(); + } + return true; + } + + +// public static String[] selectType(String Ax, String designType) { +// String[] type = null; +// switch (designType) { +// +// case "HX3_GYTRevision":// ͼ +// if (Ax.equals("A3")) { +// type = new String[1]; +// type[0] = Ax + "_GY"; +// } else if (Ax.equals("A2")) { +// type = new String[2]; +// type[0] = Ax + "_GY1"; +// type[1] = Ax + "_GY2"; +// } +// break; +// case "HX3_TYGY1Revision":// ͨù +// if (Ax.equals("A3")) { +// type = new String[1]; +// type[0] = Ax + "_TYGY"; +// } else if (Ax.equals("A2")) { +// type = new String[2]; +// type[0] = Ax + "_TYGY1"; +// type[1] = Ax + "_TYGY2"; +// } +// break; +// case "HX3_WXTRevision":// ƷͼЭӹͼHX3_WXTRevision ͼHX3_LJTRevision װͼHX3_ZPTRevision +// type = new String[1]; +// type[0] = Ax + "_PRODUCT"; +// break; +// case "HX3_DJTRevision":// ƷͼЭӹͼHX3_WXTRevision ͼHX3_LJTRevision +// // װͼHX3_ZPTRevisionͼͼHX3_DJTRevision +// type = new String[1]; +// type[0] = Ax + "_PRODUCT"; +// break; +// case "HX3_LJTRevision":// ƷͼЭӹͼHX3_WXTRevision ͼHX3_LJTRevision װͼHX3_ZPTRevision +// type = new String[1]; +// type[0] = Ax + "_PRODUCT"; +// break; +// case "HX3_ZPTRevision":// ƷͼЭӹͼHX3_WXTRevision ͼHX3_LJTRevision װͼHX3_ZPTRevision +// type = new String[1]; +// type[0] = Ax + "_PRODUCT"; +// break; +// case "HX3_GCGGTZDRevision":// ̸֪ͨ +// type = new String[1]; +// type[0] = Ax + "_ECN"; +// break; +// case "HX3_GZTRevision":// װͼ +// type = new String[2]; +// type[0] = Ax + "_GZT1"; +// type[1] = Ax + "_GZT2"; +// break; +// default: +// break; +// } +// +// return type; +// } + public static String[] selectType(String Ax, String designType) { + String[] type = null; + + if ("HX3_GYTRevision".equals(designType)) { // ͼ + if (Ax.equals("A3")) { + type = new String[1]; + type[0] = Ax + "_GY"; + } else if (Ax.equals("A2")) { + type = new String[2]; + type[0] = Ax + "_GY1"; + type[1] = Ax + "_GY2"; + } + } else if ("HX3_TYGY1Revision".equals(designType)) { // ͨù + if (Ax.equals("A3")) { + type = new String[1]; + type[0] = Ax + "_TYGY"; + } else if (Ax.equals("A2")) { + type = new String[2]; + type[0] = Ax + "_TYGY1"; + type[1] = Ax + "_TYGY2"; + } + } else if ("HX3_WXTRevision".equals(designType)) { // ƷͼЭӹͼHX3_WXTRevision ͼHX3_LJTRevision װͼHX3_ZPTRevision + type = new String[1]; + type[0] = Ax + "_PRODUCT"; + } else if ("HX3_DJTRevision".equals(designType)) { // ƷͼЭӹͼHX3_WXTRevision ͼHX3_LJTRevision + // װͼHX3_ZPTRevisionͼͼHX3_DJTRevision + type = new String[1]; + type[0] = Ax + "_PRODUCT"; + } else if ("HX3_LJTRevision".equals(designType)) { // ƷͼЭӹͼHX3_WXTRevision ͼHX3_LJTRevision װͼHX3_ZPTRevision + type = new String[1]; + type[0] = Ax + "_PRODUCT"; + } else if ("HX3_ZPTRevision".equals(designType)) { // ƷͼЭӹͼHX3_WXTRevision ͼHX3_LJTRevision װͼHX3_ZPTRevision + type = new String[1]; + type[0] = Ax + "_PRODUCT"; + } else if ("HX3_GCGGTZDRevision".equals(designType)) { // ̸֪ͨ + type = new String[1]; + type[0] = Ax + "_ECN"; + } else if ("HX3_GZTRevision".equals(designType)) { // װͼ + type = new String[2]; + type[0] = Ax + "_GZT1"; + type[1] = Ax + "_GZT2"; + } + + return type; + } + + public static Image[] setPic(Image[] img, String[] sizeType, Properties properties, String markImagePath) + throws BadElementException, MalformedURLException, IOException { + // תString· + img = new Image[sizeType.length]; + for (int k = 0; k < sizeType.length; k++) { + + img[k] = Image.getInstance(markImagePath);// ȡͼƬʵ + String str = properties.getProperty(sizeType[k]); + if (str == null) { + return null; + } + String[] values = str.split(","); + img[k].setAbsolutePosition(Float.valueOf(values[0]), Float.valueOf(values[1]));// ˮӡ½ǵ + } + return img; + } +// + public static void replaceOrcreate(Dataset arg0, ItemRevision rev) { + // жϰ汾pdfݼƺcaxaͬо滻ûо½ +// ModelObject[] datasets = null; +// Dataset dataset = null; +// try { +// dmService.getProperties(new ModelObject[] {rev}, new String[] {"IMAN_specification"}); +// datasets = rev.getPropertyObject("IMAN_specification").getModelObjectArrayValue();; +// dmService.getProperties(datasets, new String[] {"object_name"}); +//// datasets = TcUtils.getWhereReference(new WorkspaceObject[] {arg0}); +//// datasets = (TCComponent[]) rev.getTCProperty("IMAN_specification").getReferenceValueArray(); +// String pdfName = ""; +// String caxaName = ""; +// for (int i = 0; i < datasets.length; i++) { +// if (datasets[i].getTypeObject().getName().equals("PDF")) { +// pdfName = datasets[i].getPropertyDisplayableValue("object_name"); +// caxaName = arg0.getPropertyDisplayableValue("object_name"); +// if (pdfName.contains(".pdf") && caxaName.contains(".exb")) { +// pdfName = pdfName.substring(0, pdfName.lastIndexOf(".pdf")); +// if (debug) +// System.out.println(pdfName); +// caxaName = caxaName.substring(0, caxaName.lastIndexOf(".exb")); +// if (debug) +// System.out.println(pdfName); +// } +// } +// if (datasets[i].getTypeObject().getName().equals("PDF") && caxaName.equals(pdfName)) { +// dataset = (Dataset) datasets[i]; +// } +// } +// System.out.println(); +// } catch (Exception e1) { +// e1.printStackTrace(); +// } +// +// if (dataset == null) { +// try { +//// if(debug)System.out.println("·0"); +// TcUtils.setByPass(true); +// } catch (Exception e2) { +// e2.printStackTrace(); +// } +// try { +// dataset = createDataSet(rev,arg0.getPropertyDisplayableValue("object_name").replace(".exb", ".pdf"));//PDF_Reference +// POM_system_class get_owning_user = rev.get_owning_user();//rev.getPropertyObject("").getModelObjectValue(); +// TcUtils.changeOwnershipModelObject(get_owning_user, "",new ModelObject[] {dataset}); +//// TCComponentDatasetType datasetType = (TCComponentDatasetType) session.getTypeComponent("Dataset"); +//// dataset = datasetType.create(arg0.getProperty("object_name").replace(".exb", ".pdf"), "", "PDF"); +//// rev.add("IMAN_specification", dataset); +// +// } catch (Exception e) { +// e.printStackTrace(); +// try { +//// if(debug)System.out.println("·"); +// TcUtils.setByPass(false); +// } catch (Exception e2) { +// e2.printStackTrace(); +// } +// } +// } +// if (dataset == null) { +//// MessageBox.post("ʧ", "", MessageBox.ERROR); +//// return null; +// } + + try { + try { +// if(debug)System.out.println("·1"); + TcUtils.setByPass(true); + } catch (Exception e2) { + e2.printStackTrace(); + } + + try { +// updateDataSet(dataset, addPdfPath, "PDF_Reference"); + //ӷ״̬ + System.out.println("ӷ״̬:"+releaseStatus); + ReleaseStatus[] get_release_status_list = arg0.get_release_status_list(); + if(get_release_status_list.length == 0) { + ReleaseStatusInput releaseStatusInput = new ReleaseStatusInput(); + ReleaseStatusOption releaseStatusOption = new ReleaseStatusOption(); + releaseStatusOption.newReleaseStatusTypeName = releaseStatus; + releaseStatusOption.operation = "Append"; + releaseStatusInput.objects = new WorkspaceObject[]{ (WorkspaceObject)arg0 }; + releaseStatusInput.operations = new ReleaseStatusOption[] {releaseStatusOption}; + WorkflowService workflowService = WorkflowService.getService(AppXSession.getConnection()); + SetReleaseStatusResponse setReleaseStatus = workflowService.setReleaseStatus(new ReleaseStatusInput[] {releaseStatusInput}); + System.out.println(); + } + if(mainArgs.length >=5) { + //identiyʶ + System.out.println("identiyʶ"+mainArgs[4]); + if(mainArgs[4].contains(";")){ + String[] splitIdentity = mainArgs[4].split(";"); + Map propValueMap = new HashMap(); + DataManagement.VecStruct vec = new DataManagement.VecStruct(); + vec.stringVec = new String[] { splitIdentity[1]}; + propValueMap.put(splitIdentity[0], vec) ; + dmService.setProperties(new ModelObject[] {rev}, propValueMap); + } + + } + + //ж + POM_system_class rev_owning = rev.get_owning_user(); + POM_system_class dataset_owning = arg0.get_owning_user(); + if(!rev_owning.getUid().equals(dataset_owning.getUid())) { + TcUtils.changeOwnershipModelObject(rev_owning, "",new ModelObject[] {arg0}); + } +// dataset.setFiles(new String[] { addPdfPath }, new String[] { "PDF_Reference" }); + } catch (Exception e) { + e.printStackTrace(); + try { + if (debug) +// System.out.println("滻pdfʧܣ·"); + TcUtils.setByPass(false); + } catch (Exception e2) { + e2.printStackTrace(); + } + } + + try { +// if(debug)System.out.println("滻pdfɹ·"); + TcUtils.setByPass(false); + } catch (Exception e2) { + e2.printStackTrace(); + } +// if(debug)System.out.println("end"); + } catch (Exception e) { + e.printStackTrace(); + } + } +// +// // pdfݼ +// public void RecreatePdf(TCComponentDataset arg0, TCComponentItemRevision rev) { +// // жϰ汾pdfݼƺcaxaͬо滻ûо½ +// TCComponent[] datasets = null; +// TCComponentDataset dataset = null; +// try { +// datasets = (TCComponent[]) rev.getTCProperty("IMAN_specification").getReferenceValueArray(); +// String pdfName = ""; +// String caxaName = ""; +// for (int i = 0; i < datasets.length; i++) { +// if (datasets[i].getProperty("object_type").equals("PDF")) { +// pdfName = datasets[i].getProperty("object_name"); +// caxaName = arg0.getProperty("object_name"); +// if (pdfName.contains(".pdf") && caxaName.contains(".exb")) { +// pdfName = pdfName.substring(0, pdfName.lastIndexOf(".pdf")); +// if (debug) +// System.out.println(pdfName); +// caxaName = caxaName.substring(0, caxaName.lastIndexOf(".exb")); +// if (debug) +// System.out.println(pdfName); +// } +// } +// if (datasets[i].getProperty("object_type").equals("PDF") && caxaName.equals(pdfName)) { +// dataset = (TCComponentDataset) datasets[i]; +// } +// } +// } catch (TCException e1) { +// e1.printStackTrace(); +// } +// +// if (dataset == null) { +// return; +// } else { +// +// try { +// try { +//// if(debug)System.out.println("·1"); +// ChangeDbomUtil.setByPass(true); +// } catch (TCException e2) { +// e2.printStackTrace(); +// } +// +// try { +// dataset.removeFiles("PDF_Reference"); +// if (debug) +// System.out.println("PDFԭɾ"); +//// dataset.setFiles(new String[] { addPdfPath}, new String[] { "PDF_Reference" }); +// } catch (Exception e) { +// e.printStackTrace(); +// try { +// if (debug) +// System.out.println("ɾpdfʧܣ·"); +// ChangeDbomUtil.setByPass(false); +// } catch (TCException e2) { +// e2.printStackTrace(); +// } +// } +// +// try { +//// if(debug)System.out.println("滻pdfɹ·"); +// ChangeDbomUtil.setByPass(false); +// } catch (TCException e2) { +// e2.printStackTrace(); +// } +//// if(debug)System.out.println("end"); +// } catch (Exception e) { +// e.printStackTrace(); +// } +// } +// +// } +// + public static String newString(String oldName) { +// String newName=oldName; + if (oldName.contains("/")) { + if (debug) + System.out.println("bingo"); + oldName = getNewName("/", oldName); + } + if (oldName.contains("*")) { + oldName = getNewName("*", oldName); + } + if (oldName.contains("\\")) { + oldName = getNewName("\\", oldName); + } + if (oldName.contains(":")) { + oldName = getNewName(":", oldName); + } + if (oldName.contains("?")) { + oldName = getNewName("?", oldName); + } + if (oldName.contains("\"")) { + oldName = getNewName("\"", oldName); + } + if (oldName.contains("<")) { + oldName = getNewName("<", oldName); + } + if (oldName.contains(">")) { + oldName = getNewName(">", oldName); + } + if (oldName.contains("|")) { + oldName = getNewName("|", oldName); + } + if (oldName.contains("")) { + oldName = getNewName("", oldName); + } + if (oldName.contains("")) { + oldName = getNewName("", oldName); + } + return oldName; + } +// + public static String getNewName(String illegalCharacter, String oldString) { + if (illegalCharacter.equals("")) { + oldString = oldString.replace(illegalCharacter, "("); + } else if (illegalCharacter.equals("")) { + oldString = oldString.replace(illegalCharacter, ")"); + + } else { + + oldString = oldString.replace(illegalCharacter, "--"); + } + return oldString; + } +// +// +// public void sendMail(String message, String title) throws TCException { +// TCComponentUserType userType = (TCComponentUserType) session.getTypeComponent("User"); +// TCComponentUser user = userType.find("admin"); +// TCComponent[] targetUser = new TCComponent[] { user }; +// try { +// TCComponentEnvelopeType type = (TCComponentEnvelopeType) session.getTypeComponent("Envelope"); +// TCComponentEnvelope envelope = type.create(title, message, ""); +// envelope.setProperty("object_name", "caxa" + title); +// envelope.addReceivers(targetUser); +// envelope.send(); +// } catch (TCException e) { +// e.printStackTrace(); +// } +// } + public static void main(String[] args) throws Exception { + mainArgs = args; + String serverHost = "http://10.10.10.35:8080/tc"; + String host = System.getProperty("host"); + if (host != null && host.length() > 0) { + serverHost = host; + } + + session = new AppXSession(serverHost); + User user = session.login(); + + dmService = DataManagementService.getService(AppXSession.getConnection()); + fmu = new FileManagementUtility(AppXSession.getConnection(), + null, + new String[] { "http://10.10.10.35:4544" }, + new String[] { "http://10.10.10.35:4544" }, + "D://TEMP//fcc_tmp"); + tcp = PreferenceManagementService.getService(AppXSession.getConnection()); + if(args.length!=5) { + tryAgain(); + } + + try { + while(write()) { + try { + int sec = new java.util.Random().nextInt(30); + System.out.println(""+sec+"s"); + Thread.sleep(1000*sec); // 1~10 + } catch (Exception e) { + + } + } + + FTPUtils.getConfigureInfomationg(tcp,args[3]); + + //ȡݼ +// DataManagementService dataManagementService = DataManagementService.getService(AppXSession.getConnection()); + + + String revPuids[] = args[0].split(","); + String puidss[] = args[1].split("\\|"); + for(int i = 0 ; i < revPuids.length ; i++) { + ItemRevision rev = null; + try { + rev = (ItemRevision) dmService.loadObjects(new String[] {revPuids[i]}).getPlainObject(0); + }catch(Exception for1) { + continue; + } +// dmService.getProperties(new ModelObject[] {rev}, new String[] {"hx3_identity"}); +// String identity = rev.getPropertyDisplayableValue("hx3_identity"); + // if(identity != null && "Y".equals(identity)) { + // System.out.println("תͼʶ"+identity); + // return; + // } + String puids[] = puidss[i].split(","); + for(String puid : puids) { + try { + + Dataset dataset = (Dataset) dmService.loadObjects(new String[] {puid}).getPlainObject(0); + releaseStatus = args[2]; + companyName = args[3]; + loadWaitPdf(); + property(dataset,rev); + }catch(Exception for2) { + continue; + } + } + } + + }catch (Exception e) { + e.printStackTrace(); + }finally { + //ɾļ + String path = caxaPropertyHandler.class.getProtectionDomain().getCodeSource().getLocation().getPath(); + path = path.replace("%20", " "); + String exePath = new File(path).getParent() + "//"; + if(checkFile("CaxaToPDF.lock",new File(exePath))) { + String fileName = "CaxaToPDF.lock"; + File lockFile = new File(exePath+ fileName); + lockFile.delete(); + } + + } + + } + public static String consumeInputStream(InputStream is) throws IOException { + BufferedReader br = new BufferedReader(new InputStreamReader(is,"GBK")); + String s; + StringBuilder sb = new StringBuilder(); + while ((s = br.readLine()) != null) { + System.out.println(s); + sb.append(s); + } + return sb.toString(); + } + + private static void tryAgain() { + checkDir("D://TEMP//fcc_tmp"); + + } + private static void checkDir(String dir) { + + File[]files= new File(dir).listFiles(); + List exbFileList = new ArrayList(); + Map exbPuidMap = new HashMap(); + for(File file:files) + { + String fileName = file.getName(); + if(fileName.contains("@")) { + exbPuidMap.put(fileName.split("@")[0], fileName.split("@")[1]); + } + if(fileName.substring(fileName.length()-3, fileName.length()).toLowerCase().equals("exb")) { + exbFileList.add(file); + } + System.out.println(fileName); + } + for(File exbFile : exbFileList) { + if(exbPuidMap.containsKey(exbFile.getName())) { + + //ִ + String puid = exbPuidMap.get(exbFile.getName()); + File deleteFile = new File(exbFile.getPath()+"@"+puid); + try { + deleteFile.delete(); + ModelObject plainObject = dmService.loadObjects(new String[] {puid.split("#")[1]}).getPlainObject(0); + updateDataSet((Dataset) plainObject,exbFile.getPath(),"U2_EXB"); + +// Runtime runtime = Runtime.getRuntime(); //ȡRuntimeʵ +// String[] command = {"cmd", "/c", "start java -jar D:\\Siemens\\Teamcenter11\\portal\\plugins\\CaxaToPDF.jar \""+puid.split("#")[0]+"\" \""+puid.split("#")[1]+"\" \""+puid.split("#")[2]+"\" \""+puid.split("#")[3]+"\" \"Y\""}; +// Process process = runtime.exec(command); + String main_args[] = new String[] {puid.split("#")[0],puid.split("#")[1],puid.split("#")[2],puid.split("#")[3],"Y"}; + new caxaPropertyHandler().main(main_args); + } catch (Exception e) { + try { + deleteFile.createNewFile(); + } catch (IOException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + e.printStackTrace(); + } + + } + } + System.out.println(); + } + /** + * Ƿȴִ + * @return + * @throws IOException + */ + private static boolean write() throws IOException { + String path = caxaPropertyHandler.class.getProtectionDomain().getCodeSource().getLocation().getPath(); + path = path.replace("%20", " "); + String exePath = new File(path).getParent() + "//"; + if(checkFile("CaxaToPDF.lock",new File(exePath))) { + return true; + } + + String fileName = "CaxaToPDF.lock"; + File lockFile = new File(exePath+ fileName); + if (!lockFile.exists()) { + lockFile.createNewFile(); + } + System.out.println(); + return false; + } + + private static boolean checkFile(String filename,File dir) + { + + File[]files=dir.listFiles(); + for(File file:files) + { + + if(file.isFile() && filename.equals(file.getName())) //fileʱļļͬʱ; + { + return true; + } + } + return false; + } + + private static void writeTime() { + try { + int sec = new java.util.Random().nextInt(30); + System.out.println(""+sec+"s"); + Thread.sleep(1000*sec); // 1~10 + } catch (Exception e) { + System.out.println("Got an exception!"); + } + + +} + private static void updateDataSet(Dataset dataset, String filePath,String namedRef) throws Exception{ + +// try { + + + + //ȡãļ + dmService.getProperties(new ModelObject[]{dataset},new String[]{"ref_list"}); + int refListNum = dataset.get_ref_list().length; + ServiceData removeNamedReferenceFromDatasetServiceDate = null; + if(refListNum == 0 ){ + System.out.println("ݼã"); + } + else { + // + com.teamcenter.services.strong.core._2007_09.DataManagement.NamedReferenceInfo[] namedReferenceInfos = new com.teamcenter.services.strong.core._2007_09.DataManagement.NamedReferenceInfo[1]; + + for(int i = 0 ; i < refListNum ; i++ ){ + ImanFile namedRefMobj = (ImanFile) dataset.get_ref_list()[i]; + + dmService.refreshObjects(new ModelObject[] {namedRefMobj}); + dmService.getProperties(new ModelObject[]{namedRefMobj},new String[]{"file_ext"}); + String fileExtString = namedRefMobj.getPropertyObject("file_ext").getStringValue(); + System.out.println(fileExtString); + if(fileExtString.toLowerCase().equals("exb")) { + com.teamcenter.services.strong.core._2007_09.DataManagement.NamedReferenceInfo namedReferenceInfo= new com.teamcenter.services.strong.core._2007_09.DataManagement.NamedReferenceInfo(); + namedReferenceInfo.type = namedRef; + namedReferenceInfo.deleteTarget = true; + namedReferenceInfo.targetObject = namedRefMobj; + namedReferenceInfos[0] = namedReferenceInfo; + } + } + + //ɾ + com.teamcenter.services.strong.core._2007_09.DataManagement.RemoveNamedReferenceFromDatasetInfo[] removeNamedReferenceFromDatasets = new com.teamcenter.services.strong.core._2007_09.DataManagement.RemoveNamedReferenceFromDatasetInfo[1]; + com.teamcenter.services.strong.core._2007_09.DataManagement.RemoveNamedReferenceFromDatasetInfo removeNamedReferenceFromDataset = new com.teamcenter.services.strong.core._2007_09.DataManagement.RemoveNamedReferenceFromDatasetInfo(); + removeNamedReferenceFromDataset.dataset = dataset; + removeNamedReferenceFromDataset.nrInfo = namedReferenceInfos; + removeNamedReferenceFromDatasets[0] = removeNamedReferenceFromDataset; + removeNamedReferenceFromDatasetServiceDate = dmService.removeNamedReferenceFromDataset(removeNamedReferenceFromDatasets); + } + + if((removeNamedReferenceFromDatasetServiceDate != null + && removeNamedReferenceFromDatasetServiceDate.sizeOfDeletedObjects() > 0 ) + || refListNum == 0){ + System.out.println("ɾɹ"); + //µ + FileManagement.DatasetFileInfo fileInfo = new FileManagement.DatasetFileInfo(); + + fileInfo.allowReplace = false; +// fileInfo.clientId = fileInfo.toString(); + fileInfo.fileName = filePath; + fileInfo.isText = false; + fileInfo.namedReferencedName = namedRef; + + FileManagement.DatasetFileInfo[] fileInfos = { fileInfo }; + + FileManagement.GetDatasetWriteTicketsInputData inputData = new FileManagement.GetDatasetWriteTicketsInputData(); + inputData.dataset = dataset; + inputData.createNewVersion = false; + inputData.datasetFileInfos = fileInfos; + + FileManagement.GetDatasetWriteTicketsInputData[] inputs = { inputData }; + ServiceData putFilesServiceData = fmu.putFiles(inputs); +// fileManagementUtility.putFiles(inputs); + if(putFilesServiceData.sizeOfUpdatedObjects() > 0){ + System.out.println(""); + } + fmu.term(); + + + } else{ + String[] errMsg = removeNamedReferenceFromDatasetServiceDate.getPartialError(0).getMessages(); + System.out.println("ɾʧܣ"); + } +// throw new Exception("1"); +// } catch (Exception e) { +// e.printStackTrace(); +// } + + } + //TCFMSеļת + public static File TCFileToFile(Dataset dataset) throws Exception{ + if(dataset == null){ + return null; + } + //File outFile = null; + String filename = ""; + + dmService.getProperties(new ModelObject[] { dataset}, new String[]{"ref_list"}); + ModelObject[] objects = dataset.get_ref_list(); + dmService.getProperties( objects, new String[]{"file_ext"}); + ModelObject tempModelObject =null; + for(int i =0 ;i< objects.length;i++) { + + String fileExtString = objects[i].getPropertyObject("file_ext").getStringValue(); + if(fileExtString.toLowerCase().equals("exb")) { + tempModelObject = objects[i]; + break; + } + } + if(tempModelObject == null) { + return null; + } + objects = new ModelObject[] {tempModelObject}; + + GetFileResponse getFileResponse = fmu.getFiles(objects); + File[] fileinfovec = getFileResponse.getFiles(); + + + + + return fileinfovec[0]; + } + /*** + * ݼ API + * @param targetMobj Ŀݼ + * @param datasetName ݼ + * @param filePath ļ· + */ + private static Dataset createDataSet(ModelObject targetMobj,String datasetName) { + + //ݼ + com.teamcenter.services.strong.core._2008_06.DataManagement.DatasetProperties2 datasetProperties2 = new com.teamcenter.services.strong.core._2008_06.DataManagement.DatasetProperties2(); + datasetProperties2.name = datasetName; + datasetProperties2.type ="PDF"; + datasetProperties2.clientId="PDF_1"; + datasetProperties2.container = targetMobj; + datasetProperties2.relationType = "IMAN_specification"; + CreateDatasetsResponse ceateDatasetsResponse = dmService.createDatasets2(new com.teamcenter.services.strong.core._2008_06.DataManagement.DatasetProperties2[]{datasetProperties2}); + Dataset dt = ceateDatasetsResponse.output[0].dataset; + return dt; +// // +// FileManagement.DatasetFileInfo fileInfo = new FileManagement.DatasetFileInfo(); +// fileInfo.allowReplace = false; +// fileInfo.fileName = filePath; +// fileInfo.isText = false; +// fileInfo.namedReferencedName = "HG8_dwg"; +// FileManagement.DatasetFileInfo[] fileInfos = { fileInfo }; +// +// //ݼ +// FileManagement.GetDatasetWriteTicketsInputData inputData = new FileManagement.GetDatasetWriteTicketsInputData(); +// inputData.dataset = dt; +// inputData.createNewVersion = false; +// inputData.datasetFileInfos = fileInfos; +// FileManagement.GetDatasetWriteTicketsInputData[] inputs = { inputData }; +// ServiceData response = fmu.putFiles(inputs); +// fmu.term(); + +// + } + // Ӱϻȡ + public static List getWhereReference(WorkspaceObject[] obj ,int number){ + List list = new ArrayList(); + DataManagement.WhereReferencedResponse response = dmService.whereReferenced(obj,number); + DataManagement.WhereReferencedInfo[] info = response.output[0].info; + for (int i = 0; i < info.length; i++) { + if(info[i].relation.equals("HX3_ggh")) { + list.add(info[i].referencer); + } + } + return list; + } + private static Map getECNValueMap(ItemRevision rev) throws Exception { + // 2019.11.254ӳ䣺İΣ汾ţļţ֪ͨıţǩ֣ϹԱڣ֪ͨڣգ + // ֻһθļ¼ + String dateString = ""; + Map valueMap = new HashMap(); + List ecr = getWhereReference(new WorkspaceObject[] {rev}, 1); +// AIFComponentContext[] ecr = rev.whereReferenced(); + for (int i = 0; i < ecr.size(); i++) { + if(ecr.get(i) instanceof ItemRevision) { + ItemRevision ecrRev = (ItemRevision) ecr.get(i); + dmService.getProperties(new ModelObject[] {ecrRev}, new String[] {"creation_date","item_id"}); + System.out.println("ecrRev.getProperty:" + ecrRev.getTypeObject().getName()); + System.out.println(); + if (ecrRev.getTypeObject().getName().equals("HX3_GCGGTZDRevision")) { + + SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); + String dateString2 = format.format(ecrRev.get_creation_date().getTime()) ; + String revType = rev.getTypeObject().getName(); + System.out.println("revType:" + revType); + if (dateString.length() == 0) { + dateString = dateString2; + if (revType.equals("HX3_ZPTRevision") || revType.equals("HX3_LJTRevision") + || revType.equals("HX3_WXTRevision") || revType.equals("HX3_DJTRevision") || revType.equals("HX3_TYGY1Revision")) { + + valueMap.put("İ1", rev.get_item_revision_id()); + valueMap.put("ļ1", ecrRev.get_item_id()); + valueMap.put("ǩ1", "ϹԱ"); + valueMap.put("1", format.format(ecrRev.get_creation_date().getTime())); + } else if (revType.equals("HX3_GYTRevision")) { + valueMap.put("İ", rev.get_item_revision_id()); + valueMap.put("ļ", ecrRev.get_item_id()); + valueMap.put("ǩ", "ϹԱ"); + valueMap.put("", format.format(ecrRev.get_creation_date().getTime())); + + } + } else { + if (dateString.compareTo(dateString2) < 0) { + dateString = dateString2; + if (revType.equals("HX3_ZPTRevision") || revType.equals("HX3_LJTRevision") + || revType.equals("HX3_WXTRevision")|| revType.equals("HX3_DJTRevision")|| revType.equals("HX3_TYGY1Revision")) { + + valueMap.put("İ1", rev.get_item_revision_id()); + valueMap.put("ļ1", ecrRev.get_item_id()); + valueMap.put("ǩ1", "ϹԱ"); + valueMap.put("1", format.format(ecrRev.get_creation_date().getTime())); + } else if (revType.equals("HX3_GYTRevision")) { + valueMap.put("İ", rev.get_item_revision_id()); + valueMap.put("ļ", ecrRev.get_item_id()); + valueMap.put("ǩ", "ϹԱ"); + valueMap.put("", format.format(ecrRev.get_creation_date().getTime())); + + } + } + } + } + + + } + + } + return valueMap; + + } +} diff --git a/src/com/connor/signoff/soa/handler/ftp.properties b/src/com/connor/signoff/soa/handler/ftp.properties new file mode 100644 index 0000000..88977e5 --- /dev/null +++ b/src/com/connor/signoff/soa/handler/ftp.properties @@ -0,0 +1,5 @@ +ip=10.10.10.22 +port=21 +username=infodba +password=infodba +path=D:\\CAXAPLM \ No newline at end of file diff --git a/src/com/connor/signoff/soa/handler/signoff.properties b/src/com/connor/signoff/soa/handler/signoff.properties new file mode 100644 index 0000000..e2b1131 --- /dev/null +++ b/src/com/connor/signoff/soa/handler/signoff.properties @@ -0,0 +1,12 @@ +*TITLE\:\u7F16\u5236=REV.u2_bianzhi_name +*TITLE\:\u7F16\u5236\u65E5\u671F=REV.u2_bianzhi_date +*TITLE\:\u6807\u51c6\u5316=REV.u2_biaozhunhua_name +*TITLE\:\u6807\u51c6\u5316\u65e5\u671f=REV.u2_biaozhunhua_date +*TITLE\:\u5de5\u827a=REV.u2_gongyi_name +*TITLE\:\u5de5\u827a\u65e5\u671f=REV.u2_gongyi_date +*TITLE\:\u6821\u5bf9=REV.u2_jiaodui_name +*TITLE\:\u6821\u5bf9\u65e5\u671f=REV.u2_jiaodui_date +*TITLE\:\u6279\u51C6=REV.u2_pizhun_name +*TITLE\:\u6279\u51C6\u65E5\u671F=REV.u2_pizhun_date +*TITLE\:\u5BA1\u6838=REV.u2_shenhe_name +*TITLE\:\u5BA1\u6838\u65E5\u671F=REV.u2_shenhe_date diff --git a/src/com/connor/signoff/soa/handler/test.java b/src/com/connor/signoff/soa/handler/test.java new file mode 100644 index 0000000..a185a94 --- /dev/null +++ b/src/com/connor/signoff/soa/handler/test.java @@ -0,0 +1,48 @@ +/** * @Title: test.java + * @Package com.connor.signoff.soa.handler + * @Description: TODO(һ仰ļʲô) + * @author admin * @date 2024712 + * @version V1.0 + */ +package com.connor.signoff.soa.handler; + +import java.io.InputStream; +import java.util.Properties; +import java.nio.charset.StandardCharsets; +import java.net.URLDecoder; + +/** + * @ClassName: test + * @Description: TODO(һ仰) + * @author admin + * @date 2024712 + * + */ +public class test { + public static void main(String[] args) { + // ·жȡļ + InputStream resourceAsStream = test.class.getResourceAsStream("signoff.properties"); + + // ȡļ + Properties properties = new Properties(); + try { + properties.load(resourceAsStream); + } catch (Exception e) { + System.out.println("öȡʧ"); + e.printStackTrace(); + return; + } + + // ȡ + for (String key : properties.stringPropertyNames()) { + String value = properties.getProperty(key); + + // еתַUnicode + String decodedKey = URLDecoder.decode(key.replace("\\:", ":")); + String decodedValue = URLDecoder.decode(value); + + System.out.println("ֵ: " + decodedKey + "=" + decodedValue); + } + } + +} diff --git a/src/com/connor/signoff/soa/handler/testLogin.java b/src/com/connor/signoff/soa/handler/testLogin.java new file mode 100644 index 0000000..7f95d2c --- /dev/null +++ b/src/com/connor/signoff/soa/handler/testLogin.java @@ -0,0 +1,67 @@ +/** * @Title: testLogin.java + * @Package com.connor.signoff.soa.handler + * @Description: TODO(һ仰ļʲô) + * @author admin * @date 2024925 + * @version V1.0 + */ +package com.connor.signoff.soa.handler; + +import java.io.FileNotFoundException; + +import com.teamcenter.clientx.AppXSession; +import com.teamcenter.services.strong.administration.PreferenceManagementService; +import com.teamcenter.services.strong.core.DataManagementService; +import com.teamcenter.soa.client.FileManagementUtility; +import com.teamcenter.soa.client.model.ModelObject; +import com.teamcenter.soa.client.model.strong.ItemRevision; +import com.teamcenter.soa.client.model.strong.User; +import com.teamcenter.soa.exceptions.NotLoadedException; + +/** + * @ClassName: testLogin + * @Description: TODO(һ仰) + * @author admin + * @date 2024925 + * + */ +public class testLogin { + public static void main(String[] args) throws NotLoadedException { + if(args.length > 0) { + String id = args[0]; + System.out.println("id"+id); + + //ʼ¼ + String serverHost = "http://10.10.10.35:8080/tc"; + String host = System.getProperty("host"); + if (host != null && host.length() > 0) { + serverHost = host; + } + + AppXSession session = new AppXSession(serverHost); + User user = session.login(); + + DataManagementService dmService = DataManagementService.getService(AppXSession.getConnection()); + try { + FileManagementUtility fileManagementUtility = new FileManagementUtility(AppXSession.getConnection(), + null, + new String[] { "http://10.10.10.35:4544" }, + new String[] { "http://10.10.10.35:4544" }, + "D://TEMP//fcc_tmp"); + PreferenceManagementService service2 = PreferenceManagementService.getService(AppXSession.getConnection()); + ItemRevision rev = null; + rev = (ItemRevision) dmService.loadObjects(new String[] {id}).getPlainObject(0); + ModelObject plainObject = dmService.loadObjects(new String[] {id}).getPlainObject(0); + dmService.getProperties(new ModelObject[]{plainObject}, new String[]{"item_id"}); + String propertyDisplayableValue = plainObject.getPropertyDisplayableValue("item_id"); + System.out.println("id:"+propertyDisplayableValue); + } catch (FileNotFoundException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + }else { + System.out.println(""); + } + + } +} diff --git a/src/com/teamcenter/clientx/AppXCredentialManager.java b/src/com/teamcenter/clientx/AppXCredentialManager.java new file mode 100644 index 0000000..423f3e1 --- /dev/null +++ b/src/com/teamcenter/clientx/AppXCredentialManager.java @@ -0,0 +1,145 @@ +//================================================== +// +// Copyright 2012 Siemens Product Lifecycle Management Software Inc. All Rights Reserved. +// +//================================================== + +package com.teamcenter.clientx; + +import java.io.IOException; +import java.io.InputStreamReader; +import java.io.LineNumberReader; + +import com.teamcenter.schemas.soa._2006_03.exceptions.InvalidCredentialsException; +import com.teamcenter.schemas.soa._2006_03.exceptions.InvalidUserException; +import com.teamcenter.soa.client.CredentialManager; +import com.teamcenter.soa.exceptions.CanceledOperationException; + +/** + * The CredentialManager is used by the Teamcenter Services framework to get the + * user's credentials when challenged by the server. This can occur after a period + * of inactivity and the server has timed-out the user's session, at which time + * the client application will need to re-authenticate. The framework will + * call one of the getCredentials methods (depending on circumstances) and will + * send the SessionService.login service request. Upon successful completion of + * the login service request. The last service request (one that caused the challenge) + * will be resent. + * + * The framework will also call the setUserPassword setGroupRole methods when ever + * these credentials change, thus allowing this implementation of the CredentialManager + * to cache these values so prompting of the user is not required for re-authentication. + * + */ +public class AppXCredentialManager implements CredentialManager +{ + + private String name = null; + private String password = null; + private String group = ""; // default group + private String role = ""; // default role + private String discriminator = "SoaAppX"; // always connect same user + // to same instance of server + + /** + * Return the type of credentials this implementation provides, + * standard (user/password) or Single-Sign-On. In this case + * Standard credentials are returned. + * + * @see com.teamcenter.soa.client.CredentialManager#getCredentialType() + */ + public int getCredentialType() + { + return CredentialManager.CLIENT_CREDENTIAL_TYPE_STD; + } + + /** + * Prompt's the user for credentials. + * This method will only be called by the framework when a login attempt has + * failed. + * + * @see com.teamcenter.soa.client.CredentialManager#getCredentials(com.teamcenter.schemas.soa._2006_03.exceptions.InvalidCredentialsException) + */ + public String[] getCredentials(InvalidCredentialsException e) + throws CanceledOperationException + { + System.out.println(e.getMessage()); + return promptForCredentials(); + } + + /** + * Return the cached credentials. + * This method will be called when a service request is sent without a valid + * session ( session has expired on the server). + * + * @see com.teamcenter.soa.client.CredentialManager#getCredentials(com.teamcenter.schemas.soa._2006_03.exceptions.InvalidUserException) + */ + public String[] getCredentials(InvalidUserException e) + throws CanceledOperationException + { + // Have not logged in yet, should not happen but just in case + if (name == null) return promptForCredentials(); + + // Return cached credentials + String[] tokens = { name, password, group, role, discriminator }; + return tokens; + } + + /** + * Cache the group and role + * This is called after the SessionService.setSessionGroupMember service + * operation is called. + * + * @see com.teamcenter.soa.client.CredentialManager#setGroupRole(java.lang.String, + * java.lang.String) + */ + public void setGroupRole(String group, String role) + { + this.group = group; + this.role = role; + } + + /** + * Cache the User and Password + * This is called after the SessionService.login service operation is called. + * + * @see com.teamcenter.soa.client.CredentialManager#setUserPassword(java.lang.String, + * java.lang.String, java.lang.String) + */ + public void setUserPassword(String user, String password, String discriminator) + { + this.name = user; + this.password = password; + this.discriminator = discriminator; + } + + + public String[] promptForCredentials() + throws CanceledOperationException + { + try + { + LineNumberReader reader = new LineNumberReader(new InputStreamReader(System.in)); +// System.out.println("Please enter user credentials (return to quit):"); +// System.out.print("User Name: "); +// name = reader.readLine(); + name = "infodba"; + + if (name.length() == 0) + throw new CanceledOperationException(""); + +// System.out.print("Password: "); +// password = reader.readLine(); + password = "sdpxqc"; + } + catch (Exception e) + { + String message = "Failed to get the name and password.\n" + e.getMessage(); + System.out.println(message); + throw new CanceledOperationException(message); + } + + String[] tokens = { name, password, group, role, discriminator }; + return tokens; + } + +} diff --git a/src/com/teamcenter/clientx/AppXExceptionHandler.java b/src/com/teamcenter/clientx/AppXExceptionHandler.java new file mode 100644 index 0000000..5aed562 --- /dev/null +++ b/src/com/teamcenter/clientx/AppXExceptionHandler.java @@ -0,0 +1,102 @@ +//================================================== +// +// Copyright 2012 Siemens Product Lifecycle Management Software Inc. All Rights Reserved. +// +//================================================== + +package com.teamcenter.clientx; + +import java.io.IOException; +import java.io.InputStreamReader; +import java.io.LineNumberReader; + +import com.teamcenter.schemas.soa._2006_03.exceptions.ConnectionException; +import com.teamcenter.schemas.soa._2006_03.exceptions.InternalServerException; +import com.teamcenter.schemas.soa._2006_03.exceptions.ProtocolException; +import com.teamcenter.soa.client.ExceptionHandler; +import com.teamcenter.soa.exceptions.CanceledOperationException; + +/** + * Implementation of the ExceptionHandler. For ConnectionExceptions (server + * temporarily down .etc) prompts the user to retry the last request. For other + * exceptions convert to a RunTime exception. + */ +public class AppXExceptionHandler implements ExceptionHandler +{ + + /* + * (non-Javadoc) + * + * @see com.teamcenter.soa.client.ExceptionHandler#handleException(com.teamcenter.schemas.soa._2006_03.exceptions.InternalServerException) + */ + public void handleException(InternalServerException ise) + { + System.out.println(""); + System.out.println("*****"); + System.out + .println("Exception caught in com.teamcenter.clientx.AppXExceptionHandler.handleException(InternalServerException)."); + + LineNumberReader reader = new LineNumberReader(new InputStreamReader(System.in)); + + if (ise instanceof ConnectionException) + { + // ConnectionException are typically due to a network error (server + // down .etc) and can be recovered from (the last request can be sent again, + // after the problem is corrected). + System.out.print("\nThe server returned an connection error.\n" + ise.getMessage() + + "\nDo you wish to retry the last service request?[y/n]"); + } + else + if (ise instanceof ProtocolException) + { + // ProtocolException are typically due to programming errors + // (content of HTTP + // request is incorrect). These are generally can not be + // recovered from. + System.out.print("\nThe server returned an protocol error.\n" + ise.getMessage() + + "\nThis is most likely the result of a programming error." + + "\nDo you wish to retry the last service request?[y/n]"); + } + else + { + System.out.println("\nThe server returned an internal server error.\n" + + ise.getMessage() + + "\nThis is most likely the result of a programming error." + + "\nA RuntimeException will be thrown."); + throw new RuntimeException(ise.getMessage()); + } + + try + { + String retry = reader.readLine(); + // If yes, return to the calling SOA client framework, where the + // last service request will be resent. + if (retry.equalsIgnoreCase("y") || retry.equalsIgnoreCase("yes")) return; + + throw new RuntimeException("The user has opted not to retry the last request"); + } + catch (IOException e) + { + System.err.println("Failed to read user response.\nA RuntimeException will be thrown."); + throw new RuntimeException(e.getMessage()); + } + } + + /* + * (non-Javadoc) + * + * @see com.teamcenter.soa.client.ExceptionHandler#handleException(com.teamcenter.soa.exceptions.CanceledOperationException) + */ + public void handleException(CanceledOperationException coe) + { + System.out.println(""); + System.out.println("*****"); + System.out.println("Exception caught in com.teamcenter.clientx.AppXExceptionHandler.handleException(CanceledOperationException)."); + + // Expecting this from the login tests with bad credentials, and the + // AnyUserCredentials class not + // prompting for different credentials + throw new RuntimeException(coe); + } + +} diff --git a/src/com/teamcenter/clientx/AppXModelEventListener.java b/src/com/teamcenter/clientx/AppXModelEventListener.java new file mode 100644 index 0000000..45156b1 --- /dev/null +++ b/src/com/teamcenter/clientx/AppXModelEventListener.java @@ -0,0 +1,63 @@ +//================================================== +// +// Copyright 2012 Siemens Product Lifecycle Management Software Inc. All Rights Reserved. +// +//================================================== + +package com.teamcenter.clientx; + + +import com.teamcenter.soa.client.model.*; +import com.teamcenter.soa.exceptions.NotLoadedException; + +/** + * Implementation of the ChangeListener. Print out all objects that have been updated. + * + */ +public class AppXModelEventListener extends ModelEventListener +{ + + @Override + public void localObjectChange(ModelObject[] objects) + { + + if (objects.length == 0) return; + System.out.println(""); + System.out.println("Modified Objects handled in com.teamcenter.clientx.AppXUpdateObjectListener.modelObjectChange"); + System.out.println("The following objects have been updated in the client data model:"); + for (int i = 0; i < objects.length; i++) + { + String uid = objects[i].getUid(); + String type = objects[i].getTypeObject().getName(); + String name = ""; + if (objects[i].getTypeObject().isInstanceOf("WorkspaceObject")) + { + ModelObject wo = objects[i]; + try + { + name = wo.getPropertyObject("object_string").getStringValue(); + } + catch (NotLoadedException e) {} // just ignore + } + System.out.println(" " + uid + " " + type + " " + name); + } + } + + @Override + public void localObjectDelete(String[] uids) + { + + if (uids.length == 0) + return; + + System.out.println(""); + System.out.println("Deleted Objects handled in com.teamcenter.clientx.AppXDeletedObjectListener.modelObjectDelete"); + System.out.println("The following objects have been deleted from the server and removed from the client data model:"); + for (int i = 0; i < uids.length; i++) + { + System.out.println(" " + uids[i]); + } + + } + +} diff --git a/src/com/teamcenter/clientx/AppXPartialErrorListener.java b/src/com/teamcenter/clientx/AppXPartialErrorListener.java new file mode 100644 index 0000000..7ea6fd7 --- /dev/null +++ b/src/com/teamcenter/clientx/AppXPartialErrorListener.java @@ -0,0 +1,61 @@ +//================================================== +// +// Copyright 2012 Siemens Product Lifecycle Management Software Inc. All Rights Reserved. +// +//================================================== + + +package com.teamcenter.clientx; + +import com.teamcenter.soa.client.model.ErrorStack; +import com.teamcenter.soa.client.model.ErrorValue; +import com.teamcenter.soa.client.model.PartialErrorListener; + +/** + * Implementation of the PartialErrorListener. Print out any partial errors + * returned. + * + */ +public class AppXPartialErrorListener implements PartialErrorListener +{ + + @Override + public void handlePartialError(ErrorStack[] stacks) + { + if (stacks.length == 0) return; + + System.out.println(""); + System.out.println("*****"); + System.out.println("Partial Errors caught in com.teamcenter.clientx.AppXPartialErrorListener."); + + + for (int i = 0; i < stacks.length; i++) + { + ErrorValue[] errors = stacks[i].getErrorValues(); + System.out.print("Partial Error for "); + + // The different service implementation may optionally associate + // an ModelObject, client ID, or nothing, with each partial error + if (stacks[i].hasAssociatedObject()) + { + System.out.println( "object " + stacks[i].getAssociatedObject().getUid() ); + } + else if (stacks[i].hasClientId()) + { + System.out.println( "client id " + stacks[i].getClientId() ); + } + else if (stacks[i].hasClientIndex()) + System.out.println( "client index " + stacks[i].getClientIndex() ); + + + // Each Partial Error will have one or more contributing error messages + for (int j = 0; j < errors.length; j++) + { + System.out.println(" Code: " + errors[j].getCode() + "\tSeverity: " + + errors[j].getLevel() + "\t" + errors[j].getMessage()); + } + } + + } + +} diff --git a/src/com/teamcenter/clientx/AppXRequestListener.java b/src/com/teamcenter/clientx/AppXRequestListener.java new file mode 100644 index 0000000..a44def0 --- /dev/null +++ b/src/com/teamcenter/clientx/AppXRequestListener.java @@ -0,0 +1,36 @@ +//================================================== +// +// Copyright 2012 Siemens Product Lifecycle Management Software Inc. All Rights Reserved. +// +//================================================== + +package com.teamcenter.clientx; + +import com.teamcenter.soa.client.RequestListener; + +/** + * This implementation of the RequestListener, logs each service request + * to the console. + * + */ +public class AppXRequestListener implements RequestListener +{ + + /** + * Called before each request is sent to the server. + */ + public void serviceRequest ( final Info info ) + { + // will log the service name when done + } + + /** + * Called after each response from the server. + * Log the service operation to the console. + */ + public void serviceResponse( final Info info ) + { + System.out.println( info.id +": "+info.service+"."+info.operation); + } + +} diff --git a/src/com/teamcenter/clientx/AppXSession.java b/src/com/teamcenter/clientx/AppXSession.java new file mode 100644 index 0000000..849f42f --- /dev/null +++ b/src/com/teamcenter/clientx/AppXSession.java @@ -0,0 +1,285 @@ +//================================================== +// +// Copyright 2012 Siemens Product Lifecycle Management Software Inc. All Rights Reserved. +// +//================================================== + +package com.teamcenter.clientx; + +import java.text.SimpleDateFormat; +import java.util.Calendar; +import java.util.List; +import java.util.Locale; +import java.util.Random; +import java.util.Vector; + + + +import com.teamcenter.schemas.soa._2006_03.exceptions.InvalidCredentialsException; +import com.teamcenter.schemas.soa._2006_03.exceptions.ServiceException; +import com.teamcenter.services.strong.core.DataManagementService; +import com.teamcenter.services.strong.core.SessionService; +import com.teamcenter.services.strong.core._2006_03.Session.LoginResponse; +import com.teamcenter.soa.SoaConstants; +import com.teamcenter.soa.client.Connection; +import com.teamcenter.soa.client.model.ModelObject; +import com.teamcenter.soa.client.model.strong.User; +import com.teamcenter.services.strong.core._2006_03.Session; +import com.teamcenter.soa.client.model.strong.WorkspaceObject; +import com.teamcenter.soa.exceptions.CanceledOperationException; +import com.teamcenter.soa.exceptions.NotLoadedException; + + +public class AppXSession +{ + /** + * Single instance of the Connection object that is shared throughout + * the application. This Connection object is needed whenever a Service + * stub is instantiated. + */ + private static Connection connection; + + /** + * The credentialManager is used both by the Session class and the Teamcenter + * Services Framework to get user credentials. + * + */ + private static AppXCredentialManager credentialManager; + + /** + * Create an instance of the Session with a connection to the specified + * server. + * + * Add implementations of the ExceptionHandler, PartialErrorListener, + * ChangeListener, and DeleteListeners. + * + * @param host Address of the host to connect to, http://serverName:port/tc + */ + public AppXSession(String host) + { + // Create an instance of the CredentialManager, this is used + // by the SOA Framework to get the user's credentials when + // challenged by the server (session timeout on the web tier). + credentialManager = new AppXCredentialManager(); + + String protocol=null; + String envNameTccs = null; + if ( host.startsWith("http") ) + { + protocol = SoaConstants.HTTP; + } + else if ( host.startsWith("tccs") ) + { + protocol = SoaConstants.TCCS; + host = host.trim(); + int envNameStart = host.indexOf('/') + 2; + envNameTccs = host.substring( envNameStart, host.length() ); + host = ""; + } + else + { + protocol = SoaConstants.IIOP; + } + + + // Create the Connection object, no contact is made with the server + // until a service request is made + connection = new Connection(host, credentialManager, SoaConstants.REST, protocol); + + if( protocol == SoaConstants.TCCS ) + { + connection.setOption( Connection.TCCS_ENV_NAME, envNameTccs ); + } + + + // Add an ExceptionHandler to the Connection, this will handle any + // InternalServerException, communication errors, XML marshaling errors + // .etc + connection.setExceptionHandler(new AppXExceptionHandler()); + + // While the above ExceptionHandler is required, all of the following + // Listeners are optional. Client application can add as many or as few Listeners + // of each type that they want. + + // Add a Partial Error Listener, this will be notified when ever a + // a service returns partial errors. + connection.getModelManager().addPartialErrorListener(new AppXPartialErrorListener()); + + // Add a Change and Delete Listener, this will be notified when ever a + // a service returns model objects that have been updated or deleted. + connection.getModelManager().addModelEventListener(new AppXModelEventListener()); + + + // Add a Request Listener, this will be notified before and after each + // service request is sent to the server. + Connection.addRequestListener( new AppXRequestListener() ); + + } + + /** + * Get the single Connection object for the application + * + * @return connection + */ + public static Connection getConnection() + { + return connection; + } + + /** + * Login to the Teamcenter Server + * + */ + public User login() + { + // Get the service stub + SessionService sessionService = SessionService.getService(connection); + + try + { + // Prompt for credentials until they are right, or until user + // cancels + String[] credentials = credentialManager.promptForCredentials(); + while (true) + { + try + { + + // ***************************** + // Execute the service operation + // ***************************** + LoginResponse out = sessionService.login(credentials[0], credentials[1], + credentials[2], credentials[3],"zh_CN", Math.random()+""); + + return out.user; + } + catch (InvalidCredentialsException e) + { + credentials = credentialManager.getCredentials(e); + } + } + } + // User canceled the operation, don't need to tell him again + catch (CanceledOperationException e) {} + + // Exit the application + System.exit(0); + return null; + } + + /** + * Terminate the session with the Teamcenter Server + * + */ + public void logout() + { + // Get the service stub + SessionService sessionService = SessionService.getService(connection); + try + { + // ***************************** + // Execute the service operation + // ***************************** + sessionService.logout(); + } + catch (ServiceException e){} + } + + /** + * Print some basic information for a list of objects + * + * @param objects + */ + public static void printObjects(ModelObject[] objects) + { + if(objects == null) + return; + + SimpleDateFormat format = new SimpleDateFormat("M/d/yyyy h:mm a", new Locale("en", "US")); // Simple no time zone + + // Ensure that the referenced User objects that we will use below are loaded + getUsers( objects ); + + System.out.println("Name\t\tOwner\t\tLast Modified"); + System.out.println("====\t\t=====\t\t============="); + for (int i = 0; i < objects.length; i++) + { + if(!(objects[i] instanceof WorkspaceObject )) + continue; + + WorkspaceObject wo = (WorkspaceObject)objects[i]; + try + { + String name = wo.get_object_string(); + User owner = (User) wo.get_owning_user(); + Calendar lastModified =wo.get_last_mod_date(); + + System.out.println(name + "\t" + owner.get_user_name() + "\t" + + format.format(lastModified.getTime())); + } + catch (NotLoadedException e) + { + // Print out a message, and skip to the next item in the folder + // Could do a DataManagementService.getProperties call at this point + System.out.println(e.getMessage()); + System.out.println("The Object Property Policy ($TC_DATA/soa/policies/Default.xml) is not configured with this property."); + } + } + + } + + + private static void getUsers( ModelObject[] objects ) + { + if(objects == null) + return; + + DataManagementService dmService = DataManagementService.getService(AppXSession.getConnection()); + + List unKnownUsers = new Vector(); + for (int i = 0; i < objects.length; i++) + { + if(!(objects[i] instanceof WorkspaceObject )) + continue; + + WorkspaceObject wo = (WorkspaceObject)objects[i]; + + User owner = null; + try + { + owner = (User) wo.get_owning_user(); + owner.get_user_name(); + } + catch (NotLoadedException e) + { + if(owner != null) + unKnownUsers.add(owner); + } + } + User[] users = (User[])unKnownUsers.toArray(new User[unKnownUsers.size()]); + String[] attributes = { "user_name" }; + + + // ***************************** + // Execute the service operation + // ***************************** + dmService.getProperties(users, attributes); + + + } + + public User mylogin(String name, String password) { + SessionService sessionService = SessionService.getService(connection); + try { + Session.LoginResponse out = sessionService.login(name, password, + "", "", "", ""); + return out.user; + } catch (InvalidCredentialsException e) { + e.printStackTrace(); + return null; + } + } + + + +} diff --git a/src/com/teamcenter/filemanagement/FMS.java b/src/com/teamcenter/filemanagement/FMS.java new file mode 100644 index 0000000..e9f69f4 --- /dev/null +++ b/src/com/teamcenter/filemanagement/FMS.java @@ -0,0 +1,71 @@ +package com.teamcenter.filemanagement; + +import com.teamcenter.clientx.AppXSession; +import com.teamcenter.services.strong.core.SessionService; +import com.teamcenter.soa.client.model.Property; +import com.teamcenter.soa.client.model.ServiceData; +import java.io.BufferedReader; +import java.io.File; +import java.io.FileReader; +import java.io.IOException; + + +public class FMS { + public static void main(String[] args) { + System.out.println("upload:" + args.length); + if (args.length < 2) + return; + String filePath = args[0]; + System.out.println("filePath===========" + filePath); + System.out.println("args[1]===========" + args[1]); + System.out.println("args[2]===========" + args[2]); + System.out.println("args[3]===========" + args[3]); + File file = new File(filePath); + if (!file.exists()) + return; + String str = null; + try { + BufferedReader reader = new BufferedReader(new FileReader(file)); + str = reader.readLine(); + reader.close(); + } catch (IOException e1) { + e1.printStackTrace(); + } + System.out.println("str===========" + str); + if (str == null) + return; + String[] infos = new String[3]; + StringBuilder sb = new StringBuilder(); + String[] values = str.split("\\|"); + if (values != null && values.length == 3) + for (int i = 0; i < values.length; i++) { + infos[i] = values[i]; + System.out.println("values[" + i + "]===========" + values[i]); + } + if (infos.length < 3) + return; + AppXSession session = new AppXSession(infos[0]); + try { + FileManagement fm = new FileManagement(); + session.mylogin("infodba", "infodba"); + if (args[1].split("\\|").length != args[2].split("\\|").length + || args[2].split("\\|").length != args[3].split("\\|").length) { + System.out.println(args[1].split("\\|").length); + System.out.println(args[2].split("\\|").length); + System.out.println(args[3].split("\\|").length); + System.out.println("ݴ"); + } + String[] split1 = args[1].split("\\|"); + String[] split2 = args[2].split("\\|"); + String[] split3 = args[3].split("\\|"); + for (int i = 0; i < split1.length; i++) { + fm.uploadFiles(split1[i], split2[i], split3[i]); + } + } catch (Exception e) { + e.printStackTrace(); + } + session.logout(); + } + +} + diff --git a/src/com/teamcenter/filemanagement/FileManagement.java b/src/com/teamcenter/filemanagement/FileManagement.java new file mode 100644 index 0000000..ab34811 --- /dev/null +++ b/src/com/teamcenter/filemanagement/FileManagement.java @@ -0,0 +1,10 @@ +package com.teamcenter.filemanagement; + +public class FileManagement { + + public void uploadFiles(String string, String string2, String string3) { + // TODO Auto-generated method stub + + } + +} diff --git a/src/com/teamcenter/filemanagement/test.java b/src/com/teamcenter/filemanagement/test.java new file mode 100644 index 0000000..90b6645 --- /dev/null +++ b/src/com/teamcenter/filemanagement/test.java @@ -0,0 +1,12 @@ +package com.teamcenter.filemanagement; + +public class test { + public static void main(String[] args) { + String string = "value1|value2|value3"; + String input = string; + String[] parts = input.split("\\|"); // ʵϲҪת + for (String part : parts) { + System.out.println(part); + } + } +} diff --git a/src/log4j.properties b/src/log4j.properties new file mode 100644 index 0000000..1bab40f --- /dev/null +++ b/src/log4j.properties @@ -0,0 +1,40 @@ +#================================================== +# +# @@ +# +#================================================== + +# ============================================================================ # +# Set the Logging for the entire Web Application. # +# The Level can be DEBUG, INFO, WARN, ERROR, FATAL, or OFF # +# There are two predefined Appenders, TheConsole and AppLogFile # +# ============================================================================ # +log4j.rootLogger = WARN, TheConsole +#log4j.logger.org.apache.commons.httpclient = WARN, TheConsole + + +# ============================================================================ # +# The "TheConsole" Appender will write the log message to the console # +# (System.out) with the pattern specified below # +# ============================================================================ # +log4j.appender.TheConsole = org.apache.log4j.ConsoleAppender +log4j.appender.TheConsole.layout = org.apache.log4j.PatternLayout +log4j.appender.TheConsole.layout.ConversionPattern = %d{MM-dd HH:mm:ss} %x %-5p %c - %m%n + + +# ============================================================================ # +# The "AppLogFile" Appender will write the log message to a log file # +# with the pattern and other attributes specified below. # +# ============================================================================ # +log4j.appender.AppLogFile = org.apache.log4j.RollingFileAppender +log4j.appender.AppLogFile.layout = org.apache.log4j.PatternLayout +log4j.appender.AppLogFile.layout.ConversionPattern = %d{MM-dd HH:mm:ss} %x %-5p %c - %m%n +log4j.appender.AppLogFile.MaxBackupIndex = 1 +log4j.appender.AppLogFile.MaxFileSize = 10MB +log4j.appender.AppLogFile.Append = false +log4j.appender.AppLogFile.File = SoaSampleServices.log + + + + + diff --git a/syz.png b/syz.png new file mode 100644 index 0000000..43895f6 Binary files /dev/null and b/syz.png differ diff --git a/tc11soalib/TcSoaAdministrationStrong_11000.2.0.jar b/tc11soalib/TcSoaAdministrationStrong_11000.2.0.jar new file mode 100644 index 0000000..ec3bb5a Binary files /dev/null and b/tc11soalib/TcSoaAdministrationStrong_11000.2.0.jar differ diff --git a/tc11soalib/TcSoaAdministrationTypes_11000.2.0.jar b/tc11soalib/TcSoaAdministrationTypes_11000.2.0.jar new file mode 100644 index 0000000..d9524cb Binary files /dev/null and b/tc11soalib/TcSoaAdministrationTypes_11000.2.0.jar differ diff --git a/tc11soalib/TcSoaClient_11000.2.0.jar b/tc11soalib/TcSoaClient_11000.2.0.jar new file mode 100644 index 0000000..ad107c8 Binary files /dev/null and b/tc11soalib/TcSoaClient_11000.2.0.jar differ diff --git a/tc11soalib/TcSoaCommon_11000.2.0.jar b/tc11soalib/TcSoaCommon_11000.2.0.jar new file mode 100644 index 0000000..97726ff Binary files /dev/null and b/tc11soalib/TcSoaCommon_11000.2.0.jar differ diff --git a/tc11soalib/TcSoaCoreStrong_11000.2.0.jar b/tc11soalib/TcSoaCoreStrong_11000.2.0.jar new file mode 100644 index 0000000..ff4a8df Binary files /dev/null and b/tc11soalib/TcSoaCoreStrong_11000.2.0.jar differ diff --git a/tc11soalib/TcSoaCoreTypes_11000.2.0.jar b/tc11soalib/TcSoaCoreTypes_11000.2.0.jar new file mode 100644 index 0000000..77e85be Binary files /dev/null and b/tc11soalib/TcSoaCoreTypes_11000.2.0.jar differ diff --git a/tc11soalib/TcSoaQueryStrong_11000.2.0.jar b/tc11soalib/TcSoaQueryStrong_11000.2.0.jar new file mode 100644 index 0000000..88d3226 Binary files /dev/null and b/tc11soalib/TcSoaQueryStrong_11000.2.0.jar differ diff --git a/tc11soalib/TcSoaStrongModel_11000.2.0.jar b/tc11soalib/TcSoaStrongModel_11000.2.0.jar new file mode 100644 index 0000000..b02dd64 Binary files /dev/null and b/tc11soalib/TcSoaStrongModel_11000.2.0.jar differ diff --git a/tc11soalib/TcSoaWorkflowStrong_11000.2.0.jar b/tc11soalib/TcSoaWorkflowStrong_11000.2.0.jar new file mode 100644 index 0000000..6d764c5 Binary files /dev/null and b/tc11soalib/TcSoaWorkflowStrong_11000.2.0.jar differ diff --git a/tc11soalib/TcSoaWorkflowTypes_11000.2.0.jar b/tc11soalib/TcSoaWorkflowTypes_11000.2.0.jar new file mode 100644 index 0000000..973b7de Binary files /dev/null and b/tc11soalib/TcSoaWorkflowTypes_11000.2.0.jar differ diff --git a/tc8soalib/TcSoaAdministrationStrong_8000.3.0.jar b/tc8soalib/TcSoaAdministrationStrong_8000.3.0.jar new file mode 100644 index 0000000..10d9f46 Binary files /dev/null and b/tc8soalib/TcSoaAdministrationStrong_8000.3.0.jar differ diff --git a/tc8soalib/TcSoaAdministrationTypes_8000.3.0.jar b/tc8soalib/TcSoaAdministrationTypes_8000.3.0.jar new file mode 100644 index 0000000..0a38edc Binary files /dev/null and b/tc8soalib/TcSoaAdministrationTypes_8000.3.0.jar differ diff --git a/tc8soalib/TcSoaClient_8000.3.0.jar b/tc8soalib/TcSoaClient_8000.3.0.jar new file mode 100644 index 0000000..0fbba02 Binary files /dev/null and b/tc8soalib/TcSoaClient_8000.3.0.jar differ diff --git a/tc8soalib/TcSoaCommon_8000.3.0.jar b/tc8soalib/TcSoaCommon_8000.3.0.jar new file mode 100644 index 0000000..9b93c46 Binary files /dev/null and b/tc8soalib/TcSoaCommon_8000.3.0.jar differ diff --git a/tc8soalib/TcSoaCoreStrong_8000.3.0.jar b/tc8soalib/TcSoaCoreStrong_8000.3.0.jar new file mode 100644 index 0000000..7351382 Binary files /dev/null and b/tc8soalib/TcSoaCoreStrong_8000.3.0.jar differ diff --git a/tc8soalib/TcSoaCoreTypes_8000.3.0.jar b/tc8soalib/TcSoaCoreTypes_8000.3.0.jar new file mode 100644 index 0000000..dae4a52 Binary files /dev/null and b/tc8soalib/TcSoaCoreTypes_8000.3.0.jar differ diff --git a/tc8soalib/TcSoaQueryStrong_8000.3.0.jar b/tc8soalib/TcSoaQueryStrong_8000.3.0.jar new file mode 100644 index 0000000..228572f Binary files /dev/null and b/tc8soalib/TcSoaQueryStrong_8000.3.0.jar differ diff --git a/tc8soalib/TcSoaStrongModel_8000.3.0.jar b/tc8soalib/TcSoaStrongModel_8000.3.0.jar new file mode 100644 index 0000000..9f9b30d Binary files /dev/null and b/tc8soalib/TcSoaStrongModel_8000.3.0.jar differ diff --git a/tc8soalib/TcSoaWorkflowStrong_8000.3.0.jar b/tc8soalib/TcSoaWorkflowStrong_8000.3.0.jar new file mode 100644 index 0000000..33f726d Binary files /dev/null and b/tc8soalib/TcSoaWorkflowStrong_8000.3.0.jar differ diff --git a/tc8soalib/TcSoaWorkflowTypes_8000.3.0.jar b/tc8soalib/TcSoaWorkflowTypes_8000.3.0.jar new file mode 100644 index 0000000..ee6eb24 Binary files /dev/null and b/tc8soalib/TcSoaWorkflowTypes_8000.3.0.jar differ