|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
) Y. Z# C7 l" q8 f9 h" ~
9 }9 {. V1 _" B2 xTeamcenter二次开发 判断当前对象是否被check out
' b" V. F" M5 J) S/ h A[mw_shl_code=cpp,true]#include <iostream>
7 [& M5 N6 e" J( H#include <res/res_ITK.h>5 K' i# A& H% X* T( H9 \$ V
#include <sa/user.h>, i6 k$ H, T- \2 B! C6 t
#include <base_utils/IFail.hxx>
2 |& U1 g+ V1 F" g/ z#include <base_utils/TCResultStatus.hxx>+ b; k) l& ?3 z3 W5 _
#include <base_utils/ScopedSmPtr.hxx>
8 Q5 b+ m! p% B+ u* n1 R/ ]6 f8 G. C2 O5 n, B' B( G6 M2 K
using namespace std;; ~8 s: e+ a7 p2 U7 K
using namespace Teamcenter;
$ m3 E: E# `/ b; w( b) w3 [8 h( x- ~& S" ?% w6 f8 }" ^
static logical is_instance_checked_out(tag_t object_tag)
. {! c$ v* t) l{# u' m- @0 b! w/ f: c# W
int ifail = ITK_ok;5 G" f9 e, H' ?4 ?& x, B! Z# S: ~! f
ResultStatus rstat;" c: Y% h! P4 T1 T- x
logical is_checked_out = false;, z& V7 N6 m' O# J
try
3 X$ E k5 A) d4 @% E {
% R6 j+ N, k: k% @- r! A rstat = RES_is_checked_out(object_tag, &is_checked_out);
; D, {8 L. f/ D/ ^5 [ if (is_checked_out == true)6 S* H6 C" M* h
{: d* f! d/ R4 K0 I
tag_t user_tag = NULLTAG;& _1 w% ?' @* j) H6 f! {9 A) k: Q4 R
tag_t group_tag = NULLTAG;
& B$ A1 ]& l1 g6 e% _ rstat = RES_who_checked_object_out(object_tag, &user_tag, &group_tag);
7 a( M4 h3 k0 B7 w% W& s/ Y8 N( V9 Q! d+ y' M- o( N% v
scoped_smptr<char> user_id; 6 S: i7 `! K' h! a
rstat = SA_ask_user_identifier2(user_tag, &user_id);- a. k" ~% ^: `3 k# |4 c
. X$ J3 @4 Y5 Z0 M
char msg[] = " Checked out by: ";* `1 N A$ f' b; O) @) |5 y
cout << endl << msg << user_id.get() << endl;
$ a5 i1 `+ @: W5 \1 [/ S4 l is_checked_out = true;
9 o( g: y& W0 x4 D! D }
" `, A. G0 Y% ^$ l }4 c+ _- G4 l/ Z
catch( const IFail &e )( V4 U. n% L9 }! q- R1 U o6 {8 U1 e
{
# ^- n2 a) _, w" y* i cout << "error " << e.ifail() << endl;, |1 l5 P$ K0 y- b" P) _# b( w+ q. K
cout << e.getMessage() << endl;
% w$ Z2 |3 @! G/ ]1 \2 `. I }1 s: g% b; Z; U% F* H
return is_checked_out;
# n/ K; K4 q4 `0 o6 |9 s}[/mw_shl_code]
7 D/ L* y" C6 r$ t |
|