查看: 2564|回复: 0

Teamcenter二次开发源码分享: 获取当前用户信息

[复制链接]

4

主题

3

回帖

48

积分

管理员

积分
48
发表于 2020-2-8 09:34:22 | 显示全部楼层 |阅读模式

请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!

您需要 登录 才可以下载或查看,没有账号?注册

×

. ^! F+ ^# r. h( K: ?Teamcenter二次开发源码分享: 获取当前用户信息
) C8 _3 z5 c. M# q$ _" _3 l
' P  Z& {/ I. v8 i& ~7 B9 m[mw_shl_code=cpp,true]#include <iostream>
+ E/ t/ I9 ?' ~! B& ?) w#include <sa/group.h>& _# Y# D& v5 T: c6 r
#include <sa/user.h>* K2 @' v6 j2 J' ]. h7 h- C' g  J
#include <TC/LoggedInUser.hxx>
9 H' _5 {6 ~1 x8 @; ]8 O# v9 D! V. W7 D' v% O6 K
using namespace Teamcenter;
( T4 r/ R0 {5 T' Y. xusing namespace Core;( L( J& w! T8 ?! J5 X2 N
using namespace std;+ l7 g2 ]: T; @( K2 h" Q$ k' K7 {

, d. l% o, c% u0 ostatic void reportCurrentLoginInfomation()
. Z1 m% l" J$ r7 g, e- u{
0 L# n0 S7 _/ G" u( m' S    int ifail = ITK_ok;
9 z2 u! E# j/ @* T    LoggedInUser* loggedInUser = LoggedInUser::getInstance();2 _: K, G8 A1 x. Z! Y
   
1 t" O: L/ q2 D2 |; t    tag_t currentUserTag = loggedInUser->getCurrentUserTag();
( F$ Q. s4 t3 G* j* E" U- b    cout << "    currentUserTag: " << currentUserTag << endl;
1 ^+ ]$ ?& c, n9 w6 c, B   
9 B, g* k# M+ c  _* l    char *personName = NULL;
3 I& n7 V: o2 O) v% j- b6 h    IFERR_ABORT(SA_ask_user_person_name2(currentUserTag, &personName));/ \; [4 |# f) G) f% i2 A1 B; X
    cout << "    personName: " << personName << endl;0 L5 }- q7 P6 I4 e
    if(personName) MEM_free(personName);0 v/ @5 b- x/ b9 W+ w- W2 [
   
$ G# j2 N! e% r3 k    const char* userID = loggedInUser->getCurrentUserID();- `: n& B* _% s6 Q9 b( v. ?
    cout << "    userID: " << userID << endl;) T' E0 y4 |- E

6 L6 X. p! Q  Z! @7 E    tag_t currentGroupTag = loggedInUser->getCurrentGroupTag();
& M$ I7 }4 K6 B, {! N    - a1 s$ o) O: o6 a% W
    char *groupName = NULL;
' C0 J. Z# `2 O! T. ~6 a1 q, p& y    IFERR_ABORT(SA_ask_group_name2(currentGroupTag, &groupName));
" H7 A9 A- @. R* M; L$ J+ P& s    cout << "    groupName: " << groupName << endl;( c8 g1 p: E7 _
    if(groupName) MEM_free(groupName);
3 c8 u/ f  z! W. A) L3 X% w) O2 U
$ Y4 a0 J( P. w0 ^# {    tag_t currentRoleTag = loggedInUser->getCurrentRoleTag();: g# {: W3 U  \7 d/ o
    char *roleName = NULL;
4 F: b) b8 ^  m& g: y- T    IFERR_REPORT(SA_ask_role_name2(currentRoleTag, &roleName));% v. j$ P  r/ k: Y7 }7 [
    cout << "    roleName: " << roleName << endl;- ?$ r% }  p; R2 W$ x" g
    if(roleName) MEM_free(roleName);$ W$ D; u& q( f- l
    4 D# G$ l  l( ~$ T) f
    logical isDba = loggedInUser->isUserSystemAdministrator();
7 x; L3 t7 B& W* d    if(isDba == TRUE) cout << "    User is dba member "<< endl;
* E- `; g+ `/ @& M( |& m    if(isDba == FALSE) cout << "    User is not dba member "<< endl;      
6 Q+ p. ?  ~9 a$ S, ^}[/mw_shl_code]' ?  o8 P. l% [9 t! E' E7 P9 W
上海点团信息科技有限公司,承接UG NX,CATIA,CREO,Solidworks 等CAx软件,Teamcenter,3D Experience等PLM软件,工业4.0数字化软件的实施\二次开发\培训相关业务,详情QQ 939801026 Tel 18301858168 网址 www.doteam.tech
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

在本版发帖
关注公众号
QQ客服返回顶部