|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
在集成环境中,NX和Teamcenter的集成中,获取当前用户的组group 和角色 role。
( ~' }5 |( v$ a9 c2 W' V) M
5 r/ t" q/ T, V% V7 m) c7 G! H7 ^- #include <stdio.h>; m# Y" b$ ` ^; Y1 Z1 W2 q
- #include <string.h>
! y) d) D) Z; M7 b" p: K4 B - #include <uf.h>
* I, T8 I- L( V: M$ z: r - #include <uf_ui.h>
; T6 a8 E, e5 t# L N+ o& A
& x: C+ @7 P' j p5 Q9 J4 ^- #include <NXOpen/NXException.hxx>
3 ^" c' I m3 U+ R; c - #include <NXOpen/Session.hxx>7 Q1 p8 E4 W& X: K' z
- #include <NXOpen/ListingWindow.hxx>& x p& h1 J! ~/ Y& P6 I8 s
- #include <NXOpen/LogFile.hxx>9 i2 I& ] `& U' T- {3 X- q4 C
- #include <NXOpen/PDM_SessionSettings.hxx>8 o- H: T) D i# M. [- g
- #include <NXOpen/Part.hxx>
$ k. ?4 F( D# P: l+ Q - #include <NXOpen/ParTCollection.hxx>
6 j' X7 p8 Z! j* V3 J - #include <NXOpen/Session.hxx>
2 C' ~4 {) l2 ^ ~, P: `/ [ - , [( B3 v! r/ o0 r" R7 g
- using namespace NXOpen; // <== Very Important!
- S- }' a/ h9 A$ T9 A - ( O% t% |2 C: N4 t
- #include <stdarg.h>
& K" [; H4 |) G% ?
6 U; u3 R1 f( D$ e! Y: p: R1 a- static void ECHO(char *format, ...)
/ Y; \( ]8 e1 Q* o l( i5 w - {
3 q* { ~( ]3 T4 Q2 o; e0 X8 K - char msg[UF_UI_MAX_STRING_LEN+1];: f3 @, u4 j4 ~2 x. m. Y% f
- va_list args;
/ x- Y- u1 J) s# m/ z. H+ S - va_start(args, format);
* c0 q% P) Z& m5 I" F0 ]3 d% r6 U - vsprintf(msg, format, args);3 @' ]7 h" R" |
- va_end(args);, A6 p7 }" y0 s
- UF_UI_open_listing_window();
. W/ x7 b% e2 @; T" G) g# r8 v. f - UF_UI_write_listing_window(msg);
( V# T. v- Z) L% b6 m1 S! ~% h - UF_print_syslog(msg, FALSE);
: a4 J& Q4 T4 R' r - }* g/ T$ o- r1 H
- ! N8 S# a; b) S: h; o
- #define UF_CALL(X) (report_error( __FILE__, __LINE__, #X, (X)))
' X, _: }8 _) D$ i! e
0 X1 j/ Y& D4 R l6 ` l8 F5 s- static int report_error( char *file, int line, char *call, int irc). m3 b& L6 g S$ `- T! J& P
- {
( V- w- P: j, }" D: D3 B2 M* u - if (irc)+ p0 T3 E0 @; z$ ^9 I2 V
- {3 g# l$ z0 a' Y' U2 K3 Z& S) M
- char err[133]; R# s9 [6 a' k& W8 b
- / m0 R* R6 H& U/ n1 F0 D5 t
- UF_get_fail_message(irc, err);
; ]% _0 G: P0 m- W6 j! ` - ECHO("*** ERROR code %d at line %d in %s:\n",1 p) M' U% a6 p5 g# P# M
- irc, line, file);1 s% Z( P- U# [. z9 y# {* Z/ {
- ECHO("+++ %s\n", err);
" k' k: a3 C( d9 o - ECHO("%s;\n", call);
' W& V/ m( \8 J! H4 p- k- k - }
, Q4 s" h# {, i5 ~
1 c ]1 Y& d6 v( B6 p. B; `2 f- return(irc);% ?' J( W) b" E( ~+ H/ S
- }
. R" j& M9 A( C2 M
* l- J! x9 G/ a D% Z3 d
( n x& ~+ Y# b& X( H1 r- static void do_it(void)( D3 e: z7 m U N1 ?/ ?
- {
8 C8 I6 n* O* ` - Session *theSession = Session::GetSession();
* Y/ h# e! _9 I1 \- l, j* m - Part *workPart(theSession->Parts()->Work());
# ?6 Q5 O% D6 {& f! F - Part *displayPart(theSession->Parts()->Display());( \, s o P: s# F4 ?$ E4 m
- * l2 a+ {/ f3 b* Z' d/ Y% A& j
- PDM::SessionSettings *sessionSettings1;5 q. B6 v$ H# W* J) c3 [: R
- sessionSettings1 = theSession->NewDatabaseSessionOptions();
' \/ e/ x" y+ a- o/ S -
% J3 y# q) ^0 [* [ - NXString CurrentGroup;
, {. \1 |( b) d9 f$ X* M- B - CurrentGroup = sessionSettings1->Group();. q# P9 h, e J
- 5 H7 B/ u6 L4 g) n7 n8 \
- NXString CurrentRole;1 n% V# A, C1 T8 Q
- CurrentRole = sessionSettings1->Role();6 } j/ K$ ~% c" T2 T
! a* [. g H, ~* @$ h1 Y3 K- theSession->ListingWindow()->Open();
& _% e7 `9 K! D3 F3 ^' u - E% r; I& R# p3 R% ^. w
- theSession->ListingWindow()->WriteLine("Current Group: ");
5 M# j& u- j5 `. }; O/ k$ m% m* _ - theSession->ListingWindow()->WriteLine(CurrentGroup);
5 F: k; ?: t9 N3 |4 w7 x0 s: ~0 t -
3 i k/ p# K1 D3 ]' ]& f1 J - theSession->ListingWindow()->WriteLine("Current Role: "); 0 W s2 y4 n9 p
- theSession->ListingWindow()->WriteLine(CurrentRole);
; b5 c0 Q7 Y' O9 i
3 I7 c1 U. b- [0 I- }
' x$ ~& C! a- Z$ [, ~ - 9 F; ]5 D0 O4 }; f* R
- /*ARGSUSED*/. W, z3 @3 M V6 o* i3 u
- void ufusr(char *param, int *retcode, int paramLen)" c+ {* n2 ^- W) z
- {7 M$ N0 e, o# n5 l! x6 y4 P {
- if (UF_CALL(UF_initialize())) return;
1 g& }; ^# Z" I/ Q5 e4 D - do_it();( i" l* g. ~/ x* f. F* {
- UF_terminate();7 I3 J! ~/ H$ n, j1 I0 ]6 S. U) a
- }
' u; H2 M1 e* h3 |
/ o2 \' u. t, ~5 y- |( V- int ufusr_ask_unload(void)1 C& |" r+ v* @9 [6 \ |
- {
7 x6 S$ _$ P- n1 ?4 V - return (UF_UNLOAD_IMMEDIATELY);) T9 N- b$ T0 L6 f4 @
- }5 \/ G/ k& v7 u, B& @9 A$ R$ a
复制代码 |
|