|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
; L0 w7 Y ]3 t! T: TTeamcenter ITK二次开发源码分享: 创建一个工作流' D5 B9 X6 w, k, Y) i [0 {
8 Z7 a- w+ I: `/ L8 `
- /*HEAD CREATE_A_PROCESS CCC ITK */) I! i4 g8 B5 c& n" b
- #include <stdlib.h>! h0 a6 ]. u% P" V8 S/ D
- #include <TCcore/aom.h>( d7 y+ c. v- u/ `6 D, h+ v2 x
- #include <tc/emh.h>
" O3 C6 Y9 J3 @5 B, k$ ]+ W - #include <epm/epm.h>' U' t) N# {$ d, V
- #include <tc/tc.h>: L5 i$ c5 M' m5 R
- #include <sa/tcfile.h>
2 r& n5 }, Z7 G$ |$ t - #include <itk/mem.h>! Y2 ^. B$ k9 `, a* X: H9 s% ~& v
! m$ O" { D) ~! s- #define EXIT_FAILURE 1
3 g3 r8 b* b3 R8 t" s# V* J5 o, w - #define ERROR_CHECK(X) (report_error( __FILE__, __LINE__, #X, (X)))
0 J. }1 W3 X4 C1 o - static void report_error( char *file, int line, char *function, int return_code)3 e1 m% V) o: u- q
- {
9 t: I3 J# T, Z1 p3 `' `% u1 W - if (return_code != ITK_ok)
/ Y! c2 x5 b. f/ Y - {
9 a& r9 P- d! K% N - char *error_message_string;6 I3 i: t$ c! r# ]
- EMH_get_error_string (NULLTAG, return_code, &error_message_string);- s; d" o. S4 T9 ]6 e' p' Q
- printf ("ERROR: %d ERROR MSG: %s.\n", return_code, error_message_string);( I$ n& w! [2 T
- printf ("FUNCTION: %s\nFILE: %s LINE: %d\n", function, file, line);
6 E* x- A5 T: |# W5 v - if(error_message_string) MEM_free(error_message_string);
) b0 [- @/ ]3 Q" K9 F5 ~ - printf("\nExiting program!\n");8 N3 H/ u1 G( {- O) f+ P- G+ W
- exit (EXIT_FAILURE); $ @& A- B# I' u% Y2 w
- }! s, }, |! _$ p9 ` Z& A! b7 t
- }
" R7 k u3 s; Q( E
- k0 K. ^ |' t, O: { ~$ U- #define EXIT_IF_NULL(X) (check_value(#X, (X)))& H8 U# Z! O1 { O# h; p
- static void check_value( char *function, int value )
6 _0 x- i& ^2 i' ?3 G - {
8 d# a, \! ~0 N, f - if (value == 0)
- Q6 A3 e/ t5 f$ h - {
/ J5 [. k; N" s5 w6 I; i - printf ("\t%s is NULL\n", function);5 O* Q8 p. _/ M8 ]; W6 w
- printf("\nExiting program!\n");' R' O" B: o' r6 R( W" f8 Q
- exit (EXIT_FAILURE);
3 }# {6 p0 R2 N* m- k/ K- ^5 p - }
7 Q" M% h: G* w0 A6 ~0 P$ @9 X - }
8 J# t& v: |, z' g* O0 @ - - |. D$ H5 N6 O) N
# o* |$ n7 u0 D- static void do_it(void)1 ^5 [; C2 `# A
- {8 D* x: y K, M9 ]; b
- int
1 l7 D' g& p( U2 T - attach_types[1] = {1};0 o- a. d- D3 s0 \: R* L# v1 Q
- tag_t 6 _5 Y- m! G9 |4 k/ E4 [2 D
- rev = NULLTAG, Q! a m4 t* \# ^* l1 }: ]
- process_template = NULLTAG, 6 q. b5 k+ C" k# ]
- process = NULLTAG;" u3 V r% j, X3 P3 c
- : D. h# r+ \# |" y' l
- ERROR_CHECK( ITEM_find_rev("000206", "A", &rev) );& ~- \! E+ _6 K* Y
- EXIT_IF_NULL( rev );; z% k+ x+ x1 e/ w( ]8 n
- Q3 Y: F2 `; @% [4 Y1 M2 `/ q3 {- ERROR_CHECK( EPM_find_process_template("oneStepWithStatus", &process_template) );
2 a( Y; F* |; X: P& b1 \# h - EXIT_IF_NULL( process_template );$ d+ H/ p" c q+ Y7 l
8 i6 E0 O- r: P J- S" [ D- 4 }# i8 @9 O2 r* \
- ERROR_CHECK( EPM_create_process("5421377", "desc", process_template, 1, &rev, ) s9 M" [' H, h: ]
- attach_types, &process) );
7 y2 ~' x R4 X8 ?/ I
0 s$ B/ X7 m* r" j4 v$ l) h- EXIT_IF_NULL( process );2 c2 |: g* S2 a e2 j2 Z
- }
, W) r! b0 |4 _3 C - ' w1 x! r4 W% Z, w" {" k$ J0 ~8 f- N) {
- int ITK_user_main(int argc, char* argv[])
$ V8 R4 S6 |8 f6 T" M" |: r - {. x: O# B% Y ~. t
- int
8 a: E! d: b- p e6 D$ p6 {" Y - status = 0;
% ~7 a( V( d9 U$ Y2 ^( m8 e' z" Y - . \% D" Q7 d) P
- ITK_initialize_text_services( ITK_BATCH_TEXT_MODE );
8 t% _1 ?. Q- l" ~ - status = ITK_auto_login();
/ z# g0 [$ g' |2 C -
1 @) Q5 \4 {. U' j1 G) K5 p - if ( (status != ITK_ok)) printf("\nLogin Failed!\n\n");
( m7 N0 k; a8 Y1 b3 V q - else2 |8 B8 c: o2 ~6 X6 `8 N# s! B
- {
1 k; }, M- W! R9 l2 q1 ?; R- B2 ? - printf("\nLogin successful!\n\n");
: d$ j3 Q& ]2 _$ B/ z# @ - ITK_set_journalling(TRUE);* y/ `' T/ T+ g; ^) T: E% }
- do_it();0 G$ `# u: m# Y) r6 z8 h( W6 O9 S
- }: M0 S: w: n6 m+ y4 [1 L/ E! r
- ITK_exit_module(TRUE);
8 k, `5 ^+ b. K# }: E- R* { - return status;
" C% n6 F; v5 c: p- t& K% z - }
复制代码 $ x4 Z; Q0 u T6 d1 \% ]
* U9 p# ?8 _ c' F% t6 n c' E1 v: c3 L2 j( X( K
|
|