|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
2 g: g( c( ?) CTeamcenter ITK二次开发源码分享: 创建一个工作流
0 b [5 d" h! q5 r# ?4 K. t
0 u! M! a. Q1 V8 j" M- /*HEAD CREATE_A_PROCESS CCC ITK */
/ O/ i* ~: J# v" K' J. l0 w - #include <stdlib.h>
' T; A& |' r$ \! B! O - #include <TCcore/aom.h>3 r! x5 ]4 J7 A6 q& L# E
- #include <tc/emh.h>
$ H: G5 t, d ^3 W6 b - #include <epm/epm.h>
4 D8 }9 {- h) ]7 Z+ y4 q5 S - #include <tc/tc.h>
" z4 z. s4 V, \7 w - #include <sa/tcfile.h>" g/ C3 ?* Z$ O* p+ E
- #include <itk/mem.h># w0 T7 i9 N9 o$ _; O. Z
' l* o( h" c8 F( Q- #define EXIT_FAILURE 1 3 K9 c3 B: F8 ~; v! G
- #define ERROR_CHECK(X) (report_error( __FILE__, __LINE__, #X, (X)))# b% h8 ?+ L1 C6 o
- static void report_error( char *file, int line, char *function, int return_code)1 L7 Z/ ~; u: \( y2 B) J
- {3 z ?- v. Y, ]$ [: R3 o! N/ s
- if (return_code != ITK_ok)( M8 m) W& W& k. B
- {
6 h: i. E. f) c2 n# d - char *error_message_string;
( f$ `) H0 Q& f8 v2 x* O - EMH_get_error_string (NULLTAG, return_code, &error_message_string);
5 V% f; x0 s7 s* n% H0 M. H - printf ("ERROR: %d ERROR MSG: %s.\n", return_code, error_message_string);3 T6 X/ I7 ]0 ?
- printf ("FUNCTION: %s\nFILE: %s LINE: %d\n", function, file, line);
0 w/ A2 A# x! @! X8 I, `1 B1 U6 @ - if(error_message_string) MEM_free(error_message_string);5 ^8 a' p, y [+ t5 @7 y
- printf("\nExiting program!\n");
' y5 k+ H8 }6 ?. K0 U - exit (EXIT_FAILURE);
2 M4 I1 K- ?5 p2 s5 K. ^3 E - }1 h; t- W9 {- W7 E
- }
7 `( B/ M2 d: p- k2 n t* r
4 v5 E$ Y5 W! S" l1 J8 {- #define EXIT_IF_NULL(X) (check_value(#X, (X)))8 q( }' R- q& m; \1 \
- static void check_value( char *function, int value )
* V" a( L) O5 [3 T4 N8 D# d - {
" f! w3 e% M+ }8 A2 [5 [ - if (value == 0)) j9 V% ^* q; @0 n* R m8 C
- {
4 g) M7 ~8 d( x( [! ?, H g/ o - printf ("\t%s is NULL\n", function);
+ ?: V3 F* A1 c; n; l: Y1 L& |4 s7 e - printf("\nExiting program!\n");
3 I& d+ e1 U6 K8 o& g' \ - exit (EXIT_FAILURE);
3 M- N. Y. [- v - }
9 G* i' m5 o( B1 v, D N( Y1 g+ C, ], d - }
( d2 F$ ^0 H) }! d( J4 S' U9 U$ X% O - . t5 o9 q; |- p) o0 C/ X% I9 ?
- 9 s6 c" d1 {; q. e6 }
- static void do_it(void)* @. {5 v# Y8 l C
- {
0 p( [- x3 W" A; a# o- y - int $ R2 A6 t: v1 b) g! O; I4 g
- attach_types[1] = {1};
' y4 u1 k" b2 C/ @6 l6 \ - tag_t + E5 c* J, y \. w& E7 w* Z
- rev = NULLTAG, 7 w3 r |8 j: v3 a' J# U* l. b& Q
- process_template = NULLTAG, 9 f. }7 Z9 H. V, E0 O0 q: t
- process = NULLTAG;
& Y' H& \/ I9 \0 ^# x
" `: [! P6 H4 W$ x* ^9 J( B( B" Y# V& E- ERROR_CHECK( ITEM_find_rev("000206", "A", &rev) );
$ b: C* @$ \6 x9 b$ i - EXIT_IF_NULL( rev );
* R" y3 O' F \6 X
* N, o; c& u- L% u! h) u- ERROR_CHECK( EPM_find_process_template("oneStepWithStatus", &process_template) ); 3 J! Q( r0 }4 ], l& x
- EXIT_IF_NULL( process_template );
! S, n. y9 w% v' b: k - " e1 E0 q$ H# W
- , D! a7 p# w5 z
- ERROR_CHECK( EPM_create_process("5421377", "desc", process_template, 1, &rev, ! e8 |+ z# `* F) z1 m
- attach_types, &process) );' A6 n8 Y- f9 C4 n; [% F4 m
8 y& c; e/ a% K. `4 |- EXIT_IF_NULL( process );
7 ?1 S9 ]5 ~+ W$ U2 m - }
4 O; O+ d! J# j% W - 2 f& N. |# k4 `; l
- int ITK_user_main(int argc, char* argv[])% D) j2 V' ?% G, n
- {
8 U$ `7 i' b6 V4 x) O - int- Y) g) d/ d2 q, G9 h
- status = 0; & q, J3 M# s- ]9 u6 P
- 0 e5 L( n6 P% m
- ITK_initialize_text_services( ITK_BATCH_TEXT_MODE );0 Z4 P0 U: B7 _9 J
- status = ITK_auto_login();
5 u: N* \/ o# E( S3 [ -
1 `* m2 J& C- w - if ( (status != ITK_ok)) printf("\nLogin Failed!\n\n");
F# `8 F+ W4 }7 V7 [. v - else& K i! r+ _' Q3 X1 i
- {; s* A2 @! v, ^; y! }+ I( @
- printf("\nLogin successful!\n\n");& d6 }/ d+ @7 h* C$ R
- ITK_set_journalling(TRUE);8 h ~/ B: s5 q# D. p, b
- do_it();% V% _3 q7 J0 g( [5 u% s
- }
0 g4 r7 u& n. Y( M. W7 d - ITK_exit_module(TRUE);
1 e! t' t8 H1 J8 v! L2 ]; } - return status;7 [7 i7 P7 R. ^* F* J
- }
复制代码 ( N+ Q; o# z* ?& f9 c
. i/ j% g1 _ b3 e
0 v& p! h" [6 x& c3 R |
|