|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
在集成环境中,NX和Teamcenter的集成中,获取当前用户的组group 和角色 role。
! q1 t' l6 k w( A9 @) Y
4 M% g! M3 F+ u& m# c. g$ Y, w- #include <stdio.h>1 `- P1 O0 Z9 v4 `
- #include <string.h>
+ t$ K# y1 d5 q5 n! g, `7 ~) e3 U% {" i - #include <uf.h>( I4 F3 Z F9 X* d! M7 P
- #include <uf_ui.h>
2 l z$ M) h2 S! m
" N' C/ ]) e) G( [- |6 z# j: P' D- #include <NXOpen/NXException.hxx>
/ N& H. K5 [% L - #include <NXOpen/Session.hxx>
) F- @# {( L5 w, J4 P - #include <NXOpen/ListingWindow.hxx>
0 X3 N# b1 ]: A' f/ M [' T - #include <NXOpen/LogFile.hxx>
4 Z* n! u1 F% V, K" F4 |+ Z+ p - #include <NXOpen/PDM_SessionSettings.hxx>( A" b* @0 I( P8 j" M2 m
- #include <NXOpen/Part.hxx>; f- q6 ^; K- Z0 `" Q. y( D
- #include <NXOpen/ParTCollection.hxx>
) X# i$ A' o% Y0 c# w - #include <NXOpen/Session.hxx>
! a j1 R# K8 r5 X5 K! P4 _8 d
! \4 g) F' B; _, X' w- using namespace NXOpen; // <== Very Important!
; c: Q6 f' T6 X8 u! ]% z - : p- W4 |9 \8 j( N
- #include <stdarg.h>$ k/ `+ S( W- v* |
4 n7 e8 k* B, n3 W& `- static void ECHO(char *format, ...)$ }+ t1 H. x# u0 ~+ d% C; N( K
- {
' M5 l- l. I/ H& i* H% T - char msg[UF_UI_MAX_STRING_LEN+1];* l- h* p B/ }+ p- d
- va_list args;) c) t* u6 D. t5 r% H( A7 ~; A
- va_start(args, format);7 \! B ^2 [! ^- E6 a1 F1 J9 M- ?" c3 u
- vsprintf(msg, format, args);
+ g2 O$ j$ r# d# ?3 S: _ - va_end(args);
" @# q# [. g+ t2 Z - UF_UI_open_listing_window();
% U/ I- {( q) i: I7 ?2 g) @% o; p2 ^ - UF_UI_write_listing_window(msg);- N5 N& C [$ i# p' X+ K* Q8 @' A
- UF_print_syslog(msg, FALSE);, ?+ r4 C- M/ _1 q0 H1 A0 G. b, h
- }0 h8 ~7 J+ W# Y3 c9 x1 J
6 g( M( T$ Z o0 T' |8 M( ~- #define UF_CALL(X) (report_error( __FILE__, __LINE__, #X, (X)))) Q$ u _' v0 Y
) V3 y- y3 q w) J h, a: h- static int report_error( char *file, int line, char *call, int irc)
) E& p" g0 [, V6 {( u* c - {- P1 x" o% G. g- Q, X# v+ A7 x r
- if (irc)
s8 X7 G& L/ x7 l8 A - {
: y5 |* `7 `! E% V& | - char err[133];! h2 S' M- L8 \( w+ L4 w
- $ A* I0 d" s6 C& _7 T
- UF_get_fail_message(irc, err);" ^$ }% x2 C4 F
- ECHO("*** ERROR code %d at line %d in %s:\n",. ?- B( }4 A8 h% L$ C& n1 e3 {
- irc, line, file);
1 B- w8 i p. D. U- |9 m& k - ECHO("+++ %s\n", err);8 j* j# x+ e3 E% }% V" q+ V
- ECHO("%s;\n", call);
. f' h" p3 p, a* ?. c - }
3 e( e- p6 G N
4 G/ T( |& \+ f, i, b% s) m W- return(irc);- X2 x+ d$ E+ f& B& [4 e
- }
: U8 m- ]& \& @( L/ A! q - 3 `, }( N* t8 W- T9 O% b
9 u I. D& z( X3 X6 b8 T7 j- a B- static void do_it(void)
& t2 s H. H$ v5 r - {
7 Y+ ]4 t! Z( ~7 F* Q7 O1 A - Session *theSession = Session::GetSession();
. t; g" L7 o6 S6 Q/ q4 n5 J - Part *workPart(theSession->Parts()->Work());
& e) w- q' k+ I - Part *displayPart(theSession->Parts()->Display());
4 c ^& ?$ }! l - % h$ N2 v+ B k$ s% s) O
- PDM::SessionSettings *sessionSettings1;
, \+ M# [) e' U; p7 j9 g& T/ G8 c1 f - sessionSettings1 = theSession->NewDatabaseSessionOptions();
9 q/ ^. S' Z9 ^. M( O- Q - + ]0 D( P! M: I: i/ u, k
- NXString CurrentGroup;
, L7 q# x4 m; i' |& y( l/ x - CurrentGroup = sessionSettings1->Group();- X$ a# D+ Z' B. L- v$ X9 _# b0 ]7 s4 e1 P
- ) d# L) w# n1 l& P7 g
- NXString CurrentRole;+ |2 G1 @. d7 o& D/ b3 W6 C
- CurrentRole = sessionSettings1->Role();
* E2 @5 o9 t4 B; \ - ( s4 V/ C, |$ V# f; U" U
- theSession->ListingWindow()->Open();5 L9 ~3 ]& F( b8 V; K) c3 _
-
. i8 T7 X$ P0 Y: x& [! f. s* e - theSession->ListingWindow()->WriteLine("Current Group: ");
6 h0 d* m1 M' z; T# F) t' B0 ? - theSession->ListingWindow()->WriteLine(CurrentGroup);
* k/ d, u# P5 h9 s' \ -
5 g3 P5 v- z' O4 y7 g - theSession->ListingWindow()->WriteLine("Current Role: ");
1 V6 R4 `; A1 l3 Y - theSession->ListingWindow()->WriteLine(CurrentRole);
1 g: d, C+ C* X7 B% Y% a6 F: S - $ i0 b4 b3 f. O* [% Y6 l; ]1 p
- }6 N! r: m5 W& s5 R/ c( m2 B
- ' ^; }- p4 W% G
- /*ARGSUSED*/" U k( k/ c" w- R* m7 J
- void ufusr(char *param, int *retcode, int paramLen); y* c& v# L7 d% E A" F! e
- {
5 O5 Z' t9 M$ x3 |, x - if (UF_CALL(UF_initialize())) return;: C2 y4 t) ?0 o- F0 O
- do_it();
3 E* J3 [$ M; t$ _- T- V8 U - UF_terminate();. E5 C; n5 X: b$ }2 k
- }
# O5 r) }' V1 r* c
% A4 K% n; F ^) \9 q" q- int ufusr_ask_unload(void)
) d0 q, U6 ^' ?( @+ ]8 U) m - {/ V: v" F& n$ R5 \& t
- return (UF_UNLOAD_IMMEDIATELY);
' ]9 F* V l$ M7 [5 P5 v - }: I1 f1 _8 O) C6 t3 Z" F! l$ y
复制代码 |
|