|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
在集成环境中,NX和Teamcenter的集成中,获取当前用户的组group 和角色 role。
9 O8 y$ O$ l4 P& p/ Q
5 {7 K4 R- a5 B; m; e) i- #include <stdio.h> f% O8 S0 `+ B( ?( n; a
- #include <string.h>
: }( [5 C2 I3 E( p) ~ - #include <uf.h>
5 H* ^; Y/ f; Q" N% s - #include <uf_ui.h>
; A: L# \4 U. k8 q; z+ J+ m3 q% B
3 d" _- h$ b D4 e5 K5 X- ~- #include <NXOpen/NXException.hxx>( i) W& x# \& P
- #include <NXOpen/Session.hxx>
! _* U. d; t7 C - #include <NXOpen/ListingWindow.hxx>
6 x. o+ H( N y* Z, j- h& W) I6 m - #include <NXOpen/LogFile.hxx>: s2 l+ i0 d, d7 a$ o
- #include <NXOpen/PDM_SessionSettings.hxx>/ y R* b0 {. e/ e7 b* ^0 D7 x
- #include <NXOpen/Part.hxx>
8 p! x# P3 [: v - #include <NXOpen/ParTCollection.hxx>+ Y. w" {! y! f! P: d
- #include <NXOpen/Session.hxx>8 M% Y! u$ b# R
! @6 v0 ~0 y6 T4 ^- using namespace NXOpen; // <== Very Important!2 [( i. l* }& y: a0 H
3 w# P' B+ Q' k- w- #include <stdarg.h>% }& V- M! `' f b. m+ ~0 Z
- $ q: s- t' L/ V+ V% l0 F& N' i
- static void ECHO(char *format, ...)2 s* g4 n2 ~9 T6 ^
- {
+ x$ \7 W9 W" p - char msg[UF_UI_MAX_STRING_LEN+1];- W) r4 s& N a _+ c7 ~
- va_list args;
G: S: e& R% Z3 `- I8 @+ [ - va_start(args, format);/ z9 s9 {1 @4 N. C! C! }; v; C
- vsprintf(msg, format, args);) ~& F6 U& m0 _* z0 L+ H
- va_end(args);( W0 \' u- z# w! _1 J5 p u
- UF_UI_open_listing_window();* ]' C+ q5 G5 g- T( U
- UF_UI_write_listing_window(msg);* S. M3 r- u/ y* N- c' V3 o9 a
- UF_print_syslog(msg, FALSE);) ~, O* z* w2 A
- }
& z/ y: X8 V1 C
* ~: c" x; V4 C; _# F. {1 \- #define UF_CALL(X) (report_error( __FILE__, __LINE__, #X, (X)))! t/ T4 _- e$ ` B% U$ z
8 X, a v1 X6 p4 A# V" @/ ]2 G9 N- static int report_error( char *file, int line, char *call, int irc)- x! l( C h. i
- {
8 J5 S" ~+ c' @; N$ s1 f - if (irc)
0 E) n- @- [$ ^ - {. [# m6 K0 U9 a
- char err[133];
* G# u2 _" [7 a3 I- g - - z3 f2 J9 a6 D# p: m8 k
- UF_get_fail_message(irc, err);! i/ s) A9 }; X0 g5 \
- ECHO("*** ERROR code %d at line %d in %s:\n",: y0 V" Z. W' u- |; [- ^3 C
- irc, line, file);( @8 O/ J# _% i( t& u# Z
- ECHO("+++ %s\n", err);
! b$ }5 m1 u5 n0 e; g& q - ECHO("%s;\n", call);
) O2 x0 B8 Q7 ]+ i8 ` - }
* U3 z3 i: }, ?4 h$ \* D( s) [ - / R8 ^! N7 w& ^; _
- return(irc);% M6 D4 \5 ~; _. s! O3 }- P3 B
- }2 `8 z5 {2 }9 r) t6 W* g- A
8 G/ ~9 x7 c* T) S! ^
F2 N: ~0 L2 o2 z* |- static void do_it(void)
6 q# Y, }; [! Z' S! x' Y* o - {
; |# v# m; v& R - Session *theSession = Session::GetSession();: e M& H# H% N/ N) u
- Part *workPart(theSession->Parts()->Work());4 g, `0 n& I( l+ {, G
- Part *displayPart(theSession->Parts()->Display());
+ B5 \# p8 U; e9 T8 [: I( B - 9 x/ V G' o, c( [" x* z& F5 N
- PDM::SessionSettings *sessionSettings1;
+ |/ [; {, s5 Z - sessionSettings1 = theSession->NewDatabaseSessionOptions();
- y: C8 p) c- j$ Z. d& f - / H# B& F$ r+ B( X1 h& A+ H
- NXString CurrentGroup;
0 c4 C" ]' f( Q - CurrentGroup = sessionSettings1->Group();
7 a3 p. p. Y2 f+ [ -
) u6 q- F$ Y7 J - NXString CurrentRole;& e1 m$ j% Z! W
- CurrentRole = sessionSettings1->Role();
$ L6 S& `% P( [, R5 E3 Q
: I7 \. O6 b7 B. L$ I7 ~- theSession->ListingWindow()->Open();; j; J+ F& _; u" M2 S
- @3 S6 G$ a- P+ U2 B6 q& _
- theSession->ListingWindow()->WriteLine("Current Group: ");
3 G$ D* V! T0 s$ e) f# n) a" a. V - theSession->ListingWindow()->WriteLine(CurrentGroup);- Q7 }5 N+ }/ y* w
-
3 v9 h+ U4 R9 L- a N9 i+ j+ l - theSession->ListingWindow()->WriteLine("Current Role: ");
* l1 L% a3 ]8 h) Y, _ - theSession->ListingWindow()->WriteLine(CurrentRole);
$ i0 V7 P1 {& K$ h2 s, X
! P! ?% J& R; S' Z- }+ J' d6 R+ u1 H" _( }
- ! G" ]8 x8 D0 e; y/ u
- /*ARGSUSED*/
" \( a) |8 Q. G; E/ Z& H# ^: D% X8 S - void ufusr(char *param, int *retcode, int paramLen)
$ r1 V( V7 g* b% d- U/ d e) b0 c) h - {! x( Y# @5 j: X* v" r4 m7 O
- if (UF_CALL(UF_initialize())) return;
, R6 { s; b$ X2 B - do_it();" x0 ? p& W4 U) J8 B# x8 N6 w
- UF_terminate();
! W! ?( F, q- q0 l$ g: O - }
# ^5 A/ h3 Z( j& A7 J2 ?' [7 Z$ h0 d
* \! K5 t7 Q3 f9 F- int ufusr_ask_unload(void)$ W; Z I0 A' F3 L" C
- {: j4 D& B0 {7 Y& P+ U1 q
- return (UF_UNLOAD_IMMEDIATELY);% ]1 B9 z& L3 Q5 M* h6 P/ M
- }* S P, o6 y: i5 B7 |4 q8 R' j
复制代码 |
|