|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
" \5 p1 B9 D6 X5 t% OTeamcenter ITK二次开发源码分享: 创建一个工作流9 ~1 n1 v- O5 x# e$ \" j# Q
( L: @0 }# z9 c& Q5 E8 w+ f0 R4 f) X- /*HEAD CREATE_A_PROCESS CCC ITK */
. h2 X3 ]+ v8 x n5 P" |9 J1 h# s - #include <stdlib.h>
9 E v: R- f8 i8 F - #include <TCcore/aom.h>
, s6 x7 t8 X& c( N; h6 q& D) q - #include <tc/emh.h>& E) ^2 [4 r2 L; v* _
- #include <epm/epm.h>" Y- j2 x+ o! o- U0 ^
- #include <tc/tc.h>
" }7 P7 f1 M1 o - #include <sa/tcfile.h>
0 b4 K' J5 m. w* s% U: H' k - #include <itk/mem.h>/ n$ p5 ^1 s# a9 Y/ A5 {6 J, ~
- % C' [' Q. `1 ?' ?$ a- W+ s& d) B, v
- #define EXIT_FAILURE 1
5 ^8 r& H0 p' U& g; z8 ^; K - #define ERROR_CHECK(X) (report_error( __FILE__, __LINE__, #X, (X)))
& ~* m% i( v7 m) s: D, ?2 N - static void report_error( char *file, int line, char *function, int return_code)) c, C: \6 w6 z3 U# H2 S
- {7 x2 r0 ^ l' i1 u( B( z
- if (return_code != ITK_ok)1 J1 I5 O {: n V$ f' R
- {
! T3 g: f* [0 [$ E, G. n# ^ - char *error_message_string;% I1 X; y* x; T. L O
- EMH_get_error_string (NULLTAG, return_code, &error_message_string);
# ?' A4 ~9 v7 r3 a# P - printf ("ERROR: %d ERROR MSG: %s.\n", return_code, error_message_string);
! y2 S# P, f! Q G9 t! a8 v - printf ("FUNCTION: %s\nFILE: %s LINE: %d\n", function, file, line);
. I+ N1 c: O2 m% u - if(error_message_string) MEM_free(error_message_string);: p& e0 c x! |, x- L
- printf("\nExiting program!\n");7 V+ ?: }1 M2 m) c
- exit (EXIT_FAILURE); % u0 p% M( Y) V6 G+ c' f
- }; h3 p$ t& x' z: L& J
- }! @; }* e* }' I$ m. d* X
. d" ~; K( ^7 Z# c6 I- #define EXIT_IF_NULL(X) (check_value(#X, (X)))
! ?2 O1 R1 l' S4 A7 \5 ?+ U+ I1 W( l - static void check_value( char *function, int value )& p" R/ m3 f5 j: X# z; J
- {2 |, P" l# O6 e! @# d, O8 L
- if (value == 0)
/ t) Z% k1 R8 k6 @4 o# h6 D; u, J - {
: H) r; m* F3 j" M - printf ("\t%s is NULL\n", function);
! z: L7 R5 J$ g0 P h - printf("\nExiting program!\n");. z5 ?+ c0 O% v4 m U5 x- S% E
- exit (EXIT_FAILURE);
% I4 Y% A+ c3 Z, P - }
% V" F( z6 W% o& t1 C7 F( S i$ {" ~ - }
- q/ | k8 P2 p* H$ Y
- f! X$ Y" ~; g+ L# U$ l w
$ k* }% n% j H7 w6 f- static void do_it(void)
2 F5 W" P: P( ^7 Z$ K5 _3 X) W6 j - {0 ]6 n @4 B+ Y9 H
- int
- y* A4 a" r2 k) f8 Z - attach_types[1] = {1};/ P- y, U! U$ N6 z3 T+ d0 ?
- tag_t
* \ c# l& U7 w - rev = NULLTAG, & [! b/ S9 c9 i1 [4 b
- process_template = NULLTAG,
/ W: G% L& ]3 Q) O9 h8 [" W - process = NULLTAG;; l3 w; E0 S* F0 |0 z' u
Q: K1 B+ i6 }& T# P- ERROR_CHECK( ITEM_find_rev("000206", "A", &rev) );
3 W$ Z' j+ Q! s( ]' m2 ~ - EXIT_IF_NULL( rev );3 x. w+ a4 }) X" \% t: Q' `
" N' r8 u: ?2 [- ERROR_CHECK( EPM_find_process_template("oneStepWithStatus", &process_template) ); 1 S: K# P2 i4 v( i8 v( [8 w( U
- EXIT_IF_NULL( process_template );- S) @+ y( I+ P! y2 s
- : t* w+ w, r L
2 |; F* r* N2 w+ ^- ERROR_CHECK( EPM_create_process("5421377", "desc", process_template, 1, &rev,
( j/ y. z f6 {3 M7 P: M - attach_types, &process) );2 P- ?& z& o+ M, v1 K
- n* ^; A) v8 ]8 l, g$ _; }8 P+ E4 |- EXIT_IF_NULL( process );* P/ R0 C9 |$ X- ~) @9 d
- }
d4 U9 E$ c: z3 \ - 7 i# h2 K8 \/ l/ J
- int ITK_user_main(int argc, char* argv[])
# u% N3 W4 Y, { - {' c0 U z- a; w' b# \9 e# ^$ e
- int7 D9 o4 d) q; X
- status = 0;
e) \! H! s. q3 k2 |' Y - 2 }9 ~, b4 H% V4 M9 o# h
- ITK_initialize_text_services( ITK_BATCH_TEXT_MODE );
, N* S; }+ Q+ X* @ - status = ITK_auto_login();, ~: j8 R. \5 K# P, S
- 3 c0 X y( j. _) I9 G
- if ( (status != ITK_ok)) printf("\nLogin Failed!\n\n");+ C7 [+ X; a7 X2 d+ j# p+ U
- else
% Z% {) r) [9 }5 _. @6 J - {
8 J5 R/ v' @3 u - printf("\nLogin successful!\n\n");( T6 B& Y7 @* S8 U7 }/ C W- l
- ITK_set_journalling(TRUE);
3 F& ?& s8 Z7 R1 p) r3 P - do_it();7 w3 s: A& i2 r3 n
- }; z% X* \# x# S
- ITK_exit_module(TRUE);
3 ^ Q- ] ]# q/ Y - return status;
$ o. E( x3 p0 N4 v* s6 ` - }
复制代码
$ R1 U% O, f! P1 m7 L9 J) F: V
' m/ j5 T& L* o5 {
6 O3 e) ~5 K3 |( q9 R: R- h |
|