|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
在集成环境中,NX和Teamcenter的集成中,获取当前用户的组group 和角色 role。
0 P, I3 |0 T' v0 v( x G' {0 V U u& d9 _/ x6 O5 u
- #include <stdio.h>
6 a: c9 N8 e l6 t5 h0 H: K - #include <string.h>0 T2 K& K3 p5 P( r; f1 d
- #include <uf.h>
! a& U2 Y$ L! X% W3 X1 u - #include <uf_ui.h>
7 m. J' }+ X( ^: U! w9 N: S. a1 l; c
, F$ s+ T$ K4 J" H4 V/ J6 Y" J) O- #include <NXOpen/NXException.hxx> m5 l% z$ @1 N B) U
- #include <NXOpen/Session.hxx>% o* R7 U8 q+ I, }) ^$ _
- #include <NXOpen/ListingWindow.hxx>! G) N# P8 |7 ?. s6 `
- #include <NXOpen/LogFile.hxx>0 m0 {. }9 V9 {/ u
- #include <NXOpen/PDM_SessionSettings.hxx>
- e& V+ r3 B9 m1 r2 o4 S - #include <NXOpen/Part.hxx>- p4 x; _6 H7 R2 s( q- i+ u# B
- #include <NXOpen/ParTCollection.hxx>& I. f; s0 S/ Q+ P2 x4 B/ {. W: A
- #include <NXOpen/Session.hxx>
" T2 u. f0 o" {# q) M - $ z/ k) R' Z; ]- G; p4 K
- using namespace NXOpen; // <== Very Important!$ m2 y1 x {4 J' ]! g) O, G8 E2 R. |
+ y; f6 b6 n" ^0 n& h% i- #include <stdarg.h>. a5 H2 B9 x; i/ ?+ d- y
- . h+ O; F* K: |0 f) ]( i
- static void ECHO(char *format, ...)( z! ^$ d4 V& @3 ^0 ?
- {8 b' U, L2 d- c7 t3 M5 k
- char msg[UF_UI_MAX_STRING_LEN+1];
! P5 X o5 ]( |/ Q. j3 s2 u - va_list args;8 o7 C z: a% z2 {" z" ]& i- g2 ~4 Z
- va_start(args, format);
8 a0 \0 @; B: x- b# P* m1 z O5 x - vsprintf(msg, format, args);$ g s j. J+ K' l7 @7 M
- va_end(args);
5 T# V i! j: S1 f5 j+ D - UF_UI_open_listing_window();
7 w! m. M8 i( ~7 K( p1 a - UF_UI_write_listing_window(msg);
5 a7 J2 e0 s# P3 C8 L$ Z4 U7 `0 r, Z4 B - UF_print_syslog(msg, FALSE);
1 M. O1 C* y, r9 y - }# P2 r% d7 [1 l! `: W4 }
2 n( b. Y; s) v9 ?* t- #define UF_CALL(X) (report_error( __FILE__, __LINE__, #X, (X))): x! X/ ^6 K, v
" q8 r$ k, l8 C9 g- static int report_error( char *file, int line, char *call, int irc)6 N! X7 z+ x& O: `
- {6 f q3 W4 N' m& w
- if (irc)% m& h1 Q2 w: C
- {/ L5 w, f+ p1 } a' X
- char err[133];* _4 l( d0 `, k6 k) J) y
3 r- _3 c1 ^+ u! q- UF_get_fail_message(irc, err);. {! y' H) L( F f1 l3 D
- ECHO("*** ERROR code %d at line %d in %s:\n",
4 Y* N( m0 t4 r2 ~ - irc, line, file);
& p4 o) d) u$ p# p4 L: Y7 m9 i3 b m9 ^ - ECHO("+++ %s\n", err);/ I9 y* a8 [9 C/ O
- ECHO("%s;\n", call);3 A* T9 R; J9 X9 f
- }
2 j$ E4 V8 Z- g, H! M
0 A" C$ ]7 m' P* b- return(irc);/ y2 q% K" P; k: ^
- }- x- ?; G, f/ j+ d( L: U. S4 e
- 9 I$ o3 P! K& M+ Y
7 u N, h% A4 D) [. Q$ m- static void do_it(void)! B& k! F( E. ~+ j+ C0 l3 ]
- {
1 G6 r* ~9 h" E" _! [" e. M - Session *theSession = Session::GetSession();2 I! I9 D" ?1 `; L/ I" L$ }
- Part *workPart(theSession->Parts()->Work());
- U! M$ w5 Y7 X9 z$ y) q& Q - Part *displayPart(theSession->Parts()->Display());% N7 t7 L& U: u, M: M. g: s
-
# `0 Z/ A6 u% g$ g5 w& ~ - PDM::SessionSettings *sessionSettings1;; [ y2 z; C6 ]/ G8 o$ K+ I
- sessionSettings1 = theSession->NewDatabaseSessionOptions();) w1 a/ z2 X1 K+ Z1 l
- ! G. t; \6 l% E0 R
- NXString CurrentGroup;; y) S: X% [5 k: m h6 v1 N
- CurrentGroup = sessionSettings1->Group();
C( Q0 v; f9 O2 E& |# P4 C9 | -
; _0 o/ p s% F2 T% {. s, z/ k - NXString CurrentRole;* {( a: A4 R0 `: d5 _
- CurrentRole = sessionSettings1->Role();
; W& |# u9 c% ~3 `& Q - 8 b% A# a5 Z( X4 p# p! S3 o
- theSession->ListingWindow()->Open();5 F& p& g! e# G' N8 @
-
6 J" D- W0 j. ]7 @ o, o2 s - theSession->ListingWindow()->WriteLine("Current Group: ");
# Q4 ^( c* m+ |( i: v - theSession->ListingWindow()->WriteLine(CurrentGroup);
3 z7 ?8 K* Q, F/ Z* W: q - 6 _3 x% G+ ?& m
- theSession->ListingWindow()->WriteLine("Current Role: "); , H7 S9 X' x# C6 Y r$ h" V
- theSession->ListingWindow()->WriteLine(CurrentRole);2 ?( R8 C% |; |
z4 K! r! |, _9 g- }
0 V- ^6 c- I8 w! O$ S9 A) b - : `# o$ `2 k6 o
- /*ARGSUSED*/
9 S3 ?# z. J1 y7 Z - void ufusr(char *param, int *retcode, int paramLen)2 p- A7 b% X, B3 N! d/ ~, O0 b
- {" r1 z) q: z, E& ^% b
- if (UF_CALL(UF_initialize())) return; T4 }* b' o9 [; A) l. R
- do_it();
1 \, O" o* Y4 U) d - UF_terminate();
" T1 A, u# H& o& J. X7 B - }: b3 a& h0 j" ]* C
, p1 h' v( ?- @; X; E/ A- int ufusr_ask_unload(void); j: A; _% d+ Q- W: {5 v8 P$ ^) a( }
- {
4 l$ J5 u5 U$ C" k6 |6 ]. k/ W0 _ - return (UF_UNLOAD_IMMEDIATELY);8 J- n7 \, w6 c
- }4 ?- j4 b( |" ]/ R
复制代码 |
|