|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
在集成环境中,NX和Teamcenter的集成中,获取当前用户的组group 和角色 role。$ g& N* [' G* K1 A. S4 _
) ]* ~# z8 u" j) r
- #include <stdio.h>
' n2 s) v, g$ G - #include <string.h>
. P1 P! C8 w; a$ u! e2 Q - #include <uf.h>; Z' k8 B- f3 _3 C1 d
- #include <uf_ui.h>8 k' A$ P# G4 ~+ Y6 ^, o
L8 ]; j9 z" c- #include <NXOpen/NXException.hxx>
) @7 x. n( E# H4 |( ?. |- z' j - #include <NXOpen/Session.hxx>
$ f9 S* a4 b8 \, y1 C7 } - #include <NXOpen/ListingWindow.hxx>
% m8 J4 A( s- \( ?7 y9 r( c) B - #include <NXOpen/LogFile.hxx>6 m% Y1 M1 Z, c x: J
- #include <NXOpen/PDM_SessionSettings.hxx>7 u& \2 N! U: E% N, X1 {. ~4 X
- #include <NXOpen/Part.hxx>
: g' M9 M4 u. \) V- k' i - #include <NXOpen/ParTCollection.hxx>
, q9 v+ K( E% T& ]9 U. O - #include <NXOpen/Session.hxx>
: @( F$ H D/ m+ x# G. H9 }0 { - 5 ^ X9 H0 T% S3 `8 S3 }2 |: l
- using namespace NXOpen; // <== Very Important!! I. a! b4 A) I8 z
7 w( A3 B" N/ B$ K% J+ q- #include <stdarg.h>6 o9 x! Y' z4 Z& r" A7 A
- 9 a' b$ m5 g- E+ B7 P4 c& u
- static void ECHO(char *format, ...)
0 ~7 L6 i1 ]6 \3 m7 D+ L - {9 W' g0 [0 q2 n8 J/ Y T
- char msg[UF_UI_MAX_STRING_LEN+1];. R2 X0 P6 @" T7 k. _/ ]1 @1 T! C
- va_list args;* F& m+ T4 p. W
- va_start(args, format);
/ T$ M+ n9 I5 P" I" i- K - vsprintf(msg, format, args);
1 V7 {' x$ V' G3 W0 l8 Q - va_end(args);
) x f2 C: y4 t8 L5 r - UF_UI_open_listing_window();8 A/ j$ }1 g& Q- D' |( s3 f
- UF_UI_write_listing_window(msg);) ^) L8 i% h( J( p
- UF_print_syslog(msg, FALSE);# y& u4 \# [/ Z* Y6 P
- } g* ]- b' H" B9 \' j2 q+ v
' t( O% S% K' z+ w' v6 ^; C# H- #define UF_CALL(X) (report_error( __FILE__, __LINE__, #X, (X)))
# {$ N; y/ Y# X; A& M2 { - 0 W z; y* U9 O) A: i
- static int report_error( char *file, int line, char *call, int irc)
0 N' L2 A+ R2 p; i+ X - {
- d* K* i* H, v - if (irc)
5 Y2 ?4 |$ f t - {
& `( x. t N# T# ?; a - char err[133];
% X: M; o9 j+ z7 \2 @+ [' n - ' j* C5 `/ [3 B1 c5 m5 Z
- UF_get_fail_message(irc, err);4 m% X% e4 D1 u% _% h
- ECHO("*** ERROR code %d at line %d in %s:\n",7 S( d8 C' n' j4 o
- irc, line, file);
* |" w) u& |) A- B3 y - ECHO("+++ %s\n", err);
Q1 a7 H9 ?% w# S2 _6 ^ - ECHO("%s;\n", call);
# u! ~+ u9 y0 J* z4 q - }
2 O4 M" ^6 P3 K& I" X& I& P - . l1 e& G# U7 b i |7 v2 f
- return(irc);
& ]1 r1 _* O8 V3 n) j - } }4 X2 V* ^0 M3 @ U
- ' c; n* F d" f6 u5 f$ X: t$ o
* @- e5 _4 k, }- static void do_it(void)
% D5 T q9 r! T - {! k7 m9 m- j X' p4 j" ?0 E
- Session *theSession = Session::GetSession();
$ M9 w Q& }# }3 V1 T - Part *workPart(theSession->Parts()->Work());
: m6 {+ Y/ Q% L* c2 v& V9 x0 b w - Part *displayPart(theSession->Parts()->Display());! T2 e c6 R6 U6 @0 B
- / a: p) W6 M. e" j1 H
- PDM::SessionSettings *sessionSettings1;
. U* `" w+ F: t6 g, K! F - sessionSettings1 = theSession->NewDatabaseSessionOptions();
% W0 R( i& I# J3 I6 C* p9 I( X0 { - 3 ?5 o' H3 A, w/ S# ^- e5 x$ h! q
- NXString CurrentGroup;
/ s& }# X( f0 c4 v - CurrentGroup = sessionSettings1->Group();
; f6 ?3 G: Z+ h -
- D' s, ~$ ]7 ?* i7 T - NXString CurrentRole;
+ `* A* _2 i3 k& V/ K; \% F - CurrentRole = sessionSettings1->Role();
- J% @. c/ j, F% n _' f8 E
8 p x& H9 j( k" @% t( j+ h- theSession->ListingWindow()->Open();7 e% z, r+ i" v' M* B6 R! N* M
- 6 H+ E3 ~. ?, B6 R0 Z
- theSession->ListingWindow()->WriteLine("Current Group: ");
3 D( h/ U( \. k% p" p" O* n - theSession->ListingWindow()->WriteLine(CurrentGroup);
8 R8 o# M! x, Z - & I0 C8 U7 {# c4 X4 s% M
- theSession->ListingWindow()->WriteLine("Current Role: ");
: a0 {& z# Y8 }1 } - theSession->ListingWindow()->WriteLine(CurrentRole);
/ C$ n+ ?7 m A - 2 x9 ~- [; i R( f8 H' o
- }7 L/ T2 C' D+ H% j% k
- - w: ^! m+ R+ F+ P6 n
- /*ARGSUSED*/* z0 \2 V5 m% q6 s+ m
- void ufusr(char *param, int *retcode, int paramLen), T5 g- F6 _6 a) |
- {, q9 O' {8 c" A8 q+ c
- if (UF_CALL(UF_initialize())) return;
# S3 n, U$ [' h& s" `" f - do_it();
7 }. l- Y( p, E. v. u - UF_terminate();, q6 Q$ z; ~* q9 p' i; A! r2 u4 u, I$ g: X
- }
* q- e7 ~0 j* w% G3 x0 \ - # H0 c( r/ y7 V& q4 z
- int ufusr_ask_unload(void)) [7 w6 b# b& @3 l% y/ c4 x
- {5 V9 f5 `$ u5 o4 B4 S
- return (UF_UNLOAD_IMMEDIATELY);& e P) u- R1 _# {+ A- I7 Q6 a
- }9 U& P) c; a! M7 M/ `
复制代码 |
|