|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
在集成环境中,NX和Teamcenter的集成中,获取当前用户的组group 和角色 role。
( H( F) ^, ^, \% V& n. y! |* N: f# y9 z7 N
- #include <stdio.h>* ]: N z" C$ f/ ~- v) c
- #include <string.h>
4 w) Y7 W9 h- s. D; w: \1 J) M$ ` - #include <uf.h>
$ [. ` }' A: B) C - #include <uf_ui.h># p. A8 V& z7 @0 h" g" Y0 }
- . E: o- b# J1 m5 Z' w! O
- #include <NXOpen/NXException.hxx>
( Q3 E% N5 |5 `8 P - #include <NXOpen/Session.hxx>; v+ b% Y% B& j t5 m' h
- #include <NXOpen/ListingWindow.hxx>" b) t. f- j1 D
- #include <NXOpen/LogFile.hxx>
6 V8 a$ ^6 v6 b3 x - #include <NXOpen/PDM_SessionSettings.hxx>5 i, J1 n' A- R9 T
- #include <NXOpen/Part.hxx>
1 P/ t& E# T5 ]2 Q2 k% F3 h - #include <NXOpen/ParTCollection.hxx>! x) n' X; I( t1 V
- #include <NXOpen/Session.hxx>
. H7 m) I) _3 l( J: K% ~ - ; T. M4 c& H, @8 o5 d/ y
- using namespace NXOpen; // <== Very Important!6 S) h+ g8 L) ?1 `1 i3 Z) J( K0 o
- ; p5 U, ~) A% \# e7 S1 e0 B' l
- #include <stdarg.h>
3 h) a( O1 `1 b0 G7 `# {+ Q6 i - & J9 P' P& E- o/ t
- static void ECHO(char *format, ...)
2 S, E& w1 }' Y) d5 \& R4 k0 P! r: A$ o - {" t& X2 D( H# k( [& @+ i
- char msg[UF_UI_MAX_STRING_LEN+1];
. O/ A+ C) J; Z - va_list args;
6 x0 w+ _; h, b$ c+ b$ I4 f; B r - va_start(args, format);
% C9 t) Z+ ^8 e/ s& P3 T4 Q - vsprintf(msg, format, args);
) _+ P+ l# ?: ~/ Q - va_end(args);
6 X9 R. }! B8 |1 e - UF_UI_open_listing_window(); F! O" H1 G1 C. X7 v/ p
- UF_UI_write_listing_window(msg);* `( J! A& g* q/ n7 ^4 I" Y# l, |
- UF_print_syslog(msg, FALSE);
% d. e6 b" a) i - }
( T) h) s/ w& i8 ]8 e& g Z4 M - ; B6 I* z* m7 ?( T% d7 C4 Y
- #define UF_CALL(X) (report_error( __FILE__, __LINE__, #X, (X)))+ s) Z C# n6 D3 ?9 f- h6 w# _/ a! M
4 t# [ P% j/ F8 b7 ~- static int report_error( char *file, int line, char *call, int irc)" h) Q' x- O# }9 a4 a, e
- {' x9 ^; j9 y a9 e! w1 ~8 _* ?
- if (irc)6 f- }9 Y% m4 n( G& ]
- {6 i8 @3 `0 v k H' D: M
- char err[133];
7 q4 s' l: ?, s# e: B
. W# i% R! q7 l* N y- UF_get_fail_message(irc, err);
+ x) ]0 z: g6 D - ECHO("*** ERROR code %d at line %d in %s:\n",$ X1 z U, J2 \6 {
- irc, line, file);+ i) J0 @& S( ]- n
- ECHO("+++ %s\n", err);
4 b. K# F+ A. P/ v2 |5 Q, ^ - ECHO("%s;\n", call);
/ `5 z- Q$ z0 b; X4 n; Z - }
# @% `% ]! n' |& n( Q/ u - & u% r# s. `% v4 L: k: H, ~
- return(irc);. k; m( _/ p1 U
- }5 C5 g- S' c( x) h, @
- 9 W5 h/ [& h% Q [+ [' V% X
- " j" j1 L2 T( u5 j% |: Z
- static void do_it(void)
# E- t7 z0 \0 E3 U5 C - {- A: c0 ^- L U( e1 [
- Session *theSession = Session::GetSession();9 D) }1 w# u1 O" ^ Z: [9 R
- Part *workPart(theSession->Parts()->Work());
) \- T( |$ j# G! H2 ~7 P - Part *displayPart(theSession->Parts()->Display());) _& J. w# W; l: h- R2 F
-
/ q" }$ t, a' h - PDM::SessionSettings *sessionSettings1;% t6 Y, J/ t1 g" @. X
- sessionSettings1 = theSession->NewDatabaseSessionOptions();
0 N6 J" r- o' _ -
8 Q( k7 m+ L* [6 s/ k& F - NXString CurrentGroup;
7 n- @9 ]) c- s: v( e. G - CurrentGroup = sessionSettings1->Group();
7 l; A/ i; ^$ S, z: ` -
" F+ e- a% E9 l8 d$ R8 g9 Z3 n4 [ - NXString CurrentRole;
" t( S9 n2 h! T5 ~9 ?; a* Y# `) ~ - CurrentRole = sessionSettings1->Role();2 U \0 A+ A1 R$ C5 d
- # p- u2 x6 K' z% j$ [# H
- theSession->ListingWindow()->Open();+ a9 u/ a$ t o
-
, b6 h# U% X. S: Z E: C. R - theSession->ListingWindow()->WriteLine("Current Group: ");, w9 I5 l! T: {) x
- theSession->ListingWindow()->WriteLine(CurrentGroup);
) }1 t o9 U9 w4 B/ S; X7 A3 |+ v -
1 h) A6 h+ j7 L0 Y% U/ c - theSession->ListingWindow()->WriteLine("Current Role: "); 9 }1 u! l% N1 C7 _' n' u4 W, m* H Q
- theSession->ListingWindow()->WriteLine(CurrentRole);
2 ]0 B- h6 u; x. t, M% n - 6 S h. a0 m* _$ X' S1 O1 p) m
- }
- O- z0 m9 I, A7 S
' F: x+ }$ i& B7 r" L4 |' V0 m- /*ARGSUSED*/; }3 q; P. t% c2 I2 d# T" V
- void ufusr(char *param, int *retcode, int paramLen)
4 q' h T) R9 [- H. s; G1 P0 k I8 n/ ^ - {
! Q' {# Q$ d3 g; N0 l6 j6 H - if (UF_CALL(UF_initialize())) return;5 m1 q3 H$ A6 V1 m" g6 U
- do_it();9 f6 x% l4 u$ c
- UF_terminate();
6 D* X1 n$ [. x - }( L. p$ }3 ^% p" t, s2 w/ G
- ' k( L/ N: z+ o# l7 x
- int ufusr_ask_unload(void)! o7 j8 P9 L/ |4 R: t8 _) r. D
- {. g7 g* e: h! e! v
- return (UF_UNLOAD_IMMEDIATELY);
! d5 I. e/ x$ i4 \" ] - }7 O2 x* e8 H4 j+ B) r
复制代码 |
|