|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
在集成环境中,NX和Teamcenter的集成中,获取当前用户的组group 和角色 role。
0 S% F" T) m& |% c& p9 j
9 b4 c3 Y0 g7 s' g& Y$ L0 |1 ?- #include <stdio.h>
2 t# a* u' s6 V; e - #include <string.h>* L$ w/ x2 d# r2 D4 L% D
- #include <uf.h>
5 t' I& v5 N! u9 c& H( u" B - #include <uf_ui.h>
! O1 F1 k8 N# b6 a, E( F) n - 7 ^8 v3 B7 S1 U3 i0 }& Y9 h; q
- #include <NXOpen/NXException.hxx># Y& N$ J: S& Y5 g8 o; ~
- #include <NXOpen/Session.hxx> v6 W( d# g2 L( T, H/ i$ |. @
- #include <NXOpen/ListingWindow.hxx>' E& O( o: S! o6 V2 A
- #include <NXOpen/LogFile.hxx>1 c' k5 G0 u' e* x7 ]( ~
- #include <NXOpen/PDM_SessionSettings.hxx>
0 }. E/ r+ x4 w! m6 ]# ?8 u4 s' V - #include <NXOpen/Part.hxx>0 f( a) H7 ~) y7 o& N7 D0 E5 x
- #include <NXOpen/ParTCollection.hxx>; Q: c2 P6 G1 V" b8 f
- #include <NXOpen/Session.hxx>
: r- U- [/ r% U) j6 e R - 3 u. W1 e) d! D) ?
- using namespace NXOpen; // <== Very Important!9 W2 ]" a, @! ?. ~0 I
- 3 Q7 g0 M! {+ B
- #include <stdarg.h>
' k% D0 A9 `, l' ^7 V! [1 e5 ]) ?
( ?, V% n/ R* ~; j3 K2 t! _- static void ECHO(char *format, ...)# ~1 Y$ v5 o k% p' R( W0 M) M$ [
- {4 {- {0 q( ~% \+ z" h- m/ c
- char msg[UF_UI_MAX_STRING_LEN+1];
" F: B' j0 r# ` - va_list args;
% { S5 I! B2 {% P p' U - va_start(args, format);' ]5 ]* n3 r {& I. g
- vsprintf(msg, format, args);
; X' d! w. ^; E - va_end(args);
( e- ]; T3 A4 ?* { - UF_UI_open_listing_window();
& j; k! s, o* H - UF_UI_write_listing_window(msg);. M. A. `) x# V( X* d, A
- UF_print_syslog(msg, FALSE);* G2 b5 q- I1 b; \- ?3 E: e
- }
3 q% |" W, M; O& I; O* h8 [ - 9 \2 L3 n1 s! T7 A, Q
- #define UF_CALL(X) (report_error( __FILE__, __LINE__, #X, (X)))4 N. H: z0 N4 Z3 x6 _' C
- ) [- F$ c1 B% @9 w- |' f) {; [
- static int report_error( char *file, int line, char *call, int irc)
, m& |- i$ r d d9 ~6 U. G - {, g- W5 s u" R! x( x. X4 G
- if (irc) x" j0 Q, d2 C! w- W) h% L @
- {+ y3 h) \4 O7 O0 q3 W4 O
- char err[133];
/ r# y) z0 G$ ^5 J' ?- W
% [) x0 a. g7 j& J. ^4 x- UF_get_fail_message(irc, err);: Z4 g* v: O- r! u
- ECHO("*** ERROR code %d at line %d in %s:\n",' T- K. O0 a* p4 ^- t! g" M- d
- irc, line, file);
. t9 C7 w1 S$ I4 h: D - ECHO("+++ %s\n", err);3 v% ^! T! f T6 }5 k- o
- ECHO("%s;\n", call);
+ B% k/ k1 ?5 x% ?) q - }/ H3 S+ j$ X; K# N
- : j" m, x* i& }4 s
- return(irc);
+ u" ^# o M: P4 U3 p$ b - }
e' H* M# _! M f# J! [: G6 I - N0 o' j7 L1 o% y+ P) u& Q
- & e: I. e+ ?( u1 i% t; O4 _
- static void do_it(void)6 e1 @* y8 t6 }
- {
% G6 J/ Q5 c- o1 h! v - Session *theSession = Session::GetSession();
* s6 g( n, M, i4 l( z/ | - Part *workPart(theSession->Parts()->Work());) Y f+ M9 k! i( g
- Part *displayPart(theSession->Parts()->Display());
3 g$ y. e" {$ Q3 r6 d: c -
9 u! ^/ e/ ?, x, \# y2 Y - PDM::SessionSettings *sessionSettings1;
' g0 p% S3 O! S' B) Q7 F y - sessionSettings1 = theSession->NewDatabaseSessionOptions();6 X2 p% v8 Q0 P, V7 ? w
- 8 f( K7 A$ Q, w0 A
- NXString CurrentGroup;
1 u( |) \. K% r* p$ `9 w' k - CurrentGroup = sessionSettings1->Group();
5 f1 m$ c* `1 P7 P4 C -
" r* {0 Y3 L! ]3 a+ p: G7 M# K& v1 m - NXString CurrentRole;
( l3 |$ v8 G4 k: z% z: v5 H: o - CurrentRole = sessionSettings1->Role();! {: \. x* a# S/ ~1 X# j2 X
- 5 @/ u) w6 B( ]% M5 B5 O' B: k
- theSession->ListingWindow()->Open();, v9 b$ }' L, J
-
+ j- L, g* p; Q1 j% E" ?& N$ | - theSession->ListingWindow()->WriteLine("Current Group: ");
) a$ O& T/ c; T) H* y e - theSession->ListingWindow()->WriteLine(CurrentGroup);2 c( t2 @; l* y0 @; r
- , u% G& D) v( k$ Y) t, o
- theSession->ListingWindow()->WriteLine("Current Role: "); ' k+ u8 P& r+ s) z
- theSession->ListingWindow()->WriteLine(CurrentRole);8 F7 V& q, W ~, T3 k
- % ^# `: q! ?. j, y
- }, l' K" r% p; C' g
" T Z; A' m& P9 Q0 D- /*ARGSUSED*/% j9 D, D+ q/ g& r- r1 j
- void ufusr(char *param, int *retcode, int paramLen)/ b: J0 j) l0 u3 Y& l
- {- y7 u/ b9 y! g! U+ K9 m/ W
- if (UF_CALL(UF_initialize())) return;( |) h1 ~. j* a! {2 f
- do_it();0 i9 @1 m: c' A$ A; D9 A5 X
- UF_terminate();( p6 f) M: u& x, E+ L& h5 N" o, |# c
- }; d; i) s. x7 l1 P
% ]2 N7 l$ X, t9 ~; S& T- int ufusr_ask_unload(void)/ \. Z( S" A/ ^3 O* Y: i
- {
7 f' i0 J6 o) l0 A, _ - return (UF_UNLOAD_IMMEDIATELY);
; z, Q0 Q. o" ]# _3 w4 t - }2 J9 k& U* x4 P* s/ v. l( l
复制代码 |
|