|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
在集成环境中,NX和Teamcenter的集成中,获取当前用户的组group 和角色 role。
g4 P. ? {. m; x7 e8 S) C. o
$ ~- H* [3 Y' S, [- #include <stdio.h>0 }% i) H% }& D2 s9 X7 D
- #include <string.h>
9 Z- @$ Q$ ?- i; P3 y - #include <uf.h>8 U9 i# J6 V. W5 h2 {
- #include <uf_ui.h>
- d4 R% j! j- z; D - 0 M$ _! c) O9 O, q) @& u
- #include <NXOpen/NXException.hxx>
6 Y) G9 F( P$ y! h! P3 k3 d" W - #include <NXOpen/Session.hxx>- W1 ~' }# d! d8 E l X- \( E
- #include <NXOpen/ListingWindow.hxx>4 J9 J! z' R6 s
- #include <NXOpen/LogFile.hxx>- h! p, M9 J' E" i! X$ ]5 K2 N7 v
- #include <NXOpen/PDM_SessionSettings.hxx>
9 c* ~- G: x4 N; w! h3 ? - #include <NXOpen/Part.hxx>: d" o6 B( }2 u
- #include <NXOpen/ParTCollection.hxx># I l9 ]" c! Y+ @ h3 j
- #include <NXOpen/Session.hxx>
3 j' h/ ]( C k o
. x' B% B% V- V( {4 s- using namespace NXOpen; // <== Very Important!
& i ~% {2 ]& }/ O4 \% s3 B' K+ z
8 D& q: g( a7 U& ` D( m- #include <stdarg.h>/ q/ r( L# {$ f' C
- ; G% M7 w7 Z3 g. T
- static void ECHO(char *format, ...)
; t& G4 A: E+ n6 y7 B v - {: k/ b: z0 E2 q" F' ?
- char msg[UF_UI_MAX_STRING_LEN+1];' D4 S- E$ L. J3 r
- va_list args;
* ~3 D1 G q0 N" u/ ~ - va_start(args, format);8 T. u) I- a- ^4 `
- vsprintf(msg, format, args);, [" n9 g) f9 J M
- va_end(args);0 _% p% U. L2 t
- UF_UI_open_listing_window();
# H4 ~8 e/ ^: @0 B/ Q- J% m# T$ K - UF_UI_write_listing_window(msg);
' o e5 X$ I \. t% y0 J - UF_print_syslog(msg, FALSE);- n" B& u G* G) s
- }+ h7 u G+ r& N- _) ~; {
i4 H" Z% B1 W# Y- #define UF_CALL(X) (report_error( __FILE__, __LINE__, #X, (X)))
5 V# \* m' e: G+ w# e% S$ E
) e1 w* y% S& Y9 \- static int report_error( char *file, int line, char *call, int irc)# ?* c: i4 U/ Z* u% [
- {0 j/ ^% Q7 K4 i+ k9 H! z+ K
- if (irc)
; w2 \! H8 `& D2 ^* t J$ X6 B - {% J$ C9 u5 u- s6 ^) y
- char err[133];
2 I n. _" M6 M; p4 i8 b. `; k - : {' J! J2 o+ x! W/ ~1 C5 D* ~( U9 V
- UF_get_fail_message(irc, err);
( ]: |( d- a u+ C- q - ECHO("*** ERROR code %d at line %d in %s:\n",
: X4 r c4 ?( E e8 { - irc, line, file);) R& Q( f- x0 a6 N3 v: t8 C
- ECHO("+++ %s\n", err);
0 X9 r; I; i& h7 E* N1 ` - ECHO("%s;\n", call);; G( w& t) z3 S5 S
- }
S- [' _/ }9 {+ X - y' ?% N4 w7 t& }) Y$ ~4 i- y
- return(irc);
) A* ?! p0 W* [' C - }
$ ]" T# m0 j* | - 6 c3 d6 x2 J U& y/ P2 t. G
6 K2 B8 j5 z. q0 M2 _9 S' E- }) b; e- static void do_it(void)+ z0 [* A: O+ |6 d' j
- {
1 W( i$ N: Q# f5 H& [ - Session *theSession = Session::GetSession();6 k! n3 C! u4 Z# h! k4 ~! X. ^- m8 l
- Part *workPart(theSession->Parts()->Work());9 T$ x- V' E, o0 l! C5 L( p! p" J" ?
- Part *displayPart(theSession->Parts()->Display());
1 o$ b9 ]4 Q- B7 y4 K - - q* y' }* x- a- f5 D' l
- PDM::SessionSettings *sessionSettings1;5 g9 L1 w7 W# b4 R# @
- sessionSettings1 = theSession->NewDatabaseSessionOptions();' F1 N) d$ f% q+ C& ?4 |
- 8 Q/ C3 s. s$ L7 m, ~( q9 B0 E
- NXString CurrentGroup;
I" U, ^/ @% [' Q5 D# H- w - CurrentGroup = sessionSettings1->Group();! Y4 W9 B, Z5 A
-
# g2 J4 b* D: c) a- n( l) T - NXString CurrentRole;1 w: @. N4 f* X0 _) j S
- CurrentRole = sessionSettings1->Role();0 a8 l* s; L% T: b% ^, s
s+ k0 E& r- a# r, _( t: W- theSession->ListingWindow()->Open();- e. L5 j4 \! l4 ~! K1 g
- 9 w" C3 V0 V% ^* }( m
- theSession->ListingWindow()->WriteLine("Current Group: ");
# t1 u$ }5 Y' G0 V% n" T" h r, j - theSession->ListingWindow()->WriteLine(CurrentGroup);
6 L4 C* b4 a( b: } -
( W6 s8 m' T$ o, P# v - theSession->ListingWindow()->WriteLine("Current Role: ");
) K! n1 Q% S3 B8 o) f0 N - theSession->ListingWindow()->WriteLine(CurrentRole);
& x: l2 `* z7 _" b - 9 F# o F! q4 E# p
- }
4 d+ d! Q5 g% n3 V% t/ `5 A - ! j# r2 P( z/ n& @
- /*ARGSUSED*/
e3 }- Y+ f7 u2 @ - void ufusr(char *param, int *retcode, int paramLen)
- U; }3 R! O2 U# W" ~) a: \ - {
7 g7 M' ~4 I' h2 m& U R - if (UF_CALL(UF_initialize())) return;' B# E& T I' F
- do_it();
& Z# c: ^/ g/ Z/ B2 b) m - UF_terminate();
# V9 L. ] h1 U/ T* Y/ { - }2 Y' U8 u6 }9 Q2 ~7 T1 z a
- 8 d& G$ }# ~! Y& Z9 l* q
- int ufusr_ask_unload(void)
* v' \# P, e5 r2 t- ~, ^4 F - {
: P# j5 X, f' t6 X( o8 J - return (UF_UNLOAD_IMMEDIATELY);
$ n$ t- h, L- V - }- J3 [; P9 @( k5 `
复制代码 |
|