|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
在集成环境中,NX和Teamcenter的集成中,获取当前用户的组group 和角色 role。1 I' H* t# t# Z. n' U
' H# k" M# _0 m" T- #include <stdio.h>: @6 l. S1 F9 L( u
- #include <string.h>
) j$ ~- Q/ f. o b9 b+ C' |$ T6 _ - #include <uf.h>1 Z1 `! n9 k# m9 m& [6 i3 x4 G
- #include <uf_ui.h>
& l" K4 b; @4 @4 X9 _9 A% L( w- A - e/ x9 B% Y2 e2 d. m+ D3 \$ Q
- #include <NXOpen/NXException.hxx>% a* F4 L/ i! i/ ]$ I5 y: u
- #include <NXOpen/Session.hxx> `5 ~9 n: s$ V; a; T6 U
- #include <NXOpen/ListingWindow.hxx>
/ y& M' s. @3 Z A4 y k3 H - #include <NXOpen/LogFile.hxx>
5 f5 p$ z: z1 D. \& W2 B - #include <NXOpen/PDM_SessionSettings.hxx>
% G; R! h o- e% B - #include <NXOpen/Part.hxx>
1 S" i/ f5 \8 r1 X - #include <NXOpen/ParTCollection.hxx>
& l9 [, V# ~+ R$ u - #include <NXOpen/Session.hxx>6 E; w* }5 c* u9 |3 H ]" }+ C; ]
. P, \9 _: G8 {3 Z8 M- using namespace NXOpen; // <== Very Important!
5 x4 N/ K3 b6 ^- D - - H0 {; y* z* n7 `2 j
- #include <stdarg.h>. R/ m- p q' Z/ ~; e7 T
- / ]/ B2 o. h! @. g
- static void ECHO(char *format, ...)
( S+ i j& I3 m5 p2 X - {
5 L$ e- l h( H* W/ H4 j - char msg[UF_UI_MAX_STRING_LEN+1];
# b$ Q/ ?5 { a7 @) T - va_list args;3 K; u$ A# Z1 w3 b# a
- va_start(args, format);
8 n6 Y0 u: c1 a, ?. c( L( J/ y - vsprintf(msg, format, args);
5 b$ Q/ h- w0 Z* }9 S6 P - va_end(args);3 F9 P5 _6 i& `; E! @. i
- UF_UI_open_listing_window();
; J+ J! Y" F6 [ - UF_UI_write_listing_window(msg);" a; m- f8 |7 I8 w# r! ?2 T- T
- UF_print_syslog(msg, FALSE);, q# |$ _* W+ l7 p! z( D
- }. D) Y4 E) {3 g) _8 m. m5 d7 ~' q
- % `: ]6 c y/ P# B9 ^9 k
- #define UF_CALL(X) (report_error( __FILE__, __LINE__, #X, (X)))
2 N) ?, G8 r, X! D; G2 M - 4 ]+ f5 S2 W' q& j! ?
- static int report_error( char *file, int line, char *call, int irc)
4 Q7 a( K/ }' U+ x* C - {8 y4 {) @/ q. f
- if (irc)6 j9 Z5 H* L7 a2 g: N
- {) n% t+ s$ H1 ~" e+ D1 T4 q5 W4 c
- char err[133];
1 K2 Q1 }4 o. y- @ - * N8 x$ |: T& I# n
- UF_get_fail_message(irc, err);3 k2 z5 }8 b; R- E7 ]
- ECHO("*** ERROR code %d at line %d in %s:\n",; ~" }* H4 I0 @# e" ?, d! g% K$ V
- irc, line, file);. k) K7 `9 C) ^9 f* K7 R
- ECHO("+++ %s\n", err);. C; `+ }. X/ W" Q
- ECHO("%s;\n", call); v/ U7 o3 s" k+ s
- }" R$ p4 S" v; y: b |" M* p5 G
0 F/ E2 _& `$ \6 x/ l6 O j- return(irc);' _' ~0 K3 O6 x
- }
. b* K/ D& @$ Q* F4 T. N+ }7 r
; x7 ^1 ?$ W0 z) k: O) N$ B- 6 g( `7 z+ p- J; |8 e- U" [
- static void do_it(void)
8 E8 D# C) u% B- T7 I u - {
! s& [- z2 H, s - Session *theSession = Session::GetSession();
9 m0 x$ }3 F8 b- w. e- D1 w - Part *workPart(theSession->Parts()->Work()); E( M6 E& n) ?( |
- Part *displayPart(theSession->Parts()->Display());- X* j+ ]& M3 O; y6 \; e" p# D
-
" @% W' d6 ~. l+ A8 { - PDM::SessionSettings *sessionSettings1;
# \: o. a6 \- S w1 a8 \9 o - sessionSettings1 = theSession->NewDatabaseSessionOptions();/ D' y: K/ f* _1 l/ E# |
-
0 q* k0 D1 i7 T; e8 Q1 V - NXString CurrentGroup;9 k1 F8 d6 _& A
- CurrentGroup = sessionSettings1->Group();
- H7 b6 _4 `+ @4 U+ a4 [ -
3 o! c) E. A; V: W& @& C - NXString CurrentRole;
, h9 L. Z/ ~7 `% k% B" w9 P - CurrentRole = sessionSettings1->Role();
1 c( C% G8 ~6 ?; Y- ~8 u6 [ - 0 l" }. N" Q' ^; J2 R
- theSession->ListingWindow()->Open();+ T6 V! x3 P% y- _& Y, ~# ]* C
- 4 A; h' K( V8 |9 U3 b: r. R$ d
- theSession->ListingWindow()->WriteLine("Current Group: ");4 D+ ^4 Q1 N9 y. @# s. ~/ v/ _
- theSession->ListingWindow()->WriteLine(CurrentGroup);! [; b2 V% i$ X2 f# H
- ! o( F, [& d( L7 H) L6 m3 S j
- theSession->ListingWindow()->WriteLine("Current Role: "); 1 s0 e' f! D7 Q
- theSession->ListingWindow()->WriteLine(CurrentRole);' y; s+ a, [% a$ n" r B% S F
7 u$ _7 E% Y" a( C- }
1 I: F0 `3 S0 m
- R! N( k3 u) j5 Y) n; ^4 ?- /*ARGSUSED*/
* C$ {9 P9 _& C+ o9 h6 ^& p) u - void ufusr(char *param, int *retcode, int paramLen)) i$ {- E( k- Q6 C2 M
- {5 S' k, ]0 ~( ~, h y: h
- if (UF_CALL(UF_initialize())) return;; i$ N% n3 d8 b. A3 `: U+ q
- do_it();
! K" X* I* k: X$ _ - UF_terminate();/ \ W7 h8 m" o4 E% L. l" q
- }
9 ~+ x1 X2 t% f3 u! F7 c6 R; O
/ }$ q: b. w% X6 J. V( u7 P: J- int ufusr_ask_unload(void)
+ U; W' J! p/ R: b) H) `8 w - {6 R, E5 r V3 x9 C
- return (UF_UNLOAD_IMMEDIATELY); e% q- b7 I3 k( ], s
- }" J$ O ?" {/ B# o& ^
复制代码 |
|