|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
在集成环境中,NX和Teamcenter的集成中,获取当前用户的组group 和角色 role。
0 Q: x3 Q2 _$ @" T6 S, ]
/ ?/ z( B M+ e" p* B- #include <stdio.h>
* @* C9 G' ^& @! f) y3 q, w - #include <string.h>
6 q5 c+ E4 [7 B; H4 H - #include <uf.h>2 u2 z# c4 U- `6 W) L. @) b. D1 ?
- #include <uf_ui.h>9 S& q- e5 w8 N [4 ?: T
- * P2 V1 p' v$ i9 g6 Y
- #include <NXOpen/NXException.hxx>; ?/ i# \2 V; g9 B' O
- #include <NXOpen/Session.hxx>
" |6 U4 e+ W+ D) L - #include <NXOpen/ListingWindow.hxx>
. D: f8 `, g7 j7 c4 Q, o; q - #include <NXOpen/LogFile.hxx>
) Z8 l. l$ {: r! m! Y7 K- B) ? - #include <NXOpen/PDM_SessionSettings.hxx>9 K; n! p% }+ {& U H* h
- #include <NXOpen/Part.hxx>: b' b7 T! B1 T: y
- #include <NXOpen/ParTCollection.hxx>
6 W1 S- |7 ?' I, d8 x - #include <NXOpen/Session.hxx>
A4 i. W" }& n# g( C' e* C$ e - : w2 \; ~, S" z' Q( f- ~
- using namespace NXOpen; // <== Very Important!9 q* O0 c. s: o+ [- v9 C
1 E! a" |; a& x+ [. \6 C* A# ?- #include <stdarg.h>
0 W" @. { y' v' X
: v6 B/ v! M# }9 Y9 p# ~- static void ECHO(char *format, ...)* |, q; B* ?2 X4 z* ~6 R
- {( K0 D6 V. e/ Q, z" q! B
- char msg[UF_UI_MAX_STRING_LEN+1];
( b: v$ X |0 X9 q% a - va_list args;
8 q) V- W8 c& ~! d4 k6 |/ B - va_start(args, format);" g1 ~' a. ]7 F
- vsprintf(msg, format, args);
; c; K% r+ {6 X8 a9 s - va_end(args);
3 R9 q1 w! c, X j - UF_UI_open_listing_window();
|3 p5 X5 g9 L" } - UF_UI_write_listing_window(msg);- S0 I3 |3 h9 j: }* ^- H. S
- UF_print_syslog(msg, FALSE);9 v0 }2 F* ?+ U( w+ B3 O
- }
0 Y5 z$ N3 i3 ~5 E* g6 x - ( F9 {7 `0 M4 X" {
- #define UF_CALL(X) (report_error( __FILE__, __LINE__, #X, (X)))
/ @7 T& |6 i+ O3 a" u$ h$ k, M
, Q2 w) R! t( a. u- U* P- static int report_error( char *file, int line, char *call, int irc)
6 f; Y1 Z4 k* ^3 U( N& z - {
8 y# i! I! Q0 K, f7 S - if (irc)
" V) P( ~; [' m - {0 t9 u1 _- L3 y* I3 U. Q7 `
- char err[133];
' Y) R# i* ^% [1 e4 ~/ h% m' G3 x - ) y$ x; |# f1 D! g2 t5 {
- UF_get_fail_message(irc, err);! s) [2 _, w9 ]7 M% u9 I: H+ e
- ECHO("*** ERROR code %d at line %d in %s:\n",1 I8 Z- c1 A+ r
- irc, line, file); g5 I8 K; q1 ?5 w/ e
- ECHO("+++ %s\n", err);( C$ h% S$ J' h+ W6 |
- ECHO("%s;\n", call);
7 p8 }% Y; L% H- V: \( i) } - }" Y/ ^1 g* ?( @/ E' r
+ t; W! \" m3 K" o7 q% d- return(irc);0 U5 f9 m+ y7 }3 ]: x5 C
- }) i$ ?5 k) H; `7 O' ]
- : L- h" ?0 J4 q* N. r9 y: `) w
/ P* w$ Z, \ z' F9 [! G0 T& f" L- static void do_it(void)" z1 U8 [6 }; I
- {
% L; e4 C- w8 q6 l - Session *theSession = Session::GetSession();1 @4 A: \# r8 |9 O1 D- e
- Part *workPart(theSession->Parts()->Work());
2 L/ w" [% u7 h) d- b% |- v H - Part *displayPart(theSession->Parts()->Display()); B: J! s& W' E. K
- ! H# m m- H, p/ O+ ^
- PDM::SessionSettings *sessionSettings1;/ v9 T0 ^+ h4 l+ r
- sessionSettings1 = theSession->NewDatabaseSessionOptions();
# O& o$ B" a3 y: V - ! ]4 {4 H" n0 O
- NXString CurrentGroup;0 }: \1 ]! [+ L0 |
- CurrentGroup = sessionSettings1->Group();
( ]2 ]! a/ Z6 A2 \' ?1 g -
6 b' ?8 W! ?8 k8 p6 t+ w - NXString CurrentRole;& p2 P4 r4 P+ R. I1 q
- CurrentRole = sessionSettings1->Role();
$ |+ j' W) i/ N% K7 ?) |1 x( ~ - / D" N5 |2 H4 U
- theSession->ListingWindow()->Open();, m& k P7 k4 i2 F. V
-
) ^) S$ M# M+ u5 w" K/ s$ J" D - theSession->ListingWindow()->WriteLine("Current Group: ");; N3 F- _) w. o: X) y5 y" C% V
- theSession->ListingWindow()->WriteLine(CurrentGroup);7 ^8 ~3 t7 F+ n. C
- . q4 J: s) ~6 @" M# g
- theSession->ListingWindow()->WriteLine("Current Role: "); 2 Z1 U6 c& A$ {/ s r1 o7 i
- theSession->ListingWindow()->WriteLine(CurrentRole);
8 S& U( k$ A; g4 M - + t% _% B& z: Z6 K; U+ A
- }
2 N z d {& @0 m1 w6 @- a - " M) R+ S' e) b' P$ a" {# h( U
- /*ARGSUSED*/
/ T3 s7 G" N3 h! z5 T - void ufusr(char *param, int *retcode, int paramLen)9 B/ ~+ ~( M7 ]0 k4 C4 }- z! O0 f8 A
- {
8 c( u, p2 F% t! W9 ^% P: M* f' Y1 ? - if (UF_CALL(UF_initialize())) return;7 W6 ^$ T$ x4 l% O
- do_it();
$ i2 _/ r% `5 k) j - UF_terminate();
) @) V+ A9 t: u/ I" E - }2 Q) F2 r2 z0 l1 R* I
- # w- g7 d1 T s) B, M/ j) b1 t ^$ ]
- int ufusr_ask_unload(void)
7 t0 t; g' \/ g' S0 w W* n - {( D' [) Z' C1 H) ?: X
- return (UF_UNLOAD_IMMEDIATELY);- O+ g, c. Q" t2 b; x
- }4 L) _ M8 n/ }7 T/ T0 q
复制代码 |
|