|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
在集成环境中,NX和Teamcenter的集成中,获取当前用户的组group 和角色 role。
$ r% k0 c# a) r U+ C% Y2 b" s, `# Q/ h! P% f9 c6 J# X+ Z4 g
- #include <stdio.h>
" E& o2 V+ T6 M- N. G. P0 m8 n. k4 O - #include <string.h>
8 d' n) w" o# N7 n3 {! V9 K - #include <uf.h>
* p I4 f8 K# |8 E7 g - #include <uf_ui.h>9 k: _: {/ K/ H0 _9 |3 t* Z* Q
- g2 j' v( S; e8 R( B2 P
- #include <NXOpen/NXException.hxx>
! v5 T, W- B, U0 ~% J0 ~ - #include <NXOpen/Session.hxx># i, U. I8 M4 K' o" a
- #include <NXOpen/ListingWindow.hxx>
9 P; I1 _$ [# ^' ^- M7 X' A - #include <NXOpen/LogFile.hxx>
. |, _0 N2 r6 ~2 u5 Z, W# C - #include <NXOpen/PDM_SessionSettings.hxx>& I" a8 C! Z0 g" }
- #include <NXOpen/Part.hxx>
4 @" g- l9 y7 F3 v0 V - #include <NXOpen/ParTCollection.hxx>* j9 i7 @4 F( y0 `" ?3 s
- #include <NXOpen/Session.hxx>
$ s' @8 w% h2 B( W& a8 g - 1 }! Z( A* j2 v; c
- using namespace NXOpen; // <== Very Important!
. ?: ^+ x' t7 S$ P) N. y! g, z - # E" H+ ]: `- K! @* V! j
- #include <stdarg.h>. r' a, g* g9 @
, ^% [( l; |& l! u* a- static void ECHO(char *format, ...)+ K& P8 y! f+ z& m
- {' \- N) L& T7 n3 M* b0 [, {& w
- char msg[UF_UI_MAX_STRING_LEN+1];( k% e. {9 }5 M
- va_list args;7 B+ w# R. y- {8 L$ x3 ^) E2 X8 s2 M
- va_start(args, format);
! X1 t8 z! }' W2 T3 H( _# l - vsprintf(msg, format, args);
' p( O$ ^5 Z9 p - va_end(args);5 n) \: u6 b& {9 }% U9 q3 w
- UF_UI_open_listing_window();! p& h( k2 E% E( R
- UF_UI_write_listing_window(msg);( ]2 u; B% i/ }" j
- UF_print_syslog(msg, FALSE);9 _$ s5 |' h$ z) R' t( }2 Z9 Y5 d
- }
p( U! }' j9 y% c# z* O! e$ x
1 k% |! y. H1 ?% T3 E: x; S% H- #define UF_CALL(X) (report_error( __FILE__, __LINE__, #X, (X)))1 ]$ R' `- ?( ~2 f6 B: T! G$ |8 N
6 q3 X; y( e; Y2 |# |: n- static int report_error( char *file, int line, char *call, int irc)+ R( {/ s9 Z# W: K6 K& b/ W
- {
- L8 s1 X4 X! B$ z - if (irc)
T+ c& R# \# @' A - {. h* y+ S9 Y0 S8 X
- char err[133];
! b2 r% f* v" B6 c( U! k - 5 R# }" p" u6 \1 L
- UF_get_fail_message(irc, err);+ d0 F/ J K$ g0 ?/ z! y
- ECHO("*** ERROR code %d at line %d in %s:\n",# @1 k% Y& I, |# W
- irc, line, file);
9 w7 U$ n. D, B8 { - ECHO("+++ %s\n", err);
& \' l0 }. s9 n# { - ECHO("%s;\n", call);: k4 p! s" l5 v& e o; f& Z* h
- }
! I$ ~7 ?& ?" k% k, l$ @: I( s - % q5 g4 ?9 v9 B1 X
- return(irc);6 @6 E2 L9 X3 u8 }/ k+ q4 q
- }. J: Q+ F1 Y* J. h1 { O% |9 M
- 9 O- S$ q9 E1 S
) h, l* k8 {3 w4 I. I- static void do_it(void)" W; p* }" C# R! |0 i! ^
- {
) P& W% M* w" d) m6 ^+ Z v% m, ] - Session *theSession = Session::GetSession();: C! R0 f m0 i$ V( @* V
- Part *workPart(theSession->Parts()->Work());
- Z& _, K/ [, W1 g - Part *displayPart(theSession->Parts()->Display());4 K( }; B. b. e9 r: m& H
- : K; @5 W( Z, A- i# V
- PDM::SessionSettings *sessionSettings1;
( Z* t3 r8 a9 }1 |3 o0 c2 W - sessionSettings1 = theSession->NewDatabaseSessionOptions();
# T- L, f0 f r* T -
/ m$ A/ T" S) t B9 p% A" C: w - NXString CurrentGroup;
. Y+ e" a/ Q h' ?8 \ - CurrentGroup = sessionSettings1->Group();
! b$ N* ~) I. b q% z* s -
6 Y+ C" d8 b3 B. R8 ^9 F! O; p2 G - NXString CurrentRole;9 J# E5 w/ `: c: W R0 p
- CurrentRole = sessionSettings1->Role(); ?2 [7 o# y5 _0 Y% j( {, j1 F; R
- 5 C( ~/ g g w9 O- e- ^
- theSession->ListingWindow()->Open();& x$ k C; F3 {- L
-
- m1 I$ n8 C: H) t - theSession->ListingWindow()->WriteLine("Current Group: ");2 @( V2 `3 B1 P. W: l4 v6 A1 D
- theSession->ListingWindow()->WriteLine(CurrentGroup);
6 B7 W9 M6 S+ d1 v - 0 U2 h) `* ^9 {. D* k- M( I \
- theSession->ListingWindow()->WriteLine("Current Role: "); / X6 a3 V( c7 C6 Y& s- Z n
- theSession->ListingWindow()->WriteLine(CurrentRole);3 \* [# A+ m0 i! X$ V7 h
J' t7 U* \9 `. E- }
+ {6 |1 l1 }3 i2 H( P - . V' e; v1 u7 G7 y7 z% m. t
- /*ARGSUSED*/
. x; C+ B0 R! b$ ]5 Q - void ufusr(char *param, int *retcode, int paramLen)& {: u2 e; z# l# w! i
- {
f8 E7 J2 }8 m - if (UF_CALL(UF_initialize())) return;
8 Y1 h @9 t% \: f2 a3 B2 B - do_it();8 o4 _2 a) G$ r; J5 X
- UF_terminate();
6 r- F, h4 n$ l5 r& S - }
* L6 Z8 l. n8 G) O, I+ K - & J) S s4 i+ Y9 _: b
- int ufusr_ask_unload(void)
% i* I0 ]7 h" p; z - {1 V* }! N2 y5 s4 o- C, e9 ^! _
- return (UF_UNLOAD_IMMEDIATELY);
8 d6 X& m" ?' h" u6 Z0 `. U0 }3 g - }% E" h3 e0 Y: u6 P% m5 h/ [
复制代码 |
|