|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
n" Y; u6 z% J7 S/ V6 s6 x
Teamcenter ITK二次开发源码分享: 创建一个工作流
6 o d* Y1 A; ]* b% [5 [$ x$ d' D9 o9 V4 P) v f- i, Y. L$ g, n2 ~
- /*HEAD CREATE_A_PROCESS CCC ITK */( R; `6 Y, I2 @
- #include <stdlib.h>3 Z; r) w+ u3 f* b0 a
- #include <TCcore/aom.h>
% s" C/ ^- D* c% R, Z - #include <tc/emh.h>
! l7 c; g8 l$ C/ m5 N1 A - #include <epm/epm.h>5 {2 O! O& Z$ }9 V8 n& A
- #include <tc/tc.h> T8 G0 _$ [. H: Z* f/ w
- #include <sa/tcfile.h>
- }" a! L- E% f, | - #include <itk/mem.h>5 _8 L3 a$ o" C7 T/ K
- ( h- }- H, }9 D
- #define EXIT_FAILURE 1 6 y- g4 R" P2 g r
- #define ERROR_CHECK(X) (report_error( __FILE__, __LINE__, #X, (X))), U0 s9 m; E0 e2 M! b
- static void report_error( char *file, int line, char *function, int return_code)
2 b+ \. o4 C% C3 W- b2 } j% O - {
; v5 R3 Q" r) Z1 [- ~6 u0 b! \ - if (return_code != ITK_ok)
5 p' y3 j+ u& k& n( a - {
* F; f& z3 ]$ Y9 @# M$ Q* Z - char *error_message_string;
7 }4 ?$ k% a$ Z' q3 K - EMH_get_error_string (NULLTAG, return_code, &error_message_string);" H9 ?& S8 h1 Q3 |7 g
- printf ("ERROR: %d ERROR MSG: %s.\n", return_code, error_message_string);% c3 `" K* p1 H9 g+ }
- printf ("FUNCTION: %s\nFILE: %s LINE: %d\n", function, file, line);
# s6 X7 V/ U3 ?5 Y - if(error_message_string) MEM_free(error_message_string);
* G* [3 {2 m$ p - printf("\nExiting program!\n");' h! J* c# v: v6 e7 R
- exit (EXIT_FAILURE); * Y* `0 b' m9 S8 {& {0 ?
- }
0 Z0 i# }3 ?3 x - }& [$ g, V1 m$ n; B9 D6 F: R6 F; l- i
- ; A* }0 k# X+ y( a& U7 j
- #define EXIT_IF_NULL(X) (check_value(#X, (X)))
6 o8 c4 m' v9 M- A: [7 c! J - static void check_value( char *function, int value ) [% M, ?+ x7 s
- {
. ?4 Y: k. d* X1 J* p9 e7 f - if (value == 0)
. o* U- G& n1 ?- u& T+ x! u - {1 X) s- k& s* j
- printf ("\t%s is NULL\n", function);
1 Y! i1 |1 F! T* w - printf("\nExiting program!\n");4 Z6 {( `9 \( M
- exit (EXIT_FAILURE); * O" ?3 m# h, c$ [9 W% H7 O
- }0 P7 q* l' K- k+ k! f
- }
8 `: {8 ~% G/ [2 h; i- _3 r
+ Z0 |7 B, o1 U" ]; F& {- 2 ^; p, B6 i% r/ Y7 u0 p
- static void do_it(void)
6 n4 k/ {- K4 G - {
; L: H; e2 d4 N( W$ E# u - int
# |' H- L, T5 X - attach_types[1] = {1};
2 V) T9 W; y6 K* Z. k- l6 l! R - tag_t
" k+ ?- D6 l I - rev = NULLTAG,
6 E( P) ?+ m) i$ W - process_template = NULLTAG, , z, d; M0 U' e* ?, S% B5 ]
- process = NULLTAG;
. H. P" y7 E6 M
' S* }3 e0 o0 B w7 [- ERROR_CHECK( ITEM_find_rev("000206", "A", &rev) );! e7 N+ Y' F d6 z p! T" v! k
- EXIT_IF_NULL( rev );8 g0 ^2 W8 O# g2 A4 }
2 V U& f. L4 q* q" ~* z& S3 ~- ERROR_CHECK( EPM_find_process_template("oneStepWithStatus", &process_template) ); 5 j0 A& ~( g+ d, d L3 F6 R
- EXIT_IF_NULL( process_template );
. T& `: H/ h: I: N - 3 t, S3 _3 V& X5 O6 V8 g2 p- y; ?
, E3 |5 W0 a. o4 {$ R$ E [ j1 q# m- ERROR_CHECK( EPM_create_process("5421377", "desc", process_template, 1, &rev, & N* g: f; I, ~2 v0 ~2 v1 I! o
- attach_types, &process) );, K( Z( E, q9 R3 p3 ^$ W0 x. j, T
. Q3 k% ?+ w# ^1 c- EXIT_IF_NULL( process );8 [, o( e: y. y5 R
- } y2 d6 e/ @4 r: F+ ^: d# ]( k! T
- 6 ]6 j: ]/ s8 i! J3 ?0 l J8 L
- int ITK_user_main(int argc, char* argv[])
" J% G' s) i( Q - {4 Z% C* d8 Q3 D1 a- \. [8 z
- int! o7 q8 i6 c, F* R% E1 f$ `
- status = 0; + n% m7 O( W1 n
-
8 F2 p' f" v; W - ITK_initialize_text_services( ITK_BATCH_TEXT_MODE );
0 p. x: [" x# D- N% X) J3 L" [% E - status = ITK_auto_login();
/ T; x4 V8 p6 p9 p$ {: z - 9 h. m, C5 L' U3 \1 V% c# B
- if ( (status != ITK_ok)) printf("\nLogin Failed!\n\n");
' S. H6 f, j3 f0 r - else
3 ]7 U+ h' X+ y. S+ \ - {) ?0 @6 u+ f9 X+ u
- printf("\nLogin successful!\n\n");
& L) i7 L+ a) o6 g" l8 M - ITK_set_journalling(TRUE);
! I4 h0 @" m8 g5 A( p. ]& e - do_it();
3 P$ s6 c0 l7 d; {: J" B2 } - }# Y0 G/ ]) P# I/ Z& n
- ITK_exit_module(TRUE);
1 P1 N' d! m: F' h& z+ ?- S - return status;
/ @; Z+ ]' G l/ n7 I w - }
复制代码
- t: @, s0 S1 T0 Q' ^! X3 \
P. i; B6 M7 \/ S4 p8 E1 K, e) C' j
|
|