|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
Teamcenter二次开发源码分享: 报告用户登录信息( p9 g# m; l. }
( V( ]) P$ J4 X+ n
; S! L8 c' l6 k! ~$ {! ?; u' m+ ]4 a' GTeamcenter c++ 方式:
$ Y! Z8 f4 @5 Q0 H* `% J2 x
d! [+ `% G+ A8 e4 |
7 H# D' x9 r! ]#include <iostream>2 W7 @0 P" F k# g n, e( F0 _
#include <sa/group.h>+ B& `/ g9 b6 C: A" q
#include <sa/user.h>" E, \5 Q. V# g& i! }8 x3 c
#include <TC/LoggedInUser.hxx>
8 Z, i) ?- {5 v8 a" T- I! n" P8 c, r5 J; k9 _ W( t+ B
. y' f; o4 y5 f7 v d3 ]7 r
using namespace Teamcenter;
1 U1 Z& a, J6 l/ n$ R! G) ^using namespace Core;
4 ]/ x3 Z0 Z# ]8 E4 iusing namespace std;- \5 O% l, D5 F" I( o
/ h0 x+ x& q4 ^; e
. p* ^- O5 h# b2 U5 bstatic void reportCurrentLoginInfomation()/ L, F7 J9 x' T% [- o
{
8 Y- \+ T( A2 Y Z" v a% s ~* C int ifail = ITK_ok;
+ s+ l% H4 C P9 q LoggedInUser* loggedInUser = LoggedInUser::getInstance();3 P# {: s' U! m! S" h5 w( I4 D* v
8 C% F, C# v/ q9 X8 G) h, `
tag_t currentUserTag = loggedInUser->getCurrentUserTag();
. P* ?: r2 O4 h+ m' j2 ?. m$ j cout << " currentUserTag: " << currentUserTag << endl;
1 v3 H/ H/ b4 r! P- \6 ` % @: w* Z$ z: E" }8 c. Y$ @, @
char *personName = NULL;9 y V! q% S, Q( I$ g8 S
IFERR_ABORT(SA_ask_user_person_name2(currentUserTag, &personName));
6 f! M r1 h, y' I! v' S1 l+ ] cout << " personName: " << personName << endl;# H; |2 W/ p4 @! Y
if(personName) MEM_free(personName);" p2 x4 a% \- ]1 i5 E: r/ s, O
, y) C% {! v" M2 M+ w% V( U
const char* userID = loggedInUser->getCurrentUserID();
_! u5 L+ H, n ]0 h* m$ U5 H' p cout << " userID: " << userID << endl;
2 P# c7 z: e3 B1 v t |# b* R/ Z2 m6 [1 b: C7 n7 O
1 p* @" T+ m4 x2 {- {9 _3 F3 \7 D
tag_t currentGroupTag = loggedInUser->getCurrentGroupTag();* _* E D6 f; J' @6 M; [
3 a' q( b+ {4 t8 U
char *groupName = NULL;
4 g+ D; R* T% }6 { K7 W+ m5 X IFERR_ABORT(SA_ask_group_name2(currentGroupTag, &groupName));( H2 c- \1 X, [, K3 F
cout << " groupName: " << groupName << endl;
# G3 h4 B/ m' T, I Q" l if(groupName) MEM_free(groupName);, J. v4 B: G! l# l6 ~7 T3 u
, y0 X( s' R+ R0 ]8 S
1 \, q4 p8 R* v" o
tag_t currentRoleTag = loggedInUser->getCurrentRoleTag();
. n5 @: S- c( g! W1 ~& E: c char *roleName = NULL;+ @; \2 A9 X0 Y* z p w! l$ ?" R
IFERR_REPORT(SA_ask_role_name2(currentRoleTag, &roleName));4 S6 M+ F2 P% G7 d. G
cout << " roleName: " << roleName << endl;- P( y( ^/ E# k$ O/ p7 b/ V
if(roleName) MEM_free(roleName);7 O6 d8 _- h& Y& d$ s$ j
! ]) [* E7 }) T' ?. i
logical isDba = loggedInUser->isUserSystemAdministrator();
* o; F3 L8 g9 W2 k) n( H if(isDba == TRUE) cout << " User is dba member "<< endl;# G5 N& L- W7 i6 e: e
if(isDba == FALSE) cout << " User is not dba member "<< endl;
3 _: J$ H6 i3 @9 b% T}6 @9 |, S0 X/ B0 I# ~, s' t. M0 T/ e
& b* }' `% ]1 \# J$ D0 P b0 `) d
. W+ i1 J+ `3 K! [5 W2 b
: j7 |# G7 E" z. w9 [, p* D8 {+ g4 ]/ Z% _& s! w) A* c* E( t9 g: {0 G5 h6 r' M
; m4 c9 F9 m u3 v5 G$ b! e4 L
Teamcenter ITK 方式:
5 }9 Z" J+ | [! }' X
# ]! s7 B i+ y) y- Y* O
/ `3 | o" ^0 ^8 { r5 \; Z/*HEAD REPORT_CURRENT_LOGIN_INFOMATION CCC ITK */" B& H& }1 I9 I3 {- o8 t& W
static void report_current_login_infomation()
- c3 Y' m/ _! w/ x4 @- \{1 w1 G6 h( B5 E( `5 C: V
tag_t ) ?( ]& y- Q+ r! g7 D" i5 R
current_member = NULLTAG,
, Z8 k1 S: ~& I \ current_user = NULLTAG, 1 ]4 [+ ]# {: T5 q1 P4 q
current_group = NULLTAG,
- m6 A+ _5 Z; R* H$ j' n3 w current_role = NULLTAG;
& l4 f% t& T' D- ]& ?9 E8 W char
$ ^6 K0 p9 ?4 E% |+ h4 W" q person_name[SA_person_name_size_c+1] = "",- n s- e( m/ R- e- s
user_id[SA_user_size_c+1] = "",
+ J* j+ M) e3 q1 l' b* f% ?# } group_name[SA_name_size_c+1] = "",/ g: c% a r0 ^! X4 J6 a' j
role_name[SA_name_size_c+1] = ""; 2 T7 @1 ^. D2 L7 g7 y
" }& A+ }/ z# e
7 B. f4 f$ U& J8 v) J
IFERR_ABORT(SA_ask_current_groupmember(¤t_member));: q1 q/ @8 A# }6 Q9 u* g: ~: c
IFERR_REPORT(SA_ask_groupmember_user(current_member, ¤t_user));3 W: b7 a4 B1 r4 z& ]3 d. @( u8 N8 H
IFERR_REPORT(SA_ask_groupmember_group(current_member, ¤t_group));
2 o' M0 v2 Z/ \ IFERR_REPORT(SA_ask_groupmember_role(current_member, ¤t_role));- L3 p0 q. v7 w8 b9 s; i3 [
0 s; U/ [$ E4 Q" N
1 \/ _& D: v& a9 |, { IFERR_REPORT(SA_ask_user_person_name(current_user, person_name));
) o% G3 S( w3 \" `. P8 \ IFERR_REPORT(SA_ask_user_identifier(current_user, user_id));8 {' d& i5 U' n7 N# C; W: y! ]
IFERR_REPORT(SA_ask_group_name(current_group, group_name));( j3 J i* |' q* k
IFERR_REPORT(SA_ask_role_name(current_role, role_name));
8 ]# K3 \6 r, _" P9 r2 U- }' Q
2 [! W+ v0 U( B$ S) m/ j' b: ]
. d3 m# m4 U; x5 E$ a" q% d ECHO("\n Person: %s\n", person_name);
T ?. T; F+ T' K. P& @# T+ l+ H ECHO(" User ID: %s\n", user_id);% `0 j2 ?3 ~0 P. G( }/ X7 X
ECHO(" Group: %s\n", group_name);
4 n% j8 k8 l" l ECHO(" Role: %s\n", role_name);/ N/ ~; n5 b5 j
}0 K- P9 v; K1 u9 a: a0 D
8 H* x% g( \8 S6 J% y/ U
|
|