|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
在集成环境中,NX和Teamcenter的集成中,获取当前用户的组group 和角色 role。; B9 c' H9 f* s- ^
+ U8 r4 t. ]& E D+ z& a- #include <stdio.h>8 S% Z- l2 C* F. o; r
- #include <string.h>. p: V3 C1 l/ P. J5 Z1 l, P
- #include <uf.h>
0 e0 r1 o5 y: M - #include <uf_ui.h>, p) @. ~& q- _9 K/ X( J+ K6 e
# j# ~+ g1 O& s9 G0 K( ~1 ~4 c- #include <NXOpen/NXException.hxx>
- e1 o) x6 F. I7 M6 S - #include <NXOpen/Session.hxx>
$ l7 ^1 r+ f% i0 V$ ?0 k* }, S - #include <NXOpen/ListingWindow.hxx>
, x C+ C6 g* o0 @( T$ q" w! v - #include <NXOpen/LogFile.hxx>
/ L) l+ m' ` X0 R9 T0 q9 e - #include <NXOpen/PDM_SessionSettings.hxx>
4 C& {5 w" T* ^* }" E - #include <NXOpen/Part.hxx>' w$ X2 C' v Z: k' b/ I
- #include <NXOpen/ParTCollection.hxx>. F/ ~9 o5 ~- z8 c0 k# l* j7 M
- #include <NXOpen/Session.hxx>) V& ~6 w- w- [0 V. Q
- . _3 K8 j& k0 P6 v7 z) q6 Q- y
- using namespace NXOpen; // <== Very Important!
& O; V9 I5 U9 p6 T- ^; k4 t - : M4 o1 m% [1 {( O H! A0 y7 _
- #include <stdarg.h>( N7 C" w( p6 J6 `8 s2 R" W
- 9 G+ k( N% h7 m& G( k- Z. a' c
- static void ECHO(char *format, ...)* ?( R6 _2 X8 d" V, u7 Z
- {
& Y/ S n: u3 h - char msg[UF_UI_MAX_STRING_LEN+1];
* o8 B7 Y" C$ J1 x; S! `/ } - va_list args;) k' @, y! V m
- va_start(args, format);
2 j, c0 k$ X1 J/ |' \- R& a( a - vsprintf(msg, format, args);9 Y2 Y6 U3 c' w$ `3 d
- va_end(args);3 j3 k0 N& |- {# \! }. X! o
- UF_UI_open_listing_window();
" l. C v- t2 U" w - UF_UI_write_listing_window(msg);
; Y. ^" `' b* e# e2 i - UF_print_syslog(msg, FALSE);: {8 ?6 l* R: i9 ?9 `: V
- }
6 K6 H( L( y, k+ r- A0 j/ ?* B5 k - & W1 r6 T+ u2 {6 d* ?! D% E9 s: K
- #define UF_CALL(X) (report_error( __FILE__, __LINE__, #X, (X)))
F4 @, w; E9 Q" U6 ~( c& W. D - 6 o7 d0 L$ ~% J% |. H
- static int report_error( char *file, int line, char *call, int irc)& W& b# F6 Z6 m2 U- m5 b4 F
- {
# e. W3 f0 ?6 J5 A9 Q( `8 R - if (irc)" [( X; ]8 J, T) H- H7 M/ B1 G4 L8 Z1 C
- {
5 y* a( ~4 N' k+ T; K - char err[133];
2 J9 B7 H: n) g8 j+ i C# S- h" A: T
6 v$ h8 C) ]" A- UF_get_fail_message(irc, err);; m& R- i. e$ [! O
- ECHO("*** ERROR code %d at line %d in %s:\n",
* |# A3 A6 A" m" c - irc, line, file);
0 u9 l: r9 m- c8 `7 G - ECHO("+++ %s\n", err);- f2 [' K, [+ ]! ?1 c
- ECHO("%s;\n", call);$ s! ^( W: w$ Q/ K% [: L
- }# W7 S% z8 k0 U- o0 }0 D7 q
: o7 }4 d: U* {- return(irc);# a2 l2 \/ Z8 W3 J& s! A( x) F
- }
) V+ |3 d3 y8 J/ t
% W J8 w, B9 H- : Q/ a9 X' U2 J8 i! E
- static void do_it(void)7 ?3 _3 x! O/ o4 w8 ?3 p& g
- {6 Y% D. R, G: V+ F
- Session *theSession = Session::GetSession();
: O* [3 f5 a$ g; {4 O8 B- o9 B( U - Part *workPart(theSession->Parts()->Work());% H6 Q# e: f, h5 ~
- Part *displayPart(theSession->Parts()->Display());3 {; f8 x/ J I8 O9 g0 S+ N
-
, ]4 N1 u! G& Y& _: T - PDM::SessionSettings *sessionSettings1;; e" N7 V9 [- ^0 O
- sessionSettings1 = theSession->NewDatabaseSessionOptions();# I3 @1 w4 i0 d+ F+ c8 y K
- . H' h$ V) E% d* @, ]' c4 ]
- NXString CurrentGroup;, V5 ^( |: X2 T# X% Q
- CurrentGroup = sessionSettings1->Group();
, E3 s. @( H, T: l - ' L1 Y1 u. [) p) k1 W [" K$ C
- NXString CurrentRole;
& D7 `7 m8 a2 G B - CurrentRole = sessionSettings1->Role();$ I) O4 H- i! |1 X! ]! d7 @1 y
- 8 u- b4 h( R# i+ n
- theSession->ListingWindow()->Open();
7 X8 g9 { a8 {. z - 8 C4 m1 |) h7 \/ X+ J
- theSession->ListingWindow()->WriteLine("Current Group: ");
* M1 ^! g# g0 G2 k+ P - theSession->ListingWindow()->WriteLine(CurrentGroup);9 |, }9 O8 C0 A7 o
- n; w: F g9 r. ^% b
- theSession->ListingWindow()->WriteLine("Current Role: "); / q ~7 k. p+ l) T
- theSession->ListingWindow()->WriteLine(CurrentRole);6 u6 n: |' J9 D) e) Q2 V2 P
- * k( E0 E `2 z# s/ }7 @ Q- D- x
- }" G/ ]! W: u3 M- ]
1 |0 |: D7 G- {2 V- /*ARGSUSED*/
9 m4 l6 M- R" l9 _ - void ufusr(char *param, int *retcode, int paramLen)
! @0 I! y0 N6 `+ X, G, j0 y - {
) I6 F1 {. _$ p) D% e, n - if (UF_CALL(UF_initialize())) return;9 J! l; Q/ n7 h. |$ d% D! D
- do_it();
& |4 H; w4 U0 g9 E6 P0 m - UF_terminate();0 R- `: O: M" X# s. n$ L9 o: p
- }+ Q. |4 O1 D) T9 Z
- ; R8 {; [+ m. M3 Q- i$ k$ a
- int ufusr_ask_unload(void)- j+ @% I% P1 t7 {* E
- {
* C0 i4 C0 w9 W8 `, b7 L) ?/ d* [, ~* ^ - return (UF_UNLOAD_IMMEDIATELY);
; W, q3 P8 K# j; y* S - }( W* o3 H& P1 \1 w/ M! \! \4 h
复制代码 |
|