|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
5 [( ~1 t% U* R3 L" O2 X" K3 D, zTeamcenter ITK二次开发源码分享: 创建一个工作流0 \+ v$ [4 W% ]5 W
/ ~* E6 M6 K4 f
- /*HEAD CREATE_A_PROCESS CCC ITK */
! c* e9 E! O7 S3 r% V9 r7 N - #include <stdlib.h>
8 K' i& _0 y- n - #include <TCcore/aom.h>- O0 |- g+ x9 _- c
- #include <tc/emh.h>
% J8 [; l6 s1 s0 y - #include <epm/epm.h>! J6 X8 O8 x; T( V( I n* V
- #include <tc/tc.h>: u y# D: d+ Y/ B. o& V
- #include <sa/tcfile.h>
% b6 W3 {* p1 `" A7 O1 b - #include <itk/mem.h>* b5 Q& _9 n" E6 D' K1 ~8 _
- ! w: e7 D% t) d5 {" w& w4 `
- #define EXIT_FAILURE 1
. J9 O8 A$ F$ z" |, D( f - #define ERROR_CHECK(X) (report_error( __FILE__, __LINE__, #X, (X)))3 ^5 q7 z& q, P; t2 Y
- static void report_error( char *file, int line, char *function, int return_code)
4 L2 }% c3 w: P7 I& [2 i- l* Q - {
4 m1 b8 ?, [& j/ P$ L) ? l+ k4 \ - if (return_code != ITK_ok)
3 O, I9 a( ^; j/ n+ q' a2 f - {
: r& E' O+ ]" R7 w - char *error_message_string;; g! i- z3 X I; _2 `( e; f/ w
- EMH_get_error_string (NULLTAG, return_code, &error_message_string);
$ b! D: D* i% \ - printf ("ERROR: %d ERROR MSG: %s.\n", return_code, error_message_string);
. t1 _6 {# k! @( l0 H7 g+ v - printf ("FUNCTION: %s\nFILE: %s LINE: %d\n", function, file, line);: l" ~& a3 c; L+ i- \+ B: f
- if(error_message_string) MEM_free(error_message_string);
3 q" V! }5 V0 ? Q2 d - printf("\nExiting program!\n");
5 ]& m; Q% ]! U1 q: x4 ~6 q, s. v3 A4 ^ w - exit (EXIT_FAILURE);
, Q6 Y8 B* V$ ]2 b, s! | - }
. q# L3 _4 z7 _) | - }
) C8 S% b/ I. I& u4 z; l - : g" o0 Y! G: j& F7 [3 Z
- #define EXIT_IF_NULL(X) (check_value(#X, (X)))" u# k. N9 ~7 s) Y; ~4 t# L
- static void check_value( char *function, int value )
3 |# b' [ U+ ?; ]1 O& r0 I8 { - {- R; ~ @0 [! o+ L& e0 z) e
- if (value == 0)
' F7 U2 p9 V/ K2 [: I - {
. p* i% m1 e0 \& Z5 K' P, v2 C - printf ("\t%s is NULL\n", function);: U5 u% @! m+ ]4 g
- printf("\nExiting program!\n");
% Y H# a' M; u# `+ F) d7 V( E - exit (EXIT_FAILURE);
0 y j" ?& B" S& _ - }' S0 h; b$ u- \$ o, i
- }# y) h6 b: y* v0 y' j5 A v
$ O u7 N& K. L- h% W7 b
# @& V* E, E, l9 T* |3 B+ k) y$ V) E- static void do_it(void)' z, O S( F+ c9 G; c
- {) B# I4 W: n, |
- int
0 X" U& \+ y: f, u" Y1 \# K - attach_types[1] = {1};
2 l. X+ C% ~# ` v% ` - tag_t / L* G: h J0 D
- rev = NULLTAG,
/ N, t) V9 J, L2 }* t - process_template = NULLTAG,
0 m& O# v. g' D' O - process = NULLTAG;
6 K3 R4 m# C5 U5 a! f; k
( J6 i0 Q# y8 _1 C- O8 A2 n1 h- ERROR_CHECK( ITEM_find_rev("000206", "A", &rev) );
) }" T5 s- ]" R+ f. V- n; m0 c: B - EXIT_IF_NULL( rev );
' y& y8 f: j7 y$ ^/ l2 Q7 F - ' u. H2 \; N- n' q
- ERROR_CHECK( EPM_find_process_template("oneStepWithStatus", &process_template) );
$ u0 N! J8 r3 V: K0 x - EXIT_IF_NULL( process_template );
1 _- K" u& Q& {& I3 h J. y% _ - * C7 {/ _. r% e5 f: e6 L8 R% D
- 8 h- W3 G% O1 W9 M% p! J
- ERROR_CHECK( EPM_create_process("5421377", "desc", process_template, 1, &rev,
- \5 _5 F" g9 O, }* o0 W - attach_types, &process) );9 A- @3 ?+ p, p2 b
4 t1 u% v3 {8 v' p0 A: n- EXIT_IF_NULL( process );
: |5 c6 T- F8 q z/ Z8 r - }( x) C( \) K5 {3 w* G
6 P. I6 T$ d7 L6 O- int ITK_user_main(int argc, char* argv[])/ R0 _- j: f- r# V% v$ L, K! l" W
- {
! ]) m" h6 x! t% I* {( o# d( U - int
$ ?& v5 v4 V4 R v U9 o; e - status = 0;
6 T+ N+ p9 ^- a0 q -
: {0 ~5 I5 z: u* D - ITK_initialize_text_services( ITK_BATCH_TEXT_MODE );
: W, I7 f. S# |2 Q - status = ITK_auto_login();
! v7 ]7 t: S/ R9 t - : e, M% n6 H3 X+ r
- if ( (status != ITK_ok)) printf("\nLogin Failed!\n\n");
; L) f& y+ o) P: h8 w- F* D - else5 W0 J( n* U% P
- {# q( D/ W' B& l: t
- printf("\nLogin successful!\n\n");
! G8 x) o3 H! ~/ r% N - ITK_set_journalling(TRUE);) w+ U. h& f0 h% D( p: I0 d) n
- do_it();& t: y4 G7 ^; c! G
- }
& l# J0 ^8 r- s! u - ITK_exit_module(TRUE);
' N. T: n& u6 n! A% u - return status;
: J1 L6 S8 F6 Q6 T - }
复制代码
! D5 z1 _8 ` H7 H# ~5 Z2 ^& R, B/ c# l% d# R
9 z, v0 S( }1 t6 D |
|