|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
在集成环境中,NX和Teamcenter的集成中,获取当前用户的组group 和角色 role。
& j" ~5 |; ~8 m {; Y* h' v/ y x3 y6 L( e1 p7 h
- #include <stdio.h>; S" q8 u% N) G! \
- #include <string.h>
8 _% G8 F. g1 t8 f - #include <uf.h>
6 V8 c: G" i; d' z; t( v - #include <uf_ui.h>
8 ]2 W* K7 Y! x5 B1 j/ v
2 N. t9 U, J2 L- #include <NXOpen/NXException.hxx>1 N+ h7 E- m5 G' G- X3 s1 k$ d
- #include <NXOpen/Session.hxx>
* T# V$ ?# C/ m6 N# h" R - #include <NXOpen/ListingWindow.hxx>( B4 _/ A/ x* H! W
- #include <NXOpen/LogFile.hxx>- ?. u- d0 v2 ~' ^* o e
- #include <NXOpen/PDM_SessionSettings.hxx>+ s! K8 u7 @/ P" i( y" t
- #include <NXOpen/Part.hxx>0 s' g, d8 Y' S% F8 m
- #include <NXOpen/ParTCollection.hxx>
1 A" o. }5 N& m: _/ F4 S# N - #include <NXOpen/Session.hxx>1 [- u+ X% P2 H. y4 d
- 9 K- w: ], b% h$ j
- using namespace NXOpen; // <== Very Important!
& p9 G% N0 `5 ^8 Z s, ~6 H! C$ _$ a6 M
+ t8 y" H( j8 |* y- #include <stdarg.h>1 W1 p3 m$ G. Z8 D" R& h
8 _4 v7 ]/ O/ g% d- static void ECHO(char *format, ...)
* S. U; t9 k! ^ - {
; i! [, P/ N, {9 { - char msg[UF_UI_MAX_STRING_LEN+1];
$ F4 x9 I1 W0 w. y - va_list args;% b& v8 |0 Y( _8 `/ A4 V" \8 O3 p
- va_start(args, format);
( ` ?: x7 |$ }& S- o - vsprintf(msg, format, args);
% r8 _9 R- o2 E5 i$ Y - va_end(args);4 Z' D3 _( L8 f0 Z) Q5 _
- UF_UI_open_listing_window();7 H0 X6 V* l; H- T/ |: E
- UF_UI_write_listing_window(msg);: e: M( a; P. q& U( ^$ _* O
- UF_print_syslog(msg, FALSE);
* E& J0 P! {( g6 r: r( ^ - }
4 M9 `4 u' y/ s( B p! {+ q - & N, I7 @( O$ e; F7 z# n; ?; D
- #define UF_CALL(X) (report_error( __FILE__, __LINE__, #X, (X)))8 Y: p5 @: r! q6 K: l$ j; x5 [
- ( g) q9 ~6 K1 H. W
- static int report_error( char *file, int line, char *call, int irc)
2 f- r! c' S+ L G, Y6 ~ - {
3 E' U2 H& _" `7 `$ m( O$ l7 } - if (irc)
) Z1 M5 x" J, ~. A - {
3 O% l- g: W/ b5 D; g6 ] - char err[133];. X2 ], B4 c# L1 v8 { [! l/ B' b6 ^
- ; V) r! |1 e$ u \5 A
- UF_get_fail_message(irc, err);) b, Y) b9 N! C& t' E4 U
- ECHO("*** ERROR code %d at line %d in %s:\n",
1 h( E7 V k1 \; Y) `/ a- _ - irc, line, file);
* z2 ]2 `1 s' V! M - ECHO("+++ %s\n", err);& A# n( V2 [- U- p2 m5 R
- ECHO("%s;\n", call);
# [. u7 u) K/ e - }
$ c. G5 i- p+ P: |- f( K4 ] - $ S4 g- a" X: B8 p
- return(irc);
- J1 [% E" q9 s7 K, m$ \ - }
4 m" j/ F/ E0 y# m% j: x' Q3 d - # q$ w' g) Y: D7 y: o u
4 D/ r6 S; d3 \. D& X2 d- static void do_it(void)
, a( Z4 V X$ ~/ L+ { - {2 Y0 r/ h' u ~+ e! O; J
- Session *theSession = Session::GetSession();3 b! Z) L# k7 ?$ p; B9 C1 k
- Part *workPart(theSession->Parts()->Work());" O5 b- f8 m( s, D
- Part *displayPart(theSession->Parts()->Display());
% ?0 D! ?; p! m! n7 O/ }$ ] - 3 k5 l7 r7 j! B' I. [) V0 x) f
- PDM::SessionSettings *sessionSettings1; J- ~8 U9 _$ `7 ~) r! z
- sessionSettings1 = theSession->NewDatabaseSessionOptions();
- ~2 K6 I) T' h - : E6 b" ~/ P& i* i( x
- NXString CurrentGroup;
/ U; s. A, P2 z2 w! \0 s - CurrentGroup = sessionSettings1->Group();( X4 J1 D' u' j3 _- q
-
% K" e/ R( x& B2 ?7 {# H - NXString CurrentRole;% L' e2 ^8 b" {2 s- M* o+ @! q8 I
- CurrentRole = sessionSettings1->Role();
* I( Q1 T* H$ b l( N - 7 ]: H) z& A* A ~
- theSession->ListingWindow()->Open();
0 j2 `" s+ L/ Y - & R% P1 Y7 r) Q) @
- theSession->ListingWindow()->WriteLine("Current Group: ");
5 S: k6 z" q+ x! X {- r9 ] - theSession->ListingWindow()->WriteLine(CurrentGroup);& d& I) d, `5 O% m9 Y3 R+ G
-
, b M; \; z' A& y. f+ ] - theSession->ListingWindow()->WriteLine("Current Role: ");
/ N; C' P' e3 e0 t - theSession->ListingWindow()->WriteLine(CurrentRole);
6 t5 |. P% z" o; ?5 J( X - 3 o9 a( V$ {2 m
- }
* u- j$ ~9 O4 ?6 m/ Z - 1 j% ]& Q, ?; P9 i- R
- /*ARGSUSED*/ N" g! Z) H0 E' k# g- `
- void ufusr(char *param, int *retcode, int paramLen)' G7 H$ ?! d+ M k m8 |
- {
( C2 f F9 y) X' G8 H0 d! D - if (UF_CALL(UF_initialize())) return;8 u% E4 `! n6 `2 K4 n5 X' v
- do_it();
0 j. t! W$ s# o4 m, j. U- ] - UF_terminate();* L& E& I5 m$ u+ |; B5 V
- }
& I+ X0 n, o. s - ( ?) y/ U6 y' f% }
- int ufusr_ask_unload(void)4 F. y! ?4 ?2 f9 \5 ^( z
- {* |( s m5 t6 ~- T
- return (UF_UNLOAD_IMMEDIATELY);& n9 K/ c' H# c" h7 U
- }
; v9 v3 A! j. C4 @5 ]
复制代码 |
|