查看: 1970|回复: 0

【Aras二次开发】查询和迭代查找item集

[复制链接]

2477

主题

1280

回帖

8万

积分

管理员

PLM之家站长

积分
82265
QQ
发表于 2018-8-1 13:37:47 | 显示全部楼层 |阅读模式

请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!

您需要 登录 才可以下载或查看,没有账号?注册

×

' h2 V7 p" r! o+ x: {) n  \- C# ^, b. Z) o+ w* `( l) P, [$ c

( u+ O: K; K5 V1 B3 Y0 }$ D8 [

( W7 j* i% P, TTechnique  - ~: K# ?/ j# e- J8 k& s
There is no difference in setting up a query for a single Item or for many.  Only the
. {7 ~- a" [8 `- S" e+ J: |! }criteria define the set size returned.  In this recipe you create an Item and populate 2 f' Q; y6 V* L
the query criteria, apply it, and iterating over the Items returned producing a HTML 6 M* m6 H% r% I& h: ^
<TABLE>  fragment. 7 e" Q0 n6 i4 ~' r+ V8 B
# a4 v* i5 P( _0 G  X' M

) n' d, y3 J' D+ P, ?! q3 M) GJavaScript  
1 l3 B9 Z: d4 H4 rvar qryItem = this.newItem("Part","get"); # f$ I7 u) v3 o) w) l- E8 b% p$ ]
qryItem.setAttribute("select","item_number,description,cost"); " t. u" C$ f) k9 u: X
qryItem.setProperty("cost", "100", "gt");   W0 R, M; G6 H  t
var results = qryItem.apply();
  w3 d- M! S' c) n9 n/ d8 zvar count = results.getItemCount();
  F5 a; \* a+ M1 z: Tvar content = "<table>";
' R; H2 W$ Q0 J# _( e0 ~for (var i=0; i<count; ++i)
5 i; R" Z. u4 ^% l4 \( n6 k{ " d7 V) P7 ~2 p
  var item = results.getItemByIndex(i);
1 |9 o) G$ r: b' `7 t7 Z* P  content += "" + % [6 D1 ]$ a1 S6 a, \9 c) M1 m* L
    "<tr>" +
- ]+ L8 ]  s1 }      "<td>" + item.getProperty("item_number") + "</td>" + 9 O! t9 }  J2 w( u6 U% v1 C
      "<td>" + item.getProperty("description") + "</td>" + : y7 ~3 y) \% K& F+ n
      "<td>" + item.getProperty("cost") + "</td>" +
/ v4 t& f. A2 ~    "</tr>";   e& l% Z2 ^- d2 Y# y3 z4 M) p
}
5 V% A4 D$ w- Tcontent += "</table>";
7 _% s% h) Z0 b# Kreturn content;
9 ?+ t- C# w  i) R. e 0 P7 k; D; Z' `: U3 O/ H* t3 G
C#  
( r' s( \$ U( D' x/ oItem qryItem = this.newItem("Part","get"); 1 E1 }% t' y  K1 p9 R
qryItem.setAttribute("select","item_number,description,cost"); % M" g/ q# [/ ^0 U. {
qryItem.setProperty("cost", "100", "gt"); 1 S/ C4 @3 @& T5 O
Item results = qryItem.apply(); : {& H( g6 C( ~% z
int count = results.getItemCount();
/ Y" N5 b. H# V9 ?2 a- M, |% s+ p- p4 }. kint i; 9 t6 g4 e, R! D. _: ~, l
string content = "<table>"; : x/ y8 o/ @8 k7 U8 \4 n5 ^
for (i=0; i<count; ++i) $ @) K' E4 N& F$ L$ O. y1 J
{
+ Y5 d' ]7 E1 h& ?9 r: _; L  Item item = results.getItemByIndex(i); ' o8 ^4 p; p" Z! K# q$ C
  content += "" + % m; F, b, p9 M6 ~6 X1 W
    "<tr>" +
- c6 ?1 E2 l, O5 h+ \: M9 b. Q      "<td>" + item.getProperty("item_number") + "</td>" + & `( c( [3 l$ ^* \6 |* w
      "<td>" + item.getProperty("description") + "</td>" +
4 Y3 C# `+ K. ?7 B& W# {3 h      "<td>" + item.getProperty("cost") + "</td>" + # O/ o  E( U& i& l6 g
    "</tr>";
( n% I$ @& _2 e! A! ~1 ]} - X, E% D# v' m' r- n
content += "</table>"; . u$ v" o1 F$ t( h8 t+ r: A
Innovator innovator = this.newInnovator();
! V" [* r' N" q# }, }0 D( p9 y2 Breturn innovator.newResult(content);
5 I& y, {& C* e. }
: r% U9 Z2 Q) L5 `& h2 |4 W; DVB.Net  
* L1 M3 K# Z6 M' x5 V0 U4 JDim qryItem As Item = Me.NewItem("Part","get") / a5 w/ m  Q; T* p1 e
qryItem.SetAttribute("select","item_number,description,cost") 4 L3 {9 _" k5 A" o; I
qryItem.SetProperty("cost", "100", "gt") ! A: U4 {9 V" o
Dim results As Item = qryItem.Apply() ! {; D9 P5 R! j
Dim count As Integer = results.GetItemCount()
: k2 w% r. H0 MDim i As Integer
2 \, O" {; p9 \- U: d6 z6 QDim content As String = "<table>" ' A$ `4 u* I3 Z, k2 V+ q$ G
For i=0 to count - 1
5 P+ g$ O1 ^# u0 y; b  Dim item As Item = results.GetItemByIndex(i)
/ D! x8 n) o' `1 l) X  content += "" + _
: P& Y8 N9 s3 k( b    "<tr>" + _
: v: T8 R8 j8 f7 d7 [      "<td>" + item.GetProperty("item_number") + "</td>" + _
+ ^* x- `0 q9 ^/ x0 `5 _% U      "<td>" + item.GetProperty("description") + "</td>" + _
8 d( b1 V) y: A3 z  ^      "<td>" + item.GetProperty("cost") + "</td>" + _
. h( B; I& }$ o: W6 Y/ ^    "</tr>"
/ ?" x/ u+ O( N# JNext ! {  a% w, }! S1 G& w
content += "</table>" 6 Y& [: y4 ^2 ^- Y: X; ^# }. [& |
0 }1 y8 k$ z& @, u5 k; f
Dim innovator As Innovator = Me.NewInnovator() 6 \" c& }  p; Y
return innovator.NewResult(content)   [9 r- g8 D) r& W$ E* l" B* ]

. V' c0 R. s2 p' H7 H2 |  I( B( _: b: K: D2 R% F
上海点团信息科技有限公司,承接UG NX,CATIA,CREO,Solidworks 等CAx软件,Teamcenter,3D Experience等PLM软件,工业4.0数字化软件的实施\二次开发\培训相关业务,详情QQ 939801026 Tel 18301858168 网址 doTeam.tech
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

在本版发帖
关注公众号
QQ客服返回顶部