|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
Teamcenter二次开发源码分享: 报告用户登录信息
5 q- E" t5 C2 k% S: S" }; g
3 K1 S: n) U# d1 \9 P
3 D' l3 `; }9 HTeamcenter c++ 方式:1 r" i+ j5 ]( e7 r5 u: U
1 ?6 k1 H& ?( ~/ n$ a3 J" C5 ~+ i0 H; U. X
#include <iostream>' }7 a5 h1 [8 J3 ]# y: h
#include <sa/group.h>
- _, t5 F9 H! C#include <sa/user.h>0 i* v" F: D0 Y- ^* n
#include <TC/LoggedInUser.hxx>
. t* S% B$ x; _3 i
& T4 L# d% d4 V* _/ }; `- u# K9 e2 t- w- k
using namespace Teamcenter;
7 ?0 T( H9 H& F1 o1 _! `$ Dusing namespace Core;
/ b2 `5 K3 u( R) N8 xusing namespace std;
, h3 \9 u! B- b) l2 B; j3 e7 w/ I5 Q* S: l3 P8 h2 u
" p8 O; T7 ` O, e; H- Vstatic void reportCurrentLoginInfomation()' C* [9 D' n F- w, |2 j
{% l' b& G, G! F9 _
int ifail = ITK_ok;
, n0 e* D/ }/ Z- k+ S& B) c( p LoggedInUser* loggedInUser = LoggedInUser::getInstance();) e8 r4 X% b2 A8 t; N! Y7 P& A% K. R
5 d* P5 T/ B- L; w
tag_t currentUserTag = loggedInUser->getCurrentUserTag();
% g) {+ b0 d3 c$ C! s7 R) m cout << " currentUserTag: " << currentUserTag << endl;& A7 B0 p( _6 u& s' ~' ?
/ z. ^ T7 g0 x: t char *personName = NULL;
7 a( s3 g) N5 v0 k0 o IFERR_ABORT(SA_ask_user_person_name2(currentUserTag, &personName));
% m0 z Y5 N5 t8 P7 _2 a cout << " personName: " << personName << endl;
8 k" W3 r/ ^ Z- j6 N( L1 l! Y* y if(personName) MEM_free(personName);
. |: |1 |7 n7 n 4 g! U# S8 R( s
const char* userID = loggedInUser->getCurrentUserID();- ~$ R6 O% }# s# E/ N5 q; F
cout << " userID: " << userID << endl;# k) j) E. A+ m8 X
h+ j5 q4 g' S
5 j2 C) g+ j( J( x* c: Y tag_t currentGroupTag = loggedInUser->getCurrentGroupTag();
2 y1 F- m! T I2 V$ I8 t4 K
% `, L; l, w1 c1 O1 }/ K char *groupName = NULL;
" l/ k3 @ b6 T7 Y; B IFERR_ABORT(SA_ask_group_name2(currentGroupTag, &groupName));
5 i' d/ a4 j1 j3 @* I5 b7 y9 W7 E cout << " groupName: " << groupName << endl;+ O! [- x& @5 C9 R4 n4 K. @, I5 h
if(groupName) MEM_free(groupName);
! r& D0 W$ i6 n6 q9 x1 Z0 M: w9 f) B+ ~) d9 T3 ]
( d1 ^: x6 `* @
tag_t currentRoleTag = loggedInUser->getCurrentRoleTag();
! |& ~ V* p0 L+ ~ char *roleName = NULL;
( Z, u+ `$ t. _! ` IFERR_REPORT(SA_ask_role_name2(currentRoleTag, &roleName));% ~% a8 Q6 Z9 M8 X) V
cout << " roleName: " << roleName << endl;) e4 P- V: L/ T+ _- J3 V7 e- ~) A
if(roleName) MEM_free(roleName);. _: n+ H* L# v
" E1 O- P$ |# K3 @' `# T* r9 d
logical isDba = loggedInUser->isUserSystemAdministrator();
0 U0 w0 \. c5 m6 R& z, f4 S if(isDba == TRUE) cout << " User is dba member "<< endl;! h0 {9 G. D6 t3 B% Z" }
if(isDba == FALSE) cout << " User is not dba member "<< endl; 3 ?( ]2 m1 V* q$ T* s1 ` ^
}$ c, b9 A! A, g4 \) ~5 [
) f- E9 w( r5 [8 ~* {/ j
- q6 M6 A8 R6 c; x o8 N9 c2 E, e. z3 }* _
, E, A' D, @3 Y! i1 e
- Y+ T) P v: r, [) ]Teamcenter ITK 方式:7 E7 k! e8 e+ [+ ?& K8 B
1 N/ a0 g$ w; y9 d5 b" Z
0 }/ _" i& p& L3 F8 k/*HEAD REPORT_CURRENT_LOGIN_INFOMATION CCC ITK */
5 E1 s. f3 z- H- w) Hstatic void report_current_login_infomation()! J3 l# P& E- n* q5 m
{
7 G6 e3 L# U0 D/ z4 n/ ~6 ? tag_t 5 o! g: @; a& M' N( w3 k3 Z9 ~
current_member = NULLTAG,
: ^) t) f( U- F; m4 A- T! | current_user = NULLTAG,
/ g6 X' `# {: h* u! d# U1 r% ] current_group = NULLTAG,
* l- K @/ ?% f/ n3 N: e current_role = NULLTAG;
; y' l/ y X1 m char ( R5 a- e. t! @3 U* n! L8 R
person_name[SA_person_name_size_c+1] = "",
8 d3 N: j: A# } user_id[SA_user_size_c+1] = "",
1 I7 z0 l4 O C group_name[SA_name_size_c+1] = "",! B* a' J) H# m. a8 U( c9 E6 a
role_name[SA_name_size_c+1] = ""; ' M0 N; i7 h/ _1 N$ H
; U' g& P2 u2 _7 o M" Q
- d3 W4 E' [- |. f3 M; L IFERR_ABORT(SA_ask_current_groupmember(¤t_member));
1 r% p9 l7 A4 \# }5 a2 n. Y6 C+ V IFERR_REPORT(SA_ask_groupmember_user(current_member, ¤t_user));; }+ D) S9 e7 v+ z
IFERR_REPORT(SA_ask_groupmember_group(current_member, ¤t_group));, C% s* H R5 s8 K
IFERR_REPORT(SA_ask_groupmember_role(current_member, ¤t_role));
% A- K2 ?0 m+ m: l
; W' |8 `. n2 @9 s# w9 p ?3 [9 v: y5 y# K5 F
IFERR_REPORT(SA_ask_user_person_name(current_user, person_name));) H7 L8 L Q; X4 ?) ?
IFERR_REPORT(SA_ask_user_identifier(current_user, user_id));4 p- M" |/ }! p$ O9 y, d5 g
IFERR_REPORT(SA_ask_group_name(current_group, group_name));: c# Q6 l. _3 _% i3 F( I. |) `
IFERR_REPORT(SA_ask_role_name(current_role, role_name));7 I7 L/ ~5 z$ \1 X: e7 r* q: \5 m
r( S2 y7 h. n1 u
9 b/ B* v9 g- A0 D ECHO("\n Person: %s\n", person_name);( G7 P" Y) _. U$ k
ECHO(" User ID: %s\n", user_id);# W; M/ E* ^5 f8 J& W0 v+ ^
ECHO(" Group: %s\n", group_name); j& l- u6 g7 d: g" m& y
ECHO(" Role: %s\n", role_name);
/ N! [& u4 g+ P* i- L" F3 A# A}+ w) Y3 ?0 ~/ |5 |9 @! v; M- z% ]
7 D0 T$ z8 b+ Y. A; V6 _$ f
|
|