|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
在集成环境中,NX和Teamcenter的集成中,获取当前用户的组group 和角色 role。
( G' L/ M& Z3 g* u# K, D
. v+ j E" F+ a* n& T5 I- #include <stdio.h>
) p3 l7 r d# `" y - #include <string.h># S- f! s* G3 v1 ?, h% V( G
- #include <uf.h>5 @- }3 j/ P7 U/ J/ C5 G
- #include <uf_ui.h>
' z4 C" L" a; M5 U G1 } l$ @
& n' W; `& j% W7 [6 M2 ` e5 S- #include <NXOpen/NXException.hxx>
- y/ A! W. f- t5 s7 k8 X- ?( s - #include <NXOpen/Session.hxx>
( ]+ U, @. r( i, E6 Z. S% X - #include <NXOpen/ListingWindow.hxx>
3 b2 e. `! q9 e4 z2 x- S" s - #include <NXOpen/LogFile.hxx>
0 C0 {% O' g% v3 S; C, d - #include <NXOpen/PDM_SessionSettings.hxx>
: {1 A$ g. \) R Y3 Z - #include <NXOpen/Part.hxx>7 O$ v/ c8 ^: [1 g
- #include <NXOpen/ParTCollection.hxx>
) v3 U8 n- K' H" p( ]0 Y/ ? - #include <NXOpen/Session.hxx># s7 c0 t* ?" p- ?; c0 [
- / Q+ V, N7 T5 Q( Q& w% B- @
- using namespace NXOpen; // <== Very Important!, l9 A; R) A# t, T M, h$ ?
2 O9 m5 j' f0 N# w- #include <stdarg.h>; S. s, j1 C2 x
2 G$ Z( c7 H; q+ O ~; {- static void ECHO(char *format, ...)
; Q6 G7 Q$ Y+ t$ w: Z - {, ]' q( _% n8 ]! B
- char msg[UF_UI_MAX_STRING_LEN+1];0 W3 B' E% G @1 C
- va_list args;% I; f7 |. y* Q- d! q
- va_start(args, format);) H7 r5 Q5 t- L4 ^$ H8 D. M. c+ y# d
- vsprintf(msg, format, args);- `( Y8 b# e2 o6 X8 e
- va_end(args);
" X1 z4 f, R/ r8 f8 j - UF_UI_open_listing_window();4 U" [; V# w \! q
- UF_UI_write_listing_window(msg);
: C) a+ l$ r6 X - UF_print_syslog(msg, FALSE);
% ~6 t+ s4 M1 l! d$ G - }
" _$ s2 d5 B9 z& ?: T1 S! u2 q' c
- T4 l; U, Q) F2 ?# K- #define UF_CALL(X) (report_error( __FILE__, __LINE__, #X, (X)))* B6 d" \3 E% c& u0 F# C
- a: x! I* J$ s2 b$ b- static int report_error( char *file, int line, char *call, int irc)
& t) u0 e2 | B+ o - {! p4 f1 H- G- n; K, `" b
- if (irc)
2 S5 c4 ?0 G% L - {
5 J" X) Y9 f; k' z7 ~ - char err[133];
1 ~& C/ f3 i0 [% F+ n" f" O+ M! { - " p- n: h% J/ |, S; r
- UF_get_fail_message(irc, err);6 c( Y9 Z8 h" @+ h$ P0 x/ u
- ECHO("*** ERROR code %d at line %d in %s:\n",7 x0 F3 g* E& U4 q9 J7 N0 h
- irc, line, file);
+ ?. c/ ~ J5 X! V - ECHO("+++ %s\n", err);3 t0 i( S) k/ w; h* g2 H6 \; n
- ECHO("%s;\n", call);% H+ C3 t B" @& {# ?
- }
% Z( r( A4 B" c2 F3 q! V - " ]& h/ O6 q1 D4 o! \# c! \
- return(irc);
, V: C5 Z! ?" y$ q; H; A/ C- ~$ l - }
! W; Y8 ?; v* a
* d' @2 h& l# e- T/ P
5 D+ m6 j- @# i# S- H- ?- static void do_it(void)
8 Z2 f3 I l/ Q - {
) E, ^ j1 [" ~ - Session *theSession = Session::GetSession();
3 k/ g5 B4 s5 G' F - Part *workPart(theSession->Parts()->Work());) [! m& o* w. n" Q( Y5 h @/ I
- Part *displayPart(theSession->Parts()->Display());
' i! v$ @. I6 ~' q -
0 _: Q% C' V4 x0 s - PDM::SessionSettings *sessionSettings1;
- M4 l+ i8 f# v0 B* ] - sessionSettings1 = theSession->NewDatabaseSessionOptions();
% A# ]& a$ p/ w# C& Q$ K - ' N1 E+ _: S3 i% Q
- NXString CurrentGroup;* v1 T1 }9 W1 g" k+ K, S# O$ a2 N
- CurrentGroup = sessionSettings1->Group();
1 C0 I. R) R% o+ e -
" J) ^7 h s+ o" J5 @. T) [) Q, L- h - NXString CurrentRole;
p# ^7 E/ P, h/ T9 |+ P" V - CurrentRole = sessionSettings1->Role();9 D/ u2 M |5 d z. L' Z. l
- |" u, b* E; ]- theSession->ListingWindow()->Open();
0 p' W5 B9 N7 T -
+ @7 |; K/ a3 S. B - theSession->ListingWindow()->WriteLine("Current Group: ");
- c# q/ y; g+ f" z8 E - theSession->ListingWindow()->WriteLine(CurrentGroup);0 `! T% X# k7 }
- ) h, M i9 v" K& e
- theSession->ListingWindow()->WriteLine("Current Role: ");
' _9 S( M' X/ I1 l - theSession->ListingWindow()->WriteLine(CurrentRole);2 k) e, r/ N$ z3 k- i$ y: }& f% w' Z
; H" i4 W% S! b" g( ?- }
% I# `! x- {) v/ u" g3 p - ' V& G- Y$ u1 Y# E% K3 m
- /*ARGSUSED*/
# V8 e* ]8 R# ~ - void ufusr(char *param, int *retcode, int paramLen)( G4 Z4 x& U3 i
- {
: E' |) L7 k. F6 p0 o* p - if (UF_CALL(UF_initialize())) return;$ x5 G7 t) E( W+ `! V, H3 x
- do_it();* r" J0 f, }- ~2 @7 P/ D6 i
- UF_terminate(); o4 R; g' S" T) z B/ L
- } f0 l0 R! i2 r8 o6 d( F( _
- ( S& @2 B; D" {2 `0 b4 d! B+ o
- int ufusr_ask_unload(void)
3 ~0 j3 ?/ `& V( k! n6 f - {9 J2 V: d/ B. u0 S
- return (UF_UNLOAD_IMMEDIATELY);% X% D& W# ^- B% Y1 E+ b: y8 z
- }
- u: {7 I$ X1 O/ |( j& s
复制代码 |
|