|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
在集成环境中,NX和Teamcenter的集成中,获取当前用户的组group 和角色 role。
. R$ Y" L5 ^- g* [# {& y, l8 M/ V4 Q s2 w
- #include <stdio.h>% o( N( Q* V% z' F4 }! c9 Y
- #include <string.h>. Q' F) v7 V% j
- #include <uf.h>, `* E+ z. |: [5 v2 a; K
- #include <uf_ui.h>$ o6 G$ Y$ F. [3 Q) b0 _
4 N# l+ ~0 E5 Q. m8 `2 n, h' x- #include <NXOpen/NXException.hxx>
! S; ]' t" [' @ - #include <NXOpen/Session.hxx>" G" E; `9 k' M+ m# }+ L' y7 J
- #include <NXOpen/ListingWindow.hxx>
8 R/ f( A/ M! z4 L2 V - #include <NXOpen/LogFile.hxx>
4 `6 V0 \% Q' |3 \7 O5 X - #include <NXOpen/PDM_SessionSettings.hxx>
7 J6 N- U( W) ]9 l) Y: J - #include <NXOpen/Part.hxx>
6 t: Y. h2 W3 e6 B0 e - #include <NXOpen/ParTCollection.hxx>5 P1 V) o6 l% ?" u. B( i
- #include <NXOpen/Session.hxx>! A( Z) _* C0 Q5 \# G
9 e2 i& [; z3 V) m- using namespace NXOpen; // <== Very Important!- @( d- @0 K$ O7 U$ ]- {5 z5 T
. s \" ?8 |2 O. z- #include <stdarg.h>* G* J8 ~# m* t
- % f: D' D7 s; f: X! R
- static void ECHO(char *format, ...)( U/ Q; b) S& t* F- [1 y
- {3 M( l3 y0 z1 e: y' r
- char msg[UF_UI_MAX_STRING_LEN+1];- P* a2 t- ]) ?9 U. B2 A/ O$ i
- va_list args;
4 N W7 ~! j2 t) h3 x7 V - va_start(args, format);
' K3 \( P1 \3 t3 x - vsprintf(msg, format, args);5 b( b Z; h; B O7 A+ F# p
- va_end(args);$ D v0 ^1 n+ a0 H3 {
- UF_UI_open_listing_window();
8 L0 U$ h/ e) N- C5 ` - UF_UI_write_listing_window(msg);0 i6 S: Z7 C }% l* W. P( Y9 D7 T9 |
- UF_print_syslog(msg, FALSE);
) |5 E+ ^, j, e, @ - }& B# I# |' H' U3 N7 g j4 S
. ^ @5 r3 [# o/ q6 g% K- #define UF_CALL(X) (report_error( __FILE__, __LINE__, #X, (X)))
9 w4 T# o8 [* @2 F# j. j7 E8 D
* b$ O7 C: l, T* ]- static int report_error( char *file, int line, char *call, int irc); x; X% |& h) r4 p
- {. o& B6 x6 K; L9 `4 ?
- if (irc)4 h; [2 u" @4 z" a) V4 s% `, k" ^
- {* I2 `: _; U8 ?
- char err[133];2 D* c4 x8 a& |) e8 |" U
- ' n- d1 \* r/ _4 A4 x
- UF_get_fail_message(irc, err);
2 \. L4 a! D" g% H; F: K/ [1 L9 [ - ECHO("*** ERROR code %d at line %d in %s:\n",
+ | ]5 h, F# l/ o- l - irc, line, file);
- u8 F3 z+ u; w) o# L, { - ECHO("+++ %s\n", err);
- E4 N* l1 B+ u& O - ECHO("%s;\n", call);
' E- G+ \0 D; G1 P/ Y - }: L1 g! \ ]" w: Y, @; Y. U7 K* \
- [ n$ Q( M2 ^! z3 ^- return(irc);
9 ~0 A! ^% c- G9 R - }% I' y- T4 m, Y% Z& l
- $ ]+ z" o+ f2 n: t9 u# ^5 y
- ' u* v' L7 e& a9 Z4 e$ g( U
- static void do_it(void)
0 z4 [0 @3 X% _( s - {
0 V/ o8 A! N0 x0 V O - Session *theSession = Session::GetSession();
+ s0 Z6 @0 p ^' z8 x U+ } - Part *workPart(theSession->Parts()->Work());
7 |; Z8 y% r! `; z5 p- b - Part *displayPart(theSession->Parts()->Display());% e8 a4 U7 v, K2 ^( f2 K
-
% U. s0 I( h8 g( @! K; ` - PDM::SessionSettings *sessionSettings1;
& K9 ~# u5 m9 O5 {: u% j3 o4 T6 \& G" | - sessionSettings1 = theSession->NewDatabaseSessionOptions();
- t: _4 e$ o4 i6 i& e1 O; w - / g; t9 }/ g ^6 r
- NXString CurrentGroup;
9 \4 m q1 E% n3 b3 i - CurrentGroup = sessionSettings1->Group();& z' \$ S2 z5 [/ s
-
2 c6 N! e5 @3 F3 S - NXString CurrentRole;
]" u& U, g9 w4 C) ^3 z" R - CurrentRole = sessionSettings1->Role();
: a% s p, t+ s' M3 s" @& s - 8 C1 b6 x; W [3 x$ _3 j
- theSession->ListingWindow()->Open();+ `( x3 C& c7 g% F, x- s3 `
-
8 `: l! {1 o9 G1 _5 m" V - theSession->ListingWindow()->WriteLine("Current Group: ");2 S. \7 b/ n3 y$ O: P$ D7 l I
- theSession->ListingWindow()->WriteLine(CurrentGroup);9 o* ^+ D' Q5 ?
- % D- k Q4 i5 V6 l6 k2 A4 M' R
- theSession->ListingWindow()->WriteLine("Current Role: "); / T1 Z. y3 k, S' S) x
- theSession->ListingWindow()->WriteLine(CurrentRole);
* v$ G8 o# x0 ]# Q7 Z4 K( t - + H' G' f; g8 o( J: o! J
- }
! F; m8 c$ \2 t# [5 Z. b6 n - s9 X+ B) M: _1 \ R
- /*ARGSUSED*/: i3 }( U) D* [0 }% y4 P, o$ w$ C- Y* |
- void ufusr(char *param, int *retcode, int paramLen)
- j# v1 m$ x! n- g0 W - {; P' S- P& G$ _- {7 G2 H
- if (UF_CALL(UF_initialize())) return;0 B" S& Q/ Q: s; t j7 D; }
- do_it();9 H, x' ]0 H0 ]& s+ P. l
- UF_terminate();9 y1 C0 i" Y3 |9 F' w
- }3 j- N9 e" D; U3 W1 Y
- ) ^* z0 E9 U$ h8 V3 p# [/ @% y
- int ufusr_ask_unload(void)
( w' S; C/ o/ V( u! ^% N+ I - { \% A1 K' T' b3 `
- return (UF_UNLOAD_IMMEDIATELY);# G% K( J! z9 ^( l+ Y2 N5 @
- } [) K5 c0 U x, Y# p( p
复制代码 |
|