|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
在集成环境中,NX和Teamcenter的集成中,获取当前用户的组group 和角色 role。2 w d: y" E7 b! U( ~
* C' n/ v1 n) B- ]7 U3 @- #include <stdio.h>
7 l; g0 b1 s1 _6 y; W8 }' _ - #include <string.h>
7 w5 y) ~( Z0 B! o- w7 |( U% A" \ - #include <uf.h>' Y) \6 f0 `2 v4 Q+ w3 D
- #include <uf_ui.h>
. J, p1 [ w% g - 5 g7 H7 g# V3 ]% n
- #include <NXOpen/NXException.hxx>
0 F, t9 B' z6 d: O# l5 [- ] - #include <NXOpen/Session.hxx>$ M* s3 e1 z' r: q
- #include <NXOpen/ListingWindow.hxx>
) |, t) R; ` B9 \& j - #include <NXOpen/LogFile.hxx>
! r; j! X; @: s$ N8 @" n - #include <NXOpen/PDM_SessionSettings.hxx>8 A" ] J0 d' {4 B3 ~# n0 |$ U
- #include <NXOpen/Part.hxx>
( U, D5 @/ N/ _ - #include <NXOpen/ParTCollection.hxx>
: S w# x p' l/ b6 D. X: y5 @7 S - #include <NXOpen/Session.hxx>
1 q5 q; ~8 F' X) t% U - 7 S( o. c) A8 D9 P& N4 ]+ m8 E
- using namespace NXOpen; // <== Very Important!1 k' o, O- D3 I4 V
. _% i4 G" k( {6 P- w: Q, m" u- #include <stdarg.h>$ F, K5 \# S4 [" r
- $ G F. s; ]$ ?' A) Y
- static void ECHO(char *format, ...)8 d' x2 r) X. C5 I% H* c: ^) a( b
- {. r; ^4 _+ d% l0 l, F" X
- char msg[UF_UI_MAX_STRING_LEN+1];
% o% |, @: Z& W - va_list args;! g, \: {0 X7 m! u0 r
- va_start(args, format);
+ ~) y4 C8 r# b& |2 L - vsprintf(msg, format, args);" r$ h/ b' e7 e! y4 D
- va_end(args);3 A; P- U' K: n$ Y: p+ y9 W
- UF_UI_open_listing_window();. @& |' H% Y% L+ q" |) R: J
- UF_UI_write_listing_window(msg);
2 v$ s( O& k5 k M: s0 d* B - UF_print_syslog(msg, FALSE);
' B' [0 C: R1 [! d2 U - }
7 c Q3 t/ d$ B: z, ]& u
6 m; J; o- U) }& D' s- #define UF_CALL(X) (report_error( __FILE__, __LINE__, #X, (X))); B- G9 G! a! p' \. K
; `+ M u8 h# _# j7 e- static int report_error( char *file, int line, char *call, int irc)
) `. I$ e5 f% n% ^" B - {( T1 B1 f$ G' r1 x
- if (irc)
( ?% Y, U5 E5 m1 P# ~, j; e - {
6 s8 `" {2 H$ W - char err[133];8 a! ?0 K! l }
- 9 T( Q6 q' Y( _- y& I0 E
- UF_get_fail_message(irc, err);
% C* G7 o9 L/ l4 e! b - ECHO("*** ERROR code %d at line %d in %s:\n",
: C" ~( R8 e" f! C. V# }; w& C - irc, line, file);$ q( L" t; h* j: c8 e
- ECHO("+++ %s\n", err);, ?: @) V6 u- T; Y k0 U6 h
- ECHO("%s;\n", call);' F3 p- V# g* q& D! f* ]- d
- }
9 ^% G: J4 [8 @- B" r4 G/ Q - : `9 b! \& o, f/ i: a& l5 w7 l% S$ N0 a
- return(irc);
: N% j2 v- N; w$ g* M- | - }# @9 u/ ?. {8 S/ p) i
* V) r R3 ~9 I. j) S% C+ ?- 4 K- ^; [$ r" b9 ^ T# K1 ~0 A
- static void do_it(void)5 [: U0 U. H( d5 f
- {. I, D0 k8 ~6 Q! v% F$ Q
- Session *theSession = Session::GetSession();! V# W0 z% w$ f! T# h
- Part *workPart(theSession->Parts()->Work());
- g% m; M p7 A! X P. O' @& ] - Part *displayPart(theSession->Parts()->Display());
" J7 [& c$ C4 n8 Z - 2 G: o, J$ T3 ~3 F S* n
- PDM::SessionSettings *sessionSettings1;
7 ]2 r" V3 m+ `0 P3 s - sessionSettings1 = theSession->NewDatabaseSessionOptions();
* w, L8 c5 \7 B( B& Y8 E - ) }. C+ Q3 p7 p5 ^
- NXString CurrentGroup;0 s5 v& q# R& h* B4 l% @
- CurrentGroup = sessionSettings1->Group();
7 C: g h' D |1 v, _- [" w2 @! r7 w -
# A1 P5 \1 I4 l `- [ - NXString CurrentRole;
& ~' i6 |. s2 T; ` - CurrentRole = sessionSettings1->Role();! i' L( A1 [+ _" q
4 v( K8 g* [' V9 D5 M- theSession->ListingWindow()->Open();2 Y' y. d3 D9 I3 t
- 8 r/ I" S/ ?% a! `1 P; ~0 M
- theSession->ListingWindow()->WriteLine("Current Group: ");1 \! v+ O! e# c, f) r
- theSession->ListingWindow()->WriteLine(CurrentGroup);2 B3 S3 Q/ _* v. ^6 S& G
-
0 E9 X/ s; T; |0 y - theSession->ListingWindow()->WriteLine("Current Role: ");
$ O- y, F3 J, H8 N `& w - theSession->ListingWindow()->WriteLine(CurrentRole);: l) _) `* w$ S4 p
# ~/ r$ ]; s$ m# u# Y- }# t; K! u% f$ N7 @6 w% s
8 N' y; {7 F+ [! |4 h- /*ARGSUSED*// i2 S! N2 F z$ Q3 V) ~
- void ufusr(char *param, int *retcode, int paramLen)
. B1 c( |& N% T - {' ^ }+ V4 N( ], U j6 V) b$ o
- if (UF_CALL(UF_initialize())) return;$ |7 P7 J q7 l# ~- A
- do_it();
& W2 `7 Q: P# D - UF_terminate();9 t* h% a0 f4 ]2 K
- }
0 q2 U2 w! f9 s" O - 8 P- k0 `& h, H4 T8 {/ r# g& D4 j# y: a
- int ufusr_ask_unload(void)/ Y' [/ n& _, G/ e* a/ A' t7 W' u& ]" d
- {9 |0 ?8 d V0 f% J
- return (UF_UNLOAD_IMMEDIATELY);
5 I4 }+ ?) X& w8 |+ i3 u - }
! H; o6 b! n) @ n' H$ D0 T
复制代码 |
|