|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
在集成环境中,NX和Teamcenter的集成中,获取当前用户的组group 和角色 role。& E, K$ L0 v% c# u9 J
P: m8 j1 `; B2 ^
- #include <stdio.h>: d8 q4 l4 D. K/ d8 g# m/ ]
- #include <string.h>, A: o! t% L7 N: i5 x( O l
- #include <uf.h>5 a, r- I4 r9 E' Y
- #include <uf_ui.h>4 \2 k( [7 c1 l, z
- : F; h3 s1 l- p# S+ m+ p9 O
- #include <NXOpen/NXException.hxx>$ U( M2 E1 x' v! E! ~
- #include <NXOpen/Session.hxx>! i- G0 ^- b9 W* z) S* ^" t) s8 f
- #include <NXOpen/ListingWindow.hxx>! D& C! J% Z5 {- Z# o2 I
- #include <NXOpen/LogFile.hxx>- H7 D e9 g! j
- #include <NXOpen/PDM_SessionSettings.hxx>" Q e" v' d; C/ [8 d
- #include <NXOpen/Part.hxx>
5 M9 t5 Q6 J" n% U# }6 z& D - #include <NXOpen/ParTCollection.hxx>
$ D$ Z+ Z5 A. l% { - #include <NXOpen/Session.hxx>
" k; g8 z0 R2 E' f! m! o7 x
9 d; |6 k; Y7 _1 p0 x8 T+ e' b- using namespace NXOpen; // <== Very Important!9 s& [2 {. T S6 `" ?$ S W; A
3 h" b& e- F# h7 g- #include <stdarg.h>
- v! r* ^+ I2 f, |* f1 ]- N
7 y3 v! V: }( w8 G7 A- static void ECHO(char *format, ...)5 Z% t: O% {# e5 j- @0 l. D D
- {7 v7 j: u! j) O3 s# p7 ^7 n
- char msg[UF_UI_MAX_STRING_LEN+1];
( M( P& [: I' W' t! p# ?- j - va_list args;
& G4 X9 H7 [2 I7 z' H: _ - va_start(args, format);
& {0 c4 H, {( [9 f0 ?% W7 B) W - vsprintf(msg, format, args);2 i4 A5 w1 R1 L5 W2 G3 c
- va_end(args);
& B, Y3 t7 P7 N- U - UF_UI_open_listing_window(); q. Y0 i* O: J4 L) i
- UF_UI_write_listing_window(msg);7 o. f# n. N, W* u
- UF_print_syslog(msg, FALSE);
% D+ s$ K7 k+ M4 R - }
h! N" g6 ^2 ?* r* R$ J+ j) C
; Q1 B# ^) N. _$ ^: R- #define UF_CALL(X) (report_error( __FILE__, __LINE__, #X, (X))). j0 e- k$ {' O7 c. l# Z3 }
8 _$ l+ c7 }7 Y/ T. z- static int report_error( char *file, int line, char *call, int irc)
+ [2 Y3 Z3 _6 s" x9 _ - {
* M# T# P$ `- T: t9 i# a - if (irc)! u6 I- f1 E" h0 w, y
- {
4 }! u6 \: K Q, _0 C& a0 A - char err[133];
% k- h- s9 D0 M% t |* m
% `1 d6 d3 ]' A- UF_get_fail_message(irc, err);
$ \$ c+ M9 C- F! a, ^1 D, ^ - ECHO("*** ERROR code %d at line %d in %s:\n",
! {) B) C$ }& \# g. T! s - irc, line, file);
/ V$ o- |4 {% C4 m - ECHO("+++ %s\n", err);
1 l$ w- R( e1 o# C0 b - ECHO("%s;\n", call);8 z4 X6 _; u/ }+ p# ^ u$ Q
- }+ r3 r2 `5 n) H7 E' o6 G
- 0 W( U* C3 u0 c/ z# J+ _
- return(irc);4 C( h( C+ e/ y! d' e/ r% C
- }
. h5 i" d! `* V - 5 {" [+ K' v5 ~, V( k3 f
- # Y5 [" N2 S/ I. X
- static void do_it(void)3 s* N- E T( t: ^: A% s
- {& J/ o( X: h( |( Y
- Session *theSession = Session::GetSession();: ~/ v4 C; _# R5 o( e2 p' ?* b+ I
- Part *workPart(theSession->Parts()->Work());% a# y( a' q! W5 E0 F- t' b* ?6 I
- Part *displayPart(theSession->Parts()->Display());
5 @ l G8 K0 R6 Z* `" t - $ G% _4 m8 R6 E) v
- PDM::SessionSettings *sessionSettings1;) A8 T# ]3 T4 D, j
- sessionSettings1 = theSession->NewDatabaseSessionOptions();
! `) [ c0 s' y& ~ -
' ? G3 G, x$ o/ t$ A* ?. k - NXString CurrentGroup;: w2 x; Q2 Q3 D4 c6 d" W
- CurrentGroup = sessionSettings1->Group();
/ s1 y5 ?' r' R- D; ?4 p6 n9 V$ G - : ]1 l0 ?3 @; l" Y
- NXString CurrentRole;
4 Q/ k9 k3 Z V( t9 P3 F- v - CurrentRole = sessionSettings1->Role();$ c6 L, j% G8 S
- 6 }# [4 M, f* p" \" b/ J. ^
- theSession->ListingWindow()->Open();
3 c6 F1 w: e Z) A4 P$ z! V - 6 w ?/ d' z9 Z' Z- U
- theSession->ListingWindow()->WriteLine("Current Group: ");( E: D! w* d$ X4 u: G+ J$ d# m: I
- theSession->ListingWindow()->WriteLine(CurrentGroup);
4 k8 i6 }7 `8 {0 U- R# F. |( q) R; D: T - 7 X0 j8 p) ^# q& |8 r8 w
- theSession->ListingWindow()->WriteLine("Current Role: ");
1 J/ O m+ V7 d8 W! D! q - theSession->ListingWindow()->WriteLine(CurrentRole);9 C5 F. ?" }3 x, L. ]/ C% i0 ]5 ?
7 y& x9 w, A" ~% h- }
* @0 n7 g" H9 c; s
. n5 j F; V) @- /*ARGSUSED*/ g5 V0 q6 ]& y
- void ufusr(char *param, int *retcode, int paramLen)
& b: T( I2 A# x$ ?- _ - {
9 \9 t" J( m- Q - if (UF_CALL(UF_initialize())) return;
$ G, \# z5 i7 }& f: b - do_it();+ y0 b4 n8 Y9 p3 C# r1 T
- UF_terminate();
3 L$ @2 f$ ~. \1 f; r+ Q2 Q0 [ - }: e! X( N; S0 _% V% B8 J2 `
8 x- ~/ w: L3 U, J- int ufusr_ask_unload(void)
5 @1 c6 y+ [; | - {1 v l+ o: I: @2 r/ a% @
- return (UF_UNLOAD_IMMEDIATELY);. h5 A5 q, s+ a+ C
- }
; T/ A1 k0 H- |. n3 ~6 g
复制代码 |
|