|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
6 X" u( v4 F0 ]' l$ I* ?. P$ B2 L& |3 |
Teamcenter二次开发 判断当前对象是否被check out
K' h: O! j* C* ~[mw_shl_code=cpp,true]#include <iostream>" g- _9 R k) ^( N3 F7 d( r
#include <res/res_ITK.h>
* k7 a3 N* X6 P5 L. C#include <sa/user.h>7 N7 {" g5 a& B
#include <base_utils/IFail.hxx>& {; ^6 y; W& g! ~7 S
#include <base_utils/TCResultStatus.hxx>
1 m" d4 Y0 @9 H* U6 I* r#include <base_utils/ScopedSmPtr.hxx>
8 H/ \3 J- m3 M$ Y# O+ n, S8 B: Z- S8 N+ {
using namespace std;8 R, ?" i0 r/ {$ B
using namespace Teamcenter;9 O1 [5 o' r: e( e& y0 N
1 g! L) I4 Y: E$ M; Mstatic logical is_instance_checked_out(tag_t object_tag)5 y, j! o1 A0 Q, o6 t: r
{! \! `1 w6 e- j, Q( R. Z, J9 ?
int ifail = ITK_ok;5 V' H/ |" l' A9 v! c
ResultStatus rstat;
4 j* r3 O. U) P# ` logical is_checked_out = false;; y3 C W z, ~. O6 F8 ]& W. }6 r
try
9 t5 M7 z; W) m# e {
& ]/ G! j4 V7 P) @ M+ g rstat = RES_is_checked_out(object_tag, &is_checked_out);( e9 s8 r" r3 r5 u. Q" L
if (is_checked_out == true) h. W0 d3 s3 {, T* |
{. T" w7 E8 ]% s+ J: y, U- k0 L% j
tag_t user_tag = NULLTAG;" Z0 ?5 g6 L. o% C* P4 s
tag_t group_tag = NULLTAG;
' ^: Z5 }; t6 G1 T rstat = RES_who_checked_object_out(object_tag, &user_tag, &group_tag); 6 S5 O2 X0 A8 q: m/ H
) c; i/ T$ Q" ?( I/ Q: u
scoped_smptr<char> user_id;
$ x" \2 c$ ~3 V rstat = SA_ask_user_identifier2(user_tag, &user_id);
0 O/ q( T% Y7 |! N9 I Y
1 l( j6 `: k" W7 O6 O. k7 O+ i char msg[] = " Checked out by: ";, _8 C1 m7 L5 V6 e! U
cout << endl << msg << user_id.get() << endl;
; y9 t7 Q8 A% L9 R) M. K! C- x is_checked_out = true;& k. _8 t. V: b* {# n/ E
}
3 @+ X, V# y2 _3 Y5 U! ?; ~ }
5 K2 ]1 o* @4 i( i i0 n/ f catch( const IFail &e )
: S; N" Z' {5 w: R5 {8 u {
% H+ U6 v( _ U( ]2 I cout << "error " << e.ifail() << endl;
2 S$ c9 H6 n1 P( m" Z cout << e.getMessage() << endl;) N- |- _% z3 U! R, \ Y' ?. y
}! m2 J, o/ V5 F( c; p
return is_checked_out;# `% |6 V4 e9 v4 K% Y
}[/mw_shl_code]; |; D2 Z9 x- ?- D( X. |
|
|