|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
; l3 u% p) w( y/ p/ ~Teamcenter二次开发源码分享: Revise 版本 升级版本方法
/ n& i, L* z! l) F- t* i0 A) ?9 k+ F- p( O% r
0 j: T+ S* L* [1 w' s: ^[mw_shl_code=cpp,true]#include <TC/emh.h>+ M: _9 l2 f1 J8 a0 q
#include <tc/tc.h>& |% ]( @) O$ a2 O9 r$ c
#include <tc/tc_startup.h>
. g- {3 r2 S% X2 o8 o5 E8 F#include <tccore/aom.h>
- g% |, P7 Y. A0 O. b# c* n#include <tccore/item.h>
5 I2 M+ |5 ?8 [0 m' C; O( A& `. P1 f7 M) Z% q0 q
#include <iostream>, W% o# Q4 H7 k* f _
#include <vector>
0 y3 a: ^0 v3 N#include <base_utils/IFail.hxx>
: i& W7 z. q" f#include <base_utils/ScopedSmPtr.hxx>+ R9 s; Z" \3 c, S+ g
#include <base_utils/TcResultStatus.hxx>
; C3 A. l, H7 n# y: A#include <metaframework/BusinessObjectRegistry.hxx>
$ @2 d) B8 y6 J/ O#include <metaframework/ReviseInput.hxx>5 F" E' i6 l3 s8 j8 D% {
#include <mld/logging/TcMainLogger.hxx>8 `6 `" i; ~4 p x p3 W! ?. f2 d
#include <tccore/ItemRevision.hxx>% |1 ?# u# G/ t! d
#include <metaframework/BusinessObjectRef.hxx>
6 h) y) q# z! y7 [1 u#include <metaframework/BusinessObjectRegistry.hxx>; m% o! X; j! v) Y( f: K9 K5 Y
#include <metaframework/ReviseInput.hxx>
3 S* I5 B0 O) z! b) y. L8 v* @* G7 h- _
using namespace std;
/ Q# g1 E& X3 m% {! V; v2 o, T( ]using namespace Teamcenter;8 C+ Y6 w% @8 i! y
using Teamcenter::Main::logger;) n; _! J+ g0 `$ n
! \' r D1 r* X& n3 G. u
int ITK_user_main(int argc, char* argv[])
: {% W3 x, w! F+ L6 \$ H{8 ^8 ^! u; n" ]9 S) B) z
int ifail = ITK_ok;
# T* M$ j) ~3 Z+ Y7 B$ c$ H ResultStatus stat;
I/ ~" Y" C8 R3 ^ try
2 A4 [1 b6 x: b' a* M {
1 y c; O8 k! u' H0 k. E/ L stat = ITK_initialize_text_services(ITK_BATCH_TEXT_MODE); ! {& S! q z4 ^& G9 h3 ~ H
stat = ITK_auto_login();
# y7 d% h. U/ S+ y3 Z5 S stat = ITK_set_journalling(TRUE); }( G. ]1 \8 K, z
c& N. j4 P) {! Y char item_id[ITEM_id_size_c +1] = "0000000";- s7 a9 t* h; ~' i% E
char *i = ITK_ask_cli_argument("-i=");/ W% f1 b+ }3 W2 o8 A. U. Q
. `& {5 O7 _) q2 x" i) d
if (i != NULL) strcpy(item_id, i);
6 J/ }9 m6 `5 n" p cout << endl << " ID: " << item_id << endl << endl;2 Y* z* l8 i/ P1 P
5 G$ A$ _: m* ^; \ tag_t tItem = NULLTAG;
+ t& t6 v6 j4 } }6 v stat = ITEM_find_item(item_id, &tItem);. A' Z3 `: v, L w* z7 ]
7 ?5 J. u6 D2 q- _) W5 ]
tag_t tLatestRev = NULLTAG;
4 m- y- y8 C# W. z stat = ITEM_ask_latest_rev(tItem, &tLatestRev); ! c( F+ N9 k- ~. R1 W
& x) F$ E3 T6 ~% P1 a char *pszType = NULL;0 P" J0 `3 h# v8 b- M8 s5 [
stat = WSOM_ask_object_type2(tLatestRev, &pszType);# `# }4 ]5 n: _ M
( g0 P4 q! J: {8 M1 `: O- Z
BusinessObjectRegistry& boReg = BusinessObjectRegistry::instance();6 l2 |5 A/ ?( {# k* d/ K
3 j* c4 `& g+ ~$ Z9 `" B+ }$ S string revOp = "Revise";7 F/ J3 _' i& U
ReviseInput* pReviseInput = 8 k! m* O2 L+ U+ T
dynamic_cast<ReviseInput*>(boReg.createInputObject(pszType, revOp));
$ X" k# \1 O9 @. C9 v$ E( P& V
, N, n) e% J9 Z$ b1 ^ BusinessObjectRef<ItemRevision > boLatestRev(tLatestRev);: v3 q$ ]' ^$ P1 j4 D1 W7 g
) o8 X; s, V8 j6 Q$ z6 t6 }) J
vector<Teamcenter: eepCopyData* > deepCopyData;
4 v' }1 Z( F$ ~5 T2 z boLatestRev->getDeepCopyData(&revOp, &deepCopyData);
3 v9 |0 S+ o1 G 2 h7 P$ ]' r; G- S. G0 U. L4 _ O! z
pReviseInput->setLogical("performDeepCopy", true, false );
0 f7 M9 O' t8 B% V3 u" ]9 Y ! o: p9 c* I$ {( v5 ~8 |
tag_t tRev = NULLTAG;* T4 {1 d6 k3 {, r. b# h; C. i
boLatestRev->revise(pReviseInput, &deepCopyData, &tRev);
( a, f5 ~! l# D! K: K0 @" a1 u& P2 o/ b
stat = AOM_save_with_extensions(tRev);
) `/ {0 Z2 T" J" y5 p, u
u' K( C- y# G4 B. Y/ X; e8 ^6 u3 [ char *pszId = NULL;
4 ~1 T% f1 U; M stat = WSOM_ask_object_id_string(tRev, &pszId);
5 m; H L+ G4 A1 m+ @3 I9 k" ~ cout << endl << " Object String: " << pszId << endl << endl;1 a' V* X# R G1 N
+ S0 W; B6 ]/ G' J) `. k
if (pszType) MEM_free(pszType);
) Q) x4 J0 h/ P: I) }) ]& v: c if (pszId) MEM_free(pszId); # {5 d# u& p" i6 ]
}6 P0 h# g" N+ i
catch( const IFail &ex )& j4 P, [! G. N' l5 d- d
{
& i# o: Y) d8 N! c# \7 u2 q logger()->error( ex.ifail(), ex.getMessage());
, n2 [: \# ^1 g7 Q) h, b; { cout << ex.getMessage() << endl;/ r8 V' r8 I6 S/ \3 M5 e2 \2 U
cout << "error " << ex.ifail() << endl; , z5 Z) D! a6 p9 o( Y* U9 [( U' r$ x# s8 x2 Z
}
5 _& u5 l1 `4 X& i* _4 m const char* syslog_path;
- x+ E& W1 q3 l' d- p syslog_path = EMH_ask_system_log();
, w, D$ i0 q4 R" F# E7 V& B) l cout << endl << endl;
3 Y: w8 `. e4 W; a% q, w2 w0 s cout << syslog_path << endl;
. K8 [$ L! _8 O: k, ]
/ s4 P, \' ?+ H) g. V! R stat = ITK_exit_module(FALSE); * `& B! F) u) W* D* U3 ~( B
return ITK_ok;
7 K7 a; ~0 y! [/ y5 t6 J: J/ c/ U9 v}[/mw_shl_code]
$ j4 { Q) \( y& A' x) y: I |
|