|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
在集成环境中,NX和Teamcenter的集成中,获取当前用户的组group 和角色 role。. [" s0 ^4 E9 m+ N: G# E" C
/ N! l) R$ g8 {5 _
- #include <stdio.h>
3 l/ [2 k) r' N1 W, B* ^% T - #include <string.h>
9 l( x7 n! X# L - #include <uf.h>
/ O" c9 u5 w/ L4 S9 d% }* } - #include <uf_ui.h>
. V/ T$ L \, }" g
) s- V6 \$ D; b3 H) b5 @- #include <NXOpen/NXException.hxx>9 m9 ^6 p' R; ^- ~5 ~
- #include <NXOpen/Session.hxx>
2 e6 w( p& V1 d! L7 b1 { - #include <NXOpen/ListingWindow.hxx>4 T& r4 {4 B# ]% h- `- k% Y
- #include <NXOpen/LogFile.hxx>2 G. R: v) ?% d3 A$ @) Q
- #include <NXOpen/PDM_SessionSettings.hxx>
- @7 p/ Y# Z5 z7 M2 F- T y( o/ G - #include <NXOpen/Part.hxx>, U% F4 }/ j. D4 b" T( Z- |
- #include <NXOpen/ParTCollection.hxx>
0 ^5 t/ @2 x; o% x6 E - #include <NXOpen/Session.hxx>. ?5 `5 A+ y) \
- $ |) Y4 Y" V; M
- using namespace NXOpen; // <== Very Important!7 i% X+ Z8 F0 n, z) b( ~# L# h
+ Q0 H9 h, f4 k- #include <stdarg.h>
0 T* C/ _' o. P# o' n5 v& I# d
, \) e/ q0 O; J4 G( t- static void ECHO(char *format, ...)
. m% p: i! L* d - {* Y1 x5 z1 R: L; r/ o: h" R
- char msg[UF_UI_MAX_STRING_LEN+1];' g3 C6 |+ X4 `$ n5 N- s* c: a6 z
- va_list args;0 X$ j* o: B0 B V: p3 K
- va_start(args, format);
$ J; K. m5 g" x7 Q0 Z6 r - vsprintf(msg, format, args);( G" N2 Y+ s: K7 u1 d
- va_end(args);
: s& c# R; R! B( v0 H1 u - UF_UI_open_listing_window();
, A- k, C. Y: _; v - UF_UI_write_listing_window(msg);
0 c* i- M4 y: X l& y% _- J - UF_print_syslog(msg, FALSE);* B- S: a6 u3 H( ~4 ~) {3 q8 ~
- }" H9 l& _' `- M( e7 b) H( a
6 T2 O9 I8 A& R- #define UF_CALL(X) (report_error( __FILE__, __LINE__, #X, (X)))" a9 v* D3 u9 }+ C' m$ f# `
- , U# _- x6 l: k8 y) e9 y! |7 t
- static int report_error( char *file, int line, char *call, int irc)
& ?/ A, m1 _, r3 K% E1 x - {/ \# L& `* Q) ]9 F7 I5 r
- if (irc)! s$ P, o5 k6 \0 A: a. E
- {
4 m% C: @; w c1 B# C+ ]* { - char err[133];! e2 i; Y9 j, L' M8 @/ C ~
" P% k2 p3 j: Q3 v- ?- UF_get_fail_message(irc, err);1 d" R. u$ R6 w Q) y& V3 Z4 m
- ECHO("*** ERROR code %d at line %d in %s:\n",
3 Y6 d+ }: Y: `5 [ - irc, line, file);9 {' r1 y/ Q* q: d2 ~) C0 V
- ECHO("+++ %s\n", err);
/ A* k5 p- G; W* _$ Q' O - ECHO("%s;\n", call);
+ C+ p3 \- @4 b - }7 Y" \9 E4 d" G$ |! t! B. ^+ |8 m
- 6 n7 T1 Y, I) {+ ^3 |
- return(irc);
1 V$ I. Y/ s/ S% K - }
. B6 K) N- w9 B( k4 }' k- h& k
" Q8 `3 g- \% e
0 \$ _! w2 O! N$ i2 l4 @ |3 g- static void do_it(void)
: y! R: J% Z/ |& K" m/ T - {; L- v& M C8 `$ J' a- W
- Session *theSession = Session::GetSession();
& v) z# {" ^ r% H; k3 Z. V7 I. c - Part *workPart(theSession->Parts()->Work());, x% X* O7 c" Z- G
- Part *displayPart(theSession->Parts()->Display());
4 M: [* Q4 y* n - * D( W( K9 z/ ^. e1 |$ C
- PDM::SessionSettings *sessionSettings1;, ` }! ~9 Y" G
- sessionSettings1 = theSession->NewDatabaseSessionOptions();8 z# i+ u# D; n1 v! j5 B, Y( t6 Q
- 0 [8 k% z! [, J+ {
- NXString CurrentGroup;
- `; s+ h; k# k3 w. x: k - CurrentGroup = sessionSettings1->Group();
, \. U" R5 V) [2 A5 q/ Z! N -
. Z3 l" h7 `/ ]9 }% v: G - NXString CurrentRole;& L% R4 O$ T/ X
- CurrentRole = sessionSettings1->Role();1 s+ V' Y; ]! T7 j, h- q4 ?
- " ?+ v! X* f1 x# s$ o
- theSession->ListingWindow()->Open();5 W& o+ c# U2 { q
- " {2 Q# Z- T q3 B& e7 {
- theSession->ListingWindow()->WriteLine("Current Group: ");
" [, g5 n' T3 x) z- Q) p0 v - theSession->ListingWindow()->WriteLine(CurrentGroup);# n2 G5 S& g! ~5 K
- ' W6 ~: K/ ]7 z* {: B) _
- theSession->ListingWindow()->WriteLine("Current Role: ");
7 H5 Z5 S! L$ n, S0 k# W) Q - theSession->ListingWindow()->WriteLine(CurrentRole);
( E# a$ {8 Y! I, H! \% `
% `" W* }: b( I) x! W- }. t9 ]7 H5 \0 q- E Q; l9 M- L
- 2 D0 _$ e/ h& ?
- /*ARGSUSED*/
) W |! @' A5 [# |3 A8 Y8 r - void ufusr(char *param, int *retcode, int paramLen)
% }- W) V+ {0 b; k9 j - {
' ^/ P( j$ B" @. B% H2 K. _ - if (UF_CALL(UF_initialize())) return;
7 I8 D# ~+ X" y0 y1 x - do_it();
& |' e* |, D9 D8 o! `+ `+ f$ _5 J9 ] - UF_terminate();
. o- B8 U; D! \, e - }
. }/ V# y# B6 I0 I2 d6 u - 8 @1 l( w8 E! O6 v
- int ufusr_ask_unload(void)
+ f+ C- g: F& ]# q" q - {9 A; V, r {$ g j4 ]3 B
- return (UF_UNLOAD_IMMEDIATELY);
7 M8 S* c0 b/ M9 I) F' {5 _8 ? b - }
. B- o* m4 t Z6 P9 y8 a8 i- F
复制代码 |
|