|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
在集成环境中,NX和Teamcenter的集成中,获取当前用户的组group 和角色 role。0 G h Q; G; y& D+ @& v
4 q7 E; k' E$ N1 r/ K6 Q/ ?; C- #include <stdio.h># q3 i' B% c) R2 h
- #include <string.h>
) \* k* ^% H7 A" v; z$ Y - #include <uf.h> N) x9 K3 A! s) ~' I3 r- ^1 G9 O
- #include <uf_ui.h>1 H: t( s2 \* C, m$ z
+ v! T% @0 x; F2 N- #include <NXOpen/NXException.hxx>! R7 p! R/ M% I' k7 O0 q' W
- #include <NXOpen/Session.hxx>
1 d8 I6 k8 J6 [$ k - #include <NXOpen/ListingWindow.hxx>
: r6 K7 r4 P8 s - #include <NXOpen/LogFile.hxx>
% \; v% B8 }* E. R8 n - #include <NXOpen/PDM_SessionSettings.hxx>
* B# f6 T# k5 p- ]5 h - #include <NXOpen/Part.hxx>
/ Z7 V" {) n/ v4 O6 }% r2 }$ u - #include <NXOpen/ParTCollection.hxx>
; j8 c% \" Q( N$ o - #include <NXOpen/Session.hxx>
e/ Y! y" a9 B8 @; J& M - ! w$ i" p. \/ h2 {" ]
- using namespace NXOpen; // <== Very Important!
. G2 D" Q$ C `) s - 3 ]6 P( L2 U4 G, J
- #include <stdarg.h>
8 \/ |3 L$ J2 a! | - % h$ G5 Z. u2 J5 d" a5 O0 f
- static void ECHO(char *format, ...)$ m2 r" d {* K5 m6 d
- {8 u# k1 ^% M' M6 w
- char msg[UF_UI_MAX_STRING_LEN+1];
! P6 M5 a& T% E; S3 X( L - va_list args;# [0 V! S& f* k
- va_start(args, format);
# `3 J' _' x, U* i& e) w" e - vsprintf(msg, format, args);& F, }8 m7 x9 `9 N/ ?
- va_end(args);/ l0 m( _4 m) N$ |7 N; a
- UF_UI_open_listing_window();5 u" d/ ?7 {! h: n0 m& J1 V8 I
- UF_UI_write_listing_window(msg);
0 z( W- j. B" h% o8 A$ T, l1 I - UF_print_syslog(msg, FALSE);; z. e* g% O d5 ^; s6 w1 }
- }
* G0 M; s: P9 E1 a( ?& w/ z - $ e: p6 V5 K# o
- #define UF_CALL(X) (report_error( __FILE__, __LINE__, #X, (X)))
e0 \% L1 N. L/ ~6 N$ G9 K - 6 Z4 C/ m' `. F9 a1 d9 u
- static int report_error( char *file, int line, char *call, int irc)
7 v8 _% V6 J; k - {
, ~& t0 M: }) G1 {* r - if (irc)- P( n$ D y1 r) ?; }
- {
; ^+ I1 w8 r7 S L9 ?, U9 E) Q, ~ - char err[133];; ?8 K$ N9 i2 ? z$ c8 w8 P' W
: F" ^! i0 l# P! r9 `- UF_get_fail_message(irc, err);
# i9 D) C$ ?$ x; |& y - ECHO("*** ERROR code %d at line %d in %s:\n",
" A+ }7 [5 U) @" l - irc, line, file);
6 R' I7 v, L; t) {. a s - ECHO("+++ %s\n", err);" o/ O" ~0 G- k. ?* h+ C
- ECHO("%s;\n", call);; C2 P5 f X; A/ P& H
- }
. B& j5 C/ `6 T# @( n: n
$ P; Y0 f* H; {" H6 y- return(irc);( p- H) i' x9 R3 o2 W" l! ~
- }
0 \4 m# @" h1 h* j4 h$ M8 K! Y
6 x* c9 q; p N* p7 J1 Q
3 g" l; Q: }0 C* I8 \- static void do_it(void)
9 _. m J1 O/ Y8 G& S - {5 X5 Z: z% T% g" K0 x
- Session *theSession = Session::GetSession();* y: z: X/ F- u" G
- Part *workPart(theSession->Parts()->Work());- t, r2 j+ W' Z& _+ L
- Part *displayPart(theSession->Parts()->Display());
+ }0 c, o, n1 j& O |! ]% O -
$ A4 h+ ?, S* b6 |" [ - PDM::SessionSettings *sessionSettings1;0 |6 E: c; y. E* u: j1 \7 Q- C
- sessionSettings1 = theSession->NewDatabaseSessionOptions();
8 ]- l9 A/ R7 _, G4 F5 [! v$ y -
4 |; `# [) l1 Y - NXString CurrentGroup;. B- G. l, \) ? F: F
- CurrentGroup = sessionSettings1->Group();# E) M) L2 u8 D0 w' D3 k- e6 o/ t: x
-
( V. o, v: e: s) \ - NXString CurrentRole;; [5 u! d9 D4 R2 }
- CurrentRole = sessionSettings1->Role();
, Q3 S% v$ J: o/ K9 @" b. m; i
1 D8 A* f' D8 j( Z8 o- theSession->ListingWindow()->Open();
( e" ?. `. | L8 M+ n$ { f6 I - + G! X& h; D$ B* [; q4 \4 p) S0 Q1 W
- theSession->ListingWindow()->WriteLine("Current Group: ");
* z) k8 @9 g8 a$ o - theSession->ListingWindow()->WriteLine(CurrentGroup);
. \* [# H* f6 U -
7 T8 b1 Y: p/ _ M9 P7 ~; v, z - theSession->ListingWindow()->WriteLine("Current Role: "); ( a, `/ n+ m9 A& S# {3 c
- theSession->ListingWindow()->WriteLine(CurrentRole);
0 n$ J1 U! A+ T2 h6 W/ K% o7 f2 q
- Q5 x+ S# r/ p; K% ^& s- }0 H, W8 e4 {0 F* ^' o0 S
6 p( {; z/ a! g* }7 b- N0 u/ x/ M7 M- /*ARGSUSED*/! z# d; [" Z4 L* m1 |' M
- void ufusr(char *param, int *retcode, int paramLen)6 _4 G+ I' I5 E8 I/ N0 o7 S
- {( c2 j( X) i7 P
- if (UF_CALL(UF_initialize())) return;
" z* {4 R3 R e - do_it();
p( O$ u0 z4 J& u: w# b( P0 P - UF_terminate();( k# K8 D5 c: C
- }& l. E% w9 Z+ C; L0 }
- * ^0 {+ M/ h- }4 Z
- int ufusr_ask_unload(void)
5 V+ K! x5 S2 U' C - {1 V( x/ ^7 B5 m* n% I. Y/ c0 m
- return (UF_UNLOAD_IMMEDIATELY);5 N) H8 K. J" U8 g; V
- }
* {: K0 ^6 k# t( F7 P7 m7 x" J
复制代码 |
|