|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
, [$ q% c, m' t" S6 f; VTeamcenter ITK二次开发源码分享: 创建一个工作流
6 N" U# r& O+ H1 E
% q" X8 E: x. i3 k4 S+ G1 N0 M- /*HEAD CREATE_A_PROCESS CCC ITK */5 }3 t: U8 a. o/ I/ ?& i
- #include <stdlib.h>" P! J7 X* w- _4 E. O- u
- #include <TCcore/aom.h>. e; N5 | C1 m& N2 r& z- @ I
- #include <tc/emh.h>
1 f4 {4 P! }5 D$ L - #include <epm/epm.h>
7 V2 x* N1 E2 i8 u" s0 B& C - #include <tc/tc.h>* |9 [7 C$ d, F% G
- #include <sa/tcfile.h>
$ L, m( Q, v& {" M" a% S8 I5 _ - #include <itk/mem.h>
* X( t2 o3 l. V7 r6 b- i
9 {' H4 I/ q% f- M# n2 |. V$ g1 F- #define EXIT_FAILURE 1 ' B7 K# i0 ~( W6 o3 J! @: Z' C+ X" @
- #define ERROR_CHECK(X) (report_error( __FILE__, __LINE__, #X, (X)))
: U- a7 s- r" R3 M' A( O - static void report_error( char *file, int line, char *function, int return_code)
# U" @6 g9 i; i* n) P9 d - {
6 H' F# S9 g( F" m" ^1 M - if (return_code != ITK_ok)
6 g" x6 J0 u$ R% s1 N - {, f, r+ ]8 D1 e9 G' W8 \
- char *error_message_string;, z! \0 ^7 f( q
- EMH_get_error_string (NULLTAG, return_code, &error_message_string);
6 a0 m& L5 X, t# Y0 d$ M - printf ("ERROR: %d ERROR MSG: %s.\n", return_code, error_message_string);6 C' E9 \. S4 J: R4 T, Q/ g
- printf ("FUNCTION: %s\nFILE: %s LINE: %d\n", function, file, line);
; o, v6 c4 R2 T! s: ? - if(error_message_string) MEM_free(error_message_string);, k, W3 J: I# v; x' q0 @7 l
- printf("\nExiting program!\n");! E3 b" Q# \* a. Y7 v8 h0 K' U, |
- exit (EXIT_FAILURE);
3 f) g9 ]. x) ^( V, _% n. ] - }; V* d7 T6 Z; q6 x- @
- }0 J3 B' [( r, c ^5 n
9 y8 L5 M; s' S7 l. w( c3 q- #define EXIT_IF_NULL(X) (check_value(#X, (X))); ? X3 g7 @$ C: x3 s" ?" P) F' j' t
- static void check_value( char *function, int value )
' t6 ?, u7 m. n3 V1 J - {
9 P% G" o4 m, s7 h# i5 [- d - if (value == 0)
" y; R' z6 N& T" a+ d0 k - {0 t' P5 m: S, Z$ K4 z9 Q4 D
- printf ("\t%s is NULL\n", function);
! s/ U% q, U7 h9 s U2 x - printf("\nExiting program!\n");. ?9 I$ F0 O" C! G) n0 k( K
- exit (EXIT_FAILURE); 0 a \0 g0 A- _) }' o
- }# R; {0 Y1 d# Y$ z5 q
- }! _7 w7 B8 B8 C; \
- . ~+ h4 y+ J: ^5 S% u7 i
- $ `3 e& }, o* _$ J) [% G
- static void do_it(void)
. l! V1 q/ K% A- h d4 | - {
6 P0 v) ^& O6 Z% i- ^& v9 b/ c - int 2 e1 q* d) J: C0 y, K! u
- attach_types[1] = {1};/ P( U2 c" _1 ?4 c
- tag_t 7 ^, ~. B/ P( M! y) `3 n: X4 h) {2 u
- rev = NULLTAG,
+ r3 W5 y; j2 E* v - process_template = NULLTAG, C# H4 p2 F m. \: y+ w
- process = NULLTAG;
# W& o Q; ?- Q; @
9 ^2 }# X$ w) d- T0 M- ERROR_CHECK( ITEM_find_rev("000206", "A", &rev) );
2 K0 u1 c0 D8 e. E4 d1 ~& t - EXIT_IF_NULL( rev );: \+ Y- y y+ V( w/ I2 i
- 1 ^: m5 j4 U$ S7 z& r
- ERROR_CHECK( EPM_find_process_template("oneStepWithStatus", &process_template) );
6 P: I$ c& Y2 r, n- F* s. E1 d - EXIT_IF_NULL( process_template );* Y( R3 }+ z4 a* i/ A+ _
& \( ?4 \2 G% ~ j6 {/ F; u) g7 p- 7 p$ _. ]8 |9 p, @
- ERROR_CHECK( EPM_create_process("5421377", "desc", process_template, 1, &rev, + F. |8 ^3 H& y* e
- attach_types, &process) );; x* k$ h1 w7 I0 F& D# ?) j6 L. x
- $ l; `& v0 [* b' G1 a6 j8 e p
- EXIT_IF_NULL( process );
/ N o) O0 g% B6 E8 D1 r( r* | - }$ D) r# ` Z7 y4 v
- 0 _, X! O% W$ b5 S/ `
- int ITK_user_main(int argc, char* argv[])9 W" _, Z( ^; p# g, F4 v5 M
- {0 S$ e' g' F) N) f2 [$ g) ~$ F* d' E
- int
; ?' v6 g# l* P) f; O1 G - status = 0; C0 n4 M! q4 i4 L
-
4 B6 z0 o$ V; ~* _5 n - ITK_initialize_text_services( ITK_BATCH_TEXT_MODE );
0 l' n/ Z7 r8 ]6 N" Z - status = ITK_auto_login();; m) ]9 _3 h* |0 `6 j9 N
- $ N$ J9 U/ d* u$ i: N6 k. l
- if ( (status != ITK_ok)) printf("\nLogin Failed!\n\n");
: e' |4 K( o% j - else" P2 Q( R6 S0 c3 r1 L7 t R
- {
. l) H8 F8 R+ V' L# i - printf("\nLogin successful!\n\n");
! x E4 n C8 ?& R, a - ITK_set_journalling(TRUE);
4 U( P ~/ |" g9 b) _- L - do_it();
3 X5 t% E2 L; f2 m3 A2 x8 }' u. W+ V - }
" `6 c+ |8 L/ V+ x3 P# ^ - ITK_exit_module(TRUE);% M0 H! v+ B5 w9 K% w4 T+ f) N- c
- return status;+ D5 G3 \ J4 W
- }
复制代码
* _7 b! l7 f$ x' I1 j
! ?; Q& ?- Q; \9 M# @; C
# W7 p0 G2 B8 S6 F" Z1 ^: F |
|