|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
3 E) Y( J8 W/ Q3 q% a n
Teamcenter ITK二次开发源码分享: 创建一个工作流
4 N* b7 c" y* ?+ c( e3 b& e! }
, q& @! X( P- q1 k- /*HEAD CREATE_A_PROCESS CCC ITK */
/ P$ D. j: e: ^1 U3 | - #include <stdlib.h>+ l& v% S. R' n, T
- #include <TCcore/aom.h> S) o/ T- @0 H0 @
- #include <tc/emh.h>$ s0 ~9 D8 w @, Y
- #include <epm/epm.h>
6 m2 A/ e6 F' w& } - #include <tc/tc.h>
( b8 r3 r2 ^/ M; `" ~2 e - #include <sa/tcfile.h>& y* Q6 w3 S* ~# i: x
- #include <itk/mem.h>: ]- D+ t" S7 [3 _+ X5 M
# n7 [& h7 L3 a9 l- #define EXIT_FAILURE 1 . S& E: u- E$ K* l
- #define ERROR_CHECK(X) (report_error( __FILE__, __LINE__, #X, (X))), o* m& ` [5 o" I/ l3 O
- static void report_error( char *file, int line, char *function, int return_code)
; P, C. \+ b G; U) ~7 l q - {
" \/ {, F3 z. T' T! C" v( ~ - if (return_code != ITK_ok)
# g/ F8 v/ Z1 B9 X$ i - {# a) `* V9 }/ F7 A9 {& m
- char *error_message_string;
* K1 F1 Y W) M- \8 A - EMH_get_error_string (NULLTAG, return_code, &error_message_string);; z' x3 z! {1 p8 Z& Q' Z
- printf ("ERROR: %d ERROR MSG: %s.\n", return_code, error_message_string);: X5 `4 Q( ]1 v' i9 a" d
- printf ("FUNCTION: %s\nFILE: %s LINE: %d\n", function, file, line);% p4 m- Q- F8 g" H5 B/ |9 m$ w9 [
- if(error_message_string) MEM_free(error_message_string);
( ~7 d; t; c, Z; ]$ u4 f - printf("\nExiting program!\n");
5 {; m$ i. |* A# |7 ^# B) U - exit (EXIT_FAILURE); 3 k8 c, A, f# B4 O) k* M
- }
3 n3 E5 X% U' p s/ ~ - }
e0 {- R1 Y$ p0 F - : f& \/ k# q X# ~$ _
- #define EXIT_IF_NULL(X) (check_value(#X, (X)))) v* M) A9 O' K6 z0 S# t( ^
- static void check_value( char *function, int value )' ?! l! c' \7 E3 I4 `
- {5 l5 B8 |. T6 D# O
- if (value == 0)2 G: ^# G0 s* p% c
- {5 ~/ w9 m2 [6 y" s, U
- printf ("\t%s is NULL\n", function);, A& H X" B9 J. l* D8 d \0 ^ k
- printf("\nExiting program!\n");3 c% w- C, I7 h! a6 v! X7 j' \
- exit (EXIT_FAILURE); . d! e) Q" ]; V) I; l
- }
/ \7 ~1 S- e% [! G - }
; }2 f% D/ m/ `4 \' x
* f7 e9 x! j6 M+ q/ m- / a* P, ], o" j- W% d* t
- static void do_it(void)% ^, C& J$ K* |2 l5 L/ y
- {0 {3 L" h" W" M
- int
: O+ b, r) H' }0 y* w - attach_types[1] = {1};
, b9 d& \ y6 b3 o% C - tag_t / L8 n0 u* k O1 P9 t) k) k* S$ x
- rev = NULLTAG, 4 ?1 L b; I& I- A! V. f5 Z( O
- process_template = NULLTAG,
9 j* U. Z( q' j% i* c7 \ - process = NULLTAG;
+ v% w: J, w; e! ]
6 Y2 [1 F2 s( P5 l# X- ERROR_CHECK( ITEM_find_rev("000206", "A", &rev) );4 F0 \; j: M4 P- G
- EXIT_IF_NULL( rev );
7 h- }8 X6 P8 |- f1 s/ n
3 g( X1 s& k5 j; H8 M h- ERROR_CHECK( EPM_find_process_template("oneStepWithStatus", &process_template) ); : ^: q9 Z# w0 t3 a# v- W
- EXIT_IF_NULL( process_template );
4 d/ t7 R! \% m# D
3 I) T: R, l3 \$ c. [+ R. E- $ y- j& A% D1 u; e* |
- ERROR_CHECK( EPM_create_process("5421377", "desc", process_template, 1, &rev,
, z( @9 R) S+ g( ?" m8 |0 V3 n - attach_types, &process) );
: t" D* A9 K9 J+ R2 H: z$ P }5 H
; V/ k4 M, N" G4 E( w; k6 I5 [- EXIT_IF_NULL( process ); w8 v; G( z" o
- }5 L L, K# R' K, k \0 f, W
* s* N0 G& A! D8 q- k# [( _- int ITK_user_main(int argc, char* argv[])- x% H; g1 v" }4 i( K0 N
- {
4 g) [0 [/ ~& R y" r2 } - int* O+ V+ T% D* ?5 k, W, N1 z
- status = 0; ! n) H; s1 o1 O m0 n
- 6 D, X, y& Q, V* a& o% C: ] T
- ITK_initialize_text_services( ITK_BATCH_TEXT_MODE );: v. v3 d7 g$ Q. f) @$ r+ z
- status = ITK_auto_login();
" @( @ ~# J" [2 ] - ! b* k- P1 E6 E1 O0 c
- if ( (status != ITK_ok)) printf("\nLogin Failed!\n\n");
d) f' A# l8 R6 ]+ e - else
6 D+ |* z: X Q$ s - {6 O2 B! a3 |% e4 ?' i
- printf("\nLogin successful!\n\n");2 C4 ]. b# O4 b
- ITK_set_journalling(TRUE);
2 C) _0 }! d9 m* {. ]' t - do_it();
: C3 u( E$ @# Y$ j( L( h - }
' q- e# Z4 |+ ~1 R9 k% M, [ - ITK_exit_module(TRUE);
0 G( o* _4 n) b7 ?/ U7 N3 y( } - return status;4 Y1 h0 A0 F4 J( E9 m
- }
复制代码
; K5 _$ y" }. w$ J1 d( T" ^( O8 r; }+ A/ X* V
/ o2 C2 T! x$ Q* p
|
|