|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
* o( e2 e2 y- M- T5 WTeamcenter ITK二次开发源码分享: 创建一个工作流8 h: p, }$ i3 B3 }/ f( |
5 b$ F: f# k$ i) }1 Z5 v2 S- /*HEAD CREATE_A_PROCESS CCC ITK */4 B1 K! ?/ F5 t9 x
- #include <stdlib.h>
9 ^ }) P( Y7 m% e2 U, j2 y! N - #include <TCcore/aom.h>2 U+ ~5 p1 i* ]0 T$ P1 P) U0 h
- #include <tc/emh.h># e; H5 D/ q" L6 L
- #include <epm/epm.h>/ w4 k, ^* x z1 ?
- #include <tc/tc.h>& q0 x4 F3 {9 `2 ~
- #include <sa/tcfile.h>
0 z# g$ u- Y2 t - #include <itk/mem.h>6 V1 ]7 f- X; y3 Y9 l, ?+ u& ~; E
- 5 \7 A/ r$ z h
- #define EXIT_FAILURE 1
' u2 K6 U" F% S6 [/ A) Z' z7 t - #define ERROR_CHECK(X) (report_error( __FILE__, __LINE__, #X, (X)))/ c, Q( O" ?7 ?$ @" ^# H/ t
- static void report_error( char *file, int line, char *function, int return_code)
0 Z- C& B1 h) {6 R - {; ]; o, D( s+ i, O$ x6 w
- if (return_code != ITK_ok)# }' s3 b9 z) y8 S
- {) q! y9 P( y) H1 g4 V, n+ z
- char *error_message_string;
3 A1 \7 ?" c* m; o* _1 p' n - EMH_get_error_string (NULLTAG, return_code, &error_message_string);
9 B1 R/ d+ `% O! h8 y" @8 {$ b - printf ("ERROR: %d ERROR MSG: %s.\n", return_code, error_message_string);
: e7 u) V4 |& X+ D& ^# b - printf ("FUNCTION: %s\nFILE: %s LINE: %d\n", function, file, line);
- r8 p, g4 d. m+ Z6 N. b% w2 J - if(error_message_string) MEM_free(error_message_string);
" ?( A; S }9 v$ J4 J! p - printf("\nExiting program!\n");
6 {2 N5 i! Z+ @. Q - exit (EXIT_FAILURE);
1 j p% i7 d2 Z# F$ J8 W2 } - }
# z/ t( P6 d3 B) } - }
- g. j9 X$ q( @# q2 S6 U8 Z9 m - , ` v) E+ U+ C" K+ ~: Q
- #define EXIT_IF_NULL(X) (check_value(#X, (X))); r; E, B! U0 i. J# e( Z
- static void check_value( char *function, int value )
/ O/ I/ E2 i; s0 z% e8 i. P. t% z7 I - {6 [' H* ?9 \7 l5 g% `4 l# r
- if (value == 0)
" [7 K$ c1 ^) F- U2 K) w" p - { Z' n- {0 O! ]2 u$ ^7 F' V7 l
- printf ("\t%s is NULL\n", function);
, O6 g9 Z+ D. s( Y) r, J - printf("\nExiting program!\n");: `$ S3 m8 @7 a- D
- exit (EXIT_FAILURE);
. G% E- @2 i! A# F2 G1 o - } t8 s, X" O7 y9 ^; M6 q
- }
6 A% j. x9 A9 U - 5 d1 c- n: G- V# P( F/ |2 @6 [+ |
- * f5 ^1 j) N4 W% e' @
- static void do_it(void)4 t1 u2 U# Q: w
- {$ D( o3 p" n4 D7 O0 I1 \1 E
- int
4 ]" I3 Z( N! W' L+ ^6 h- L) `$ ]4 f - attach_types[1] = {1};
0 h z% s! l n. j, ~ - tag_t
. J5 B8 F8 W: G0 X: D6 K - rev = NULLTAG, " ]9 D# U+ O2 |- A
- process_template = NULLTAG, l. F1 ~/ v) D$ x* C7 O
- process = NULLTAG;
[5 f9 |$ W+ v+ N9 m3 d4 P7 ]
! p- ^6 k2 Y4 S- ERROR_CHECK( ITEM_find_rev("000206", "A", &rev) );
6 D* F1 U- i5 R: M; [ - EXIT_IF_NULL( rev );
" d- G; w0 N* a2 W3 b - 8 _; L& [% L' V/ A' J# Q
- ERROR_CHECK( EPM_find_process_template("oneStepWithStatus", &process_template) );
4 F) e V' M& y9 K0 g! O - EXIT_IF_NULL( process_template );
2 B+ d: g& [5 \; |
' P" g) i' a% P: g, ~$ `
% q) u$ l& t3 s8 k. E- ERROR_CHECK( EPM_create_process("5421377", "desc", process_template, 1, &rev,
" c3 r" L* q, g! |" H - attach_types, &process) );
! G6 ]! ^4 t2 U - 2 n5 J0 d$ b2 b7 t6 j" x
- EXIT_IF_NULL( process );
5 O: j2 S8 E, m: E1 Q- P - }7 a/ [- X/ z! {) h- r: B: u6 d
- ( \1 m' \5 F% ?; J# C% R/ ^' m
- int ITK_user_main(int argc, char* argv[])
; k) A5 w" b/ d3 n4 O, o7 { - {
8 h+ N$ v5 k( s5 i# I - int
4 a4 @0 o4 F2 Q( q* O- a. d - status = 0;
( t4 m- t5 V/ X0 j {5 a; W; D -
1 j) Y0 x6 b3 ~1 v; Q2 G1 Z - ITK_initialize_text_services( ITK_BATCH_TEXT_MODE );
# j! w7 b7 S# h; q2 |. m1 I - status = ITK_auto_login();
{ J' q* b( b3 h5 T - , @! ~. E' ^, X) d' z& t' F5 Q
- if ( (status != ITK_ok)) printf("\nLogin Failed!\n\n");
' ~8 `: `* R, [ L. ] - else
7 J4 I1 B! b" [: _7 T+ s8 ]; d- j - {1 X- w; V7 S$ d2 r/ \
- printf("\nLogin successful!\n\n");3 o% F& |5 ]% h/ P' b0 }
- ITK_set_journalling(TRUE);9 E" Y7 k/ H% `! ^* e# t3 h
- do_it();2 n; Y" d- Z/ g: p
- }
! S4 e" h1 \1 X4 s3 ^- |, | - ITK_exit_module(TRUE);
* [: J i6 g2 }) f - return status;
& R, E- p- g# B' G8 C ~& s- O6 c3 I - }
复制代码
2 s* T$ M/ L/ ^+ }/ t" z: a. S' K4 ~! \* Z/ ]
' p% I' f$ r+ ~# J4 | c |
|