|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
4 e" h2 k6 ^; p+ l/ b! A
. N5 N% H0 W! ~; k* s: W; z0 @9 b- gTeamcenter二次开发 判断当前对象是否被check out
$ r$ ]$ T# D& {' }[mw_shl_code=cpp,true]#include <iostream>9 y6 f) @: c# W. |! T3 [- `
#include <res/res_ITK.h>+ g7 G7 H% D5 j
#include <sa/user.h>0 ]6 V7 `- I. ^+ }+ _
#include <base_utils/IFail.hxx>
& I h9 }, L& d! m( P#include <base_utils/TCResultStatus.hxx>
- ~: G/ Y( U* p" e) H# }2 C: q |#include <base_utils/ScopedSmPtr.hxx>
8 d% b: q2 W/ ?: h2 w4 {. j/ {1 Z( g. n( k4 D' N
using namespace std;2 T# X9 K8 A+ V4 b4 c) F% V* p
using namespace Teamcenter;5 r- ?5 o3 w% x7 m$ v) k
, K9 R: t/ s) W0 Jstatic logical is_instance_checked_out(tag_t object_tag)
' d; q) y, n# p( |, l{
7 L$ r& H! I! f+ u3 q+ M int ifail = ITK_ok;1 W4 q( y2 }6 G
ResultStatus rstat;* H) Z% S, t9 |* I- B$ D, W" U
logical is_checked_out = false;, s2 \; q: F9 t
try
( [( f% E q% W3 {' \5 S { R, K4 B4 P" v
rstat = RES_is_checked_out(object_tag, &is_checked_out);6 T$ N9 A" e5 X& z+ U2 Q t8 J
if (is_checked_out == true)
! k% e" G) o2 R+ w: N2 T {
( [" ~% _( j5 f0 n tag_t user_tag = NULLTAG;2 m1 l) g7 a3 O1 Z
tag_t group_tag = NULLTAG;
# r( m5 P) `, \1 r3 \" R c rstat = RES_who_checked_object_out(object_tag, &user_tag, &group_tag);
3 E, o6 E7 E! K# l
% U) R7 R0 b( ?5 A scoped_smptr<char> user_id;
7 D7 L9 b, C+ p+ ~ rstat = SA_ask_user_identifier2(user_tag, &user_id);& [6 T" J$ _; L! J, V( s
) C) ?8 r' ^- r4 w% h8 E3 z- b3 `7 X char msg[] = " Checked out by: ";/ D2 C9 o& V9 l+ o8 r
cout << endl << msg << user_id.get() << endl;: w# B7 _' i; X2 T
is_checked_out = true;
4 o7 |- |! j# f% H0 G }# C1 p) ] I) I4 I; ?, l% V2 E- }
}
% F6 r. [: S4 |* p: r catch( const IFail &e )
/ i X2 p7 W! e8 R- q" v; Y5 D {
E9 T7 d/ M3 J% C- w9 `4 ~: g cout << "error " << e.ifail() << endl;0 s0 z/ ~! B w' b
cout << e.getMessage() << endl;' i5 ]) h2 N; k5 g
}
% M# X* o/ N% H9 {8 j return is_checked_out;( o# C3 B M5 v. d! p% H3 h" o
}[/mw_shl_code]
& h; k+ |% p4 n% o4 J |
|