|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
在集成环境中,NX和Teamcenter的集成中,获取当前用户的组group 和角色 role。
: x. t- N: g) k3 e7 L5 S3 E" a, S2 m2 T8 |' l" N2 G* h+ I
- #include <stdio.h>
( C3 @8 s7 z: S- I- l/ o) E" V - #include <string.h>. C2 c) y5 |$ ]
- #include <uf.h>/ v- H8 O d1 X
- #include <uf_ui.h>% H) m( d9 _5 i X
1 A5 q* N% P& v. Y9 x- D- #include <NXOpen/NXException.hxx>% _' t r% H a. U: y) O( T" j
- #include <NXOpen/Session.hxx>
6 ]9 C9 y" g# f" G3 Z: Y - #include <NXOpen/ListingWindow.hxx>
% L* m+ z' x0 v8 m4 W4 I1 K; [ - #include <NXOpen/LogFile.hxx>. a* i/ j, ?5 M$ O. E4 e Z, U, ]
- #include <NXOpen/PDM_SessionSettings.hxx>4 K7 n- o+ j* n, D+ ~0 t9 ?; V
- #include <NXOpen/Part.hxx>
3 r7 u/ W/ U, q6 Q) r, N - #include <NXOpen/ParTCollection.hxx>, c6 t% j# u0 V+ S7 T% m4 G
- #include <NXOpen/Session.hxx>% b! p0 _1 d i2 E! Q( X
- & X6 k+ a9 u9 B
- using namespace NXOpen; // <== Very Important!
7 D: y' R s: w
$ u' h; ? S# ]) D3 Y9 e- #include <stdarg.h>% h+ E/ t; Z6 t$ E- j ?) Y( \
) P5 j$ t' w ]. v: B- static void ECHO(char *format, ...) k! K$ j+ J( u6 [2 |% S6 @
- {: ]! e* e* v1 q3 A2 {6 C
- char msg[UF_UI_MAX_STRING_LEN+1];) c7 `, u" z$ R) t! B5 S
- va_list args;9 A1 R9 v9 _& W R& j" U7 W% B
- va_start(args, format);3 U7 d- Z; i" `1 }0 Z( m
- vsprintf(msg, format, args);0 }) T; D* k* ~4 g
- va_end(args);' S( h, L; T, ?0 q% p
- UF_UI_open_listing_window();- o; j) o$ n* O' {& \
- UF_UI_write_listing_window(msg);8 R X) Q! E) |5 K, a z
- UF_print_syslog(msg, FALSE);
! [& V Q- i4 G$ G/ O - }4 |) l& }2 _( X1 v# D
- , b# k. _! o! `) {6 q a
- #define UF_CALL(X) (report_error( __FILE__, __LINE__, #X, (X)))
. S2 ^' D2 Y7 ~5 f2 l' M - / z) S& }8 z6 e3 s
- static int report_error( char *file, int line, char *call, int irc)1 \# H2 e1 W2 s* l x# P
- {
1 P8 w! J2 q5 c5 J/ `# l% F - if (irc)
9 H* P- k2 s" _$ Z - {+ Y) J) [4 \! @" ~# L9 }* D! p
- char err[133]; x0 ]) ?' \* a6 N8 S0 o. S. d
- 8 C+ [: i" _; B4 Y6 t7 c1 [4 q
- UF_get_fail_message(irc, err);! t7 N" n* T! f/ L3 N
- ECHO("*** ERROR code %d at line %d in %s:\n",
% o4 J5 A5 { D4 U# y$ h - irc, line, file);
) Z9 Z" P) ]. _ - ECHO("+++ %s\n", err);# q; _; u- x n1 h# [" p
- ECHO("%s;\n", call);: Z2 S2 b4 ~) g1 ? P# b
- }
5 D5 K, Y- [5 z) O, }3 W; u
% w, F! ]( l( K4 o& W! m! h- return(irc);2 R0 P7 U" Z3 B
- }
/ j, m( i8 K1 d
; x+ B" }, x( X! Y1 ?- , s' r9 q. I/ D5 }5 x
- static void do_it(void)
) k6 i2 O( u. p1 n - {
9 @* J5 n# g Z: X2 l+ ^ - Session *theSession = Session::GetSession(); g% v* W; E6 P4 U1 l) I* @
- Part *workPart(theSession->Parts()->Work());
3 P$ v6 l" `5 B) B$ ~/ ^' q; s - Part *displayPart(theSession->Parts()->Display());
' M7 v* N3 m& K. X# h7 ]# ` - & u) ?4 [/ m- i& c+ H; `4 _
- PDM::SessionSettings *sessionSettings1;
! d0 R1 B* i/ A - sessionSettings1 = theSession->NewDatabaseSessionOptions();( k9 x( d% ?, p$ l r9 t
- . b# [( d4 Y- E4 G' U/ x9 v+ |
- NXString CurrentGroup;" `3 ]- P/ _' ~
- CurrentGroup = sessionSettings1->Group();
9 s) L2 w9 Y5 i! I; u# v -
% a0 R, [( N! C: e2 W$ w7 W$ \3 N4 B - NXString CurrentRole;3 h0 T3 x# Z5 h& Y
- CurrentRole = sessionSettings1->Role();# Z" W1 n1 F5 {; T i) m) t
- ) W4 V% Q7 M& S3 O, U/ Z1 e
- theSession->ListingWindow()->Open();, X9 e( O9 j& {& E: f
- : J( ?7 x0 }/ }3 D% S z
- theSession->ListingWindow()->WriteLine("Current Group: ");# Z/ _$ ~9 X* x7 h" ]
- theSession->ListingWindow()->WriteLine(CurrentGroup);
5 s1 A+ M( j3 |, [1 i& C! b - 6 w( W4 i9 \" C- H( `( t; P B
- theSession->ListingWindow()->WriteLine("Current Role: "); ) p$ R" E- d" W4 D2 f$ U
- theSession->ListingWindow()->WriteLine(CurrentRole);) q# W3 q7 I* i! e
) r, Q$ V- J$ ^2 k4 p- }
- S: j6 s8 Z$ l6 g - , j" Z3 N& H# e7 n' y7 E
- /*ARGSUSED*/
, t; R* e7 t) r5 ]/ R - void ufusr(char *param, int *retcode, int paramLen)2 O" `, J% J. M! w2 V
- {( `& |4 X# u# M8 P% T& N8 }) ~
- if (UF_CALL(UF_initialize())) return;1 V, E: m3 b8 K
- do_it();
! o& h. G+ i/ Z7 \6 m: v6 [6 ]5 z" F - UF_terminate();
% d4 e/ ?1 h y* v3 o4 e - }
# h* O3 b2 B4 e; ~. R! ^
1 i+ x6 X% F/ @% a$ x* }- int ufusr_ask_unload(void)8 c# I" q- q2 F% D, Y' J0 D1 ^
- {
# \3 k# {1 a8 ] x( f o+ s# k - return (UF_UNLOAD_IMMEDIATELY);
; B$ R5 v" k' o - }5 W5 V. B/ [ H' `
复制代码 |
|