|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
在集成环境中,NX和Teamcenter的集成中,获取当前用户的组group 和角色 role。
: v! h @( q6 g+ x7 w- j( X5 X- G, l
- #include <stdio.h>
: d6 v J1 M8 Y1 [& O) ] - #include <string.h> Z7 J& k$ n2 U2 }3 G
- #include <uf.h>
U8 Z0 ?, c+ U5 F. z - #include <uf_ui.h>
) h$ |7 ]- r4 V& J. B, N8 ?% p1 F
' R6 H; ?) C6 C- #include <NXOpen/NXException.hxx>
$ s! T9 x/ m" k# J0 b" ~5 V4 K, T - #include <NXOpen/Session.hxx>+ s) A( A# z- g# U! g
- #include <NXOpen/ListingWindow.hxx>* |1 I( f% Q$ g7 L
- #include <NXOpen/LogFile.hxx>3 E) j8 S& `/ i/ G
- #include <NXOpen/PDM_SessionSettings.hxx>
; c7 K/ t& b. p& V( g9 u - #include <NXOpen/Part.hxx>2 k4 i* u# U, _
- #include <NXOpen/ParTCollection.hxx>& {9 J* o' t6 e7 c$ n- w/ ~
- #include <NXOpen/Session.hxx>- F' \, z6 c' W0 q9 t
- O" \! Z# i$ a0 r& Q& |7 K. M% i- using namespace NXOpen; // <== Very Important!
8 A! k: D5 y# e6 D, N1 C
$ @4 A9 e$ j, u- #include <stdarg.h>
9 a V# X1 H- X0 ^+ K; j - & a$ R' ~9 r1 u* x
- static void ECHO(char *format, ...)
! Q! L0 V3 j, |- ~' G$ I9 l - {5 N7 _9 t( ], ~* A0 u Y
- char msg[UF_UI_MAX_STRING_LEN+1];
( e/ H% Z2 ^! c; a& w4 K - va_list args;% ~8 f) ^3 Y( P
- va_start(args, format);
6 Y$ P; K4 d2 [" C- X8 b% d - vsprintf(msg, format, args);
+ W z* K+ n1 g - va_end(args);% ]! l7 s8 |/ b0 V0 B) W/ g/ _
- UF_UI_open_listing_window();4 a4 o( e2 `' V
- UF_UI_write_listing_window(msg);" y/ |7 ^# m6 E, G# o2 B
- UF_print_syslog(msg, FALSE);# `5 R& d8 b; F3 k ]. c
- }
- n0 q& |- D H2 H& n - $ q+ h0 T& [: m; `' i4 a8 I" S+ P t
- #define UF_CALL(X) (report_error( __FILE__, __LINE__, #X, (X)))
3 V3 E9 U; Q! V; n
3 g8 x* Z. q$ J9 i1 T- static int report_error( char *file, int line, char *call, int irc)' S: w, r0 F3 n0 N! l0 |7 j& n$ Y& c
- {
* K. j( ~+ @; E- s" }% F - if (irc)
% Q, V% ^7 w! M! W# l0 I - {/ b6 Q) R/ d* l5 I% [) g
- char err[133];
) b$ L5 v* \$ i3 a6 [ - . v5 s' V h1 @: k1 p/ w' p; f
- UF_get_fail_message(irc, err);
2 p# W; _+ x0 P: o& {$ O$ A; L - ECHO("*** ERROR code %d at line %d in %s:\n",
! j8 I1 q* G6 S7 k; g) R4 H7 w - irc, line, file);
. c, a G6 }, @/ P3 X% Q - ECHO("+++ %s\n", err);6 ]$ B) I$ s0 ^- i7 Y: S
- ECHO("%s;\n", call);
) J2 W# F& T! i. {0 h, e2 M! g - }; p9 s$ D* ~5 E: }0 v y+ Z! j
- & s7 Z3 j! v3 ~0 G( n/ a
- return(irc);1 v- ~* X# G8 |6 g4 r7 ~, d
- }
5 J2 ^# q2 Z% G% @# I+ C2 w6 t% G - 7 u4 J- C6 G: u4 {
- ; e4 o1 x) f, [# Y
- static void do_it(void)
% N# \) s5 N) m( v1 f - {! F7 f" m9 e, e( H. V; I% h3 x
- Session *theSession = Session::GetSession();
' p$ @' u4 u3 S. D - Part *workPart(theSession->Parts()->Work());) P' t7 L1 F* W2 ?4 ]& X
- Part *displayPart(theSession->Parts()->Display());& [, U5 m% h& @; D, k+ ]
-
' ?. {% W% j/ ` - PDM::SessionSettings *sessionSettings1;/ s/ \9 X% i' }9 T
- sessionSettings1 = theSession->NewDatabaseSessionOptions();' v9 W& `7 c. @2 I5 `
- $ s" i0 ]1 }$ n6 F) i( D
- NXString CurrentGroup;
4 h6 z; _8 r5 ?' n5 R - CurrentGroup = sessionSettings1->Group();3 N% ^3 \8 b/ }' `- ~
- 1 V+ i6 l) ~6 o
- NXString CurrentRole;" y a; a4 |" s6 \
- CurrentRole = sessionSettings1->Role();( e0 r5 ]9 q6 w) R
- % E( u) z( L- v; r
- theSession->ListingWindow()->Open();
* W( A$ X* J- h; E" o2 ~! @4 F1 u - % t5 G# U- x$ _, T N% q
- theSession->ListingWindow()->WriteLine("Current Group: ");! c) U+ z- R; C3 K& Y( J
- theSession->ListingWindow()->WriteLine(CurrentGroup);% ?+ n. M4 m* B# [8 w5 @) a, Y1 t x
-
) `, E, E0 c- m3 ` - theSession->ListingWindow()->WriteLine("Current Role: ");
/ I3 l5 B# C/ S3 G7 _ - theSession->ListingWindow()->WriteLine(CurrentRole);/ `) `- o( B+ b# M( v- ` Y7 n6 I
' M: Q0 G" E7 R3 J. X' d- }9 H7 C) t9 X3 P# c* K3 b
- 5 z. Y; S: r1 _9 f7 ~* Z
- /*ARGSUSED*/8 O( L; G4 ~3 f& R
- void ufusr(char *param, int *retcode, int paramLen)
. a" J4 ~: @8 `$ k - {
0 L- s: ]4 C0 [0 M! ^) _* f ^; U' f - if (UF_CALL(UF_initialize())) return;
2 M2 r" W, a$ C0 O& j - do_it();$ [6 b$ g* u% o: o1 q! j' P
- UF_terminate();0 p4 n$ g! i' N8 {
- }
; p4 \, h6 @* _1 `( i. w
, s l% s2 {9 `, r! N- int ufusr_ask_unload(void)
* L1 L- j2 _; C - {' a1 P- J; q* w0 Z" d) q
- return (UF_UNLOAD_IMMEDIATELY); p( d8 n6 E4 Z& C( H, s% d
- }8 M# f- k% A' j$ P7 W
复制代码 |
|