|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
在集成环境中,NX和Teamcenter的集成中,获取当前用户的组group 和角色 role。
( X0 [1 h% o4 Y* @" p8 U: r% w8 b% ~* N
0 f9 H6 y1 Y$ B& f0 Q" Z- #include <stdio.h>' f8 e' ?9 H3 y) Z/ A+ j: b
- #include <string.h># @2 z$ Y" X' w5 n
- #include <uf.h>
+ J, F1 c9 L2 x2 `: Q - #include <uf_ui.h>
3 Y, O+ f* [7 ]1 {+ W# I# h) M1 R - 2 h, l! f1 [2 I% C; X. r
- #include <NXOpen/NXException.hxx>
) M c' V. Z5 X9 ?" K - #include <NXOpen/Session.hxx>
* P; x+ l2 |# C. ~+ Z3 } - #include <NXOpen/ListingWindow.hxx>
; }* R* c& ] z D1 z - #include <NXOpen/LogFile.hxx>0 B: g0 E& ^7 q2 R& D, }/ e
- #include <NXOpen/PDM_SessionSettings.hxx>
% E. ? M" |% Y. T5 X8 s } - #include <NXOpen/Part.hxx>: u7 `+ o8 ?& q1 p/ Q5 W
- #include <NXOpen/ParTCollection.hxx>% R9 ?6 _" J* {7 K2 i
- #include <NXOpen/Session.hxx>
. ^; B# H8 I' [% U+ `$ ]) r! I8 b - 2 Z! n% E$ Y1 ]
- using namespace NXOpen; // <== Very Important!
9 C& G; w2 z/ ]2 ~
$ f% J3 O1 o H7 f/ f9 B4 ~& E! `- #include <stdarg.h>
8 e) k" X0 F$ j
. v; ^8 M3 [% U/ q, w% W0 l$ E- static void ECHO(char *format, ...)/ t! c' y, k4 p
- {' T/ q6 p; J3 `5 h' N
- char msg[UF_UI_MAX_STRING_LEN+1];, e0 h' O4 l- J! Y! K5 p
- va_list args;9 p; J* { @* ?% u E8 w+ C0 G
- va_start(args, format);
7 ^8 |! z$ e' s - vsprintf(msg, format, args);
# B0 o/ `+ g9 ?3 s' T - va_end(args);
) {, j R$ F/ A- [' j) O - UF_UI_open_listing_window();( P% u3 h- c0 G
- UF_UI_write_listing_window(msg);; p, t/ @( z% z6 q1 W8 }0 |- N
- UF_print_syslog(msg, FALSE);4 I, B3 {* S% d. ?6 H) A4 ^
- }) J1 T7 I% z3 s- [9 D
- " C+ p1 z; O& B* p
- #define UF_CALL(X) (report_error( __FILE__, __LINE__, #X, (X)))1 ]# D0 D7 K& i& C/ m7 O Y! R
* Y* ]0 g; Z8 O' { }8 L; E" F( Z- static int report_error( char *file, int line, char *call, int irc)0 B7 {5 Y4 g; S- k
- {+ I) _0 q+ k; U& E9 J
- if (irc)
4 \' V( x$ t/ P% k( z4 H# w' N - {: V3 K- s( [3 u4 C, r
- char err[133];2 r7 r8 h: A/ ~, P7 e
6 t+ d& q/ y$ U9 u6 c" k- UF_get_fail_message(irc, err);
0 i% d7 ~# A& a& C5 S: |. ?) u9 R' z - ECHO("*** ERROR code %d at line %d in %s:\n",
! b7 s. h# I1 \. f4 k: _ - irc, line, file);
) K# [5 B/ |+ J8 N; X! q/ `9 ?5 m - ECHO("+++ %s\n", err);% ^" x. {& q/ z7 F3 X0 K
- ECHO("%s;\n", call);
7 Q5 G1 k* P' W3 U5 O4 }+ G4 B* p - }$ u' j8 K2 V$ W" T$ P- M6 A
- & \9 M, C' \ E z5 _" T8 {
- return(irc);
2 V Y: x( q: e4 T" C - }% |$ Z( O7 r, q, s! v5 r
$ P% d9 G/ c# ]+ P1 b
8 ~9 h4 o* U; ~+ {) C* u, U( E- static void do_it(void)
/ ^. x. D U5 z% N6 O1 e - {
' V% \' N; H* g8 M - Session *theSession = Session::GetSession();# k5 }9 C( C$ W, s! h% Z! a8 T7 F
- Part *workPart(theSession->Parts()->Work());6 ]6 Z9 W: ]( M1 M
- Part *displayPart(theSession->Parts()->Display());1 Q; x9 k6 R, d8 `( D
- : R! f6 @; m3 M' T6 f* i/ `7 t" c
- PDM::SessionSettings *sessionSettings1;
) v9 P! K' [3 D6 k- T% G - sessionSettings1 = theSession->NewDatabaseSessionOptions();
o& E7 f1 e3 x( z- S - 6 D7 }( V* C' a1 Q
- NXString CurrentGroup;
9 d; }% `& Q$ A* J, H - CurrentGroup = sessionSettings1->Group(); q$ n$ s4 ?4 s7 m5 a' w
- 0 j6 r2 i! W: ^5 Z0 Q
- NXString CurrentRole;' k) t7 L/ @- y
- CurrentRole = sessionSettings1->Role();
1 u; Y A1 c4 n! }. v3 l* g
5 Q1 z% [9 t' {6 M& m- theSession->ListingWindow()->Open();
- O- U( ~0 Y {. N: x - , H5 U# h' x& \7 _4 c
- theSession->ListingWindow()->WriteLine("Current Group: ");, p7 O: K- k$ N5 L3 W0 J' ]' c$ ?
- theSession->ListingWindow()->WriteLine(CurrentGroup);# |6 P3 M$ j$ @* D- f6 X% T
- 9 ^: T' A( g$ ?: n3 j @+ A
- theSession->ListingWindow()->WriteLine("Current Role: "); 3 U0 J: j$ a! p2 `4 o5 w/ j
- theSession->ListingWindow()->WriteLine(CurrentRole);, P8 z7 s( m3 l! \0 Q& ]- \
/ S5 i W/ W! F# Q: C1 C7 h- } h0 {3 u H3 h; @8 d/ u5 X5 c6 M' ^
1 C1 D# C& Z k: _4 U& y- /*ARGSUSED*/
0 F1 R h' D- Q" O7 X8 i - void ufusr(char *param, int *retcode, int paramLen). C" Q5 i( F- q9 t9 s6 {2 A# Q
- {
1 r. X! K+ A7 n1 h/ g% Y. G- F - if (UF_CALL(UF_initialize())) return;% }5 |+ m; g" E" r, V' W
- do_it();
/ A: v: M9 S; \. X. O7 ]6 ^3 t: f - UF_terminate();
5 `5 e* P4 ^9 E - }
+ N* S: b0 A1 \2 r: L6 ^: Z - # v- C8 F! b2 P. }
- int ufusr_ask_unload(void)
0 j: N, ?: l3 c6 ]7 ]7 K* x4 E, g - {; Q0 Z# [/ H# a: B, K
- return (UF_UNLOAD_IMMEDIATELY);
& m- ]/ @2 L D& x5 n/ A' L - }( u. O! M! M& Z0 {
复制代码 |
|