|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
在集成环境中,NX和Teamcenter的集成中,获取当前用户的组group 和角色 role。, _- W) U: Q" g9 V
8 d: g9 ~( T: X0 G% ]" K- #include <stdio.h> ^! L) q% J+ P9 i* N, d$ ^) [2 s
- #include <string.h>2 K. x& r& W6 O5 @+ \2 D% P& _
- #include <uf.h>9 I& \7 j M& t2 L1 ^$ n
- #include <uf_ui.h>
/ J& n) E3 i2 s' _2 r6 D6 [! W
0 [" A% [- w- [3 L- N- #include <NXOpen/NXException.hxx>
& k7 w: E2 K% n - #include <NXOpen/Session.hxx>
+ B6 q7 l+ u- }$ d, z - #include <NXOpen/ListingWindow.hxx>
/ O; [# k% K. n0 B) O: Q O# \+ b! @ - #include <NXOpen/LogFile.hxx>
5 t( c# D' O A) Y - #include <NXOpen/PDM_SessionSettings.hxx>0 \% Q1 u2 v/ v. e
- #include <NXOpen/Part.hxx>
( g$ |7 K, ]/ |/ x2 C( k: R/ R8 P& c7 V - #include <NXOpen/ParTCollection.hxx>
& U" q- I3 ~; j3 F0 F) p7 L - #include <NXOpen/Session.hxx>: P; d. S/ T' M$ a \6 q' U3 m
- : j* F! u6 \* k8 W. c; `
- using namespace NXOpen; // <== Very Important!2 Q9 P. O! z$ C* f. p4 p8 f
3 C+ S" a1 h" C: y2 o$ R- #include <stdarg.h>, @6 c- v8 V+ v
- \. V+ P% |8 E" g' k g1 a- [- static void ECHO(char *format, ...)
9 O; {. B. t7 T8 y' e+ k, b8 W - {- w+ q7 W7 `& \
- char msg[UF_UI_MAX_STRING_LEN+1];4 e8 `7 W+ F6 q) n l$ j& R% Q
- va_list args;( i6 Z* G2 [- t# S4 D
- va_start(args, format);
- L4 _, M+ I/ N; D3 d' x( P - vsprintf(msg, format, args);
4 V5 V) Q% l' P. a& w! ~ - va_end(args);
6 z0 k" j9 i( E4 u6 P6 {$ H3 E - UF_UI_open_listing_window();1 ~) ~. V' s, y) `0 y9 {, v
- UF_UI_write_listing_window(msg);: L5 i2 p3 u; d
- UF_print_syslog(msg, FALSE);; D; M+ n6 \2 s, F3 D
- }
: {- @! J! P, U. k+ Z! f
6 _9 L3 [* x7 k l2 _- #define UF_CALL(X) (report_error( __FILE__, __LINE__, #X, (X)))
( I7 v6 h D# X. l. p( O
0 h2 ]+ r0 O S5 A4 s- static int report_error( char *file, int line, char *call, int irc)2 N* i4 F) V8 F' @; V, }7 A
- {
9 w7 ?- }: L" Q$ n* o. x - if (irc)- A" v" c# Y3 M3 i
- {
/ g/ I V; `" t" Z' @ - char err[133];
4 @5 E i- g- E( b
; D& h& K3 B8 y( y9 G+ [- UF_get_fail_message(irc, err);
! r! _9 y; G8 N; M* M$ L% J: C7 [ - ECHO("*** ERROR code %d at line %d in %s:\n",( v* A. I/ l& t- u$ E( Q1 @
- irc, line, file);; P, S8 w7 u6 K8 A, a1 w
- ECHO("+++ %s\n", err);# \8 i( m; Y F+ E8 B3 O
- ECHO("%s;\n", call);
- V! _3 R& }4 B0 o3 _ - }
, t/ G& A% q( b. O
3 d0 S" ~' q) T% O$ u3 B- return(irc);
# n7 d3 y8 Q; @9 ~5 \1 D/ _ - }) J- B% | y* }1 d: b5 W
- 7 z5 q6 r0 m* f7 N; n: @% [' Q4 J
1 v1 H8 k3 F% y7 a% K" y- static void do_it(void)
" r t% N, T7 J! N9 s& y% K - {! X# F: p2 T5 s4 K0 ~
- Session *theSession = Session::GetSession();( x+ H) k1 k ~0 C( Q4 A+ W" R
- Part *workPart(theSession->Parts()->Work());
! b* X+ N$ O# Q1 _0 E% J" ^. g - Part *displayPart(theSession->Parts()->Display());
7 C$ {. y* {: ~4 n) H d -
! x- Q+ u/ }1 f9 s3 V x - PDM::SessionSettings *sessionSettings1;$ c& l; a6 e3 P, ?
- sessionSettings1 = theSession->NewDatabaseSessionOptions();0 I- J; ]1 s0 f; b+ W
-
$ ?) q6 b$ I0 {7 _ - NXString CurrentGroup;
6 Z; Q( v& ~( b# F$ \5 T' p - CurrentGroup = sessionSettings1->Group();, w3 `8 ?7 [; W8 t- c: i3 _
- 3 ~: b2 ^; q! X" Q, r( ^
- NXString CurrentRole;* V! i/ P0 Z. S
- CurrentRole = sessionSettings1->Role();
; ?( c0 K4 U! Y3 T8 E6 J/ f
9 d0 Y+ Y" u$ [9 y, p- theSession->ListingWindow()->Open();
8 L; f* \3 v- l- P -
! r2 I, x' R7 l8 } - theSession->ListingWindow()->WriteLine("Current Group: ");/ `, s E! _5 [8 {5 S* ^% A s* z
- theSession->ListingWindow()->WriteLine(CurrentGroup);
% v% {- w+ |6 M* n# b- u7 Q - 7 S5 A: x+ M5 q
- theSession->ListingWindow()->WriteLine("Current Role: ");
0 S" P# I& g4 ]; c$ R2 R - theSession->ListingWindow()->WriteLine(CurrentRole);
# [# k3 ?1 U% B, _1 E" w - 5 {; _, [4 w# v% n
- }
9 V5 b; h+ A7 |( h* x2 F2 x4 I
" N$ r# d1 H3 U$ a* H9 k& f9 K2 X- /*ARGSUSED*/# |7 ]3 Y6 E* {# S
- void ufusr(char *param, int *retcode, int paramLen)
3 I4 j% H p9 _! l& K - {. C* g& s: ?0 j
- if (UF_CALL(UF_initialize())) return;; g! k1 C. L) C! _1 ~4 }1 R t
- do_it();$ _" t1 {. ~2 I# [" r) R
- UF_terminate();+ _( V% e9 L; d! L/ R! E
- }
6 _ x7 {# M8 v* F4 v- J. ?
2 x% Z# J C F& d( [- int ufusr_ask_unload(void)
8 g6 @( p5 e0 `# J& L% C' j - {
1 h6 t, C. N9 \0 e# X9 X( V - return (UF_UNLOAD_IMMEDIATELY);
; m- F0 Z: ]8 }$ P5 |6 m8 P+ r - }
8 x1 h* `, Z3 J7 k: I A6 f
复制代码 |
|