|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
在集成环境中,NX和Teamcenter的集成中,获取当前用户的组group 和角色 role。
2 Q+ t* \& u) S+ m3 l: C$ b6 ?% S) j; ?8 K o
- #include <stdio.h>
: p8 p' i5 X2 q; s7 w/ g+ R - #include <string.h>
; _, L4 O. I+ ]& C0 I9 n - #include <uf.h>, S) p+ y2 _7 J' M
- #include <uf_ui.h>- s7 Q. ]2 q5 G. j. E9 M
7 O) _% p+ [* s j3 y; z2 x3 u- #include <NXOpen/NXException.hxx>) z% w# G6 }$ Q- |( s5 h
- #include <NXOpen/Session.hxx>
2 u" c" H1 ?6 T& z - #include <NXOpen/ListingWindow.hxx>
+ K3 R7 m3 h% N6 h. k6 f; ~ - #include <NXOpen/LogFile.hxx>
' a: j6 l/ E4 ~" O) \ - #include <NXOpen/PDM_SessionSettings.hxx>
- Z; {! t/ `" I% H7 o; L3 g7 [ - #include <NXOpen/Part.hxx>
/ X0 s. s, L. |% C& S8 J) N( F - #include <NXOpen/ParTCollection.hxx>
! W" P! Q! t2 W - #include <NXOpen/Session.hxx>5 \8 K8 {; a! k# ^( b# C
% P$ |2 }' c/ ?$ y- using namespace NXOpen; // <== Very Important!' {, l; t* q# N! v8 X+ l/ z# C
- # x1 N" b* w0 C2 B* }
- #include <stdarg.h>
# J# u2 B9 c1 U5 c* ?; x% G - . f5 D! H$ \' o$ H
- static void ECHO(char *format, ...)* [- }8 \' j, S. ~1 U H
- {
, _; D, [+ o; \- Q# Y7 { - char msg[UF_UI_MAX_STRING_LEN+1];
( @8 A0 p5 E& X - va_list args;
' [" ^, h! y# h4 g4 J. { T - va_start(args, format);; N% K: u& A& M" o- V' Z
- vsprintf(msg, format, args);
; z! R! F+ p& p, w3 W1 t+ G - va_end(args);" U$ S& O' E6 \ E
- UF_UI_open_listing_window();% P5 G; w9 U' G2 X( u/ d' a; {
- UF_UI_write_listing_window(msg);8 t3 ]' ]# H* `
- UF_print_syslog(msg, FALSE);
9 {" x6 L. a1 F: u - }. _# I4 R* W4 \; {# D3 V
4 e% E- }: G2 c+ m$ W$ x- #define UF_CALL(X) (report_error( __FILE__, __LINE__, #X, (X)))
5 Z( ]4 m/ ?" A- H( U" Q- X - / p* {+ m2 a3 C- @8 t* P) d. D
- static int report_error( char *file, int line, char *call, int irc) J7 n1 F) U: e5 h2 n. Y
- {
- D& X8 a* }% z$ U7 R1 x W - if (irc)
8 O% s0 e, h4 {* c/ b' q1 M7 E9 L1 a - {( b' K9 B- k! D F4 S! ]! h
- char err[133];
" y6 X! i0 @" y) C4 W - 0 T( o; d; H# m1 I9 N
- UF_get_fail_message(irc, err);' r/ X2 P" i; o8 Y
- ECHO("*** ERROR code %d at line %d in %s:\n",
8 P* v% j Y4 F' v G - irc, line, file);
1 O) z- y7 f5 P$ q - ECHO("+++ %s\n", err);
& \2 Q+ \/ x2 R7 ] - ECHO("%s;\n", call);: X% r5 v f5 c% r# S% I6 ?
- }
: K; R/ S6 t3 ^
" c/ }8 H; b, c; u) _- return(irc);
, `2 I9 E5 L7 N/ @3 K9 |0 ` - }7 U( }# T' x7 p) K
. X1 p5 R0 y9 b+ T. c* C! A
" Q) |$ u U+ f( a- static void do_it(void)) w. ]+ u0 {/ M
- {5 F8 l' @( ]9 G* n) O M
- Session *theSession = Session::GetSession();2 Y6 w# V {2 S! k
- Part *workPart(theSession->Parts()->Work());! p5 _# ]+ r1 o$ S8 Y' i" G" u+ g
- Part *displayPart(theSession->Parts()->Display());
5 n2 [6 T& W: x3 O9 L% _7 A: V* p6 p% w -
, B7 w9 F" {/ [) P - PDM::SessionSettings *sessionSettings1;9 P: \( y3 ?2 H0 m; s- f
- sessionSettings1 = theSession->NewDatabaseSessionOptions();; L% X8 v- J, i% u( _
- 9 u4 m) W/ o+ ?+ r- m
- NXString CurrentGroup;' N; g9 r* M2 a" G+ b* K1 {
- CurrentGroup = sessionSettings1->Group();
$ E# w2 N2 Y2 O5 A" @5 z7 l - ; P e0 @" c, M3 E
- NXString CurrentRole;; }6 q% g$ T3 j
- CurrentRole = sessionSettings1->Role();( G' \6 `' r/ v% Z( W: j
- / H, f0 O( ^+ T; ]
- theSession->ListingWindow()->Open();: C# @( C! x* n2 ]6 u( c4 A9 g
- : C; u4 o3 X+ o4 K+ x1 m
- theSession->ListingWindow()->WriteLine("Current Group: ");
* s6 q4 e4 X- E5 _ - theSession->ListingWindow()->WriteLine(CurrentGroup);6 m) M0 ?3 n' {
-
# z$ u: U, Y" C' h+ h - theSession->ListingWindow()->WriteLine("Current Role: ");
8 `3 {$ M* _7 y' t9 |, [ - theSession->ListingWindow()->WriteLine(CurrentRole);
; `; e4 u ]' z: G% U4 C: } - . ]; l( l) Y2 |* x! N& D; G t# g
- }( O9 i, K% @6 t2 W
- 4 {+ c: Y* x0 M; q' M' T% h
- /*ARGSUSED*/
+ ?5 g5 `8 g# c; l2 Y! z( U4 d - void ufusr(char *param, int *retcode, int paramLen): m# \. `7 b; Y/ M0 }
- {2 Q9 U! S* }% j9 D$ S' Y+ a
- if (UF_CALL(UF_initialize())) return;
3 H' A" y) p. u# ]* `2 O6 J) W - do_it();
. k. i) b3 C& m' c5 ] - UF_terminate();
6 G+ k/ @. k5 Z$ P8 o; U! \! m: n - }
2 l& F! u$ n4 x" a( |/ e - # B% _2 j$ a( S6 Q$ `) i0 l
- int ufusr_ask_unload(void)- M. f# I0 p: ]; Z# C+ `/ k
- {
% L0 `' `4 m2 W$ C - return (UF_UNLOAD_IMMEDIATELY);
8 K& ?+ }4 {. o* {# _ - }
, R( I3 P3 o3 L# c
复制代码 |
|