|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
在集成环境中,NX和Teamcenter的集成中,获取当前用户的组group 和角色 role。
2 u2 k: ?! Y) t- w
0 ]; y# Y& K: E/ j2 |4 H- #include <stdio.h>
4 N5 R& x+ S9 q* V2 j - #include <string.h>
; H( ]2 V: C. ]. N7 F, V/ L - #include <uf.h>
' V7 R( o$ V/ U! ?4 }! B2 r - #include <uf_ui.h>
0 Y [ W9 X' w4 l+ d( s
# q% _! G9 s9 M' ]) d6 g- #include <NXOpen/NXException.hxx>
0 t* t' a/ `, ^ S" V. S - #include <NXOpen/Session.hxx>
3 _0 r& a: y. N+ V+ W* E4 n - #include <NXOpen/ListingWindow.hxx>* Y. [6 r4 S0 f; r
- #include <NXOpen/LogFile.hxx>9 _ R) n- o- V7 L+ l7 `
- #include <NXOpen/PDM_SessionSettings.hxx>- X. l7 O8 |4 H$ c/ G% c
- #include <NXOpen/Part.hxx>
% N( R! f# S/ h! i2 j - #include <NXOpen/ParTCollection.hxx>0 C; Q! l0 p( r/ V
- #include <NXOpen/Session.hxx>
- r7 j( d0 U Q' x% a& v4 T e F
# D! |3 l2 L( ~( A- using namespace NXOpen; // <== Very Important!
- s0 d+ x7 W6 F# A( b1 k$ s
/ A; C) y; G- ?: z Q. O- #include <stdarg.h>, T7 k5 U& k! S8 t
- 2 X0 v; Z/ r! d5 k2 K9 \( `
- static void ECHO(char *format, ...); Y; ]- ^3 ?: N5 g2 L6 L
- {& q' W" X- V+ Z- D7 D
- char msg[UF_UI_MAX_STRING_LEN+1];
v* @4 w. Q. {& q+ q0 u - va_list args;
& x9 o3 o, @- L - va_start(args, format);
! `% i+ D# u6 |" ?+ o' O - vsprintf(msg, format, args);8 j6 _7 N" L- m( g Z/ E
- va_end(args);* q% a9 G# |# C" Q' g
- UF_UI_open_listing_window();8 c/ r' p" W7 Y/ o& R% m
- UF_UI_write_listing_window(msg);& i$ b, H/ Q1 X3 m f
- UF_print_syslog(msg, FALSE);1 m7 {! B' i m5 {+ i* E
- }
$ |) q- [6 P; O) H& r
0 m; }4 p# S8 d/ O7 r( b. s- #define UF_CALL(X) (report_error( __FILE__, __LINE__, #X, (X)))! m$ D3 L/ m$ u) i# G' W
% a8 f5 W! e F( U$ c- static int report_error( char *file, int line, char *call, int irc): W4 U( `" z9 q# y( q6 e
- {
! {7 |9 t1 s7 W( k; i4 T, l( e& u - if (irc)0 k+ u1 c# @: q7 C
- {0 @8 Y! h+ M/ i8 S# q" B: V0 K
- char err[133];
! l/ I# i9 |: m' G6 N) g9 j
& ^7 c: f( M V! e. W( I3 v- UF_get_fail_message(irc, err);
; @& u8 t- s- ` D( x: ? - ECHO("*** ERROR code %d at line %d in %s:\n",* K3 }4 i w9 M& m0 W! B$ g
- irc, line, file);
/ y( ~6 Y3 j0 h4 y, }9 n1 u - ECHO("+++ %s\n", err);
0 P! W. C: |0 f0 ]+ Q* J - ECHO("%s;\n", call);, W9 U3 M0 k9 S; Y1 E; J
- }) ~7 O+ j. L, i1 Y4 z
) q) o/ S! ]$ \& B- return(irc);
3 `* P) w G8 R* u5 c0 m1 G) D - }; D5 d+ X4 G }( M/ q8 S
, N6 B) M- C0 ^) ]9 J/ b; S
# U8 Z! s1 J; m, r& v$ u1 o. Z- static void do_it(void)/ r `% L$ i* D% g& t
- {( l o! O' }9 O& U4 B! f0 x
- Session *theSession = Session::GetSession();
2 p! ]. m: x# \* l" D6 R - Part *workPart(theSession->Parts()->Work());3 u' b: W8 A2 O9 \
- Part *displayPart(theSession->Parts()->Display());
( e, K' {* T: m' ]3 e; Q8 \ -
& w; Z' ]; |; H' V8 n0 k - PDM::SessionSettings *sessionSettings1;- B0 G H, W! N2 T& ^' \
- sessionSettings1 = theSession->NewDatabaseSessionOptions();
7 Q; n1 y% o6 ~6 _) j3 a" u# b -
$ A( i! D0 q. G! B6 C - NXString CurrentGroup;$ K( N/ t1 d) a( {
- CurrentGroup = sessionSettings1->Group();
# x8 V. d& X0 F; Z -
5 t0 R0 u X, ~9 K - NXString CurrentRole;- _: y3 j7 r4 o
- CurrentRole = sessionSettings1->Role();, Z- J8 o' I3 Q& |4 E
- ) m& @8 ~5 H7 N6 C& o& h
- theSession->ListingWindow()->Open();
1 g3 X9 _& a- [* Y - 7 f8 c" c* B1 k+ j8 p" U; d
- theSession->ListingWindow()->WriteLine("Current Group: ");( R: Q8 Y* T) N3 g) O
- theSession->ListingWindow()->WriteLine(CurrentGroup);1 G2 N# _6 K$ u6 J* X {
-
) A/ k: l2 P+ Y; n6 o - theSession->ListingWindow()->WriteLine("Current Role: "); 9 y- H- V1 F) e' n2 ]3 A/ q' z" u
- theSession->ListingWindow()->WriteLine(CurrentRole);6 ?) Q: P( o" X5 j* @! {' e$ j
- 4 h% n- [8 _: K; i' j" |# S
- }8 M) P+ f' @ z( p' W
- , _' K6 m8 Z5 k9 a; R
- /*ARGSUSED*/- n. l6 E/ U# b! y; b' z% s; S0 r( Q
- void ufusr(char *param, int *retcode, int paramLen)
9 p1 y3 m8 H: m; w6 K+ N/ g0 D - {4 h! i3 B- l0 A2 d
- if (UF_CALL(UF_initialize())) return;
- `+ Q; U. ]" [2 Y& ^ | - do_it();# {/ s5 `' h" a, e( o) j# f
- UF_terminate();
; P# e l' K* j6 V; P! d - }
4 @# a' ~* {9 t7 K - - M2 b% E# I3 e6 P9 P4 _
- int ufusr_ask_unload(void)
' V2 Q0 m- z% p: q; Z - {: ?! |6 v8 k1 f: [" A; L
- return (UF_UNLOAD_IMMEDIATELY);6 e' v' X# ]4 s0 q6 m" a
- }) M' S" }% w! f6 t
复制代码 |
|