|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
Teamcenter二次开发源码分享: 报告用户登录信息
3 Z, O0 M& P" s1 r. G1 |( Y8 l0 e
% g8 ?3 d. E" p( T' z, t$ @. Y# A1 G U
Teamcenter c++ 方式:3 \3 G h: _8 Y" G3 ^
; ~5 p+ c5 I! R( z" o
2 w5 B( f' t( N {4 x) ?) R
#include <iostream>
( Y) c) a: @- B7 i2 `7 ^( _" s#include <sa/group.h>
$ z2 E# b' d& `% Z# N) g+ X' D3 m#include <sa/user.h>
/ O) U! M% q& `* p; {& P#include <TC/LoggedInUser.hxx>4 X5 y' P2 |. }# x* T: P
9 V3 \ q" s r7 \9 q. h8 {3 e6 C
2 y( ?5 x9 A( }* o, e2 }6 A
using namespace Teamcenter;
0 d4 D7 c$ z, X) T, xusing namespace Core;3 a. Q& z+ q. N
using namespace std;0 F3 D' |+ c( ^: z9 X/ r
$ h! d# V8 s+ E# I5 `8 }$ { C, r( j) u! ?
static void reportCurrentLoginInfomation()
, F. p% D# X5 n( K{: G! G8 Z/ Y' t U' M" @
int ifail = ITK_ok;
% j: J% ` r, M LoggedInUser* loggedInUser = LoggedInUser::getInstance();$ N: q% @$ m+ d0 M. z
7 X: ]' v/ K U$ o; |; z tag_t currentUserTag = loggedInUser->getCurrentUserTag();
/ ?( |' |; ?3 A; G5 }* D cout << " currentUserTag: " << currentUserTag << endl;
* I9 w) I$ w! y ; Q$ s2 ]8 O, H* l$ j/ q
char *personName = NULL;
% @7 z, i' q( Z9 r" |5 u% z IFERR_ABORT(SA_ask_user_person_name2(currentUserTag, &personName));
% [! d2 N x4 o; u ^0 i [ cout << " personName: " << personName << endl;
: E' M. K ^. Z3 B" k9 X/ r# x& Q if(personName) MEM_free(personName);) ?' p( [4 @1 o5 k# z
' L* i$ V7 N8 u# O
const char* userID = loggedInUser->getCurrentUserID();% {7 o# o) I4 x/ ]% W
cout << " userID: " << userID << endl;2 ^ h! \6 e( v3 B8 Y
0 k- Y1 ~' n( ` X$ C3 u
% {! n' p3 B ?! c
tag_t currentGroupTag = loggedInUser->getCurrentGroupTag();- G* f* L: f1 Q; e! w( C, d
5 m3 c3 I+ W# R4 V; m2 A {0 D char *groupName = NULL;" V' `. U# _- d' A, C
IFERR_ABORT(SA_ask_group_name2(currentGroupTag, &groupName));/ ?$ q2 m% c0 m1 d( V
cout << " groupName: " << groupName << endl;
8 U2 K- g. \3 T/ i( `. Z7 Q( p8 { if(groupName) MEM_free(groupName);
( V0 w$ e* g% ?8 n" y+ _1 S2 Y7 R/ G+ X; [. i- I. Z$ c$ z) p
* Y+ u& X' ~ j1 H% `8 j
tag_t currentRoleTag = loggedInUser->getCurrentRoleTag();
; k5 L6 }1 ?. g- m/ G char *roleName = NULL;
" y2 Q3 N# g. _8 a+ z IFERR_REPORT(SA_ask_role_name2(currentRoleTag, &roleName));
}- ]( V5 m* E' h8 e cout << " roleName: " << roleName << endl;$ r- q* n- W& Q% I
if(roleName) MEM_free(roleName);
7 e% m& D) b* F* K7 F3 F
$ Y: Q6 m7 C8 J0 F4 Q2 y2 r2 Z O logical isDba = loggedInUser->isUserSystemAdministrator();
; ~( E. R! ?6 P+ s/ j, {# @ if(isDba == TRUE) cout << " User is dba member "<< endl;
' k( h. z& b2 V" i( f# `2 L& e if(isDba == FALSE) cout << " User is not dba member "<< endl; . M/ E6 J, s6 q1 T- a) m
}; q; h: F q- h) S# y
: J/ m3 o$ ]9 v! i0 f
5 E/ h G: \- F: D5 G! l: ^- z; |' @ u
" U- Q- g( e# T/ q& \( ]$ ?$ Q* g# M( g0 H/ k# q5 f
Teamcenter ITK 方式:! D, B+ \" L" x
6 D" _: x L/ k8 Q7 P; z0 U( _/ {% l8 B/ t L; p
/*HEAD REPORT_CURRENT_LOGIN_INFOMATION CCC ITK */
3 g5 m/ Z% Q5 ystatic void report_current_login_infomation()7 l9 |1 j7 T9 R- N" a
{- y& `" ~6 `; M+ J: u; K& j
tag_t $ F$ {7 b7 k# C1 {: ~4 v1 @
current_member = NULLTAG, 6 `8 q" y' A4 B& y7 [
current_user = NULLTAG, $ r& \2 c# z# n, z
current_group = NULLTAG, : ]1 K8 X4 ], A
current_role = NULLTAG;
M" X* L6 G# c2 s char : F+ {9 i7 n# l+ l9 m
person_name[SA_person_name_size_c+1] = "",* ~5 E' w* s q& D# T( V$ L
user_id[SA_user_size_c+1] = "",
) p" ~4 m) h% L) q: m4 A, n+ W group_name[SA_name_size_c+1] = "",
3 T8 } D0 k4 F6 k, v% R+ }+ z! K role_name[SA_name_size_c+1] = ""; % }+ R" \/ j e3 s% G
* w$ e3 J9 ~% I v7 b( x9 ?5 E( K+ I$ x) N, M; l
IFERR_ABORT(SA_ask_current_groupmember(¤t_member));9 N. u' C" i K9 W. H
IFERR_REPORT(SA_ask_groupmember_user(current_member, ¤t_user));% G- X4 Q% q) X0 W! @
IFERR_REPORT(SA_ask_groupmember_group(current_member, ¤t_group));8 w4 V$ f4 d' w Y2 \
IFERR_REPORT(SA_ask_groupmember_role(current_member, ¤t_role));
, M/ i7 O; L4 y3 [/ _ A# f! W
0 D+ b6 k: d3 a. M, X' y' M) n4 h: `( }
IFERR_REPORT(SA_ask_user_person_name(current_user, person_name));
* S* D: ]. H6 @1 z' s IFERR_REPORT(SA_ask_user_identifier(current_user, user_id));
0 G9 Q, z" z5 ]2 H4 \% p7 v. \ IFERR_REPORT(SA_ask_group_name(current_group, group_name));5 L3 ]" l; m, R- X9 e( G F/ X
IFERR_REPORT(SA_ask_role_name(current_role, role_name));/ Q# c0 N3 \* a' q
" g' |3 ~0 u3 h" ]" `. [1 Y
) i+ R0 Z, l. t; m7 ?( b$ w
ECHO("\n Person: %s\n", person_name);
) M" y. X: o/ Q) m1 E i ECHO(" User ID: %s\n", user_id);+ S, w# I( [4 U9 g5 ?6 a
ECHO(" Group: %s\n", group_name);
5 B* H1 t" C0 C1 o% j! x: Y, Q ECHO(" Role: %s\n", role_name);
& ~ B! Q# h% ]9 U9 R; }+ J+ K( G% Y}
+ a- F8 e* b% Q9 ~! F& B$ o7 i6 T
& X( V! y& G) N6 F; w: q |
|