|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
在集成环境中,NX和Teamcenter的集成中,获取当前用户的组group 和角色 role。, O/ Y0 ~+ e) W4 q) T
+ _1 }* I0 C- Z' K6 U5 S+ s8 p- #include <stdio.h>
! L4 M) K* o+ Q4 K - #include <string.h>
0 T5 K1 ?- h( g( r7 v - #include <uf.h>7 q J1 e/ t( _4 L/ M* Z
- #include <uf_ui.h>
3 L! u, k! j6 J. [ - 9 r1 C y5 b; S( ^- q
- #include <NXOpen/NXException.hxx>
" J; G2 T, ]/ M1 Q - #include <NXOpen/Session.hxx>
6 L3 j, t; P, C) E& j5 t- s - #include <NXOpen/ListingWindow.hxx>
" P% F7 a z2 w, \. T `( _% _ - #include <NXOpen/LogFile.hxx>4 X/ i r0 m9 W, O5 A6 P0 Q6 U
- #include <NXOpen/PDM_SessionSettings.hxx># ~4 x k/ I" ^. h8 p. a
- #include <NXOpen/Part.hxx>
6 u- t6 x4 _1 y5 t - #include <NXOpen/ParTCollection.hxx>
8 f9 C: | Y1 K$ _) T$ S - #include <NXOpen/Session.hxx>$ C- n; _! a2 R) {# Q* F
- $ @6 ^8 f& W3 a! G' f
- using namespace NXOpen; // <== Very Important!; w# J$ M9 m0 @" O% G
" z: b0 M1 f1 i- #include <stdarg.h>
# D1 K3 K8 m" m; M% f - & s) V7 u) @* R6 G
- static void ECHO(char *format, ...)
/ G9 `0 C# e( o8 V8 Y - {) s( E# M, f3 P+ W* r
- char msg[UF_UI_MAX_STRING_LEN+1];( D/ C D! A& U
- va_list args;" h8 S5 q) W1 r
- va_start(args, format);4 W2 ~( u7 J4 w; Z0 ?% l: i
- vsprintf(msg, format, args);
8 E& ~8 x+ y2 Z/ A- I! n - va_end(args);
$ N# F3 \$ u0 ]7 u4 D4 B- Z) x - UF_UI_open_listing_window();
# a( i* D# Y9 ~. c: i) H - UF_UI_write_listing_window(msg);# p' n: |$ j- X) j
- UF_print_syslog(msg, FALSE);1 S8 i9 y B5 C2 A! `
- }
; O2 P8 d* Q3 Q1 @& R9 A - * _& c/ ]) ^' l# z+ z. K
- #define UF_CALL(X) (report_error( __FILE__, __LINE__, #X, (X)))8 L* ^( \( ]) c3 A$ x; ^2 B j
3 ?* g* n% U9 W! x/ P- static int report_error( char *file, int line, char *call, int irc)
1 j5 B, S$ Q( J2 J6 m - {
0 S0 x9 U8 |) S1 k: l. d! I6 p. p5 M - if (irc)
$ V- Z) z% P; y' e2 Y% u - {2 H5 [; Q: l. c+ T
- char err[133];
8 \# V( _1 M( k( y X - 8 _5 S: G9 I$ b% [+ k6 M D7 p
- UF_get_fail_message(irc, err);; R+ h: r0 t, V: O4 k- [5 {) T
- ECHO("*** ERROR code %d at line %d in %s:\n",
5 C$ }- C. |7 k5 r j - irc, line, file);
' `! f4 N- y# i, o3 F3 m4 a& R - ECHO("+++ %s\n", err);' y2 _8 a$ w! J$ a
- ECHO("%s;\n", call);5 E# I' W2 z3 R8 R/ l" ~. d2 @" R
- }
0 ?0 Y8 w) F$ ]; b m5 r2 x, S# W
8 x, X3 c) J6 J `" }2 S5 Z- return(irc);, \: j5 r, r& ^7 P, b3 X6 S8 S
- }2 l2 w9 r" W/ k0 b* f& j
) d' o" h: u9 I6 A. ]
# {/ e3 J. n, h6 ]/ |- static void do_it(void)$ G: s A+ v& V9 X, w, E
- {
5 I1 [6 H) K# k7 k - Session *theSession = Session::GetSession();
7 D- F: t0 V. q" d! a3 d u, @) j - Part *workPart(theSession->Parts()->Work());
3 _$ J; V5 ]9 ^% E5 }) ^3 u - Part *displayPart(theSession->Parts()->Display());
8 R" L7 y' v5 D. K - 1 P' P. {7 O- n$ l# k
- PDM::SessionSettings *sessionSettings1; r4 F) D4 `' l/ _3 o+ g5 b
- sessionSettings1 = theSession->NewDatabaseSessionOptions();. j9 a2 a; [; C9 Z' C3 h: j' f6 U
- ( G( X7 h0 k5 Y2 H2 M, ?& F4 h9 f
- NXString CurrentGroup;) \5 h" b/ C$ d0 ~, s2 b3 t
- CurrentGroup = sessionSettings1->Group(); [6 R) S1 \. a0 _+ j+ H+ ]
-
# v3 ^! p, P8 T/ J - NXString CurrentRole; B5 i, a2 _" H3 b
- CurrentRole = sessionSettings1->Role();) K" a" o1 F5 h& ^, L
- ; d0 C1 l& k# @ a& N
- theSession->ListingWindow()->Open();- B2 Z9 u @# Y) ~
-
( @1 f! J5 U: R+ Y' u# @ - theSession->ListingWindow()->WriteLine("Current Group: ");
, _3 o0 Q4 E3 L$ V) S1 [5 W$ u - theSession->ListingWindow()->WriteLine(CurrentGroup);- R1 B8 j$ h7 E0 f3 _
- ) [! ~ l+ t% f/ ]! k/ O/ D
- theSession->ListingWindow()->WriteLine("Current Role: ");
+ K5 [+ M7 a# P7 a. @# z2 v - theSession->ListingWindow()->WriteLine(CurrentRole);! l5 _/ T( E/ ]/ P1 Y) T
7 a0 q" ]; v4 |! G; o- E& P- }
, d3 K. V% H' n' W
! h/ o9 V- S) g8 D m3 s- /*ARGSUSED*/
# J G% v# t; a( s- X - void ufusr(char *param, int *retcode, int paramLen)) g. y+ }' c/ [% w4 H& p
- {5 h2 Q) U; x, X
- if (UF_CALL(UF_initialize())) return;
8 X1 g. Z. i2 o$ ^: i - do_it();0 W l& M7 _! L5 k- E+ Y8 U
- UF_terminate();
( ]' N3 C* c0 r) J& G - }# g1 @. L1 r( w, h3 E$ l& g
" C. K, f( q, h0 _- int ufusr_ask_unload(void); i y* F% }; P! e) h
- { L3 X7 z2 g) _2 I6 W& h0 ` N
- return (UF_UNLOAD_IMMEDIATELY);& Q" A7 u3 F2 E* L
- }
0 r% ?- x2 j& v- k. a5 T5 i/ f" Q( R
复制代码 |
|