|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
在集成环境中,NX和Teamcenter的集成中,获取当前用户的组group 和角色 role。% E: [. E* \& u7 A$ B. G
; Q! c' Z* `3 p8 \- #include <stdio.h>
) v/ b) q7 K. ]& p5 a S2 h& D1 k - #include <string.h>
; @4 i5 |# x% e, q5 p. _; O - #include <uf.h>
; l/ j( E( z6 |3 t - #include <uf_ui.h>
7 W _8 f4 N' n - / L1 J+ t1 s4 I! T$ B3 m) D* R
- #include <NXOpen/NXException.hxx>+ j1 i7 p2 {5 S$ s" ]
- #include <NXOpen/Session.hxx>! t5 O- E4 w& b! j+ C$ I
- #include <NXOpen/ListingWindow.hxx>
2 R0 g' Z: Q: V5 D5 r' |9 U - #include <NXOpen/LogFile.hxx>' B* u4 t( Q: s+ b, k5 J- s z5 v
- #include <NXOpen/PDM_SessionSettings.hxx>. D4 P& x7 k2 C7 _
- #include <NXOpen/Part.hxx>! C. E/ f8 J1 {' g( V
- #include <NXOpen/ParTCollection.hxx>
9 Y* E! s0 G2 q+ }$ [5 ]7 \) z) s - #include <NXOpen/Session.hxx>$ b B/ J/ ?8 F8 J# A& t0 w
# b& c) x- F$ r2 X+ j" c- using namespace NXOpen; // <== Very Important!/ ~. c: \& D% |9 w
- ( m! v B2 F* w: I- Y0 T
- #include <stdarg.h>
' t& `, T' z4 x
* P1 b- G% S" z" P2 c7 H" h3 e/ e' M- static void ECHO(char *format, ...)
4 x: _( \* L' t5 y$ \ - {- R5 `# E+ Q- \; O$ ^
- char msg[UF_UI_MAX_STRING_LEN+1];
& R ]2 x( P6 G! M8 M0 c, K - va_list args;9 g( [6 l7 N7 j1 k
- va_start(args, format);$ U2 z5 t2 i7 T n6 R
- vsprintf(msg, format, args);# T O- k" b) h' n' W% n" F4 s
- va_end(args);9 s8 n. b% y, _
- UF_UI_open_listing_window();
* |# y9 v* z$ X& r$ n - UF_UI_write_listing_window(msg);
X7 n& t0 O( i" q5 n - UF_print_syslog(msg, FALSE);( F/ W2 V' L4 F$ x+ N0 c
- }- U2 ^2 X3 ?- ^0 b* Q1 [, s3 b
- , e; C* M" ?9 a" T5 O& ^& M8 c
- #define UF_CALL(X) (report_error( __FILE__, __LINE__, #X, (X)))
" I4 r& W8 U% j - z+ L Z3 y9 }: S0 H0 b, J
- static int report_error( char *file, int line, char *call, int irc)
5 y" P" [: o. I# I9 W: E - {
* z; I8 ~) c( D8 _ - if (irc)
* [5 h/ z3 Y* w0 `3 l - {! ^& S! Q$ a6 U
- char err[133];
R) T* W' r) A7 K" @ G
7 q p, `8 s0 m3 k. V+ x' a0 O' a$ b- UF_get_fail_message(irc, err);0 u/ p+ Y8 q' L3 f
- ECHO("*** ERROR code %d at line %d in %s:\n",
* `- i# ?2 i9 l- b7 B! I4 Z# n o - irc, line, file);7 _' U% A/ B+ b% N/ L+ m- X5 w
- ECHO("+++ %s\n", err);8 l$ V" R+ h; k s* A- Q1 {
- ECHO("%s;\n", call);
( x$ u) S7 Z2 Y# N) [ - }
, l4 J1 ~7 @" {$ h/ g
$ k/ u$ E1 I6 [7 L t- return(irc);
7 l2 C d/ R/ E R- } - }8 T" k' j6 G$ F) W0 Y' g* R
- 8 d2 V3 U% Q$ P0 |
- ( c+ g4 V; B, a) l6 d2 p
- static void do_it(void)) X0 z0 G: ]2 p: e: X3 P$ B( A% B
- {
* R. G `+ C! E - Session *theSession = Session::GetSession();. ^8 l' T# q$ e1 r f+ u0 V
- Part *workPart(theSession->Parts()->Work());
2 E& M* W' @. q5 d9 Q8 ^ - Part *displayPart(theSession->Parts()->Display());
$ h8 c) z$ ~2 p( _% o# { -
) z9 p, ]* _3 L A# s- S+ w( c7 j, b7 Q - PDM::SessionSettings *sessionSettings1;
7 H, G. T3 X% m: F. L8 L+ ] - sessionSettings1 = theSession->NewDatabaseSessionOptions();
' @* b; m+ n( n ? -
0 u3 I; ]1 L$ R% J7 T N6 c - NXString CurrentGroup;
- P3 D! b% ~3 ?& V5 x - CurrentGroup = sessionSettings1->Group();
0 S& n# _2 V! L& R' G* F) f, N -
7 N3 f- A( g, G - NXString CurrentRole;) M: r: v- C: z) O3 c
- CurrentRole = sessionSettings1->Role();
( Y- h% ?. b$ b2 Y
3 g; t& h8 ~4 O0 {+ f6 t* p- theSession->ListingWindow()->Open();
/ I/ B: p: ?: T, W$ K1 C% k. V -
* ~9 W# f, ]) J - theSession->ListingWindow()->WriteLine("Current Group: ");
8 d5 A: k7 ~7 r4 u+ r - theSession->ListingWindow()->WriteLine(CurrentGroup);
8 \: v" u' U* B -
5 D( u& } W! t8 ~8 J - theSession->ListingWindow()->WriteLine("Current Role: ");
! ?3 w8 D2 u8 Q$ E1 ~8 s: Q* O+ w* _ - theSession->ListingWindow()->WriteLine(CurrentRole);
1 B! y: H# G F8 s1 p0 t
: w- @2 }' K) x$ f4 B- }# j& v7 X/ e1 X# Z+ W* x* f
! _: T2 Y* T; j! ?; B- /*ARGSUSED*/! l/ t8 A% B# i9 M6 j! Y$ c
- void ufusr(char *param, int *retcode, int paramLen)
2 S0 `' p6 P/ i - {! F4 t/ v9 p& Q8 y
- if (UF_CALL(UF_initialize())) return;' \1 r u f% ]& B- T: m
- do_it();- [& N) w U7 L0 ~5 O0 x0 ^9 }& B
- UF_terminate();+ V8 U) m6 `3 j1 B- X1 W
- }
) b0 C1 ^2 x* _' T1 l6 L5 h6 P - 6 j/ Z) v/ U$ R' m- n/ g- v
- int ufusr_ask_unload(void)" P& v! _) @4 O5 d+ c7 _7 [: ?
- {
! f# {% h7 r7 S$ J& d - return (UF_UNLOAD_IMMEDIATELY);
! f$ O. {1 g* }& Q6 D: `9 | - }
) ], V& }+ W# Q9 O
复制代码 |
|