|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
# M& y* k/ S' W2 |/ o
Teamcenter ITK二次开发源码分享: 创建一个工作流
4 p. I% V; H! u& y/ n
6 E) G) E; G7 [5 L! L$ i- /*HEAD CREATE_A_PROCESS CCC ITK */1 _+ Y: X0 q w3 f& H; n, }
- #include <stdlib.h>* M; |7 D) p$ ~) L3 z4 L
- #include <TCcore/aom.h>
9 t; b. R) U9 d b# v' J" k) w. v - #include <tc/emh.h>
- n/ T* n, j7 [ - #include <epm/epm.h>( |3 u/ M" \% { a+ T* L0 `! O
- #include <tc/tc.h>$ ?3 E3 U# U; |# j5 d6 @/ `
- #include <sa/tcfile.h>
' w+ b, `. `- [/ R0 r4 \* a - #include <itk/mem.h># p! a/ d6 k+ \/ I" o8 H
1 M( a( h6 v) j5 A- #define EXIT_FAILURE 1
8 ~# S7 i' F1 D+ m* n - #define ERROR_CHECK(X) (report_error( __FILE__, __LINE__, #X, (X)))4 r% {" G" i7 x5 H
- static void report_error( char *file, int line, char *function, int return_code)
) E! `% w; ~6 H% T/ r) \) N; \ - {. a4 O6 y# M* w1 M f
- if (return_code != ITK_ok)9 b% J% x) r7 D h
- {1 L3 Y$ l: _7 y5 B b) O. F
- char *error_message_string;4 U. q) s$ V4 `1 s9 ~& I
- EMH_get_error_string (NULLTAG, return_code, &error_message_string);
( I+ S/ V% P" P' @1 h - printf ("ERROR: %d ERROR MSG: %s.\n", return_code, error_message_string);! a) m+ K" w) R
- printf ("FUNCTION: %s\nFILE: %s LINE: %d\n", function, file, line);0 w' G1 M+ ?6 p" [3 q4 u, W
- if(error_message_string) MEM_free(error_message_string);! k* G& V/ ?, F l
- printf("\nExiting program!\n");* l* h0 Q5 I" O0 b
- exit (EXIT_FAILURE);
* G* l `$ Q9 d/ w+ f1 P6 b/ g - }' K# d( ~# w2 P9 H% U
- }1 t: x( J, F$ O: }- A ^/ R1 X" B
5 M- ]$ `/ v5 B* |4 T5 A' o- #define EXIT_IF_NULL(X) (check_value(#X, (X)))+ S, U# g$ H" r* x- E
- static void check_value( char *function, int value ). i0 Q2 ?. t6 d7 d! C: \
- {7 \( N$ _+ |2 \% h. ^
- if (value == 0)
% }' B9 K% i7 }- q! X& A - {
. c3 ^& ?. x. A: Q. E" L2 t! U9 u - printf ("\t%s is NULL\n", function);
3 D* u1 h- N* R - printf("\nExiting program!\n");
+ r8 T3 F! M# s; A0 x7 W- v - exit (EXIT_FAILURE); 6 m: A N" `4 c5 _
- }% A! j. W2 M( C7 P$ ~4 Q
- }+ t* D0 Q3 B5 t" O! ]2 o/ y5 w2 v
" m' g+ M, l: _$ h- # Q, t- s9 c& j- b* G
- static void do_it(void)
/ z+ @( A# e/ u _7 ] - {6 D6 L1 N& y: R1 ^0 @! G
- int ! B! u$ C4 x4 [2 P5 y2 f( J$ |
- attach_types[1] = {1};
$ `& v# E4 p R5 d- ]. l1 Z - tag_t
0 Y6 a! A& z3 e7 h" M. ? - rev = NULLTAG,
* ^% t; ^2 f% U3 E0 l, B - process_template = NULLTAG,
7 ~6 {4 Z( u* ] - process = NULLTAG;
( B J4 J; Y) I b8 T( j- t - $ _% ]1 X2 O) m
- ERROR_CHECK( ITEM_find_rev("000206", "A", &rev) );' A7 A5 Q* `% W8 ]0 k
- EXIT_IF_NULL( rev );* x+ C9 O$ w7 p( e. |# Y5 l
- 6 x& E. ?$ r/ n" p: {
- ERROR_CHECK( EPM_find_process_template("oneStepWithStatus", &process_template) );
* X( X9 j$ x& x4 |7 ?8 B - EXIT_IF_NULL( process_template );
7 g; T" a3 W4 w3 @& [) y - * B. ^" |7 f: \' O A
6 M7 {' i- H2 w; ?, I- ERROR_CHECK( EPM_create_process("5421377", "desc", process_template, 1, &rev, ' N. B. m0 W8 P3 x, ^; Z$ g7 I5 e
- attach_types, &process) );
# B+ @9 k2 \2 W) U4 H - 1 l5 G& ~/ g% L6 w. [# m
- EXIT_IF_NULL( process );
- a3 w% ~& G3 O; v; h) Z - }' j, r9 F7 d) _! D6 L/ n* t
' D4 U, D1 q$ h3 m' c$ e- int ITK_user_main(int argc, char* argv[])7 j7 A f# F |4 z% N
- {
7 [) M* k; Y! U, C4 h - int
. M, O3 a% C' n7 _* Y# i0 d - status = 0; " S3 U8 V' O0 X: D
- ! P' k1 c6 j- ~( W) W
- ITK_initialize_text_services( ITK_BATCH_TEXT_MODE );
8 J: b' s8 `0 G% ^/ i9 V( V - status = ITK_auto_login();3 L0 |+ A+ ~; E) {8 G2 K+ a+ W
-
5 r; W) }9 @& t - if ( (status != ITK_ok)) printf("\nLogin Failed!\n\n");; n) h3 S- A' K0 x& Z; e0 \
- else! y. I4 w4 O& H: b6 y7 w
- {% }' G3 [2 W) L+ D1 Z% d! b
- printf("\nLogin successful!\n\n");* [* S0 [, o' t3 A
- ITK_set_journalling(TRUE);; | Z: e1 I3 U- _' x. u
- do_it();9 y! {1 e* _7 C
- }7 r3 ^- @* D. \+ n* v7 {/ s' [) f
- ITK_exit_module(TRUE);# A. L% s) O2 y! \
- return status;
! \! ^7 m0 a7 F: i - }
复制代码
: ?1 _" a3 j1 \) }" ^* A/ Y) v; c1 j; E; x: w* _; A. F5 l. I
+ R' n2 j/ C4 ^/ ]
|
|