|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
在集成环境中,NX和Teamcenter的集成中,获取当前用户的组group 和角色 role。9 u7 Y7 m- \: Q3 ]6 m
+ h- u. a0 K/ D0 a- #include <stdio.h>
* n. c" @7 A4 U6 o0 p* f# m0 W - #include <string.h>1 E+ U6 a% ?& M4 Z
- #include <uf.h>
% O/ l: x# [2 _! P - #include <uf_ui.h>, i- V5 ~) r `" l' R% W
- 6 h2 e1 Y& ~8 a$ m' H6 q% g
- #include <NXOpen/NXException.hxx>
" T: j6 @8 I! F) \ e, D; W6 O - #include <NXOpen/Session.hxx>
8 q5 t/ F' m5 b - #include <NXOpen/ListingWindow.hxx>8 U9 A X" }' @
- #include <NXOpen/LogFile.hxx>
, V# V/ o& @5 B9 P( O- x' v# L - #include <NXOpen/PDM_SessionSettings.hxx>
( h. K) d4 @ y, g1 i3 `* t - #include <NXOpen/Part.hxx>
8 R9 b9 f/ D+ ~' z, r# V/ c* c2 p - #include <NXOpen/ParTCollection.hxx>. L7 x9 u# R# W- [, W5 e# E8 B/ {
- #include <NXOpen/Session.hxx>% G* v0 q7 p. U2 d+ E: z
; ~* P/ l+ q' a- using namespace NXOpen; // <== Very Important!* O' q$ _5 j3 H1 t' [# X5 Z
- % b: e9 f$ y/ q3 y$ b; h7 k3 O
- #include <stdarg.h>
* ]% x# L) f' s( b - d7 V7 P/ f. p& \
- static void ECHO(char *format, ...)0 I/ @8 q" L$ c$ r
- {, I: d; C! ?- w: ^2 Z; k5 F5 h
- char msg[UF_UI_MAX_STRING_LEN+1];
2 {& j3 M; d8 B M! z h - va_list args;
- W9 g1 V( r0 T3 D5 N, b - va_start(args, format);
' l" H1 r) W* ~ - vsprintf(msg, format, args);" q* v( n* T2 w- b- O8 ]2 f
- va_end(args);9 z" B8 d1 b1 i1 l) y( x- S
- UF_UI_open_listing_window();
- E3 l( R% L/ w1 Y1 U, E3 G/ G - UF_UI_write_listing_window(msg);( q" U& J ]8 y2 q- _$ [& I
- UF_print_syslog(msg, FALSE);
/ N% t* o9 `! `9 \- D" X - }/ N" c' a: g8 W" R6 l4 Z& V4 E
- 0 p! Z! i+ c3 Q$ [. k& U0 h! v0 N
- #define UF_CALL(X) (report_error( __FILE__, __LINE__, #X, (X)))
* C/ c6 s6 V: ?) v
* x1 Z: p2 b6 r3 L3 Y+ O$ d+ t- static int report_error( char *file, int line, char *call, int irc)
/ E7 t. h( o3 G, m - {
{, c- M R) i, r. q J - if (irc); S, t" p. X# X- f9 d( j0 {5 }
- {
1 I% B D7 Z# J0 b) c1 D) ` - char err[133];' `" D1 R; i$ b; Y, l1 u ]4 C% }
- 9 {: w; J' {9 W) l& X
- UF_get_fail_message(irc, err);
}+ H0 g9 ~6 X4 O - ECHO("*** ERROR code %d at line %d in %s:\n",. h) D* ` K3 |9 g l/ }# n. q
- irc, line, file);
# s, e& |, o% x- u - ECHO("+++ %s\n", err);
1 a' J( ?% Z- w) v4 K% j; m - ECHO("%s;\n", call);
* Q" y( T* a% `5 z, L8 Y" q' V - }
8 t8 B* |' ?+ l8 I( ~$ h - 2 n* x0 T; K+ s- e7 B( O8 m
- return(irc);
3 _3 ^* m' M2 Q6 |8 S; o( y - }, A1 M" `4 [8 s# _# }8 L+ }2 `. Z
( ~( X+ t6 P# R- 8 N+ T# `; M4 w y5 G
- static void do_it(void)
& I8 u. x6 G: P! |& Q" E B0 ?1 _" k7 p - {
1 \% A; l/ ~! r1 M$ G+ @2 m - Session *theSession = Session::GetSession();! \7 }6 u: Q$ N( v/ V; B, b
- Part *workPart(theSession->Parts()->Work());7 x9 U& g% i' ?* R5 B
- Part *displayPart(theSession->Parts()->Display());
4 O: v) K/ e; I. A3 g2 o -
+ O% }+ l# p3 o# V4 Y - PDM::SessionSettings *sessionSettings1;6 g( o- V) M3 U: r& \0 W
- sessionSettings1 = theSession->NewDatabaseSessionOptions();
3 x5 r# h! |/ E: l7 t -
, o, t& ]1 Y- Q0 \% N8 x' `. M/ | - NXString CurrentGroup;
) Z3 ^9 l, z6 b) T0 Y( b - CurrentGroup = sessionSettings1->Group();* B" v% s! _/ E
- 6 {6 Q6 i" P4 j; R. E; ~6 I
- NXString CurrentRole;" T7 j. b6 ]. f/ H
- CurrentRole = sessionSettings1->Role();
' U" b! ^% R% U e9 I0 S2 H* U
# b8 F, O+ T: ^; @" d: f- X8 u; t- theSession->ListingWindow()->Open();
, g1 _( i8 {6 `2 g/ `3 N - ( {0 s0 X" O5 P7 i `2 ]
- theSession->ListingWindow()->WriteLine("Current Group: ");
" n1 R$ X) m4 C# f$ o - theSession->ListingWindow()->WriteLine(CurrentGroup);
1 o: G: ?% n: z - / m6 `* Y9 k) n2 h' i6 h
- theSession->ListingWindow()->WriteLine("Current Role: ");
+ J$ ? y! V/ D/ h e: V - theSession->ListingWindow()->WriteLine(CurrentRole);7 D4 q- U. v; p+ |
3 o+ ^8 T. P4 N' f9 u* R: ]# O- }8 M' P) L3 H7 O
8 n P* m5 S1 }! a4 Z8 Q: w6 T- /*ARGSUSED*/+ l4 P/ V' k/ r
- void ufusr(char *param, int *retcode, int paramLen)1 N* q; ~6 R Z4 R
- {. H5 v5 u% q/ s+ D' X$ m$ N$ z
- if (UF_CALL(UF_initialize())) return;) F! b' L2 i4 t$ `! E+ D
- do_it();/ |* ] \9 t _$ V; ~
- UF_terminate();
5 b$ R: r! p2 [" Q, s4 X. z8 O - }, t+ l; W5 ]& T* W. I$ }
- ' w5 K/ N$ p$ b
- int ufusr_ask_unload(void)
* R, s3 l6 r U: \5 n9 e, q2 ] - {* \7 k3 p0 l+ B8 o
- return (UF_UNLOAD_IMMEDIATELY);
6 t/ c9 Q& Q, t; q: k7 Z - }
! Y4 {, u5 z1 u3 _9 N6 M7 p- n) n
复制代码 |
|