|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
在集成环境中,NX和Teamcenter的集成中,获取当前用户的组group 和角色 role。
5 c# [4 C( q( ]+ h3 Z
- P. i- J5 E: r7 C) S. z- _$ o- #include <stdio.h>
7 p! e. N& [) ]2 X$ l; K3 v - #include <string.h>
+ x, `0 Z5 G2 A/ l0 G# Q6 Z# N9 p) M - #include <uf.h>
% v3 ^1 ?" z0 ~- k; i8 ? - #include <uf_ui.h>
, M% x3 P/ E& Q6 ~. x4 R. m
' ?; n* g5 E! s* r- #include <NXOpen/NXException.hxx> \0 I9 \, o# H
- #include <NXOpen/Session.hxx>6 o9 c& Z9 H9 h+ G
- #include <NXOpen/ListingWindow.hxx>2 P: l$ P' c+ K8 Q: E
- #include <NXOpen/LogFile.hxx>+ D) j" R1 N8 e* H6 L! _. } B
- #include <NXOpen/PDM_SessionSettings.hxx>
& ?9 ~$ h5 w+ q0 z - #include <NXOpen/Part.hxx>& F& R6 F% t% ?9 Q' R
- #include <NXOpen/ParTCollection.hxx>
% ]0 I$ h H3 x e - #include <NXOpen/Session.hxx>% b, I/ y4 x9 C) C6 `, @; H' W
- # Q9 |( C* t# a
- using namespace NXOpen; // <== Very Important!+ c& R3 `1 J6 L; s* O) q
- + ]7 N: g6 _5 |) F9 V/ t
- #include <stdarg.h>
# ~; l5 | f9 o" \ - 6 D% u3 n" t, D: c h2 P+ y
- static void ECHO(char *format, ...)/ l" P& K' @% W( l4 n
- {% l s* o: q) v1 F2 G
- char msg[UF_UI_MAX_STRING_LEN+1];! o0 _1 V6 g5 s. t0 k8 ~
- va_list args;
3 a& v( X, D& r# U8 y - va_start(args, format);
2 r$ p) w6 p8 F8 k! V: f - vsprintf(msg, format, args); ^: a& Q9 c4 E/ J( c7 m9 t
- va_end(args);+ I0 I6 P0 G ~( ^ @ p
- UF_UI_open_listing_window();3 p: @: p F5 ?1 Z
- UF_UI_write_listing_window(msg);
: c- s. ?! N; ~8 Z- k - UF_print_syslog(msg, FALSE);
# I- V/ S1 X! Q4 p4 r# ]" n - }7 @1 t! s. J' Z7 C8 E
/ i. C" x9 |1 C6 T- #define UF_CALL(X) (report_error( __FILE__, __LINE__, #X, (X)))9 v8 ?% n: g9 A9 h2 a
% C0 q( C8 T% J5 |- static int report_error( char *file, int line, char *call, int irc), O0 }7 V# R6 J- k6 n; y1 k. l
- {
' k8 n: N1 _2 ~/ n9 D6 }3 e3 h- n - if (irc): j( `0 _: W. V; R! o: }9 z
- {4 `6 F7 l+ {: c
- char err[133];
0 t' n" p! F2 c9 _. u$ x - 8 t. `, m3 ~1 S' l2 N. r5 C
- UF_get_fail_message(irc, err);
* x( _* p) O2 r1 D/ ^6 ?5 U7 z# ~ - ECHO("*** ERROR code %d at line %d in %s:\n",
8 P* R( S) S, R7 Z, s2 y - irc, line, file);0 v* H1 N0 h. Y; M: E2 U/ i- u8 I/ u
- ECHO("+++ %s\n", err);/ g' t+ d- X: n8 c. p: b+ `
- ECHO("%s;\n", call);
' K" [' t! i2 t - }9 Z S$ l0 j' w$ I# W
} W9 _* `8 H7 ` p( Q( w F* O- return(irc);, E) D9 S8 `6 R+ j0 s4 @+ _7 L) F: `
- }, X+ Y& ]" n3 x9 ~2 K
& x) A+ g3 v# `. Y% p
" N- Q9 M0 d* }4 L- static void do_it(void)- l, g4 z6 d* }% h' D" `, ~. a
- {/ _2 j, A/ ~5 m: M
- Session *theSession = Session::GetSession();$ j3 \5 m4 Q1 ~- K4 s! s
- Part *workPart(theSession->Parts()->Work());
+ f" K1 m7 D* u8 v1 f* P - Part *displayPart(theSession->Parts()->Display());; a; z/ g# a; @4 v( Q, @0 |
- 4 Y, M) ^: l7 B+ |
- PDM::SessionSettings *sessionSettings1;
. z ?9 ]4 s0 K0 X7 @) l7 c - sessionSettings1 = theSession->NewDatabaseSessionOptions();6 y) R& g! q7 X2 b
- ( O8 I, q s1 U. s' B
- NXString CurrentGroup;: g0 n: s# F; I
- CurrentGroup = sessionSettings1->Group();1 T4 l, v% x+ c; c0 n) R
- + t4 [. w7 v6 ]: n0 X" L4 A, b
- NXString CurrentRole;, O- _- y+ g9 \% o$ N6 ^! J2 X$ d
- CurrentRole = sessionSettings1->Role();0 O+ v" T/ _( w0 }# J, G
, c, @- g* R$ Z/ `1 [- theSession->ListingWindow()->Open();9 F4 [; z+ |: S x9 X
-
: ~2 g' O0 O5 \: F$ r4 } - theSession->ListingWindow()->WriteLine("Current Group: ");
/ i' d3 D# ~* H b2 b$ \. l - theSession->ListingWindow()->WriteLine(CurrentGroup);1 V2 ~# a9 J9 r7 a+ j/ \
- ) f3 e, e3 `0 Q( W
- theSession->ListingWindow()->WriteLine("Current Role: "); ) `# p8 ^2 c. t3 A4 y: D! f* q( x' l
- theSession->ListingWindow()->WriteLine(CurrentRole);
6 ]0 n; i H7 x" ?* Q6 I) ~ - 5 G: k3 A3 d6 X. D
- } r( q: b% i& D2 b1 Y9 P
7 K5 a O! P' e& |' o6 }+ o- /*ARGSUSED*/; H7 H+ i* i+ A! }" A2 m2 j. p0 K# c# v
- void ufusr(char *param, int *retcode, int paramLen)) y! d$ _+ M1 h6 E4 b: K6 B7 {
- {3 \- O! c& E# s4 Z( y0 `
- if (UF_CALL(UF_initialize())) return; ^& v6 P& |5 A7 H: W
- do_it();
; B' e% j4 J) u3 f. j, s; t9 m - UF_terminate();; a$ R; H2 _( l0 A- M
- }; f3 R; l/ Q: V+ a8 v
( V6 |) L( L$ F9 H: G) H9 K- int ufusr_ask_unload(void)' U& V" B; J$ g4 R- R0 T6 e5 {1 s
- {- k: l8 R5 c4 Q# @
- return (UF_UNLOAD_IMMEDIATELY);
& C3 w, E7 V/ ^& l# I - }
) X" k$ u. b& D
复制代码 |
|