|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
×
3 I7 y- [2 R& s8 I d- {! B# _
" g0 H% K' y8 S( j* _" t$ E/ [Teamcenter二次开发 判断当前对象是否被check out
& S8 B& X& @% y0 ?% c[mw_shl_code=cpp,true]#include <iostream>
# m2 L3 o9 u' l0 S$ Q3 S#include <res/res_ITK.h>' Q1 R5 u/ w( X' q) I
#include <sa/user.h>
* `2 I& W! P& @+ J#include <base_utils/IFail.hxx>
5 {% W; i* ^3 ]: w. j) Y6 F1 A#include <base_utils/TCResultStatus.hxx>4 t3 c1 c- L0 [- `8 k) r1 x7 X% K
#include <base_utils/ScopedSmPtr.hxx>
* _ r8 E' D- Q" _, @0 J+ ^( Q& ^& ~8 e
using namespace std;
$ W& g( {" N9 m% `8 Yusing namespace Teamcenter;
; a7 I4 v' Z) Y7 n. e
6 S6 ^, Z; M: F# C9 |1 wstatic logical is_instance_checked_out(tag_t object_tag) h! N d- z! N7 Y* O& Z
{
% B* A' q2 |% B" c int ifail = ITK_ok;
( T* l. | v( Z ResultStatus rstat;
I Y; t- q1 \' H% l1 _ logical is_checked_out = false;
1 h4 q/ p# b+ U5 }4 e7 M- c try
7 h% i' C& _. H( M4 H {- Q, Y# \* R& f7 x) d: z) N5 Z- x
rstat = RES_is_checked_out(object_tag, &is_checked_out);
, v4 T! F8 Y! T' I& K7 }$ p( F if (is_checked_out == true)
" u. r* S$ u. N4 H+ M {5 L4 O5 p3 `3 B b$ o6 \" F
tag_t user_tag = NULLTAG;4 _% _0 z+ r& n, |
tag_t group_tag = NULLTAG;2 B* F: m, k) B
rstat = RES_who_checked_object_out(object_tag, &user_tag, &group_tag);
- O+ M0 ]0 f& }; [, \* ~* c
, e" q+ ]! h' C; t2 G. B" A scoped_smptr<char> user_id; 0 z }7 i1 m2 N0 q) e
rstat = SA_ask_user_identifier2(user_tag, &user_id);: ]$ V7 I& w7 K' Z; P/ P }
/ P+ u" K$ G" Z. O! _" ` char msg[] = " Checked out by: ";( e( P# C2 I- P6 a) E( M" M0 l
cout << endl << msg << user_id.get() << endl;- l: C3 t9 I1 a& ?' g
is_checked_out = true;& i P' p% M) g, C6 \
} ?% F, b3 l! S8 u7 m
}9 {! F5 O( H- {: b: q
catch( const IFail &e )2 H, N9 K( D5 o, d
{- m" q# \* j1 d' q j4 n
cout << "error " << e.ifail() << endl;$ K( Z; }1 T) u5 F0 w) Y* Y+ L
cout << e.getMessage() << endl;: i3 c/ I& Q1 E" l2 U! S& u
}
. c2 s- Z0 P1 E: B- H return is_checked_out;
4 u* q. o7 ?; Z1 P: ^}[/mw_shl_code]
. q6 w# c4 W2 K |
|