|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
在集成环境中,NX和Teamcenter的集成中,获取当前用户的组group 和角色 role。
. W) q, f) v8 e2 f+ L
}, ?; N& I; i* Z! H' j- #include <stdio.h>
( T; h: k' U# X - #include <string.h>
4 ]" `. @3 L2 R' U5 s - #include <uf.h>
" ^! o$ h n9 _$ ~1 M - #include <uf_ui.h>6 a8 C! I6 \- h/ P4 j3 B
/ p: m3 q; X* R9 S* G4 M- #include <NXOpen/NXException.hxx>
* [) P: \5 G6 B0 F3 i# ?) I4 q9 @ - #include <NXOpen/Session.hxx>
& F' i7 H; e, B6 x" N* u. B" V - #include <NXOpen/ListingWindow.hxx># i( Q2 [' o$ x p: x
- #include <NXOpen/LogFile.hxx>
! D& C" P" w1 B5 Z4 \3 C - #include <NXOpen/PDM_SessionSettings.hxx>9 L, a1 d- M4 A: T; J! q& ?
- #include <NXOpen/Part.hxx>$ \# i$ o# G3 H
- #include <NXOpen/ParTCollection.hxx>
2 N" `: k2 S( {( U1 n4 e, R - #include <NXOpen/Session.hxx>( \/ r; {, {+ V2 r* S
- 5 ~; X2 I& i; p+ d1 D
- using namespace NXOpen; // <== Very Important! u8 T1 m' y! d$ i
- 4 R1 l2 P! o! X$ s
- #include <stdarg.h>
, x7 G; X+ R+ O
9 ]: `8 X" H2 w3 C9 ~* s( L- static void ECHO(char *format, ...)1 D+ `4 h3 m6 f
- {, Q- \+ ^, _* M" ?% x2 s
- char msg[UF_UI_MAX_STRING_LEN+1];8 w! j% `: Q6 J( U( |
- va_list args;6 y2 j# n i7 Z* S
- va_start(args, format);- z: J. \0 G) b6 @: P, i- ], @
- vsprintf(msg, format, args);
* G' D x% `7 I/ ] - va_end(args);
8 ~0 [2 A k$ c& r$ N - UF_UI_open_listing_window();
, j; s+ K/ u8 a- h - UF_UI_write_listing_window(msg);
0 v$ f9 n7 x0 k0 e K A - UF_print_syslog(msg, FALSE);' ~! x( E# v6 q& y
- }
% H0 w' E! l, W D5 P2 q* k, N2 | - 8 _; R6 E# ]+ Z8 y( t) [' e
- #define UF_CALL(X) (report_error( __FILE__, __LINE__, #X, (X)))7 f7 d5 a; a* M _8 L$ z' `% w
- 5 T2 Q, O' U/ ^' z8 s3 Y$ U
- static int report_error( char *file, int line, char *call, int irc)& ^ M9 I# b8 N' S' j# w3 b& y" `) p4 o
- {
, s0 h, \. C" s1 q7 Y3 L" y5 e# d - if (irc)
) [4 y! L9 i0 G0 J, @# D - {
0 ?3 I' [2 i2 O5 o0 ]! C: g( N - char err[133];, j+ \* Q8 ]+ V1 J' o8 O( V& _
- / w' o! ~3 L9 v. U
- UF_get_fail_message(irc, err);" a; b+ Q* q7 F
- ECHO("*** ERROR code %d at line %d in %s:\n",
6 }: u( C1 p9 G: |$ ? - irc, line, file);
3 q6 N( z3 e0 l - ECHO("+++ %s\n", err);4 T9 d5 O1 O; {" a( @4 s1 n
- ECHO("%s;\n", call);1 e6 @( c9 l' h# N# e# s8 E
- }
: A' O' K3 i. x- c z - % f, X6 t' @/ Z! r- p8 z
- return(irc);
' |: o. R8 S. @ - }
' i5 Y" [' J! ^3 B7 X - ! t; V. ]' f/ f# w: U" m( x5 ?
- + F* I. S/ g t- |& l+ J: L# g% ^
- static void do_it(void)& p* P0 m" T6 }. E
- {
( b! \- f" U% | - Session *theSession = Session::GetSession();
( w" y3 E$ D1 L1 M0 }1 F - Part *workPart(theSession->Parts()->Work());2 B" a3 O# Q0 q a9 c
- Part *displayPart(theSession->Parts()->Display());
# W/ z6 A9 e# @9 Z3 U, l - ! R% r4 {. b @. H
- PDM::SessionSettings *sessionSettings1;
/ r: z2 B* b# f- C( W& l - sessionSettings1 = theSession->NewDatabaseSessionOptions();7 @' I# ?; G1 q2 F, _9 f8 I: Y
- 0 S6 M5 l) S, ?% L% t" W/ _
- NXString CurrentGroup;' z' e" |' s( a2 [" K
- CurrentGroup = sessionSettings1->Group();
5 E7 ]( ?. x* t) i - , ?+ @ X" [8 O( H! U- R* j
- NXString CurrentRole;
0 S5 |, D5 m4 i' @5 c0 } - CurrentRole = sessionSettings1->Role();
3 Y5 r$ v P" r$ @% f
4 L" c4 _; ^& ^- x/ I% b! ^2 s- theSession->ListingWindow()->Open();9 k; |" E& o* ^) C S8 R5 B
- ( L6 w; g& m& G& G0 G6 O
- theSession->ListingWindow()->WriteLine("Current Group: ");9 j+ v# I+ c; M t
- theSession->ListingWindow()->WriteLine(CurrentGroup);
4 t, b, l8 U- i3 O -
4 R. [1 b- u* J$ j- Z - theSession->ListingWindow()->WriteLine("Current Role: ");
2 V& A3 R% B1 Y6 v# G3 K- k+ j - theSession->ListingWindow()->WriteLine(CurrentRole);! {% I% f1 k/ j& ^4 P
' Y& [6 c+ m( }( B+ i- |1 Q+ n- }
' U; \6 S! V, l5 U# ~" F6 p - 0 `7 z) L0 T; Z; X9 H
- /*ARGSUSED*/
- ?' b: s3 G6 h/ e$ G' F; S. {8 d - void ufusr(char *param, int *retcode, int paramLen)! Z, d0 L; l( i
- {1 [& a$ n6 ~3 r& z
- if (UF_CALL(UF_initialize())) return;
; s$ I( C3 {4 K8 j2 h6 j! [' H" t6 f - do_it();
6 x" n* Y$ M( @# i- W. G - UF_terminate();
: T' }% a+ b. F" ], ?, x - }- E0 @2 H1 H1 B
" m, \" ~7 k0 r+ H7 T- int ufusr_ask_unload(void)
K* w m/ H2 ^ - {
9 b }# @+ c5 i" ]$ W - return (UF_UNLOAD_IMMEDIATELY);" s9 i l9 O5 b# t+ p
- }
; U- O8 o1 [6 z: i# [! V1 Z" V
复制代码 |
|