|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
在集成环境中,NX和Teamcenter的集成中,获取当前用户的组group 和角色 role。+ K I7 P* u3 H; v% Y
% p( D; K( y, O6 m
- #include <stdio.h>4 k& r5 B' J+ R8 `8 S# K+ Y! h2 I0 v
- #include <string.h>' { x) J2 w: L! W6 v, h9 o) t
- #include <uf.h>
/ @/ F m: c9 R8 n0 z. ]$ `( U& ? - #include <uf_ui.h>3 B. C2 t: s) n
( P m$ }: \4 H# \+ q1 a- #include <NXOpen/NXException.hxx>3 m$ S2 j, ]+ L, M# Z5 S
- #include <NXOpen/Session.hxx>& U2 m* F9 S/ y
- #include <NXOpen/ListingWindow.hxx># M' y2 k4 Z, K, q
- #include <NXOpen/LogFile.hxx>
* h3 X. v) _; v1 O7 ~ - #include <NXOpen/PDM_SessionSettings.hxx>
* f0 ]& V! ~$ ~. J B - #include <NXOpen/Part.hxx>/ r! M% [% z; h( \
- #include <NXOpen/ParTCollection.hxx>& s: k$ R9 M6 I7 f
- #include <NXOpen/Session.hxx>
' Z! W0 Z' @) |8 M" G
$ `& Z. k3 j( o! R& s6 u% ]: b- using namespace NXOpen; // <== Very Important! J w6 f" W% [9 B6 A
- ! D" |- B% p/ M5 f9 D
- #include <stdarg.h>
7 _5 t* T3 v! E, L5 v6 O
- W+ L0 Q9 ^- a7 O6 a1 K( @- static void ECHO(char *format, ...)) {, ]/ l5 [- W) F1 w, m8 r
- {) C0 G: f& u: o& `
- char msg[UF_UI_MAX_STRING_LEN+1];2 p# p$ `. s. K1 E0 W
- va_list args;7 G" O; w0 g7 H1 ]$ a! u
- va_start(args, format);
; l; \$ h$ @8 a) P5 P# K! W; \ - vsprintf(msg, format, args); Q- ^0 |& j. K5 Q- R9 {
- va_end(args);
4 q, Z* @, }$ Q1 W - UF_UI_open_listing_window();4 L E# n% @% w$ z* v- Z: a
- UF_UI_write_listing_window(msg);5 G2 n" ~+ f5 [. m
- UF_print_syslog(msg, FALSE);
( Y; }7 T# Q* \ - }7 q: Z/ q& r6 o: s! L9 v
- 6 k+ a5 z4 f, u+ R& s3 p
- #define UF_CALL(X) (report_error( __FILE__, __LINE__, #X, (X)))
% B+ P& b- B0 e* m0 _7 r7 f
, g" j; G" i' D k: ~+ e' o o* L9 |7 Q- static int report_error( char *file, int line, char *call, int irc)& q6 S @, H% i1 S y
- {, ?) v0 p. L2 Y- \
- if (irc)
2 r0 J- T$ D* v' n5 P' F7 L! i - {
- j4 J; E' @1 v" s3 @) F - char err[133];, U+ I3 J, q/ z D3 e- }* v
0 y6 Y+ F; W" @. @" {8 [- UF_get_fail_message(irc, err);0 [ z: F! }9 y6 c; |% z
- ECHO("*** ERROR code %d at line %d in %s:\n",4 A7 y& D# W% X
- irc, line, file);
2 K. n2 U! c" @; {1 R8 O$ N - ECHO("+++ %s\n", err);' w* z% C, b4 k" d9 v! F; y4 E' @
- ECHO("%s;\n", call);
. f8 y* N2 ?1 I5 b# |. U - }
% d4 }) f* d5 i {9 M4 O - 7 N/ O( K1 V0 N' N# Z( I: }
- return(irc);+ M6 `' c' q. S) i, O) a
- }0 n/ B, S1 u; L [* f: p4 Z
- 7 \/ B% z$ T/ ]' e% _# Z3 P/ w. l
- # V) ~6 P, q' z R2 V8 g7 Q
- static void do_it(void)0 I9 S$ Q) l3 k/ Y6 s' k6 H
- {
/ s: O, G8 t7 v - Session *theSession = Session::GetSession();6 I/ v0 W: P! v% P( Z
- Part *workPart(theSession->Parts()->Work());
( n% I! Q! h! I7 m7 g( L4 M& m - Part *displayPart(theSession->Parts()->Display());
/ z0 t2 Y5 i {2 P, |4 C6 A* ~ -
9 A6 V- M- O( G9 l2 L - PDM::SessionSettings *sessionSettings1;5 K" i+ V8 V9 G# Y7 {, ?
- sessionSettings1 = theSession->NewDatabaseSessionOptions();
: H5 o; R1 i8 \# N3 n9 @0 N -
3 C* d5 ^1 b/ G0 U - NXString CurrentGroup;
5 b, n& ^2 ]! m2 c* T# }7 V8 x) u7 y - CurrentGroup = sessionSettings1->Group();8 ~5 ]3 k- ?: B' v7 {" ~
- 6 `5 ]( z, A3 b8 `. p+ g
- NXString CurrentRole;
: r- t6 P. C" q+ s - CurrentRole = sessionSettings1->Role();
; E- p% i$ Q9 ~0 G4 B3 J3 m
5 p6 ?5 L/ v& B7 ]- theSession->ListingWindow()->Open();
3 k# J* [1 W, n: A - , O4 c! x7 a0 x9 T/ R
- theSession->ListingWindow()->WriteLine("Current Group: ");! j6 ^/ R9 q1 d/ D! m# N! `/ F
- theSession->ListingWindow()->WriteLine(CurrentGroup);, g+ c: ^4 I7 V6 a
- + n3 ], A6 R3 ^7 S; |
- theSession->ListingWindow()->WriteLine("Current Role: ");
5 j, a/ o% `/ ^/ H - theSession->ListingWindow()->WriteLine(CurrentRole);% g( O6 B+ a( U6 N8 Q0 t9 s% _2 f
- 2 Y0 Y' {. M1 W& Q# H9 I/ t" d
- }
) s9 F7 y( T& V- a2 h0 C# e
+ r# H! s1 w4 P$ r9 I' ]- /*ARGSUSED*/, d) l* ]4 l/ g/ i- u1 p3 y
- void ufusr(char *param, int *retcode, int paramLen)
1 ]" r; k% _- T - {
8 ?6 h5 G. {+ x3 ]# `' o3 Q - if (UF_CALL(UF_initialize())) return;0 s( a9 z! k" W7 _9 E# i+ ~
- do_it();. k. i* G- B+ i. U
- UF_terminate(); M& ?" h0 M1 r
- }
9 R9 k: Z. }3 o% f - + R+ f# e5 ^% d) }. ~0 S- w
- int ufusr_ask_unload(void)( v$ L2 l5 {, \. W& y4 I0 j# W
- {# F' g' T& }1 X: G9 Z0 s
- return (UF_UNLOAD_IMMEDIATELY);
" q4 R6 F( ]2 y( b/ Z1 M, {! V - }
t( o5 B. A" G& m5 E
复制代码 |
|