|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
在集成环境中,NX和Teamcenter的集成中,获取当前用户的组group 和角色 role。
) S4 P1 T( g8 `0 @" `; o. `4 _
$ @* R% H' _6 M: q/ h) M- #include <stdio.h> F# r3 A! S- f; S
- #include <string.h>4 a3 m# }. Q+ W: a6 I
- #include <uf.h>
8 _6 p4 q2 q* w) A - #include <uf_ui.h>
7 L. R9 d- a, E - 4 n% S6 L0 t: u8 f0 t" C3 N
- #include <NXOpen/NXException.hxx>/ A! v- z+ @) S4 s- t
- #include <NXOpen/Session.hxx>- e& M$ K* i; K
- #include <NXOpen/ListingWindow.hxx>
& i8 {& s. N/ p, o - #include <NXOpen/LogFile.hxx>
/ _7 c; |2 ^! _1 ~1 p - #include <NXOpen/PDM_SessionSettings.hxx>+ p; K" \! `, N6 y' x+ }
- #include <NXOpen/Part.hxx>
* Z2 G8 A, X" C* r' k - #include <NXOpen/ParTCollection.hxx>
5 h( o+ m* Y( Z' ?+ |& c - #include <NXOpen/Session.hxx>
% d+ O" W4 c: n+ S! z% x
" E- g! F% R: n2 w. T- s6 f- using namespace NXOpen; // <== Very Important!
" j R/ u6 R& M1 d$ a/ r/ p' C8 \9 j
; C2 y- h. W! V# {1 i& S6 f* W: @" X3 q- #include <stdarg.h>
* ~ w" M4 q) M; x9 v# U
# E& O- B7 Q$ Q1 l: f( J- static void ECHO(char *format, ...)
4 B# {, W7 h* h8 C6 A9 ^5 f i, c2 ~ - {
L+ C" w* U' l - char msg[UF_UI_MAX_STRING_LEN+1];. h& G9 n8 x' T. u `
- va_list args;
6 g' W! _: i3 f! L4 V- T9 p1 j! D - va_start(args, format);. d" ]4 ~4 Z8 D- t
- vsprintf(msg, format, args);6 G6 }6 y5 s( J2 i( ^" s
- va_end(args);
9 b/ a9 e" x5 ]- }3 o n - UF_UI_open_listing_window();/ Q( o+ M1 k! \* o U2 a
- UF_UI_write_listing_window(msg);
; D6 w* V% ~, p5 r4 o, v1 \ - UF_print_syslog(msg, FALSE);# H+ M9 B( h8 E# L# Q4 e
- }
+ b) e0 }9 ]3 l5 j - 7 W8 j+ j; p" c1 k. S$ Y
- #define UF_CALL(X) (report_error( __FILE__, __LINE__, #X, (X))), x9 D+ D+ K) y0 y4 _% Q
- 5 z- b* t+ j7 I# L8 N) Y
- static int report_error( char *file, int line, char *call, int irc)
& ?# L/ A8 x+ {* I# S) {' n - {& W8 x) I. Z0 ~- A" ?0 @9 H
- if (irc)$ D+ g+ i' b- m* ]5 l. C
- {
L7 s) ?. v1 k" s - char err[133];
+ |6 m( s; f0 \5 w# g2 t - 7 n( ~* l" U+ y) r! M
- UF_get_fail_message(irc, err);
0 y) Y! y/ ^/ {$ r - ECHO("*** ERROR code %d at line %d in %s:\n",8 _. j3 S. p; q$ r2 X3 C' y! p' ^
- irc, line, file);
3 O* ~" [) A( t* W" I3 w4 q, J - ECHO("+++ %s\n", err);
) X$ {6 E; I6 D9 }( | - ECHO("%s;\n", call);
8 y5 [+ t* X+ f' U: T! { - }
( O: D' S' S Z* C. [2 _- m - 7 g- P X) A g7 w
- return(irc);
8 s1 y7 H6 b: A - }
- x1 j/ ^9 q( H" e2 i; g# k
+ s/ | a% T; ~( I) |! A" z8 |- " D( A3 G- |- O: J( M* g
- static void do_it(void)
- e( b4 H S, r, y4 y - {
z" p7 p& `% |, C# i - Session *theSession = Session::GetSession(); A K5 R: S) K% }8 d9 v0 Y% @
- Part *workPart(theSession->Parts()->Work());" j2 [) y/ S# ^' C
- Part *displayPart(theSession->Parts()->Display());; X5 |: g+ S/ z6 M2 b7 b# k
-
) b# u) [: }, E+ v5 Q& N- X( G - PDM::SessionSettings *sessionSettings1;' Z9 R$ Z8 Y' t4 W
- sessionSettings1 = theSession->NewDatabaseSessionOptions();* E7 L3 i/ i" r, v2 _ N, \( ^7 ?
- , h9 t8 C3 ?" ^# a" w2 w# v: |
- NXString CurrentGroup;& T; ] G. j8 k
- CurrentGroup = sessionSettings1->Group();
( }4 i+ {! p1 Z: s- Q5 M( { - F- `+ J0 P. B5 l* n
- NXString CurrentRole;
* `2 S$ I3 {9 `5 r8 z - CurrentRole = sessionSettings1->Role();- Y: B$ l: M7 Z- ]
- & s1 c; p4 S- J/ F
- theSession->ListingWindow()->Open();* y; l! J) R( e9 ?8 r! D @7 W
- $ m, [) r6 ?! J7 P4 Z* K
- theSession->ListingWindow()->WriteLine("Current Group: ");
% U3 s. b9 c. \) I8 C; y" c - theSession->ListingWindow()->WriteLine(CurrentGroup);+ R% b& h' S2 p
- # R( t& u$ N! v9 k
- theSession->ListingWindow()->WriteLine("Current Role: "); + \2 X5 k% d% _- y
- theSession->ListingWindow()->WriteLine(CurrentRole);$ M8 y1 F# @- Y1 T& U
& n6 W) n4 e1 k# i4 G- }* e( |3 s8 C6 f0 o v0 U" g
- ; b; g/ ~" U2 @* {; U8 ^
- /*ARGSUSED*/4 d5 u) }. ^( W, a; ]
- void ufusr(char *param, int *retcode, int paramLen)
: h" y/ I5 H% F* s7 P$ t+ s - {, e* G! B" s& G/ q( p& r% B
- if (UF_CALL(UF_initialize())) return;
d( Z! R7 F9 C( c - do_it();
$ I1 b; V N# G1 g( T0 ] - UF_terminate();- d. T0 K% g3 Z1 y0 r
- }
/ M; o& _' [8 M - 9 T8 ~, e# |+ h
- int ufusr_ask_unload(void)# P+ V& e& d: r4 D8 U4 ?% S
- {
* d/ \7 }/ |" |3 ]1 {* ^# Y; t - return (UF_UNLOAD_IMMEDIATELY);4 U& ~8 C6 |) e. i
- }3 h& Z4 L, M# w2 A) @- a
复制代码 |
|