|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
在集成环境中,NX和Teamcenter的集成中,获取当前用户的组group 和角色 role。
' C0 L _1 C3 O$ H* t2 d# F- T
4 j ~! E4 J: A8 p: x! R! l- #include <stdio.h>
( T7 `% m! `! R! B - #include <string.h>
1 B1 Q/ b. Y2 c, K7 ~8 H; } @ - #include <uf.h>; f% Q' A; `; {: S
- #include <uf_ui.h>
& P7 m3 [% N- b# j+ W
9 S3 R% L& m! s' Y: N2 K" H4 r- #include <NXOpen/NXException.hxx>+ d* M2 E+ I4 p7 m8 m8 |3 \
- #include <NXOpen/Session.hxx>4 O* t$ e& ?8 ~- ~
- #include <NXOpen/ListingWindow.hxx>) K' T" h8 h& r/ E5 D
- #include <NXOpen/LogFile.hxx>
5 n7 q2 M. K# f! v; p& K - #include <NXOpen/PDM_SessionSettings.hxx>
; A0 `8 \- T5 h! Q- ` - #include <NXOpen/Part.hxx>( w6 i7 G3 Q( S' s0 Z2 F2 P
- #include <NXOpen/ParTCollection.hxx>" j: k! d9 e0 I, e9 x& p
- #include <NXOpen/Session.hxx>8 y4 z. b4 W* x: I8 C; i* I3 l, k( Q& H
- 6 [8 k9 f) K) [3 T7 h
- using namespace NXOpen; // <== Very Important!* [* j! ?/ Z9 n, L8 @" Z( ?5 A
6 V% v% Y- C- y# m! d9 s9 E- #include <stdarg.h>
% q) }+ L4 R& v5 w/ s5 w6 y - + s9 e: }, \& p7 ~2 X% R$ A& a
- static void ECHO(char *format, ...)
5 p1 V( b- |# E" M5 ^7 V1 e c0 c - {
( }# U2 ~) w& e1 h+ U- Y* x' J9 j - char msg[UF_UI_MAX_STRING_LEN+1];
@1 V9 ^, J0 Q b - va_list args;
' `/ j& t; e! N - va_start(args, format);
N% w# c; }; j7 ?' e1 k: q - vsprintf(msg, format, args);' q: @$ f4 g' @; o4 f1 E+ A
- va_end(args);
/ Y: p8 \. _0 ]" T$ P. I - UF_UI_open_listing_window(); z" }6 j y) K
- UF_UI_write_listing_window(msg);! I& z* t0 p9 p7 r) X
- UF_print_syslog(msg, FALSE);
8 U2 g$ d1 i* j# | L - }
0 ~8 n4 ^: [0 g1 X - 2 N! q- c9 D- J
- #define UF_CALL(X) (report_error( __FILE__, __LINE__, #X, (X)))
6 u/ q# w, I, A. k - ' d- [% E0 s2 e# j: Z
- static int report_error( char *file, int line, char *call, int irc)% s6 [' z9 \$ a, x3 x; c
- {
! R, @# D* k8 f6 i4 E; o2 H/ X' E* h5 J - if (irc)& D$ J6 f) d. n& Z6 @' j5 Q
- {
) }1 U% P% P8 p8 s - char err[133];3 f9 b0 T/ V4 {- _
& X4 A( {5 y( |# o- UF_get_fail_message(irc, err);
3 Q, t& U6 z6 E7 ] d" _* O - ECHO("*** ERROR code %d at line %d in %s:\n",/ a! q( l! n; l2 y3 u! h
- irc, line, file);
" r+ V# \7 x5 \& S( w) z' u - ECHO("+++ %s\n", err);
) e. m9 l" B* ?/ ?$ G# F - ECHO("%s;\n", call);. } O) }. y8 o3 P- }* }
- }' i2 {, B7 [9 `
- . w6 m* h I! T0 L3 E u$ N
- return(irc); F# l- B Y+ r8 t5 p$ v7 ?
- }
8 }% c# w% ^3 W. x7 z* p - c4 L [% l' l
; r8 T( @- ^# T$ J* p7 E- static void do_it(void)
- l5 l# {5 O4 k7 t - {) K- J/ H0 r0 _
- Session *theSession = Session::GetSession();
4 z; j! o3 Z$ V - Part *workPart(theSession->Parts()->Work());
1 k0 F4 S9 c( p8 v3 w' V - Part *displayPart(theSession->Parts()->Display());9 k$ P4 o+ c4 I
- ' I* s% |% e. _9 n
- PDM::SessionSettings *sessionSettings1;
' T7 B8 x% a% b1 g; N; [( ~ - sessionSettings1 = theSession->NewDatabaseSessionOptions();) T4 N4 R3 p0 H0 [
-
U5 t' K& `* L0 t" d6 c7 I! h6 j - NXString CurrentGroup;
1 R# B; Z8 C7 e9 H2 u& [) }( C7 k - CurrentGroup = sessionSettings1->Group();
1 U* T3 K% k# w4 m$ Q4 Z, r- G - ; p u: W: ^5 w% b$ L
- NXString CurrentRole;
+ Q. i y3 D6 E5 u) }: G" W - CurrentRole = sessionSettings1->Role();, l6 u% N* k3 U H" u0 Q
- I; b% E0 j7 W. W# \' [
- theSession->ListingWindow()->Open();. R& K+ `4 Y: X- m/ B
-
r" t1 U' j1 Q0 | - theSession->ListingWindow()->WriteLine("Current Group: ");
1 _" Z# e7 E3 B% \# i - theSession->ListingWindow()->WriteLine(CurrentGroup);. c9 }9 h- f% R3 o5 I8 T1 e
- # w$ Q% ]4 [3 Z4 ?! `
- theSession->ListingWindow()->WriteLine("Current Role: ");
4 Z% P1 q. i9 z - theSession->ListingWindow()->WriteLine(CurrentRole);; j' K4 M, n9 y+ S2 F1 J
- a/ d( {' H/ ]9 X
- }
5 Z/ F* ~+ a# Y" Y9 f H! } - ) \% a4 @% y% p9 k8 C; l0 I
- /*ARGSUSED*/
; V! F' e6 y0 n9 |; u5 Y+ x2 z6 d) s - void ufusr(char *param, int *retcode, int paramLen)
9 K6 R' E( X& n! E; e0 D, ]5 i" M - {+ y, b9 q7 V4 q e: v6 t2 Y* H4 l# p
- if (UF_CALL(UF_initialize())) return;5 q: H3 d8 U: D; F( P3 n" B
- do_it();
- T2 E) Q9 X6 P. l4 m. U/ y - UF_terminate();5 N/ @# R, C% P. u
- }( |3 g9 g r# p4 e5 Z5 L0 |. R
- , W+ D5 I4 Z% G
- int ufusr_ask_unload(void)! F# I' F8 J9 z/ h; y
- {
( Q+ N# l( E7 S! O( b" Q - return (UF_UNLOAD_IMMEDIATELY);
9 K! z# @3 I A" k, S2 m& o z - }
: b k% w6 M9 e) C4 j
复制代码 |
|