|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
在集成环境中,NX和Teamcenter的集成中,获取当前用户的组group 和角色 role。* E9 R7 P: }/ z4 n; k
- d- e8 P; u: f$ q- #include <stdio.h>( N' l0 C* Y# v- P( y
- #include <string.h>3 b+ v K# l, q# t6 u
- #include <uf.h>3 K4 o8 e# }" N2 |& U/ g, K
- #include <uf_ui.h>
( B8 M; h% B# N' S" @* v
/ {1 C6 J+ M% x( F- #include <NXOpen/NXException.hxx>
4 Z+ o" H2 y) ~9 ^* v - #include <NXOpen/Session.hxx># K* R+ X" @, r9 Q7 c
- #include <NXOpen/ListingWindow.hxx>2 T0 J6 Y# n% y) t9 _
- #include <NXOpen/LogFile.hxx>+ X5 y R8 S9 G, e" c
- #include <NXOpen/PDM_SessionSettings.hxx>
0 e# r3 Y9 y3 u+ v. E" Q, B - #include <NXOpen/Part.hxx>3 G2 s7 b7 `1 {: o1 P, u
- #include <NXOpen/ParTCollection.hxx>5 L- @4 H2 r4 B; O9 f$ z, h8 Y
- #include <NXOpen/Session.hxx>
4 K4 Z$ A" z; N6 y - ( U, o9 G2 [: W+ C* Z* d
- using namespace NXOpen; // <== Very Important!
3 [) W8 t: t0 W1 t
$ ]4 f" p) M0 W( @7 _- #include <stdarg.h>2 c$ V0 U3 A8 y7 ?
- ( A0 f, O! w* d1 s* A) w
- static void ECHO(char *format, ...)
) a, I6 ~! a7 \% j* @# Z - {
! c# P% `4 ~ }! T* n6 B - char msg[UF_UI_MAX_STRING_LEN+1];
( b& g/ ?* [6 y - va_list args;
! T$ x; r% W' j) }8 B# _) _) ]- ] - va_start(args, format);
- Z8 G' v- g7 m) B - vsprintf(msg, format, args);
! S, a; Q8 u; R - va_end(args);
. Z: w# u1 U% I" ^" l - UF_UI_open_listing_window();
/ N }1 {. A; ^$ t c- T, l - UF_UI_write_listing_window(msg);
* I! n7 _6 N5 T% B - UF_print_syslog(msg, FALSE);/ B( N; u2 |7 Z( _* C: ?% b
- }& S; x% {& V& |2 `6 o( q6 _
; |2 h3 ?5 h$ I# ]5 [( N- #define UF_CALL(X) (report_error( __FILE__, __LINE__, #X, (X)))
* s6 v1 h1 R, r T% x
) d" C4 y! A! d5 y7 M9 E# z* U- static int report_error( char *file, int line, char *call, int irc) k: w$ L7 ^3 K9 k2 I) S* m4 M% Z# P
- {
! N0 {2 q1 [) i- ^7 s1 ^8 {; J - if (irc); e! `4 P5 t- k# T3 R
- {
) E3 [7 L* F3 q, y - char err[133];
0 E' `" q0 w. D g" ^% J - 7 ^. M6 c' u0 r/ H
- UF_get_fail_message(irc, err);. i: ^4 y" y- p0 T5 f0 b5 o
- ECHO("*** ERROR code %d at line %d in %s:\n",
4 B% F1 k) C, l8 I - irc, line, file);
0 {; X, I1 A V% y0 `6 W$ r& W - ECHO("+++ %s\n", err);6 G# M5 x) m$ x( O2 j! {, V) g
- ECHO("%s;\n", call);' P: P! s* T* J3 E
- }
: C$ b: G9 \' n
9 k0 e7 F& J8 |7 c9 W: n- return(irc);
3 c& k- d, n; m4 e; N8 V) O, k! C0 ^ - }# m; {% q( P, u9 }' Q7 k) d6 w9 n
- " ?: f! ?4 A1 j+ M& z0 j" j
- 4 v2 r0 }3 m8 ~8 a7 p, x9 B
- static void do_it(void)
4 ~. W) L8 F1 u/ V9 r% j - {! `& b Q# k- O& W
- Session *theSession = Session::GetSession();
* G# y9 K" g5 b- \- \( ? - Part *workPart(theSession->Parts()->Work());2 Q6 {+ o. s! q; R. u
- Part *displayPart(theSession->Parts()->Display());! S+ P7 ] }7 ~4 g$ n% v2 ]
-
S' W2 w9 ^) x v5 X$ Y - PDM::SessionSettings *sessionSettings1;, m" R4 _0 F/ g6 o/ @( x
- sessionSettings1 = theSession->NewDatabaseSessionOptions();/ E1 m: Y( E3 y. _' K
-
; E5 H* n0 z) t/ G- l - NXString CurrentGroup; U* @2 f7 h* H7 l3 D; I* B
- CurrentGroup = sessionSettings1->Group();
/ {7 m: W |; H. M. z -
( T8 h7 j' P$ r5 g9 T* ` - NXString CurrentRole;# m+ z/ T( B% O2 ]
- CurrentRole = sessionSettings1->Role();/ N' D: }# k, }- Z1 O y
- & T* R5 Z/ j; k) v
- theSession->ListingWindow()->Open();8 W; f3 Q& v! e+ z. s
-
# i7 l; d! _" Y0 z5 k8 Z8 k/ K4 ] - theSession->ListingWindow()->WriteLine("Current Group: ");
" u3 e1 t# r4 h5 \: ]0 s - theSession->ListingWindow()->WriteLine(CurrentGroup);
$ r3 }6 E+ b% {, w& H# ` - % A. \' J. k. ?3 E
- theSession->ListingWindow()->WriteLine("Current Role: ");
" ~: ~& ^; _# @, u' X - theSession->ListingWindow()->WriteLine(CurrentRole);. u2 ~2 \& l* e: P( k
- ( t" w% G. m5 Q0 C
- }
/ V; [* L! ^, W+ H2 u9 u+ W - " O5 N( e/ U3 P) l# R( E; h; k/ N# y6 V
- /*ARGSUSED*/
$ w2 g, e- K& D! Z5 c6 e9 y - void ufusr(char *param, int *retcode, int paramLen): Q6 D# Q* q2 ~" I- o
- {0 p) s5 i, J2 U8 ^1 U
- if (UF_CALL(UF_initialize())) return;$ _7 Z/ B: l1 }+ S* @; t
- do_it();% u1 q. h: u2 B% ~. r7 S
- UF_terminate();
, o5 d2 P) G5 r7 y% w% G4 _ - }
9 k) b) D3 l( Y- o - 6 \$ j. e1 f. O. ^
- int ufusr_ask_unload(void)8 p$ l7 c3 n/ x5 [- a
- {% u- l t1 @( z) f! R
- return (UF_UNLOAD_IMMEDIATELY);& z/ ]. T) S# F* N
- }
4 z- Y' V% D0 J
复制代码 |
|