|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
5 }4 {9 e, Z5 O3 iTeamcenter ITK二次开发源码分享: 创建一个工作流 c7 |" l" n3 d5 t$ H
& e; a8 s7 S) r0 H- /*HEAD CREATE_A_PROCESS CCC ITK */" Z, N6 ], w" F$ Z: J' j
- #include <stdlib.h>4 w4 `. |: g& q# e% O$ m' W; N+ ?
- #include <TCcore/aom.h>" f5 u1 G& a5 D; W3 a5 R: F1 T4 P
- #include <tc/emh.h>
( n4 k' P9 ?9 x1 W5 B - #include <epm/epm.h>3 k4 [: A+ m' T7 }! A
- #include <tc/tc.h>3 s" I1 X0 x7 _+ ^
- #include <sa/tcfile.h>
# x! m ~- P) R5 g$ O% G) K - #include <itk/mem.h>
: q( T6 ~- G2 k, A: q# J5 J - ; g Y7 g, P' d
- #define EXIT_FAILURE 1 j" l& M, n3 X' l
- #define ERROR_CHECK(X) (report_error( __FILE__, __LINE__, #X, (X)))
6 }8 e, B/ U6 ^& e1 N3 q - static void report_error( char *file, int line, char *function, int return_code)
2 ~% _" c, q! i0 F; A& F$ w - {9 T, e; Y2 l. }( I
- if (return_code != ITK_ok)" d2 b7 [$ i! `$ e8 m% q5 ]7 X4 P
- {& H5 u2 u( _8 U [6 J& o8 d
- char *error_message_string;" c: v2 q: y; C8 S9 ^7 V3 E( Z5 v2 w
- EMH_get_error_string (NULLTAG, return_code, &error_message_string);* E( n7 ?( b/ A y- h& \# l- J
- printf ("ERROR: %d ERROR MSG: %s.\n", return_code, error_message_string);
; e f& t& \& W' X - printf ("FUNCTION: %s\nFILE: %s LINE: %d\n", function, file, line); v Q% k% a- K6 {' S
- if(error_message_string) MEM_free(error_message_string);: ]* r$ W' F/ `+ J' a
- printf("\nExiting program!\n");9 l8 z! C, w. r( e, B
- exit (EXIT_FAILURE);
0 W& I- [3 Z7 L/ d$ M9 s9 H" X! [ - }
& x: F* M3 w- D' g - }
! n; P. _" e7 ] - ' I) i3 u* p% E' f: k, T7 w6 U
- #define EXIT_IF_NULL(X) (check_value(#X, (X)))
5 |) ]" D( S! \; { - static void check_value( char *function, int value )3 C6 `; w6 R4 I E* h
- {
, @, n- `; u& O6 ]* y - if (value == 0)0 ^4 s4 }) i0 r- X: h
- {; t0 \, x* o+ S! m3 V0 b
- printf ("\t%s is NULL\n", function);
4 G; D" L2 G" x: h - printf("\nExiting program!\n");
# ]2 T! \& N) T% ?* p; V+ }3 i - exit (EXIT_FAILURE); ( u# v0 C: A* W7 \
- }
5 M5 {1 D+ Z5 G2 l+ X - }
) t" e4 a4 c N3 r2 m* D& D, y - + C9 j$ w- L" o4 C7 A/ d
- $ b6 O- h1 r( G+ Z. d L
- static void do_it(void): \- _5 [8 O, _; i7 T: z! @% R
- {
8 t7 }) |2 l. M4 t& A - int
& \0 _6 R! P! f. n/ x - attach_types[1] = {1};! M* ^1 `- p' L# x+ P- K- W
- tag_t $ S" W$ y3 k: Y
- rev = NULLTAG, # E% P! j$ Z* O8 X2 s
- process_template = NULLTAG, 8 y1 x: ~- m/ m/ c4 j' B/ J S
- process = NULLTAG;
- C* y: ? D- c# S& d0 q" b. p* X
4 \2 l7 \& a$ {7 O6 d- ERROR_CHECK( ITEM_find_rev("000206", "A", &rev) );
1 G7 {( J" I) p8 i- f7 X* E - EXIT_IF_NULL( rev );: T+ _; d' M# t3 z# I7 w
- + ~; E! O) Q0 X; N4 E9 n
- ERROR_CHECK( EPM_find_process_template("oneStepWithStatus", &process_template) ); 5 O' R; K& ?: x4 w+ P: l8 f
- EXIT_IF_NULL( process_template );1 U* ^* ^1 b9 ]7 @9 g: d
|0 c T- ~1 @: ?- h
: K: Z- ]/ A5 e0 S& s. t# O- ERROR_CHECK( EPM_create_process("5421377", "desc", process_template, 1, &rev, 5 M) v* l1 Q% a; c3 L0 g! k8 N
- attach_types, &process) );$ C) Z( g7 s4 x, ~2 `# A& b
5 j/ P' Y; E! z2 ^1 C1 z/ M( M- EXIT_IF_NULL( process );% I0 G7 k) ~8 @; e) R
- }! \7 L8 s7 m5 K6 G* j1 G5 n- z m
- ( F$ D) j T6 ~0 @. c; P7 Q
- int ITK_user_main(int argc, char* argv[])
8 n( E+ E1 T! l& q - {
' V: Z- u5 Q) ~; } - int! m4 M. v; \( d+ W. V; g! Y
- status = 0;
2 \- Y- Y, `6 H/ \2 D# M2 ]( g -
( a' b1 V7 M, P; P% K! h- M - ITK_initialize_text_services( ITK_BATCH_TEXT_MODE );
' t5 J1 n! b" f2 J - status = ITK_auto_login();
1 ?% [+ q# _* r0 ]; {& R3 y - 8 S, L6 _3 X8 t# }6 T
- if ( (status != ITK_ok)) printf("\nLogin Failed!\n\n");
4 S! v; \8 l, Y' N - else R8 ?% W9 S: r
- {
; n1 C! g9 q% F; p3 ^/ b( H - printf("\nLogin successful!\n\n");
- N) c( @) h a$ `; w - ITK_set_journalling(TRUE);1 ?( d' V8 K, m6 o( G0 v% T
- do_it();
! \/ n- ]3 T- s- Y5 k+ \ - }
% c3 F* S% \: j" \5 g+ F - ITK_exit_module(TRUE);
3 r* y* P' `, v5 I - return status;
. V1 N- s: g9 {9 A B& p4 o6 b - }
复制代码
/ k/ f; H% q I7 t- j* s8 m0 J) q& H- N- D$ z
F% _8 _) ?! t- V9 p
|
|