|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
% g+ U M9 G# z, N! TTeamcenter ITK二次开发源码分享: 创建一个工作流, `/ u4 [9 E" ]
- X4 W/ s/ z/ G! f- /*HEAD CREATE_A_PROCESS CCC ITK */
8 O) D% q* f7 L/ w$ T - #include <stdlib.h>
; x) ]% e% f/ X" Y9 a) r. z/ Z - #include <TCcore/aom.h>' _+ s, ?8 d* }. I4 [
- #include <tc/emh.h>9 [4 a2 Z( t# j% d8 K) k- \
- #include <epm/epm.h>
+ W0 P& K; z5 v; t: z - #include <tc/tc.h>( K+ n# r4 N, t7 z
- #include <sa/tcfile.h>1 O& A" L- R- w
- #include <itk/mem.h>. ]7 }7 c4 w% D. p
) O4 N6 J' `8 e( ^- #define EXIT_FAILURE 1
b( _$ y9 G% Y+ P" B. @* Y - #define ERROR_CHECK(X) (report_error( __FILE__, __LINE__, #X, (X)))" E1 j4 E7 k& H2 ?
- static void report_error( char *file, int line, char *function, int return_code)
3 ]1 d* F2 C- U - {
# Q( y+ Q3 n- U8 D9 @ - if (return_code != ITK_ok)
. R+ c" l W% F! t! N0 P! y% K5 f - {
/ Y: ~8 ?1 E& S, h' c - char *error_message_string;
9 M+ _5 A9 n9 p( t9 Z, h - EMH_get_error_string (NULLTAG, return_code, &error_message_string);" W- i/ t$ J5 r2 s- k( H& M; n2 X
- printf ("ERROR: %d ERROR MSG: %s.\n", return_code, error_message_string);
+ n. J( T, ?+ U - printf ("FUNCTION: %s\nFILE: %s LINE: %d\n", function, file, line);$ r% E8 e; I. U2 G1 ^5 G
- if(error_message_string) MEM_free(error_message_string); d" ^% R7 r% t% a
- printf("\nExiting program!\n");5 q( c# U' @ V/ w- y# O$ A
- exit (EXIT_FAILURE);
6 ^. h B6 x1 @8 j+ x$ Y7 H - }
7 \$ W5 O/ d+ y - }
# l& Y! |2 |; H1 C# ^% `- k# s2 q7 Q, C
; J2 k* K0 f1 Q& B8 ?( S7 E- #define EXIT_IF_NULL(X) (check_value(#X, (X)))
& `# y0 K. B0 N% `! a5 D - static void check_value( char *function, int value )
+ W! p9 R) m7 c( k- ]& T. S0 F - {6 R1 e0 F, ^0 o: x9 I/ {9 v+ a. ?3 C
- if (value == 0)' c" c, _5 C( i, d$ L! x4 A
- {
; O/ f# o1 \1 o5 ]; m - printf ("\t%s is NULL\n", function);' y0 x& i: c( L" X0 S' \
- printf("\nExiting program!\n");
& h X! a) Z' q2 L) T& n/ v - exit (EXIT_FAILURE);
5 U* [. f+ i6 U - }
% r, t4 m) t8 s* C) m* C+ e - }
# U1 \( q0 ^! L" @2 V# F X
! {* X* t$ C) p! F
; [# `# g# K0 K; U) ^. E" m- static void do_it(void)
! l% n3 O i* { - {
8 A1 l( P! t8 ]# x" w" k( z/ L T - int
( D( m) ?2 \( Q0 @# }, \ - attach_types[1] = {1};
( V/ d- Q& R* W$ G; H - tag_t
2 B5 I' J" {# a1 Y+ @6 N$ \ - rev = NULLTAG,
! U& h+ x% L* T' A - process_template = NULLTAG, / x/ b, M3 Z2 d; r
- process = NULLTAG;
" h9 w* ]/ I& b9 S( K - 7 {) U) r5 T0 ?/ D' k6 W
- ERROR_CHECK( ITEM_find_rev("000206", "A", &rev) );
% ]# {& s4 l4 V7 p, c+ [7 e& n - EXIT_IF_NULL( rev );% O' K9 D2 s3 ?" z% s, R) O {
- " g- L y( e+ }+ }$ M7 y7 z
- ERROR_CHECK( EPM_find_process_template("oneStepWithStatus", &process_template) ); 0 R! _+ e, Z9 _( v- E0 ]
- EXIT_IF_NULL( process_template );/ i8 G! H$ J- J% L) l7 A
# t [1 [) N0 ?0 P5 U
. W P" L8 _. ^- p6 z- ERROR_CHECK( EPM_create_process("5421377", "desc", process_template, 1, &rev,
! F) Y$ R1 U" t1 p# t! @+ A - attach_types, &process) );
9 q# j: J" D: e( B7 F - / X& q1 e+ y* S4 }* _
- EXIT_IF_NULL( process );
3 j1 V/ R6 ^$ P7 w$ K4 w7 H: b - }
, M3 k1 B2 X7 I
y% S! I/ Y8 b, V3 D% }- int ITK_user_main(int argc, char* argv[])9 u! @* A2 w5 m8 C6 Q* K- j0 F. q0 |
- {# t# T' J! v# g, t0 d7 f
- int
+ B+ J3 E- y' p+ n/ c - status = 0; 2 ]! I) P* M6 M# S1 f
- / z7 { R5 B1 N# x" d6 N$ X
- ITK_initialize_text_services( ITK_BATCH_TEXT_MODE );
% M p5 H, i2 t - status = ITK_auto_login();/ e8 {3 b/ l; \8 K
- ! L; f3 c, @. y ?( S+ K! h
- if ( (status != ITK_ok)) printf("\nLogin Failed!\n\n");
$ E9 @; u+ y5 a - else
$ G) x( }5 {1 e2 b$ [! T8 d - {0 F0 L' x Q8 n9 W! x& E! j) w6 E
- printf("\nLogin successful!\n\n");
/ x5 m0 ~1 L e+ i: R) K, ~; R% z4 c - ITK_set_journalling(TRUE);, q. r) d/ s7 l: ?' X: ]8 N; v
- do_it();
1 A1 t; h% k/ c) s% F1 d - }5 h. M$ H: {+ w M& M, Q
- ITK_exit_module(TRUE);0 J3 d3 G3 r& G' L" G) v, G" a+ o
- return status;$ D4 `, |* }* r3 S4 ~
- }
复制代码 # f7 x; M, ~: ?+ s, X
! r( o. `& t5 m
, L u# j/ ]! c3 X
|
|