|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
& C" c! e- [2 _5 ^* G
Teamcenter ITK二次开发源码分享: 创建一个工作流
! w' V* X/ ?5 l5 s# k7 s5 p- Y$ g' q$ f- m6 ~- A
- /*HEAD CREATE_A_PROCESS CCC ITK */
( F: w$ s- a* _7 A" F( b z - #include <stdlib.h>8 s, B8 I6 |4 h" i7 e
- #include <TCcore/aom.h>
& v m; R. H8 t' c' @ - #include <tc/emh.h>
$ x- p" ~' x6 b+ l9 X - #include <epm/epm.h>9 d! b. i6 A# {
- #include <tc/tc.h>7 v8 |0 K5 w1 i8 Y) ]2 U
- #include <sa/tcfile.h>$ h9 s5 P3 D7 Q% z3 M' z& ^9 t
- #include <itk/mem.h>2 i% Z! b3 Q4 N2 I% Z9 Z3 m
- - u% S. y; ^% h
- #define EXIT_FAILURE 1
) u2 W3 O ?* T( H- e8 { - #define ERROR_CHECK(X) (report_error( __FILE__, __LINE__, #X, (X)))
2 |$ J% L9 H+ i Q, m - static void report_error( char *file, int line, char *function, int return_code)* y; n8 `* v8 P7 C
- {) G' t9 v% @* q9 |! C8 p
- if (return_code != ITK_ok)
4 F4 p$ U! g* H1 l* s - {
9 R! M" Z( y; B, u - char *error_message_string;. I$ T" R9 i% w( Y! g1 c) g
- EMH_get_error_string (NULLTAG, return_code, &error_message_string);
5 Y$ D3 ^& v9 @3 ? - printf ("ERROR: %d ERROR MSG: %s.\n", return_code, error_message_string);
/ C/ `5 [% N' D - printf ("FUNCTION: %s\nFILE: %s LINE: %d\n", function, file, line);# u/ q- O" I$ K `% a. L$ M
- if(error_message_string) MEM_free(error_message_string);+ l* }5 W. ^$ B5 q$ K
- printf("\nExiting program!\n"); q" }' O, D1 Q
- exit (EXIT_FAILURE); . e2 B8 w- U8 u9 y7 M; b; n1 S
- }4 N# t9 B$ @" @0 F4 v( a
- }
1 E; y6 i; ^& C! ?/ ^. b! X
' n" n- _5 Z3 I; c! D- #define EXIT_IF_NULL(X) (check_value(#X, (X)))7 p" t$ ]3 h% j2 o, P
- static void check_value( char *function, int value )
: E! s! W: @. _ - {5 P8 p* z% }* U- b' T4 _
- if (value == 0)
; X7 b2 [& U0 h, }# j. }, z+ z - {
8 F1 t, ?; e2 z1 }& c: ~' N- _ - printf ("\t%s is NULL\n", function);, h0 y9 d, @; k9 [6 }$ ~4 v, I
- printf("\nExiting program!\n");2 K5 N1 Q5 Y/ J
- exit (EXIT_FAILURE);
( _9 z7 E. b y8 [2 N! o/ W+ q7 ?1 }. } - }) m0 V3 C. ~# [0 z; B
- }, h- Z& {2 H8 c: o
O, _0 a: D1 ^3 p2 |
% u! E+ N( s+ K- static void do_it(void)
- O2 e$ c' c: k- L - {
* X# \0 i# x. S2 I; W - int
' q; o$ J4 U$ j5 ~) | d - attach_types[1] = {1};
" U1 e( C& g" p, A8 l2 E - tag_t
, f1 M) O: @# \ I* @; u - rev = NULLTAG, 5 J' J/ E6 ]9 a. \* F
- process_template = NULLTAG,
; W, c$ D- x1 R# q - process = NULLTAG;/ |, M( b7 N: I3 B, N! q
- * m, J& r- `' a1 _1 d: E- U
- ERROR_CHECK( ITEM_find_rev("000206", "A", &rev) );
8 z( Z* c6 t0 i/ o R7 M - EXIT_IF_NULL( rev );
; d5 C N$ J3 g) j9 t& T8 A
' k# n9 ^+ c y" q( G& N' n- F- ERROR_CHECK( EPM_find_process_template("oneStepWithStatus", &process_template) ); 8 B- z. i, u9 Z! ?6 q3 J
- EXIT_IF_NULL( process_template );
. h6 d5 Z z& g: E% `9 | - ! q- g$ a) f; g' u# b6 u
- $ G0 A; D! p5 r% E4 `: R
- ERROR_CHECK( EPM_create_process("5421377", "desc", process_template, 1, &rev,
7 \# }' ?& _7 p7 g - attach_types, &process) );
5 V/ `" B, N$ G% l) L- a8 D
x3 u4 f w+ J- M! L/ d- EXIT_IF_NULL( process );9 a1 {& Y8 a( o E* i _
- }
a( D+ \4 S4 }) T* ~4 | - % j* W1 V0 H9 P
- int ITK_user_main(int argc, char* argv[])
2 `* e5 `" E! [* o( W - {; v8 N3 q' u3 P9 U9 m
- int* \2 O) A0 v2 K: u9 q
- status = 0; " Z# a/ A% f1 p4 |- f( u6 l$ s9 H! z( C
-
' a _! F& o, Z7 n) F - ITK_initialize_text_services( ITK_BATCH_TEXT_MODE );& x3 h8 i5 O9 X% c- M
- status = ITK_auto_login();
+ I6 l' m) b0 s" J, i! ~8 v -
# V0 b- m3 N" n& t - if ( (status != ITK_ok)) printf("\nLogin Failed!\n\n");* ^. @& D3 P. \& b* z& M6 y1 w% V
- else
$ V. G3 m" q. X: g# _- q/ j - {; {: Z# j2 Z$ ^5 o% V2 g$ k" k6 N
- printf("\nLogin successful!\n\n");
* o3 S- Z: q# T$ @3 m5 x: Q - ITK_set_journalling(TRUE);. e: H* e; d# g( w
- do_it();4 L" k$ `& d7 P. U" z
- }# \) T4 T) ~) k3 Y9 l0 R! r
- ITK_exit_module(TRUE);' D! w( W3 I w" U
- return status;: E. O% T4 Q+ ^% o2 }
- }
复制代码
* B( ^2 ` U% ^& e
/ [6 o7 `3 `* Y$ S
# H8 d" `5 t3 s. z- V! t5 ]3 x# y: Y |
|