|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
2 k, z+ `! o4 _6 k! W: f% d: s
Teamcenter ITK二次开发源码分享: 创建一个工作流
% I# F: @( l6 c1 C7 S. B- J: i; D1 i5 r( o6 M, f
- /*HEAD CREATE_A_PROCESS CCC ITK */
. r% k2 ]) @9 T% t! w* \- s - #include <stdlib.h>5 X* H7 s* A9 C9 C3 X/ B% {
- #include <TCcore/aom.h>* W, \- `2 v% C
- #include <tc/emh.h>8 _. M* G; U5 |
- #include <epm/epm.h>! [$ l' N) B U/ I
- #include <tc/tc.h>
) A" r; T2 f- r) \) H - #include <sa/tcfile.h>- f2 D/ M) |1 P: M% l( O X4 Y# q
- #include <itk/mem.h>( B0 P( s. ` Q$ g' u( Z9 i$ w
0 t6 G) m' J! b4 N* n! G1 n- #define EXIT_FAILURE 1 , z; ?$ E3 }$ a9 Y- z
- #define ERROR_CHECK(X) (report_error( __FILE__, __LINE__, #X, (X)))
I% ~3 T J( _* y/ V - static void report_error( char *file, int line, char *function, int return_code)
) S6 \ f5 Q8 f0 W) \2 l* t - {: g( h6 ^; S, f( F( P
- if (return_code != ITK_ok)
! U: ?+ e, J8 a - { e6 o8 C+ K& d' X- Z! n* Z2 t
- char *error_message_string;
f6 t; d9 I5 G: S" r. e - EMH_get_error_string (NULLTAG, return_code, &error_message_string);
' [1 h5 q+ r. H1 J$ @ - printf ("ERROR: %d ERROR MSG: %s.\n", return_code, error_message_string);, ^7 u6 I+ N9 M& H7 J* e
- printf ("FUNCTION: %s\nFILE: %s LINE: %d\n", function, file, line);4 R, W! U7 R! |* e+ s) G
- if(error_message_string) MEM_free(error_message_string);
$ ~: k( j7 x' Z' R9 f& q y - printf("\nExiting program!\n");
) V% o7 R8 \3 Q r# J3 q - exit (EXIT_FAILURE);
- F5 t) w8 s7 _6 [/ x% t3 p% ?2 u - }+ b+ E% F& U0 E( y5 n& d
- }3 z) L7 x9 L5 x, ^' T
- 1 E( Y$ Z4 i% B, i- b3 H
- #define EXIT_IF_NULL(X) (check_value(#X, (X)))
5 W/ u6 |7 U4 N# o - static void check_value( char *function, int value )) A; |' _# R( J- f9 S
- {5 b# v: m$ l( \2 B
- if (value == 0)
/ U+ q k1 c* T' e9 n - {
* {4 t2 k9 t7 T. S4 U; y - printf ("\t%s is NULL\n", function);
8 X* f7 [% a) F' l- H& j- n4 Z - printf("\nExiting program!\n");1 X% m0 g# q# y# A _
- exit (EXIT_FAILURE); 2 O* |1 {9 s8 J# y$ R" j
- }
1 R5 p" _. _' T+ O m+ b3 n8 G9 r/ Z - }( b: J6 D4 _0 \9 ?" D
, g2 f* T; v0 Z6 b7 S3 N- 1 G6 H2 v- j% c- S$ t3 f
- static void do_it(void)5 n" b" S% V0 p- f! e
- {
( D" w% ?/ J- w, o9 k9 L6 [$ D - int 6 N7 k1 S3 J# @7 z2 c
- attach_types[1] = {1};
/ }! g+ h% F, H+ p, Q( L$ r - tag_t * V' t" Q, g' \" |, {7 A
- rev = NULLTAG, 2 C2 d) D8 r' T+ c1 s o8 ~
- process_template = NULLTAG, 9 C8 p4 D: U! @
- process = NULLTAG;
; a$ j& H% T, m; A& n0 O& c, I5 n - " F1 B) p& x2 w' ]4 ?- ^% H
- ERROR_CHECK( ITEM_find_rev("000206", "A", &rev) );
" r# v4 \& h7 n9 \7 ~* ? - EXIT_IF_NULL( rev );" d1 l5 x% l5 D# A1 [2 g
6 m( O, Y4 i" _0 Y! C7 m- ERROR_CHECK( EPM_find_process_template("oneStepWithStatus", &process_template) ); 5 h: i; W/ \0 e& x" Z* a* }
- EXIT_IF_NULL( process_template );
0 Y* p) K" u% p! Y) I: b; H6 V- D - 5 G- i% h% j+ o4 q3 P6 |1 B
5 c0 R7 r, z: H, G ]- ERROR_CHECK( EPM_create_process("5421377", "desc", process_template, 1, &rev, 6 k* M& O6 {1 Q ?7 ~
- attach_types, &process) );
* I, |2 m( c- e" k( _- h
& W( H0 J7 Z$ o+ C% O% ~- EXIT_IF_NULL( process );
6 M |; `6 r4 a - }3 ~7 [' o0 h7 n" P3 h) ]: Y
- ' R3 U# r* J. R/ \2 _
- int ITK_user_main(int argc, char* argv[])7 i9 ]$ N! ~( O! e5 q
- {& I) X0 ^7 R/ `+ [! `2 s. X
- int9 y# {4 _( H7 Q }9 n) l
- status = 0; * e% K+ _/ l u! J# r
-
) @9 \6 Z+ { R: A1 B0 [0 h - ITK_initialize_text_services( ITK_BATCH_TEXT_MODE );+ @6 E; s; _& d0 y% \9 a) O8 b4 A
- status = ITK_auto_login();
+ S: C- e5 V4 r -
% R: h c6 }. p* T0 Z) G8 U - if ( (status != ITK_ok)) printf("\nLogin Failed!\n\n");
" k" I; v% _2 r) i5 o$ D; G( [, }# p - else
0 Y* @/ F! r& Q S4 } - {
- L& |7 g* V; Z2 e" M: W3 o6 U: R! n - printf("\nLogin successful!\n\n");
+ _6 ?. {0 t) {& C9 Y - ITK_set_journalling(TRUE);+ @& z1 [' A$ V7 |
- do_it();, B' S6 ^# M' M4 ~) v
- }
+ N* O- x& K3 c$ {7 B' Z; q - ITK_exit_module(TRUE);
2 b! A' ~7 c* {7 X+ m. V - return status;
* g, v( l8 d: T7 P7 Y' \$ s - }
复制代码
7 b3 `. W J0 ^
2 }% L; w2 b6 A& ?
5 o+ t0 G$ w' J/ g& E% N |
|