|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
在集成环境中,NX和Teamcenter的集成中,获取当前用户的组group 和角色 role。# r+ d! K w, V* D" M$ m( q: p/ R
2 K; p, I& K$ D/ S5 e1 J! H& D
- #include <stdio.h>/ h# f- S* w7 |- B0 A* C; [
- #include <string.h>/ z$ S6 s' f" i) o
- #include <uf.h>
& @6 P; w$ _5 H4 _ - #include <uf_ui.h>
0 @" V8 z( H0 k9 ?+ p! I2 T Q* {
# c# @% ?8 ~! y' n, S- #include <NXOpen/NXException.hxx>$ \( d5 O$ [ S+ |) }6 \: w. @
- #include <NXOpen/Session.hxx>7 s( m3 b9 q8 E# M6 O3 r3 ]
- #include <NXOpen/ListingWindow.hxx>2 N5 b: D% H7 j) S- w
- #include <NXOpen/LogFile.hxx>( E5 {9 I& ]0 y- Q: }# V
- #include <NXOpen/PDM_SessionSettings.hxx>
u0 {: l4 N2 S2 E! ], s( u/ d7 x; o" T - #include <NXOpen/Part.hxx>. B) c) o! A" c$ e
- #include <NXOpen/ParTCollection.hxx>; r; A2 p/ d! G! B
- #include <NXOpen/Session.hxx>% S* g9 w; f% D9 h; W2 e; P
- % ~6 T1 t3 v, r' [* k
- using namespace NXOpen; // <== Very Important!& t' M) H `* f+ D: u
+ P' ~) y1 I* C- @- #include <stdarg.h>
! L; c) B9 m( N% `, l6 O
; c% w$ t4 \6 s" j8 a" x. }- static void ECHO(char *format, ...)2 |4 J* e0 e, P3 b8 R e# B
- {
+ |! h8 u& [7 z% z - char msg[UF_UI_MAX_STRING_LEN+1];
2 [% q" ]6 L3 T2 A% B - va_list args;' L& T6 R7 P. b3 D6 R& F8 A5 ]
- va_start(args, format);
0 D6 ?0 k( v- S6 B - vsprintf(msg, format, args);0 t) M" w1 G5 M) j: W9 J m9 o0 t) b
- va_end(args);( K, i8 h9 h; B( w, F# o5 [7 F; K
- UF_UI_open_listing_window();
2 K$ b5 h v0 n7 a0 C+ x5 g: | - UF_UI_write_listing_window(msg);
* }5 f: a& d2 v& n5 d* B) A - UF_print_syslog(msg, FALSE);
r+ K" R7 A+ k - }8 v: s0 H0 c8 ~5 ]3 q8 U+ h
- ' B6 G7 d- D2 V! f$ x4 o. h& v
- #define UF_CALL(X) (report_error( __FILE__, __LINE__, #X, (X)))
* G; y- q7 w* l
$ `) u9 S+ Q7 _6 X4 V0 c/ Z, X$ ~$ w- static int report_error( char *file, int line, char *call, int irc) e) w' f. R# ^3 [9 }
- {- D! \2 @$ t, s" N" F! F. p) q
- if (irc)8 D7 u0 g7 j2 ^+ ]: v: p* C
- {, s" G7 n& N, `2 T, _
- char err[133];
* T [* x( f b' x, ^1 p
, o3 I7 W4 {$ m( u5 L5 {! ~- UF_get_fail_message(irc, err);
! ^2 d. t- \5 X( e. ~# F - ECHO("*** ERROR code %d at line %d in %s:\n",+ c9 @+ P- R# B- z. X! b; ~
- irc, line, file);
& o$ S7 w! U9 E2 T/ Z7 } - ECHO("+++ %s\n", err);
5 V! {4 |7 Z! C+ p1 R: x { - ECHO("%s;\n", call);
+ t M7 F; y8 ?2 L9 D - }
" c* l6 u+ Y( U! v( y. {, f
" o1 N$ C6 H( _3 |! T6 v/ f- return(irc);
" L# S7 U0 @& D. L0 e* t - }
0 B& s2 ^ J: Y3 Z. a$ s" l) ? - ; E4 @% P+ E1 ?. [7 O0 Q8 B
- ( P; T+ z8 z- z7 R
- static void do_it(void)
! S5 i: t" k) K! A* {/ ` - {
; x/ c8 V, q* z+ N3 M- t, y( A - Session *theSession = Session::GetSession();
0 F8 w% w! Q' D - Part *workPart(theSession->Parts()->Work());
+ ~: ^' K7 u. ?, p1 q6 [2 ~. j2 O - Part *displayPart(theSession->Parts()->Display());$ _4 p& ?: h2 l6 l) _
- / _* F& @! I4 V* d
- PDM::SessionSettings *sessionSettings1;
; D2 c b' ?: h1 P& r8 ~ - sessionSettings1 = theSession->NewDatabaseSessionOptions();" h7 V: l- f/ @* @2 k
- ; y, {8 v- w- ]- E! w2 f7 q( }
- NXString CurrentGroup;% _2 B; f& A3 @" }( v( H3 R2 ]
- CurrentGroup = sessionSettings1->Group();
& k( z; b6 Q1 E1 H - 2 Y' W* u5 N. m7 E0 j" u6 _' \
- NXString CurrentRole;
4 R9 R- v% u* [( H& G! B! `6 }" | Y - CurrentRole = sessionSettings1->Role();" M F, R& { N2 S9 _
, r! }9 s; Q5 N7 o- theSession->ListingWindow()->Open(); I4 G9 ~% R: g$ Q( d
- # u8 @" s$ L0 P" L; w
- theSession->ListingWindow()->WriteLine("Current Group: ");
& T+ \" k- o J+ `8 S6 z - theSession->ListingWindow()->WriteLine(CurrentGroup);: m7 p$ @' J/ u8 @4 i4 d% F
-
, m5 A0 W: f: k2 { - theSession->ListingWindow()->WriteLine("Current Role: "); 4 H3 _; h% W' {6 l, |
- theSession->ListingWindow()->WriteLine(CurrentRole);+ s }1 g. ?% ^
- 8 N8 h/ K# t' d l# _/ _. u
- }0 X2 m/ g) J0 c2 Z2 V" U1 b0 q+ I, e' H' |
- 6 x/ @6 O% @9 V9 a% c A/ G
- /*ARGSUSED*/
3 E2 W6 m( L9 S& @ W! d" c - void ufusr(char *param, int *retcode, int paramLen)( y2 ?6 `8 ~ _$ L/ @& {! ?/ _6 P
- {
' o7 H1 R E9 z) A6 b u - if (UF_CALL(UF_initialize())) return;2 z) f) m2 v8 n/ p9 l1 Y
- do_it();! [* `$ M- l5 u* R0 n
- UF_terminate();
7 }3 f, R( U5 F. V - }$ a* E" Z J; i, \+ c5 X: C
- ! I* Z. q- J* V* [
- int ufusr_ask_unload(void)% G) O$ y& t8 U5 y7 t' Y
- {
' W5 e0 _3 n1 t" u0 m; @) r - return (UF_UNLOAD_IMMEDIATELY);0 r4 x* m! f3 ]) b7 ]. Y3 u/ A' Q9 e* t
- }
. [4 _4 W3 m( T
复制代码 |
|