|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
在集成环境中,NX和Teamcenter的集成中,获取当前用户的组group 和角色 role。
: v7 S# K k+ @* k5 g
7 I2 G9 @; R4 b+ J/ P- #include <stdio.h>
5 v& z. H1 ~$ B - #include <string.h>+ S' q0 \0 b0 @5 J
- #include <uf.h>' N* \: o. X$ L
- #include <uf_ui.h>
7 ^, l/ b* u5 b8 G4 ~/ k
9 U4 F1 g3 w8 m. P4 d- #include <NXOpen/NXException.hxx># |' p @; m; q. m5 {# p0 D
- #include <NXOpen/Session.hxx>' Z2 W7 A" I; {* t/ i$ {- }
- #include <NXOpen/ListingWindow.hxx>
. Z: v+ x6 t$ j2 s b; ?! C) q+ X - #include <NXOpen/LogFile.hxx>
' _/ x+ e: L9 F2 l - #include <NXOpen/PDM_SessionSettings.hxx>
% m: O: [: H* e$ I9 ~2 y - #include <NXOpen/Part.hxx>
) C. y( ^. P- k# k( m2 N! r - #include <NXOpen/ParTCollection.hxx>
4 \% D" n, r! Y4 | - #include <NXOpen/Session.hxx>) E7 h1 W. e# L6 ^! n5 Y' N4 K9 |3 Q L
& H, l$ ~& V* E! r! t% {- using namespace NXOpen; // <== Very Important!$ ?( b/ n6 F/ ^
, R4 G3 I- b) r! H$ K- #include <stdarg.h>
% t4 I# U: O6 ^. d, k5 C9 b0 r
$ l, @; m2 }; e- static void ECHO(char *format, ...)
8 n% f/ Q P' T6 }# V - {- N7 j. o& J) V0 j# H
- char msg[UF_UI_MAX_STRING_LEN+1];' u1 f) G+ ]0 f3 [; T2 S( |
- va_list args;6 D4 T) t+ P7 ]8 N" `) ]( g
- va_start(args, format);
" l. l4 P/ ?' k/ E - vsprintf(msg, format, args);
( l9 l& l7 x, g% `0 L - va_end(args);( x( B: T5 `) C# F' ^( _! x2 Q
- UF_UI_open_listing_window();( p2 i- [- y8 m0 C5 t
- UF_UI_write_listing_window(msg);
8 a$ i* r" g6 w0 ~/ U" \% D - UF_print_syslog(msg, FALSE);
' H4 e: _9 p3 w - }$ F9 D# I( a/ u: r4 { \
* z# E C) j" @- #define UF_CALL(X) (report_error( __FILE__, __LINE__, #X, (X)))
) D3 Y" U5 B- D+ D - $ A" W! V7 O) C) H* `2 N" s
- static int report_error( char *file, int line, char *call, int irc)8 o" j: B0 H8 X4 |0 P
- {9 _/ \$ G9 ~+ v/ J( S
- if (irc): S5 D9 f- C& q0 @1 P/ A
- {0 [ a+ O( l& q' e* U
- char err[133];
8 c8 O+ W" x# _, Z4 @3 R - * b& z- X1 X# K5 _
- UF_get_fail_message(irc, err);
: d/ V, } ~, k4 q/ l4 l6 i - ECHO("*** ERROR code %d at line %d in %s:\n",
8 O8 H* e& |/ @ - irc, line, file);
+ W3 o/ b& {7 X u, E - ECHO("+++ %s\n", err);
) G* [/ p' D9 ^ - ECHO("%s;\n", call);7 k8 a8 K9 _& J, o5 H& G) n
- }* e) E3 E+ S& ^# e J7 ~+ t+ I# s( ?/ A
- ( i" [( N& h3 k# H! v ~
- return(irc);* s9 y1 l" e* F9 p7 i$ I
- }2 w) C N5 c- G$ H$ q8 [
) C9 U" W; Z& {; j! R9 W7 ^- 2 Q% u: c0 H' ~. |9 i
- static void do_it(void) C2 M/ \ b2 e" ~/ n+ c( }
- {' V. k f, g& {' s
- Session *theSession = Session::GetSession();
0 J) k# z* a' y8 n$ i, ^* J) q( @7 g - Part *workPart(theSession->Parts()->Work());5 z- g _+ }' x
- Part *displayPart(theSession->Parts()->Display());: G+ v, j1 W1 ~1 e8 d* p
-
9 }$ L0 ]5 J7 v* W/ V; | - PDM::SessionSettings *sessionSettings1;& H K% t4 N! u0 n
- sessionSettings1 = theSession->NewDatabaseSessionOptions();
/ h6 N0 t9 r7 J& |% i - 6 ~! U+ ~) {; L1 l
- NXString CurrentGroup;6 w3 o; g( C8 p6 t
- CurrentGroup = sessionSettings1->Group();
1 p$ q" `5 O: J N -
2 S: s4 o! p) E) h. h" P p7 |! R - NXString CurrentRole;4 H# ^' ^) C2 d: e0 l
- CurrentRole = sessionSettings1->Role();3 [# ?; }& B+ R8 E' [7 X
- 1 k+ }7 Q" S# E; B% B) d6 m3 y8 W
- theSession->ListingWindow()->Open();
/ a" Y' p' T" I - ( \) Z/ W, w5 Z4 y) F/ X1 t( Q
- theSession->ListingWindow()->WriteLine("Current Group: ");
& g3 z' k. T, u; M) p4 X3 N+ l# W# `# q - theSession->ListingWindow()->WriteLine(CurrentGroup);
+ B* o' L$ S+ s, t -
4 C" t! [# A* |+ l2 S - theSession->ListingWindow()->WriteLine("Current Role: "); ( c5 L' j: \6 ?) q9 U* i
- theSession->ListingWindow()->WriteLine(CurrentRole);6 k4 {+ h. r+ K4 c
- + g9 T$ i, K& Z- ~, z3 S
- }; c5 ~+ `" g% T: W8 H
4 Z5 @! X) W- j9 \6 J: X- /*ARGSUSED*/
! a/ C- c* _, U4 g, R - void ufusr(char *param, int *retcode, int paramLen)
' L0 K, I% ~+ {1 l" F8 G - { s/ e5 P; m% U( b% `
- if (UF_CALL(UF_initialize())) return;
1 j( F; H: K/ z1 `+ Z0 f3 Q6 ]. Y1 @ - do_it();
( Z. q4 J" i/ E) z - UF_terminate();
. P$ W7 x& ] X) C - }
]: `' S) `; H, H - 0 Y K9 U7 z3 m) ?. z, f
- int ufusr_ask_unload(void)( e# E4 [- N5 S3 _- q
- {5 Z/ L, R) Q+ t, X$ j- k
- return (UF_UNLOAD_IMMEDIATELY);$ i" k/ P p: K( \$ i5 s
- }
' y# p/ M+ H$ Z( o* V
复制代码 |
|