|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
9 R+ ^! l% L( I4 Q( @- K+ p! m
Teamcenter ITK二次开发源码分享: 创建一个工作流
1 ^# L @' \; v) }
4 v7 F' w; x. U4 |- l! S- /*HEAD CREATE_A_PROCESS CCC ITK */
% g; y5 I! g5 v - #include <stdlib.h>
; e! O; F; ~! e! r - #include <TCcore/aom.h>0 D8 M0 |% N$ z; v' \( }
- #include <tc/emh.h>
1 j& y! B J+ b p* S g& C - #include <epm/epm.h>
( X( r! @% Z9 R. k/ F2 F - #include <tc/tc.h> {/ e; g% M' H m: o9 M' e
- #include <sa/tcfile.h>
]: l: d+ G8 M% x - #include <itk/mem.h>& U3 `% k+ x/ D4 i; }; H% f! ~2 {
- ! P! Y# z J. {+ I6 w
- #define EXIT_FAILURE 1 " c- k" E! {" q% X6 b# {7 U, K
- #define ERROR_CHECK(X) (report_error( __FILE__, __LINE__, #X, (X))) t ^2 }! j4 K( ^$ ?* z
- static void report_error( char *file, int line, char *function, int return_code)
# k+ m# J7 T- x - {) Z p1 U. t5 E6 }) x9 x
- if (return_code != ITK_ok)$ k* w- J5 q* P: j
- {" x- @: P' b0 T' I, o4 Q
- char *error_message_string;
+ X4 I. X. i1 m1 T+ w - EMH_get_error_string (NULLTAG, return_code, &error_message_string);
% R( G. Z4 h/ h/ Y' i - printf ("ERROR: %d ERROR MSG: %s.\n", return_code, error_message_string);
6 s' Y7 l; \ m" U4 q- w4 S: X - printf ("FUNCTION: %s\nFILE: %s LINE: %d\n", function, file, line);& _/ Z: L8 v; j
- if(error_message_string) MEM_free(error_message_string);9 X# Q( R' v' [% p& e4 e$ |
- printf("\nExiting program!\n");
* k" F2 Z7 x6 w$ T* Q - exit (EXIT_FAILURE);
0 N( ?4 ]8 E4 s0 y0 s* @( b - }0 v9 A. S/ S! O' I) ~! r
- }! R9 G f: u7 h( d: @ p( S4 t
! ]! L' o( U( J# t% M& G- #define EXIT_IF_NULL(X) (check_value(#X, (X)))! k3 m& Q N. B. e% R2 A" c- A* G
- static void check_value( char *function, int value )- F# n) O' a; |( U$ Y
- {. }/ `4 o4 P8 C% |" }9 _
- if (value == 0)
8 ~: o1 I& M5 @5 Z6 X0 {& l R/ Y4 x4 c - {
) K G7 Q0 h4 n3 Z: C - printf ("\t%s is NULL\n", function);
4 M2 s, P' Z! _$ p5 } - printf("\nExiting program!\n");1 H |/ j; _: H7 {2 m9 S
- exit (EXIT_FAILURE);
# I4 K) q" V% Z/ c8 K& _/ V - }+ E! @2 H/ P7 x+ \: s7 g
- }
7 Q/ p' a5 B3 `4 M. O2 | - ' R) i6 O. X% C8 d$ V
# l$ o2 i J- m) d, _- static void do_it(void)( ~7 k7 L. o; X8 g+ [) a# H* F
- {. M3 C- S& {- r& p0 {+ K+ y* {
- int
! P1 p6 S' h E: N+ R2 _- v1 b - attach_types[1] = {1};8 J! l' y' \* W- [, d* m. f
- tag_t " s& i" l) M6 v; }, A+ s1 \
- rev = NULLTAG, 5 i$ c/ D: p1 j5 g q3 ^4 J* _
- process_template = NULLTAG, 9 e! B9 R9 z; X4 }
- process = NULLTAG;. o ^! c# ^: w% C; |
+ W4 K. x7 Z1 S3 \7 S- ERROR_CHECK( ITEM_find_rev("000206", "A", &rev) );
) v/ d! `6 N6 A0 |2 ^ - EXIT_IF_NULL( rev );- A( }* j& T7 Q8 S! z/ E' Z. N; m
. O+ R9 ~; t+ t" ]3 `# N- ERROR_CHECK( EPM_find_process_template("oneStepWithStatus", &process_template) );
5 P1 M4 U, Y1 p5 b - EXIT_IF_NULL( process_template );( Y2 h _7 W4 z* u
- ' k- i D* l& x. P1 ]' v) M
- 0 K7 s+ v V3 Y8 r2 u
- ERROR_CHECK( EPM_create_process("5421377", "desc", process_template, 1, &rev,
. X0 O" Z6 |3 }% x+ e$ U - attach_types, &process) );
$ _5 a# e0 }( G+ C+ S- n8 N5 R - c( y: [( Y4 t8 O
- EXIT_IF_NULL( process );' H0 c2 V& ^9 r6 m6 d, F M& n
- }$ D4 R9 x4 o, T: ~
& _3 F- R7 i: L- int ITK_user_main(int argc, char* argv[])2 c2 C* h) k$ V: k" F6 M
- {# i8 [ ]7 F& X0 `
- int4 w- ~: G* |4 H( F
- status = 0;
0 g! \0 f$ Y6 A2 u6 E -
) \9 K4 G% S& ^8 ?3 B8 f! V+ X - ITK_initialize_text_services( ITK_BATCH_TEXT_MODE );
7 X5 W" ^, }6 c: e - status = ITK_auto_login();
3 h: k$ B% @: ~8 T - - e' S$ g9 e& Q0 |% a% Q E
- if ( (status != ITK_ok)) printf("\nLogin Failed!\n\n");; y& ~9 U$ s" d4 I6 ^
- else- }9 e! F9 R( m) U0 }4 O
- {
5 F, S: s& \: K, c" ~5 z* x! O0 B - printf("\nLogin successful!\n\n");
4 }" e( x; ^ I" z* E* q2 M - ITK_set_journalling(TRUE);1 J( G4 k* `- f( h( b# I! K$ @" \
- do_it();+ u" y) j% l6 g+ D
- }& ?$ k5 @' V0 E. V7 B! [+ ^% K# S! J! I
- ITK_exit_module(TRUE);
! W/ o \* s6 z8 j% |- x- t - return status;/ m: p- }. Z2 A8 {& {6 v
- }
复制代码
9 r/ ? @9 s9 g1 G
R6 z z1 J: P1 \3 O, s1 g- O" L9 y5 f D$ B! `
|
|