|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
在集成环境中,NX和Teamcenter的集成中,获取当前用户的组group 和角色 role。. W( `6 b( N& n; U; y. }6 d* s
+ ^: W! A3 k" ]& s$ p- #include <stdio.h>4 x) B: r$ Q: T- v$ g
- #include <string.h>
" }3 f/ C" O+ r& \ `. O1 N - #include <uf.h>
5 ~6 x4 \4 E" R# K z - #include <uf_ui.h> Z$ X0 I6 T, V! U- {! B; \ q
% q6 D7 I+ ]% s( P/ v- #include <NXOpen/NXException.hxx>
+ l z$ f: _* P0 C9 k+ ]+ x - #include <NXOpen/Session.hxx>1 z" i; V# {& E+ d3 k1 C
- #include <NXOpen/ListingWindow.hxx>; K3 b. u; l! | t8 |
- #include <NXOpen/LogFile.hxx>
5 Y7 Z$ |4 o7 V/ r. I, n7 I" C - #include <NXOpen/PDM_SessionSettings.hxx> w1 |. ]; g; o
- #include <NXOpen/Part.hxx>
& h) D. x- x7 |% @" Z( \7 ]. [ - #include <NXOpen/ParTCollection.hxx>
; V+ a; z3 Y; Z# t - #include <NXOpen/Session.hxx>
* X) V% [( m- u$ H3 `
- }$ g, G/ A$ U7 _- using namespace NXOpen; // <== Very Important!) i/ n1 C m& C% N& A( ^1 Y
- 9 W! F' F% |0 V
- #include <stdarg.h>, {4 M4 k+ x' `# \7 l
" U+ z' J) v) t" ^/ n( q- static void ECHO(char *format, ...)
* ^2 U& _$ w9 q: Z; H - {5 ?" |- M. M: n, [0 v
- char msg[UF_UI_MAX_STRING_LEN+1];
% v H1 b' j- X0 I: O, r# B5 {4 P. R* u$ A - va_list args;
4 P, k3 Y0 k2 ~! R$ G - va_start(args, format);
2 X/ O6 P4 W# R2 X3 K4 s - vsprintf(msg, format, args);
* o( w5 p: {3 y! A" w% G8 Z* E - va_end(args);
# Y( ?7 h1 ^ a1 G. a' q - UF_UI_open_listing_window();5 Q6 P) {" k3 |2 q- v% p
- UF_UI_write_listing_window(msg);
- E" T1 i5 @% a ~ - UF_print_syslog(msg, FALSE);
0 X6 y3 i7 v2 v9 t; n; f - }
7 q! [ {% D0 P s3 k1 @: Y, O% y' t
& }( \4 ]% r V1 ]* r- #define UF_CALL(X) (report_error( __FILE__, __LINE__, #X, (X)))
5 p: Y `# |3 Q: q" [+ ~
6 z. ^4 r) D4 i9 Y; X4 H- static int report_error( char *file, int line, char *call, int irc)+ ^ K- J% M: \4 l8 ]" O
- {/ C ~, s3 v; _6 M4 X- `7 g. R
- if (irc)8 h% L2 o1 [6 h) t- C2 j
- {
, l" R- M+ B6 W* K9 B: Y4 a - char err[133];
- O) F' Q" ]1 _
4 N7 ~" D* @( a7 w- UF_get_fail_message(irc, err);% L" B! }" M4 ]! n' p! e
- ECHO("*** ERROR code %d at line %d in %s:\n",1 o/ Q* Y. {$ A" A1 h2 @% n4 o, q' ?
- irc, line, file);
7 l' ]0 w) q" {4 N }9 q2 p& ^ - ECHO("+++ %s\n", err);
& W8 d! B/ \% z( j - ECHO("%s;\n", call);
* Z- ?9 T' i! ^/ m3 ^8 b& R( T7 R - }5 H M z2 [" z& G% c. m
& B3 @5 R8 l4 e& E6 z. m- return(irc);
" s9 U# P0 a2 H6 n1 x8 t- f2 f - }
9 i" L# o0 t) e6 R( t
1 `) B0 ^/ v0 N! o! K; V1 o- 8 `7 e" B9 n+ {" V7 I5 p/ g0 w
- static void do_it(void)
; L8 J- G9 x- r I1 [ - {
. p; v- b: H. N2 i4 ? - Session *theSession = Session::GetSession();6 ~, s1 G; y5 o; H$ \
- Part *workPart(theSession->Parts()->Work());
, p8 {& F5 D6 M# g- l$ l - Part *displayPart(theSession->Parts()->Display());6 G6 j) |$ L6 I# @* j
- ' T z1 S |( x. {& g( \. a/ p! W
- PDM::SessionSettings *sessionSettings1;
/ S( f2 w+ D q - sessionSettings1 = theSession->NewDatabaseSessionOptions();
5 |6 e$ k1 L, \0 L* F -
3 p4 ]+ j: B" [. p$ e' e/ A - NXString CurrentGroup;
7 f8 V& P% o" f - CurrentGroup = sessionSettings1->Group();
: n E6 Y8 v2 _8 M - 3 `# \" B. ~) R5 Q, M+ j9 x0 L
- NXString CurrentRole;
$ I" N/ Z* s; }* a3 P7 m1 a - CurrentRole = sessionSettings1->Role();! @' b' D4 k; R1 Z
- , E" G$ i' O( }6 {4 X$ T
- theSession->ListingWindow()->Open();, X4 N- C( o. i+ h- ~# H) c1 ]
- 6 O* G; r: x" @0 w5 `: @
- theSession->ListingWindow()->WriteLine("Current Group: ");
- m6 r4 B' D9 s2 I k# Y( b8 A+ l - theSession->ListingWindow()->WriteLine(CurrentGroup);" W9 r% O o% E+ i* C- A
- ' O7 }! Z- L0 W- h6 Z' D3 Z' K
- theSession->ListingWindow()->WriteLine("Current Role: ");
! G: `6 ~9 C9 D. H+ b2 c - theSession->ListingWindow()->WriteLine(CurrentRole);
* ] M$ E4 A; Q; Y
# C) H# K/ N1 Q/ E- }
8 B; Y; H5 Z+ [. C% ` - 8 Z1 M6 w* L+ i
- /*ARGSUSED*/+ x1 J/ _, B6 p, @/ B% H4 a) Z8 t
- void ufusr(char *param, int *retcode, int paramLen)# G h- `) O5 u- @9 I; ]& V, c4 t
- {0 Z, K; o( F1 U) W$ Z
- if (UF_CALL(UF_initialize())) return;
$ W- n5 n! ]2 ]- r4 x" Z; h5 q: G' ~) } - do_it();2 O2 D% p7 h; ]; T
- UF_terminate();" N/ z0 m$ c" X. p4 X$ h8 N
- }
- v6 i; d9 ~- }2 O' u1 M - ' s% j* E+ s5 \6 ]
- int ufusr_ask_unload(void)
' I+ a& q9 s9 W% R" ? - {7 ?5 n4 X! J* c0 W) Q/ N- I
- return (UF_UNLOAD_IMMEDIATELY);6 z2 Q& a- c* a( S! G2 @
- }
% H+ Q5 B* j# m" b- Q
复制代码 |
|