|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
在集成环境中,NX和Teamcenter的集成中,获取当前用户的组group 和角色 role。
2 y- j# s e! a( h- n$ v4 Y; Y9 _4 ~& K/ J4 N6 l
- #include <stdio.h>: O1 ^3 M* w9 Q0 K
- #include <string.h>
* L2 m. s/ Q2 Z$ L, }8 ]$ \0 w5 ^5 s! E - #include <uf.h>. \* S6 F0 x4 p6 K
- #include <uf_ui.h>
2 D }, k' X. O" ?4 e/ I - " G* W8 |& K* J3 j* N
- #include <NXOpen/NXException.hxx>/ i8 g! W3 f/ F+ O
- #include <NXOpen/Session.hxx>
" a" |$ s: d- j# z$ e - #include <NXOpen/ListingWindow.hxx>; k T: p+ f5 ~! X- I1 n
- #include <NXOpen/LogFile.hxx>
9 K' j" u; N' _7 r) D - #include <NXOpen/PDM_SessionSettings.hxx>
) ~, Z1 @* l1 J2 |( r - #include <NXOpen/Part.hxx>; m: F0 ]& T5 I) r
- #include <NXOpen/ParTCollection.hxx>4 X1 [6 M3 i9 m3 ]6 K
- #include <NXOpen/Session.hxx>0 k$ S4 \, i" F4 E, v) x
, `# h: b4 C; s9 k- using namespace NXOpen; // <== Very Important!
; R7 _. f3 g0 v3 f% T
+ g9 X: X6 T2 m5 ^) ~0 A- d- #include <stdarg.h>
/ u! `1 I. u, B, S6 I3 r
; w2 o- ^2 L2 H' F- static void ECHO(char *format, ...)
: F7 E, T C, n - {
: ]2 l2 I# F7 Q" q2 L" } - char msg[UF_UI_MAX_STRING_LEN+1];' c. O# @* C3 i- |+ G3 w
- va_list args;
3 t* T% @1 t y! g3 `9 ~! { - va_start(args, format);* Y& [$ `/ _2 l: i% u) Q5 N
- vsprintf(msg, format, args);3 v1 ^5 [) p i- j( b
- va_end(args);
5 \: b) |- g# C - UF_UI_open_listing_window();
2 W& D: T3 X" w) b/ j' O0 | - UF_UI_write_listing_window(msg); F$ C* q7 a% O
- UF_print_syslog(msg, FALSE);- ?4 }, |6 Y) _
- }( ? R' u# r2 W* Y3 g
- 2 u! c! I: {* c2 O3 t/ v
- #define UF_CALL(X) (report_error( __FILE__, __LINE__, #X, (X))); {8 G8 i. Z" H% w$ e* n
' Z( J% E) Y. } @; ^# H) C- static int report_error( char *file, int line, char *call, int irc). L' f; m% l, d9 ^& |) [- t
- {
- u' Y+ x/ e( V C9 P - if (irc)
( P; _7 d$ h' C3 E' I3 w+ ? - {+ ~7 V) u. o$ B- m. ^
- char err[133];$ g, J' q0 u4 q, T* w+ w0 E
@; E( L( m# u$ C3 ^; S% G; r- UF_get_fail_message(irc, err);9 }& a- l3 g9 s& s5 N
- ECHO("*** ERROR code %d at line %d in %s:\n",
, T3 r* H/ _: y+ R - irc, line, file);
. H0 ^( ]! d. g3 s - ECHO("+++ %s\n", err);+ Z! y8 p) v4 l& W, ~4 B
- ECHO("%s;\n", call);
# r3 u' b% f! a - } E" y! N/ ?; m8 P# Z! z
- 1 W6 C, Y$ o" k+ S2 G/ R6 Y
- return(irc);; X6 _, R# M% ^& p* `# N- r+ Z
- }. a( U t7 `- I1 ^; L) F
( N$ Q0 D% E9 V
+ @: i( \ c/ v8 @) p/ P- static void do_it(void)
$ _2 H9 X" _9 K7 L - {
8 _6 ], @6 }! x& @. k1 b - Session *theSession = Session::GetSession();
+ E/ Y$ ]0 a: `) t: | - Part *workPart(theSession->Parts()->Work()); f; T/ y# t+ A! H
- Part *displayPart(theSession->Parts()->Display());
6 Y/ ]& B- g( q% ` P" ] - 9 T7 v% t2 c2 o$ L
- PDM::SessionSettings *sessionSettings1;& {' m/ ~- S# z* v1 u" {) B
- sessionSettings1 = theSession->NewDatabaseSessionOptions();& Q5 c& ~% V, f& {9 R4 {& a V6 o
-
7 I1 S3 C5 ~1 L$ ?4 q4 B3 m - NXString CurrentGroup;% i) O1 C& o% Y$ V, Y
- CurrentGroup = sessionSettings1->Group();, V- K/ a8 U$ [ U! N8 M' Y
- 0 d; {( O0 _) q. u
- NXString CurrentRole;
: d' Y6 X8 e) e4 a - CurrentRole = sessionSettings1->Role();
) s) f" I% H3 t - 4 n3 v5 F9 c1 H( N% ]
- theSession->ListingWindow()->Open();9 p: e5 l) _9 l7 s; s \
- 6 n1 [6 p+ s9 i X6 p. C8 U
- theSession->ListingWindow()->WriteLine("Current Group: ");
' F" T8 Z8 b) W# f! A3 N - theSession->ListingWindow()->WriteLine(CurrentGroup);& C/ D* H, r8 W. A
-
: {$ w7 z; E3 E% h1 e1 i0 g" F - theSession->ListingWindow()->WriteLine("Current Role: ");
8 [3 x% z8 m- C! C' t% |$ ^8 q - theSession->ListingWindow()->WriteLine(CurrentRole);
6 p8 V, `! `4 N# d
+ ~ A8 N* w! k3 l- }/ I7 ^% i9 V+ @9 X* R
- ; ~* F8 D A" e
- /*ARGSUSED*/
; `/ i* Q2 V) w$ M) v* U5 V9 ? - void ufusr(char *param, int *retcode, int paramLen)9 z" [2 s! w1 [. c# M
- {
- s: |5 J. d4 z5 W s$ ^/ \ - if (UF_CALL(UF_initialize())) return; e8 a3 ]& G& V! d ^6 I2 {* @; S1 Y* Y
- do_it();1 q C; ^- [8 I6 m) e
- UF_terminate();
, G* \6 I: O: b2 z1 w - }& r4 u; h) ?/ A# Q9 d9 ^
; J) F, b4 _! ]2 e8 |8 w- int ufusr_ask_unload(void)
5 u4 p5 \! R* ^3 b& v* R - {0 `8 h" p0 I6 @/ ]& J
- return (UF_UNLOAD_IMMEDIATELY);* U# o$ m7 v0 u+ z2 m; ~" P
- }7 p9 x) i) S7 ~
复制代码 |
|