|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
在集成环境中,NX和Teamcenter的集成中,获取当前用户的组group 和角色 role。
! d3 C' b$ z; I/ ]6 k3 b2 h. ~8 Z1 p( x+ _/ J
- #include <stdio.h>; |' _6 Z; @/ A" w7 D0 ]
- #include <string.h>
: \6 v4 N7 U" Y3 g! U, g0 ~) X( ] - #include <uf.h>
; Z# G. A h& Q3 C- y8 |$ {* e - #include <uf_ui.h>
1 _+ U1 G8 e6 N2 {" } - . C1 l1 Y; w- g3 i4 D- Q) u6 d; W
- #include <NXOpen/NXException.hxx>
2 V8 i3 m) t- E7 R - #include <NXOpen/Session.hxx>1 u" s: k; d* @. [8 b
- #include <NXOpen/ListingWindow.hxx>
9 g6 K6 J, E' }0 _ - #include <NXOpen/LogFile.hxx>
5 O; f7 x9 U8 x7 f% I- i5 ?% f - #include <NXOpen/PDM_SessionSettings.hxx>
( ^$ G7 p7 a1 K m8 N+ c - #include <NXOpen/Part.hxx>
; V2 e: q' H/ o - #include <NXOpen/ParTCollection.hxx>
$ H$ V" g+ H$ ^ - #include <NXOpen/Session.hxx>
. A! U" O7 _+ |4 \" `) O& r - ' G: ~ K5 q" i4 v7 w6 c" \
- using namespace NXOpen; // <== Very Important!/ [: o) G, C* q8 c7 [
- 1 u# ^0 j5 B0 V* ]* Z
- #include <stdarg.h>
3 B* ~4 g& N' L! g) Z+ D1 ~( _, Q: t
4 c4 E: J' l5 z8 M. j) K- static void ECHO(char *format, ...)- a8 \* d5 H8 m8 N( S. b) C# R' [
- {' R. D" T+ g* Y9 L
- char msg[UF_UI_MAX_STRING_LEN+1];! i! I$ U% x: ?/ I7 e3 S/ P4 t
- va_list args;9 p2 h/ \$ O3 c# A* W% i" Z
- va_start(args, format);
3 g# T2 _7 v/ H5 O$ B' E6 L/ J - vsprintf(msg, format, args);
x9 F* W* _' K, R6 ?' y6 I+ N - va_end(args);
8 E( T/ x5 q, w/ N# |* f - UF_UI_open_listing_window();6 n; p) c! T0 H* {5 B% N
- UF_UI_write_listing_window(msg);
9 q% S2 S+ L; x5 t0 z4 U- [; a2 ` - UF_print_syslog(msg, FALSE);
. ^& e0 S+ f: p l$ g, M! R2 m - }
# C0 R$ U$ o+ p3 I5 U
" d, q6 L" q% d! z& J& Y- #define UF_CALL(X) (report_error( __FILE__, __LINE__, #X, (X)))) L) P% Z) Q* g' }! o" u- A
- . \+ E2 f# X6 e* j
- static int report_error( char *file, int line, char *call, int irc)6 c7 M% `" O0 `
- {
+ |( h5 f* _ |; e4 u - if (irc)7 ^8 m4 Z: t2 a9 q e6 K! |
- {) X9 A7 k* Y7 j. C
- char err[133];% L2 V* ]4 A. \0 X2 F+ Z4 x
- 6 P3 f% f* V% o. q) w- L' d% l
- UF_get_fail_message(irc, err);
5 E5 `/ U& { m: O* H - ECHO("*** ERROR code %d at line %d in %s:\n",
w& m2 |$ y P! Z - irc, line, file);. @# F; c; F6 j5 ~; T/ S9 c! b% X3 K
- ECHO("+++ %s\n", err);
1 K5 R' i+ {( T7 Y( B - ECHO("%s;\n", call);
: H0 U4 i4 M' `: ^" j0 [, f - }2 [6 Y- }7 ^2 L0 \' {3 l S# k
& d5 B% g1 I# X+ H$ w3 N- return(irc);
& t: o; J7 l+ P - }* B d9 m/ F* }0 q
" b% ]2 [) C2 _# p, @. H- ( h0 \; H$ e6 k
- static void do_it(void)& P- [4 ], T! ^+ w: ~
- {
8 u( Y# L+ D/ g6 q - Session *theSession = Session::GetSession();
0 ` U5 p. ^0 D - Part *workPart(theSession->Parts()->Work());
2 E9 r/ h6 I: Z" Z8 x - Part *displayPart(theSession->Parts()->Display());0 Z. N! [9 Q/ v3 Y O4 J9 d" z
- ; }. K4 c3 c( S) A. q: _
- PDM::SessionSettings *sessionSettings1;
d/ q1 z9 K" f% r: z - sessionSettings1 = theSession->NewDatabaseSessionOptions();! A/ i9 u, s( U- N
- 9 I9 C" r( |- U; A9 ?( I
- NXString CurrentGroup;
* ?! R* v1 m/ b# ^ - CurrentGroup = sessionSettings1->Group();
g2 o/ a0 l/ w0 \ - 5 {' s0 i [6 m+ S# N- ]
- NXString CurrentRole;
4 E2 M) T' v4 j& w+ a5 I$ p - CurrentRole = sessionSettings1->Role();! N6 f0 O' V4 L1 G) T a+ \
- . v* C2 B. E( }9 E/ r) X& c/ E
- theSession->ListingWindow()->Open();3 O" m" X8 B* d6 _( u; p2 i& Y$ S
- + A/ ~- e9 o1 `% R( }! c" D
- theSession->ListingWindow()->WriteLine("Current Group: ");
$ v/ i0 u! @- w3 T1 g" v - theSession->ListingWindow()->WriteLine(CurrentGroup);
' ?' b; L' T5 o3 v% ^7 v/ ?. p - * |% ^1 C5 Y$ S" H- A0 {3 N
- theSession->ListingWindow()->WriteLine("Current Role: ");
! f& _" h" }. P) P2 g) U* A - theSession->ListingWindow()->WriteLine(CurrentRole);& U( e8 {3 P6 W4 o
- % Q2 C* z8 r! Z) v1 N3 {7 ]
- }, l' X% {( w5 T& `: R( w' A; e
- , m% f, \$ B, R1 ^) G% Q; E7 H
- /*ARGSUSED*/" e& h; \ i: S% L& T
- void ufusr(char *param, int *retcode, int paramLen)
( x6 _3 Q* U, j7 O% V) q - {
' ^6 z4 r9 w7 R% W; r6 i1 ^ - if (UF_CALL(UF_initialize())) return;
) L4 w' O% p9 t9 \9 } z - do_it();3 G+ C" g& r; |6 S) K- q) ]- e
- UF_terminate();
1 P( Y7 k/ l2 A: J - }
/ Q. v! k1 c" B4 |' A' X - / D' f! D( l$ t5 o9 Q) [8 s% P
- int ufusr_ask_unload(void)
8 |$ {. I: |( Q2 J- { - {
5 s& m4 r; d* ~: Y- r4 H" q: |" Z - return (UF_UNLOAD_IMMEDIATELY);3 R7 E! }1 r$ {3 x* w! z
- }5 ]' G1 V+ M. M% d5 ?. N' o* J+ U
复制代码 |
|