|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
Teamcenter二次开发源码分享: 报告用户登录信息
* i7 j4 P& G9 a( j+ c
: G+ e: Z% R1 \6 r, i6 S( O$ R# v( O1 \6 i. ]
Teamcenter c++ 方式:
' q- J7 `9 T# y3 t C9 @- i
6 C9 Y! y# o) W8 g; W, m% S
G0 Q9 m# I- Q* g8 y! C#include <iostream>
: {4 K e2 Y3 ^! ^: o" P7 I _: X#include <sa/group.h>
0 i" G/ |1 \8 k: Z#include <sa/user.h>! h' U) H3 O# j# D5 B5 [& j( n/ F" J
#include <TC/LoggedInUser.hxx> l( p1 |4 G8 R0 c1 X" N
9 r8 Y3 N3 @+ F& D, c2 W- k" C
7 W. I4 ]+ M$ q3 t, uusing namespace Teamcenter;
2 a s" ]! w1 c2 H2 xusing namespace Core;2 ?7 F t$ O6 K( S' h' m
using namespace std;( a$ B9 b5 N+ P8 N% Z* k
" }: Z9 T& S( j/ l8 {) _0 y
' `+ j( N( V( p$ D0 `* q- Wstatic void reportCurrentLoginInfomation()
; R4 N9 h- i) W" n+ w" W{
( ~% Z( o9 }0 h5 e% {8 z int ifail = ITK_ok;
0 m: d& x G- K9 d4 N/ w LoggedInUser* loggedInUser = LoggedInUser::getInstance();! D8 D( Z" Y3 O- n& N# n& m' K
5 ]9 X- m4 _6 |* W5 ]" ~) b
tag_t currentUserTag = loggedInUser->getCurrentUserTag();
m4 @* I4 i7 A" k. m# W cout << " currentUserTag: " << currentUserTag << endl;
, W0 O* J- m8 U5 H( A 6 l+ p& I1 k0 W, {+ t
char *personName = NULL;
7 i' I) p# U% m+ x+ L. r$ e, v+ u0 m IFERR_ABORT(SA_ask_user_person_name2(currentUserTag, &personName));8 N9 R0 a, s- t6 Y
cout << " personName: " << personName << endl;, l/ k/ |( D. U- u; [% F G/ c
if(personName) MEM_free(personName);4 z4 m- Z* L" N/ k# _
; d: O' B; O p const char* userID = loggedInUser->getCurrentUserID();
/ L' [8 y3 b. S5 m. f cout << " userID: " << userID << endl;
- y5 i4 P! R' G2 e! X9 @$ }. A0 k. D* Q8 \8 O3 t
# U& C& R: c# K/ w1 \( ^ tag_t currentGroupTag = loggedInUser->getCurrentGroupTag();* f2 s* U7 K+ ]! X. E
5 H! g- O3 a- N
char *groupName = NULL; i& B3 w0 m6 e) n$ S
IFERR_ABORT(SA_ask_group_name2(currentGroupTag, &groupName));
& ^- D+ `: J* \) S, Q. P" K cout << " groupName: " << groupName << endl;" L2 T3 |& y S6 C/ j$ \1 q7 \1 E
if(groupName) MEM_free(groupName);
# \ J J, J8 u! ]0 H. K
6 o1 A0 f) A2 I% j$ q6 Y& C# K. _# \# v; R$ N
tag_t currentRoleTag = loggedInUser->getCurrentRoleTag();
" A4 ]+ ?! m9 m2 j char *roleName = NULL;
/ }) u+ S0 O# j7 J6 N$ {* u IFERR_REPORT(SA_ask_role_name2(currentRoleTag, &roleName));
- F. J! M3 E2 H9 X4 z cout << " roleName: " << roleName << endl;5 \3 {$ m! j8 S; {1 c, Z" P
if(roleName) MEM_free(roleName);
' Y/ v$ W) b% v7 }" Z) G, Y/ S! ] 1 V8 P6 j3 l3 g% w6 A
logical isDba = loggedInUser->isUserSystemAdministrator();
6 ]: G: V7 t, f8 \2 Q% V if(isDba == TRUE) cout << " User is dba member "<< endl;3 J/ x. Z; Z' V$ k9 z/ W& T- M
if(isDba == FALSE) cout << " User is not dba member "<< endl; : i+ p- C6 u4 i7 p, L2 |$ _
}4 I H' h/ |& i& m! ~9 m y- O
1 ^5 y2 Z: Y2 }
, `+ l$ S# c1 n$ C% C0 S+ l. m5 b# l
7 A# i- ^( j* O ^2 E7 ?2 E$ c- |
! G% ]& {9 M0 x# n8 [Teamcenter ITK 方式:
' B+ x% p5 T& B$ ] D
5 a# F6 x: G3 U! N' [- R! B3 Y# ?; k( T7 |
/*HEAD REPORT_CURRENT_LOGIN_INFOMATION CCC ITK */
4 B9 E: S/ X) O6 K2 f Tstatic void report_current_login_infomation()
- S+ T; u6 `$ `6 T U{
# `* a6 r+ m! x tag_t * q) F6 ?* |! [: W: g0 }2 m
current_member = NULLTAG,
b" Y p8 h: S) i/ m current_user = NULLTAG,
+ h& Q9 b1 e1 k; s current_group = NULLTAG,
% B4 Y6 T. |1 a% q( w current_role = NULLTAG;/ ]' y ]" X Y: _& r+ b
char . |' h6 f4 R* e
person_name[SA_person_name_size_c+1] = "",
, ]8 W# D5 @# Z& \' d user_id[SA_user_size_c+1] = "",
0 @5 z6 J" R5 a9 N' { group_name[SA_name_size_c+1] = "",2 p# a$ @+ `0 N* B* L: l
role_name[SA_name_size_c+1] = ""; + _4 R# h( k3 [, [
3 j1 P/ C/ p. w2 N9 }7 E
" x: {; O' b) t s0 c IFERR_ABORT(SA_ask_current_groupmember(¤t_member));
0 _2 X! x) s" u IFERR_REPORT(SA_ask_groupmember_user(current_member, ¤t_user));
& S, ^/ P" K2 P+ O& E2 F, W4 k/ x IFERR_REPORT(SA_ask_groupmember_group(current_member, ¤t_group));
. Y2 ?4 L7 y7 |$ T& P# A8 J# l; p IFERR_REPORT(SA_ask_groupmember_role(current_member, ¤t_role));
1 u8 s# [# A- U6 t. Q1 S! R/ X2 V! W; s, d9 a) Y+ e
, j& S- y" c R% _8 u; r IFERR_REPORT(SA_ask_user_person_name(current_user, person_name));% C# y5 r c# |. {. K- `
IFERR_REPORT(SA_ask_user_identifier(current_user, user_id));
5 y$ [2 W% k* Q7 O* L& M IFERR_REPORT(SA_ask_group_name(current_group, group_name));9 W0 I0 w$ {( S& n8 |
IFERR_REPORT(SA_ask_role_name(current_role, role_name));
7 _4 H5 T' ]! f1 h4 k8 k( m) h+ x3 {; L1 I2 V6 L, I
) i, u+ T& D8 q0 C- \$ p ECHO("\n Person: %s\n", person_name);( a# g! f; V! O N% V" B: C
ECHO(" User ID: %s\n", user_id);, G# z& A, M! e/ y( y& `
ECHO(" Group: %s\n", group_name);' L0 x+ g1 Y, L" f5 M% C+ {
ECHO(" Role: %s\n", role_name);9 @! p; I9 J! S: ^$ z# u. F. i
}
8 W4 P1 Q, G: F5 V, B) a# _, H3 \2 u4 r# l
|
|