|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
% q4 H9 b+ a1 P7 ^, J% P
Teamcenter ITK二次开发源码分享: 创建一个工作流' b2 p* i' S# z* w
+ P* I7 V& {8 }* x
- /*HEAD CREATE_A_PROCESS CCC ITK */
* ?( Q% `( q) z1 ~! q. A# y1 E - #include <stdlib.h>
0 l* q( Z0 L/ b - #include <TCcore/aom.h>
& f; I# t, S, b# \; L - #include <tc/emh.h>2 V& y w- {, X1 V% g+ q& X% d$ R9 D
- #include <epm/epm.h>7 y8 C8 |' X8 Z* {: E9 n0 _
- #include <tc/tc.h>5 a. U6 {( j9 T* O& X
- #include <sa/tcfile.h>
( |' }' Z; P: I$ x( g - #include <itk/mem.h>* V- P1 `5 O' e( q% A
: |5 f1 y" k4 S- #define EXIT_FAILURE 1 ! N9 v) t) Y, a% Q, J
- #define ERROR_CHECK(X) (report_error( __FILE__, __LINE__, #X, (X)))
/ e F: C) R& ]; \ s0 y. c- V6 j - static void report_error( char *file, int line, char *function, int return_code)
& o$ C! u" O# r: r - {
) [! @* K& {7 z J f) ` - if (return_code != ITK_ok)
; E5 y% B) _3 M - {/ Y4 E. |. n/ k4 x; M8 Q. v L% C2 x5 p
- char *error_message_string;
" M# F$ n J. | |+ h5 a - EMH_get_error_string (NULLTAG, return_code, &error_message_string);1 ^) S t( Q9 f* s, S7 z
- printf ("ERROR: %d ERROR MSG: %s.\n", return_code, error_message_string); ?" P7 A6 X( D& v$ q$ W- a
- printf ("FUNCTION: %s\nFILE: %s LINE: %d\n", function, file, line);
- ?3 y5 e! f+ s2 `% Q1 i+ C# } - if(error_message_string) MEM_free(error_message_string); w x9 ~: _% X$ @: w
- printf("\nExiting program!\n");
- C% S G' i: l6 P - exit (EXIT_FAILURE); * U. J4 X) {4 a% q* R' u; ?
- }5 U# e5 h x0 @8 \8 ~
- }
9 L( d5 G4 B# q8 e% H6 c - 2 @: S3 u1 E7 a
- #define EXIT_IF_NULL(X) (check_value(#X, (X)))
) }+ C$ I& N1 T, m2 r4 s - static void check_value( char *function, int value )" s/ L. \0 l+ i" F0 ~% q
- {
a3 ?$ X% B% z6 D; L/ m: s% b - if (value == 0)8 f+ l* A! k- h2 O( D. F3 R! k' r
- {( Y& V& Q& k/ B; B8 H& ?. i
- printf ("\t%s is NULL\n", function);
6 e. f+ e4 A; R, }$ _- k - printf("\nExiting program!\n");
. u* G% M$ U. z$ N, @8 _ - exit (EXIT_FAILURE);
: j3 P# S2 G% l - }2 r E% A( i, @- p
- }$ h4 H# f/ `5 R+ A8 E4 |
2 u0 z/ s1 T* `* x$ `; l- 2 F1 W. \! q8 }/ e
- static void do_it(void)% C; S9 X5 w* A i4 H9 D, A$ K+ c5 Q, d
- {
! C y4 Q. t' Q! V. | - int W3 {' G: ^' d0 o
- attach_types[1] = {1};; U# \# ^3 q @* M' t" J. _
- tag_t \. Z* A3 c3 }: i( b) s3 J
- rev = NULLTAG,
d x. f5 \. _4 o# I* `+ S - process_template = NULLTAG, , J1 q i' P# q# F" Y1 d
- process = NULLTAG;5 V; |& R2 f8 J2 n% z, ]
- - j+ N* ]& i# g. b. d
- ERROR_CHECK( ITEM_find_rev("000206", "A", &rev) );$ b; e( m* |! s% Z6 I: O
- EXIT_IF_NULL( rev );# L$ X/ T1 Y- q$ Z$ o( ~* ~
- , \& ~3 _; [1 h. `: Z
- ERROR_CHECK( EPM_find_process_template("oneStepWithStatus", &process_template) ); 8 ~! j5 v/ H4 V1 v
- EXIT_IF_NULL( process_template );
( ~% y$ X6 \1 p1 {
4 q. a/ P/ k1 F5 R- {2 U# U3 T- 4 ~9 d7 T: G9 P
- ERROR_CHECK( EPM_create_process("5421377", "desc", process_template, 1, &rev,
. n' T9 i# @0 |3 D8 f - attach_types, &process) );2 }. ~% W$ i* f, b0 u& x
- ; M9 F; O9 H# j6 O8 a2 Q" t" O
- EXIT_IF_NULL( process );
( u/ ?/ ^, g, h) u N - }: K2 X8 v# j$ e" \# `
' k5 J* B3 `0 Q- int ITK_user_main(int argc, char* argv[])% ]! w% \/ N6 l3 `2 E6 U
- {: ?* f$ \; `5 Q+ A5 R
- int4 K: d3 r t* @, W
- status = 0; 9 M) c) H) y* |+ m) U
-
; K4 e" O/ n1 m! ^' P' r. y. R - ITK_initialize_text_services( ITK_BATCH_TEXT_MODE );
2 I; ~+ g/ z/ ]5 u, r H - status = ITK_auto_login();
) x2 H1 m1 e) ]$ M - 5 _! x# o- @' p ~0 W$ w' X
- if ( (status != ITK_ok)) printf("\nLogin Failed!\n\n");% \% z* Y: q( f6 T% h+ _7 y2 C6 c
- else
5 F3 Y( P. r* ~! u% r. Q" y9 m - {; l% o" i: @7 U
- printf("\nLogin successful!\n\n");
9 |( ` q$ T+ {0 a7 n k - ITK_set_journalling(TRUE); }) \8 Y. Z8 O4 ~ I- j
- do_it();
0 ]- f/ P. ?3 n8 x* g8 A) f - }
. I G6 o, w% u5 d - ITK_exit_module(TRUE); {# F' {9 i& N& K+ K% [' L! S+ ]& ~
- return status;
5 D1 ]9 y k( D/ ~1 q2 `6 X* G - }
复制代码 0 W A1 i* T. u
7 F3 Q* C. n/ j1 {- ~! o* T7 n
* G v4 K4 v. ]3 v |
|