|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
在集成环境中,NX和Teamcenter的集成中,获取当前用户的组group 和角色 role。
7 n' ~. w3 T8 p6 z, y, _2 t# x5 H# E8 H9 r; Y/ S0 Y1 c
- #include <stdio.h>6 J" i; C; e' n8 l
- #include <string.h>
8 B: [7 {) C# Y- ?2 j - #include <uf.h>+ Q( b: ] p3 m3 u4 |( a: g
- #include <uf_ui.h>3 \( E6 z$ `/ K
- ! W/ M& z. y, g" F# O
- #include <NXOpen/NXException.hxx>
5 l/ @2 ]4 ^" I0 A$ v7 d5 F/ x* W+ I - #include <NXOpen/Session.hxx>
/ k- _* [. D* E5 o - #include <NXOpen/ListingWindow.hxx>
" O" L$ F" Z% [9 o( ] - #include <NXOpen/LogFile.hxx>
$ O8 [5 Z" E# a3 B - #include <NXOpen/PDM_SessionSettings.hxx>9 X" k( \! o# O: h
- #include <NXOpen/Part.hxx>
& o1 v* m/ z1 W4 x" \; f6 o% L - #include <NXOpen/ParTCollection.hxx>
, X( y* p0 e) O% `. }! L4 U0 M - #include <NXOpen/Session.hxx>$ l L: W* T& i8 c5 Z
- ! S% a" r* e( z0 v: C, t
- using namespace NXOpen; // <== Very Important!
! r* d# j" B- O6 u& l+ ^ - ) A; [5 l% I4 Q
- #include <stdarg.h>
9 B/ p8 [; C! {" Z+ a+ ^2 Y, z - 3 k: T" o' g( W) Y# S+ _
- static void ECHO(char *format, ...)
9 X8 G' |8 [* l; n% P$ k6 [ - {
/ |$ E$ a/ B& \- E0 W9 \ - char msg[UF_UI_MAX_STRING_LEN+1];5 D" _0 Z- d% l3 s$ z; {
- va_list args;
- Q) J% Q. E! i - va_start(args, format);' w0 X0 k" h" Z4 B2 ^( ?- {7 V
- vsprintf(msg, format, args);
$ v3 g7 J# o1 T5 ^$ q( L - va_end(args);- x; T/ w$ [% [+ k8 G1 O
- UF_UI_open_listing_window();7 j. t# ?) g( ?4 N! s+ x
- UF_UI_write_listing_window(msg);
6 l+ h3 a, [8 r7 ^1 c9 N - UF_print_syslog(msg, FALSE);$ a2 ^' ?2 ^/ `5 ~0 d0 T, s
- }
; [$ s& t/ t* b! ~( U3 B - % z9 ?9 Z5 X3 l/ i
- #define UF_CALL(X) (report_error( __FILE__, __LINE__, #X, (X)))
{ j$ x( e2 a, y - 1 N7 S- Y4 O3 D3 n, V# Q
- static int report_error( char *file, int line, char *call, int irc)# v. S! T X; u1 b$ C9 C
- {
' G# e( A5 y6 U6 O+ P- p& x# N - if (irc)
" _* e. H& D6 p$ g' ] - {
$ v. m! \" k' N: d# R5 k - char err[133];
5 U- v0 V' ~1 R! N) N
2 C( b- T3 e# |. G/ w2 ~- UF_get_fail_message(irc, err);
! K) |' E/ \: r" }# Y( u - ECHO("*** ERROR code %d at line %d in %s:\n",% Q9 v* E; h+ [9 y' T: c4 i
- irc, line, file);
, M* V2 d3 G7 y% l7 _& ` - ECHO("+++ %s\n", err);; V: b) h3 i7 ~) _! a9 A: k$ a% b7 g
- ECHO("%s;\n", call);# v7 x, f, z: R) l P3 R
- }2 g0 \7 F) ?, X
& c0 R1 M3 \3 [; `0 U8 E4 ]- return(irc);' T$ q k, U* Q
- }# J5 d& n* U. E. a; ~) l* I
+ c" S& t2 K- c! N( H0 w2 Y" x- 4 i7 l5 V$ y ~5 y j( {! H3 V
- static void do_it(void)
6 V3 {% V5 g1 \) K/ O2 I - {
& k# O+ x6 Z% F7 e$ G - Session *theSession = Session::GetSession();
3 S! r- p! g, D+ y6 O d - Part *workPart(theSession->Parts()->Work());
* W5 r% C" g6 F! b! C - Part *displayPart(theSession->Parts()->Display());
' C( O( U1 d' C/ ~ - , z: e% a, D1 g3 d
- PDM::SessionSettings *sessionSettings1;
# b) v' _2 r7 F+ p. f - sessionSettings1 = theSession->NewDatabaseSessionOptions();+ X7 D/ i. ^+ `$ S9 I- W0 S' Z
- ~" q% ^6 K* o; Y
- NXString CurrentGroup;3 F( X* L+ H# ]4 l3 l9 A) K7 Q
- CurrentGroup = sessionSettings1->Group();
% p5 K8 v5 h2 c2 T+ C8 w4 Z -
/ ]* {7 J9 U" l7 u" o" O - NXString CurrentRole;
) S7 y$ W+ W- \& v: u5 V - CurrentRole = sessionSettings1->Role();
D. N% o+ M" T4 F D6 y
$ T- a- P* ~4 W9 k0 l- c- theSession->ListingWindow()->Open();
) w- C, q1 a1 ]9 {3 d' K% B& | -
7 K- n. n7 ~/ u; o5 J; X - theSession->ListingWindow()->WriteLine("Current Group: ");
' p; q$ x+ _: ?: Q5 w - theSession->ListingWindow()->WriteLine(CurrentGroup);
( S- L7 s/ u" G* d - - S8 O9 z) d' }9 E
- theSession->ListingWindow()->WriteLine("Current Role: ");
( C" J& D8 j% v - theSession->ListingWindow()->WriteLine(CurrentRole);+ L* d; n* z' i
- " V8 P0 a/ S7 f/ l6 a% }7 S
- }
# T1 [5 B% d& _! @0 I8 P - 3 o" H) `) l0 \. l! N
- /*ARGSUSED*/, w% I- o6 b$ \' G
- void ufusr(char *param, int *retcode, int paramLen)
4 } y0 X3 f. a# J4 E! A. R6 K - {5 Z2 o5 J: Z+ `3 V% z2 `1 Q
- if (UF_CALL(UF_initialize())) return;
9 l* ]8 [5 S% s( ~2 `3 ^6 ]9 Y - do_it();- m6 ?+ n; Y0 y' }! y0 [/ i! x
- UF_terminate();
/ x9 H3 X; J) m/ M' ]! w - }1 X: w# v3 A K. ^. N
% I+ n0 o C6 u& \: z& U- int ufusr_ask_unload(void)
# y$ h" n4 m/ O7 q1 j - {0 K9 C& c; j; r8 \8 d6 \- d
- return (UF_UNLOAD_IMMEDIATELY);- y% ~( r& j8 n1 d
- }* B0 I; [8 E9 P' G
复制代码 |
|