|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
; e6 q5 Q3 Q5 L! P3 `: }: X
Teamcenter ITK二次开发源码分享: 创建一个工作流4 U+ D2 u$ w/ A
+ V5 N& x7 w& Z5 E# N
- /*HEAD CREATE_A_PROCESS CCC ITK */
, s, Q: ^! D6 k: l5 O, o* i: X! Q+ t - #include <stdlib.h>! h8 Y' j# b* [: \' p- ]& L$ B
- #include <TCcore/aom.h>
- v3 [( Z Y: R$ b2 C4 | - #include <tc/emh.h>
4 c }5 q* I" G0 m$ E% W - #include <epm/epm.h>( ]' T- R7 |5 @
- #include <tc/tc.h>
& t$ I& z, N, {1 z- ~+ o; k - #include <sa/tcfile.h>
9 r* [+ a$ W% ^7 u0 H, F# `' F - #include <itk/mem.h> y# s: e$ r* M$ e
- " [" Q/ m) a, m# T. d4 U
- #define EXIT_FAILURE 1
. s' C9 z, X0 J8 \- Z( x. p* q - #define ERROR_CHECK(X) (report_error( __FILE__, __LINE__, #X, (X)))
4 c3 l, p' `& H' q% B. E& E9 J - static void report_error( char *file, int line, char *function, int return_code)
4 M- y- ~- R' Z1 {+ S6 X- B - {
# ~1 r% o: C% ]2 D3 Y3 h - if (return_code != ITK_ok)
J7 i9 H5 w9 ]* P - {' s4 N5 _% E/ t1 v$ f% j
- char *error_message_string;6 _6 s' m) A4 p+ f5 y
- EMH_get_error_string (NULLTAG, return_code, &error_message_string);
" }" G2 ?6 B2 Y* D9 P9 i7 [ - printf ("ERROR: %d ERROR MSG: %s.\n", return_code, error_message_string);( ]9 s5 Q) G2 ? [1 Q5 V
- printf ("FUNCTION: %s\nFILE: %s LINE: %d\n", function, file, line);
+ J4 U P4 ^5 `8 Z% C - if(error_message_string) MEM_free(error_message_string);
9 B1 @3 L- Q5 C0 ~1 d/ O8 s! G - printf("\nExiting program!\n"); O, A; h5 q V' [: a- {; Z
- exit (EXIT_FAILURE); 6 C; }) j7 m' q1 I" v8 h! L
- }
) J: _. D$ @5 B1 Z# k - }
. j( ?9 z: _) ?" K1 W - - Y% o3 c& J. ~7 [0 z* G
- #define EXIT_IF_NULL(X) (check_value(#X, (X)))- y# m! ^& g* R; C& k9 ]
- static void check_value( char *function, int value )8 a; r4 J6 c6 X7 _5 Q. C! Z* I
- {( H4 ^* g" A" Y% h H( |$ Y
- if (value == 0)
- e& k6 E, d' \, e# t: K - {4 @& b7 F& f$ | Q
- printf ("\t%s is NULL\n", function);
9 t% {& o1 p# i6 z7 s: [! w G$ ?# U - printf("\nExiting program!\n");2 }% w" |3 n, d; e
- exit (EXIT_FAILURE);
, l# _0 t1 S# X* \- j - }
& i! B% T; x1 B1 J: \! l- q - }$ F- p5 o; u+ L X
( b/ P: Y5 y7 Q1 b1 [
) ~& P3 K8 d6 Y" l- static void do_it(void): } ~5 x; j* d/ @" B1 H1 ^
- {
# [" S. `# T* _* K& ]% R( y - int
% c' {" y Q/ K: ~! v - attach_types[1] = {1};
8 F% m+ l- P$ z5 `1 T' b( r, m - tag_t
; \$ Z: Q6 H* e' E1 A - rev = NULLTAG,
5 S7 }/ J$ ?2 h2 H6 q3 X, ]( | - process_template = NULLTAG,
$ i, ~4 B( X+ ^/ N - process = NULLTAG;, g3 W0 f, S2 ?; m3 Z& D
- 8 b2 r, Q% ?; ` T$ r* |2 }4 b, `
- ERROR_CHECK( ITEM_find_rev("000206", "A", &rev) );
. d/ Y8 F9 W3 w/ Q( R* q3 E& g# b - EXIT_IF_NULL( rev );1 U, l! s* W) o: c& u
H5 b& R& y2 x/ _$ w% n* q/ ^1 |- ERROR_CHECK( EPM_find_process_template("oneStepWithStatus", &process_template) ); + L: ^' a5 _/ ~
- EXIT_IF_NULL( process_template );! ~% f) F/ e& d' \( H- l" ~2 ^7 ?
- ! Z8 ~+ |/ m4 s3 T( j# y
- 4 X' n7 A) g5 r
- ERROR_CHECK( EPM_create_process("5421377", "desc", process_template, 1, &rev,
" ]( ]0 n; J; h1 ?5 e# x - attach_types, &process) );9 k+ v2 c$ V) b% E0 }: n7 G
+ |6 T- l1 G0 \2 O& u- EXIT_IF_NULL( process );
4 m9 t/ m; m2 z1 l - }
/ _/ e4 s! h& P5 k% ? - " a3 y. m2 h& v9 T) a9 Y: n
- int ITK_user_main(int argc, char* argv[])
* j" p+ \' y9 T, v - {
: Y7 u: J3 z7 q+ D9 t2 w - int
" Q2 v" C S4 n0 }! ~- [ e7 a - status = 0;
+ _; O7 x/ N* K. f -
4 j; T3 F! |! k! T4 M9 E7 h - ITK_initialize_text_services( ITK_BATCH_TEXT_MODE );
+ M' o( y- C% W* j - status = ITK_auto_login();: i) k$ b( S% p$ d
-
3 w4 j9 A8 @& K5 J' A* P# W - if ( (status != ITK_ok)) printf("\nLogin Failed!\n\n");
( R+ p e# f2 F - else
- x) I! R; y* C) ^' [# e) ` - {5 C* i8 v& Y. v+ d' W
- printf("\nLogin successful!\n\n");
+ J) V& f5 D( C1 v+ ~ - ITK_set_journalling(TRUE);4 j8 P/ |# Y/ a4 ?. B8 ?+ j& }
- do_it();( T/ A* h* O6 `* u4 [' n
- }% [. K. U* o( O$ x7 M
- ITK_exit_module(TRUE);
5 _9 c+ Z9 i, z2 ]7 D - return status;" `2 |6 t" d1 Z! [4 O
- }
复制代码
! w4 X, y% N' c8 H: @8 F1 X8 M% ?, m R; B( U* C# P' a
$ }) S0 ^+ |1 ~0 f8 {6 W |
|