|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
Teamcenter二次开发源码分享: 报告用户登录信息6 X0 G% g# D9 x, l( B9 C
+ ~+ E5 h( M& S& X5 s T
% T3 I- O5 U+ k* f' _Teamcenter c++ 方式:* N* H9 E; ` o. @& G: |
7 f/ g' b; t7 D1 q
7 N+ u9 c9 C6 [- t) w9 v#include <iostream>
! U, q- | O) W1 H7 S8 b* J#include <sa/group.h>
5 t8 z& ]7 O+ t3 a1 r- a/ |7 z0 I#include <sa/user.h>* f# b7 v' M/ l8 B3 W/ Z1 b
#include <TC/LoggedInUser.hxx>; H( w) d0 ~- M% K* w& h6 R
9 j8 f% J: U+ B, I3 i) T b0 a5 T4 n. g* B
using namespace Teamcenter;
9 q0 r; Q& x& @$ e- f/ a+ X- }using namespace Core;
4 s I4 X* `4 ?2 b3 Vusing namespace std;
$ {; \ h; a6 t2 m3 p5 ^+ g4 }; P/ w; `$ v9 f a
. S% Z9 J+ H! Z- z8 g, c# D" q% e, ostatic void reportCurrentLoginInfomation()6 u3 ^- v# x4 W. x: Y
{
9 q# J' \% C- c J int ifail = ITK_ok;
7 U% Q# b3 x! t LoggedInUser* loggedInUser = LoggedInUser::getInstance();* |* r# ~7 @4 ~
3 T/ h, s0 x! s
tag_t currentUserTag = loggedInUser->getCurrentUserTag();
) n8 i/ @% x2 r: _* W: [) g m- q4 F cout << " currentUserTag: " << currentUserTag << endl;* R" k. W5 L" K. O( D
3 P/ {( j' e: H& I! j! T' [% Y9 m" c char *personName = NULL;/ B1 X' y2 O5 o$ V0 x' @! T. d
IFERR_ABORT(SA_ask_user_person_name2(currentUserTag, &personName));
F7 G6 L) d1 N6 J cout << " personName: " << personName << endl;
" t( Y' }0 L) Z if(personName) MEM_free(personName);
9 C0 u5 t$ V7 |5 X z9 c- y9 [ * U& [% ?, L3 O3 e5 C, }
const char* userID = loggedInUser->getCurrentUserID();
1 Y, d$ m Q1 I' G% }; U cout << " userID: " << userID << endl;/ ]7 p* C" P" N3 P
/ w: M) J1 N* k& b% z" Y' p+ I
2 o$ Z8 y& [4 K Y" R6 }5 r
tag_t currentGroupTag = loggedInUser->getCurrentGroupTag();
% `% S; D9 e0 i k
) u% g; X: K8 H$ r char *groupName = NULL;
8 F) T2 y l4 b) T4 E, }6 B9 C IFERR_ABORT(SA_ask_group_name2(currentGroupTag, &groupName));
7 W* P% j0 d2 Q5 z& [+ e cout << " groupName: " << groupName << endl;* o1 {; t6 ^ Q0 _
if(groupName) MEM_free(groupName);
& N& _) m1 c6 f. k8 e, D' E, g+ Z5 l6 w @% T4 e- l6 M
, F/ ]! o {- i' x/ ?3 f/ d% K# G
tag_t currentRoleTag = loggedInUser->getCurrentRoleTag();; ~# _6 w9 y. V" {5 t! V
char *roleName = NULL;
, @4 E) D/ w+ }. i% _8 T8 q- V# |2 R P IFERR_REPORT(SA_ask_role_name2(currentRoleTag, &roleName));
( D# l0 c) `1 O cout << " roleName: " << roleName << endl;- M% q2 D; S$ t0 {& i7 _ m! t
if(roleName) MEM_free(roleName);
" F) M& ]) N4 D4 a$ ]+ b; Q
( W A5 L# n( D/ F7 _9 R logical isDba = loggedInUser->isUserSystemAdministrator();' H# N- H: n; r+ u+ ^( |7 ^
if(isDba == TRUE) cout << " User is dba member "<< endl;- z, X q$ Z3 \, T% s$ g- u
if(isDba == FALSE) cout << " User is not dba member "<< endl; l3 H+ r3 [) a: b7 `3 v
}' [* i* u& ]( l4 v5 p
) n) [" v d9 U6 d! I8 q0 Y
+ s U A5 g( Q; c0 w
- M p: c. r. A k% L3 `& Z
C" Y# E& t! t- u S8 y5 N1 ?% E* M- g
$ @) i4 _5 M- {Teamcenter ITK 方式:
! t& c* N# d: p# o( L0 x$ _8 r3 Y/ ^( N- Y9 c. K
, [; ]8 N4 V' K4 s* s5 O/*HEAD REPORT_CURRENT_LOGIN_INFOMATION CCC ITK */
7 D: V( m5 Z: Jstatic void report_current_login_infomation()! n0 K7 r9 P: s) p
{ Y+ D$ Q) {+ v2 l$ }) b
tag_t
' t( i% W2 _4 q# z4 B current_member = NULLTAG, & O2 ]2 `3 r2 C5 |
current_user = NULLTAG,
7 a9 h5 V; z/ _/ E. T# g current_group = NULLTAG, * p* A( u4 P: u6 ^" S9 h7 Q
current_role = NULLTAG;+ G3 N/ }1 B R/ J9 a2 h& J, r
char
q. k% z1 l: m+ V% G V: I person_name[SA_person_name_size_c+1] = "",
; w* {# u# {! G( Q user_id[SA_user_size_c+1] = "", & l( m) ]0 o4 z- }2 k3 Q1 Z
group_name[SA_name_size_c+1] = "",
+ M+ ^3 c) z9 E7 H6 M' u0 d* ] role_name[SA_name_size_c+1] = ""; * J' l3 }. x0 K0 [
) r1 b0 N2 V( u! R% }! d0 f( O$ c* f) J# X+ Z
IFERR_ABORT(SA_ask_current_groupmember(¤t_member));
. _$ S5 {* c) p/ L; m5 r IFERR_REPORT(SA_ask_groupmember_user(current_member, ¤t_user));) x2 @8 h2 \0 W
IFERR_REPORT(SA_ask_groupmember_group(current_member, ¤t_group));
# E2 w6 a( F5 r; G/ a4 s9 H/ ]9 P IFERR_REPORT(SA_ask_groupmember_role(current_member, ¤t_role));% m9 Z% {4 x. r+ [. t2 Q+ X
3 m) E( \: e0 f8 x
Q: ]" u9 P# S8 x3 Q IFERR_REPORT(SA_ask_user_person_name(current_user, person_name));
, a# l9 N; F; Z0 ~% Y IFERR_REPORT(SA_ask_user_identifier(current_user, user_id));- v! E- X5 d! B3 e k; s
IFERR_REPORT(SA_ask_group_name(current_group, group_name));
; }" t& I' G1 Y, f4 `3 @4 |9 | IFERR_REPORT(SA_ask_role_name(current_role, role_name));
+ V! s6 M5 h V, i2 n9 |
# g. V) i- h8 u t9 p
" ^8 Y& h' r4 t& t: O" Y ECHO("\n Person: %s\n", person_name);
. }& y) T" {1 n6 u0 J3 o+ |+ e ECHO(" User ID: %s\n", user_id);
. V% w7 l& Z0 j* H+ p& e9 ` ECHO(" Group: %s\n", group_name);* x. f1 V) K0 U; M
ECHO(" Role: %s\n", role_name);
; m0 V+ _) I+ ?5 p" N/ [$ H1 \}
& I2 h* V9 ]4 i
, _# l5 ^& `6 p8 x {3 T) \ |
|