|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
在集成环境中,NX和Teamcenter的集成中,获取当前用户的组group 和角色 role。* D% ]; J$ ]: p% m* [# h) S0 ~
4 ], Z' O# p) O& |( N( [- #include <stdio.h>& j1 X M3 g0 X: q5 n- H# Q
- #include <string.h>, H! j' G, e+ J( `
- #include <uf.h>
9 k0 E. t8 c% ~8 R3 s2 n - #include <uf_ui.h>
+ D1 M" \# J' d0 h5 O# _- H. ^ - # C) H; m# Y" Y
- #include <NXOpen/NXException.hxx>+ t* z) S0 r/ V% E
- #include <NXOpen/Session.hxx>3 o K9 M: t9 s6 f& u
- #include <NXOpen/ListingWindow.hxx>
& g+ i) t9 y6 o7 h& i4 K5 T - #include <NXOpen/LogFile.hxx>( p: a: M' D- U9 _
- #include <NXOpen/PDM_SessionSettings.hxx>1 o* O% n8 w8 W. B0 l+ q- p
- #include <NXOpen/Part.hxx>
" Y( p4 {( \, g) P6 e4 X$ @* g - #include <NXOpen/ParTCollection.hxx>
$ u# x8 w' c5 {: g* T - #include <NXOpen/Session.hxx>" F' D, y5 U6 f; J- I# N( I
- 3 l) s- |4 y$ R. [8 w1 x& u( k
- using namespace NXOpen; // <== Very Important!
M; @1 G* {' u, |! r6 y - ( C. Z7 d* ~. c. P
- #include <stdarg.h>
9 E8 n) q6 O/ i& m( \# l5 ?/ [
C% v& g0 `. S- static void ECHO(char *format, ...)
/ i9 y% c ~' k2 _% K6 s0 s) ]2 g3 } - {
* v) v1 k# c5 ]( {- y - char msg[UF_UI_MAX_STRING_LEN+1];1 N. I' J- g7 ~0 c, L4 v- p" H
- va_list args;) `/ u4 }! W% J# \1 D( g3 ~
- va_start(args, format);
2 K% x% O* M7 R( C( k. Q - vsprintf(msg, format, args);6 C" ]% ?6 ]; |1 e( q
- va_end(args);
. d! y0 x9 [* |- I - UF_UI_open_listing_window();5 H8 q* ~, b& j+ v
- UF_UI_write_listing_window(msg);/ I/ i z, y2 e4 {
- UF_print_syslog(msg, FALSE);( t* ^7 j9 Z. J- C7 k9 z7 c, d
- }) X( j; u; e9 ]2 b8 U, Z
+ f2 }5 z" i3 K4 N3 ^- #define UF_CALL(X) (report_error( __FILE__, __LINE__, #X, (X)))* Y3 k5 |7 L* g8 d: [
- , S# @; ~' ?0 P6 {7 I ^% h& ?
- static int report_error( char *file, int line, char *call, int irc)) r+ T) T% p0 i. N
- {" y3 C2 z* ^1 g- a4 C. d
- if (irc)
% g$ Y7 ^" S+ p4 K$ u - {( T8 u+ b; M) i; }" }7 C8 R
- char err[133];9 g: z0 L+ g* @# E' l2 d
/ C) x4 E2 \ {- UF_get_fail_message(irc, err);
3 a O1 W! F5 \1 k! S - ECHO("*** ERROR code %d at line %d in %s:\n",
* w( \8 V L5 V3 _8 q5 D - irc, line, file);9 E8 L* S+ g' {
- ECHO("+++ %s\n", err);
& n- y3 S! L0 g( V7 u& j. s+ } - ECHO("%s;\n", call);
- Z; g, t0 I' E( @% | - }
6 [4 I, N" A) U- X# ^2 _$ a# m' u
8 L+ J6 c, T0 X' l j9 \; j q; s- return(irc);% R' K+ q0 l# L
- }
^, G$ J" \/ j - ( ~. q. D$ q3 {. u7 ~5 M
- 4 n8 b' ?9 Q7 k% j1 D5 L& @" |
- static void do_it(void)
* P# f% ]$ {7 z6 e% {+ n - {
# D; P/ {& Y4 f9 ~) e3 k0 ~ - Session *theSession = Session::GetSession();" ]2 s% J( G6 \6 t
- Part *workPart(theSession->Parts()->Work());- X" ?7 v/ s2 I+ R, |
- Part *displayPart(theSession->Parts()->Display());* V% K2 H" W% P! l" G
-
7 k" O8 D1 b) Q# B - PDM::SessionSettings *sessionSettings1;
) k) r/ `+ E6 `* h5 Z! [ - sessionSettings1 = theSession->NewDatabaseSessionOptions();/ G1 t" F# N" X7 X' y
- * \3 ?/ ]2 h6 N/ [9 {0 w% a7 @
- NXString CurrentGroup;
; H* p( J/ r J& u' J& G# a7 j5 ~ - CurrentGroup = sessionSettings1->Group();7 Q7 b7 F0 n$ H( ?, o$ G; i8 f+ N
-
$ H, a$ u7 V2 r& m" r5 M - NXString CurrentRole;& I* A2 M! Q9 k4 n4 {
- CurrentRole = sessionSettings1->Role();
; s- Z* F/ b" K2 i
5 d9 A6 m) B! ]/ K/ ]- theSession->ListingWindow()->Open();
0 m" Z: M* }- \& a2 W1 T6 Z - % f: A# z% Z: P
- theSession->ListingWindow()->WriteLine("Current Group: ");3 M! L: n- `' `% D R! J
- theSession->ListingWindow()->WriteLine(CurrentGroup);
: g D' Z' }8 q: O* | -
1 ?/ m, o5 ?2 w, x0 N) }8 D - theSession->ListingWindow()->WriteLine("Current Role: "); 6 Y7 k; d$ U, G V& |& _5 J
- theSession->ListingWindow()->WriteLine(CurrentRole);$ x% P+ R; C' _
- 4 r7 y6 \ d, N9 U: j
- }/ }9 ~$ y) M5 x7 W
7 U( l' Y" ^4 b% g* U2 R- /*ARGSUSED*/
% P- F5 Q& m! ^& e% e1 } - void ufusr(char *param, int *retcode, int paramLen)
2 W, @* ^5 I8 j$ k" | - {
4 b6 M, D: Q, w3 h; r6 Y - if (UF_CALL(UF_initialize())) return;
o6 T* Y4 F. ^! @3 s$ K0 O - do_it();" O" N! }& m$ b3 z+ Y; \
- UF_terminate();7 e R6 A2 q+ I7 z) v7 C
- }
& C) g" k5 [% h! t! `% A. s - % W: g# Y: g" J9 |2 d6 q, E
- int ufusr_ask_unload(void)
( Q: p3 o. n, }: q& x - {
% q+ o) t# z5 G+ K$ S& I+ G - return (UF_UNLOAD_IMMEDIATELY);6 L0 v0 N/ w- ? x( i& ^) x
- }) p+ v# {8 g+ ]1 i* l
复制代码 |
|