PLM之家PLMHome-工业软件践行者

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

[复制链接]

2018-8-1 13:37:47 1631 0

2470

主题

1275

回帖

8万

积分

管理员

PLM之家站长

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

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

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

x

+ s& s/ U) i- ]8 I+ T" f, u# \9 Y' a/ B, R

' H' \" f/ y$ c7 B0 v

' r( I$ w) F$ p; H$ ]# a- P! b- HTechnique  
( C% p1 w- y: z9 b# |- dThere is no difference in setting up a query for a single Item or for many.  Only the
9 a3 ]. w" _; o* bcriteria define the set size returned.  In this recipe you create an Item and populate * S/ {& L( [4 B5 _
the query criteria, apply it, and iterating over the Items returned producing a HTML : C  U0 f- F! U; b1 c4 [$ g
<TABLE>  fragment.
- D, `* p5 d- P! x! I% f
) ?! _' w: k- X$ Q
7 V$ {7 {! W+ S3 S& U# Y# F
JavaScript  
. L3 I8 {( B1 |" M* J& z: Y; Yvar qryItem = this.newItem("Part","get");
  c+ }" F" S6 K- {4 ^0 y. j# JqryItem.setAttribute("select","item_number,description,cost");
: Z; T2 I  U) XqryItem.setProperty("cost", "100", "gt");
9 U1 P2 H7 f+ E7 ]. I/ Zvar results = qryItem.apply(); 6 |5 f" @5 C$ w6 O, R2 ]6 s
var count = results.getItemCount();
# X$ m6 C% d& V& w  ?% V* H& qvar content = "<table>"; 6 X( e! {1 ^/ i5 \2 o  R
for (var i=0; i<count; ++i) " I0 R2 N. [) f0 I* r
{
9 r" H0 H& n" K- U' K( Z; N9 J  f  var item = results.getItemByIndex(i);
. y- N6 B+ z! [2 ]" y- [* N  content += "" + 1 y% Y# [4 M2 ?" p; s
    "<tr>" +
+ u: C  C' |$ u      "<td>" + item.getProperty("item_number") + "</td>" +
! W% L% Q1 S* R6 D8 P      "<td>" + item.getProperty("description") + "</td>" +
$ q0 P1 U) u, F1 r      "<td>" + item.getProperty("cost") + "</td>" +
7 l. d$ H4 p2 f0 p& S. ^" W. h- I3 G    "</tr>"; 8 ^# ~: Z* f  x$ s0 i# a
}
- t: }; T2 n7 D  Wcontent += "</table>";
4 O( x7 f- z# x, k0 Z, ~return content; 4 U% Z! K1 ]; t' X; ?

# E" E0 N  c: p5 t" dC#  
2 R7 j+ T  N! m& P1 }+ qItem qryItem = this.newItem("Part","get"); 1 u1 F. G4 a! Y  V: ]/ h6 I
qryItem.setAttribute("select","item_number,description,cost"); * y8 [, ?2 c5 X2 Q/ s
qryItem.setProperty("cost", "100", "gt");
  W  P5 Y5 V( ^/ ^- d! Z- TItem results = qryItem.apply();
( L* ~( F" I2 U2 h4 i5 L# nint count = results.getItemCount();   }+ l4 W, o9 D8 P
int i; 3 V7 |- ~) H! m) Y
string content = "<table>"; . k6 P2 `8 r5 k+ B# N
for (i=0; i<count; ++i) / Z0 m; `0 _* Y/ s# g
{
7 B0 j+ _  b" Q  A, K6 t1 y6 u  Item item = results.getItemByIndex(i);
, h/ v4 d. D6 M, i  r) G: q% B  content += "" +
; C  b9 E; d  H    "<tr>" +
( r$ O& m* Q6 W+ b" a, z      "<td>" + item.getProperty("item_number") + "</td>" +
& M. p$ q! `6 w7 q      "<td>" + item.getProperty("description") + "</td>" +
' ~( K, n2 v! F+ q1 W) M: G+ E      "<td>" + item.getProperty("cost") + "</td>" +
0 u& s9 ^! F3 Z    "</tr>"; 2 g' g2 B8 o; H, Q/ ?; j  ?
} # k, B5 R$ }7 B
content += "</table>";
4 Q9 V+ N! E+ G; AInnovator innovator = this.newInnovator();
+ N7 Z0 _; o9 Z( N9 t9 U& Mreturn innovator.newResult(content);
) j8 R) |8 x' R* _& X$ l
8 Z' S! [" U9 b  R& H3 [VB.Net  " @; x) Y0 ]4 }( a* ^9 }  z0 K
Dim qryItem As Item = Me.NewItem("Part","get")
# y; R9 e0 q) F/ TqryItem.SetAttribute("select","item_number,description,cost")
) u+ h3 l& `9 R9 p& u# v9 b3 DqryItem.SetProperty("cost", "100", "gt") 0 L8 d( O! D  A/ T
Dim results As Item = qryItem.Apply()
  |* C+ q0 T' `Dim count As Integer = results.GetItemCount() : Z1 r  ~4 v1 N2 ~  U
Dim i As Integer
) K8 m4 v1 Q' Q0 L5 VDim content As String = "<table>"
$ H7 k2 v8 h9 _9 @0 g3 D7 w8 r7 _For i=0 to count - 1
2 B$ Z) z/ p+ Z. s5 A  Dim item As Item = results.GetItemByIndex(i)
: x. V0 n- X+ y4 J" T  content += "" + _
) B+ f9 @% b! o# d% u    "<tr>" + _
  _( @! ?7 T+ N6 L% C4 n, G0 g. K. t2 O      "<td>" + item.GetProperty("item_number") + "</td>" + _
8 @" L! w3 M% B' K( D8 W* ~      "<td>" + item.GetProperty("description") + "</td>" + _
& y+ J" Y1 T2 m. }# R      "<td>" + item.GetProperty("cost") + "</td>" + _
( [! P# _) V6 _' _8 U$ G    "</tr>" & E* C  e& p. g7 A5 s" ]
Next 4 q5 h6 L, o! o7 e9 z" v- ^
content += "</table>"
, q- x! ]; D& d + O/ j7 e0 u, s. R5 z
Dim innovator As Innovator = Me.NewInnovator()
3 C. v6 ~# q# p& g9 `! P; G3 J# \return innovator.NewResult(content) * B2 p/ i1 p7 i( f# @

0 J6 M; E+ w, v
& C6 L  r0 a" y- _
上海点团信息科技有限公司,承接UG NX,CATIA,CREO,Solidworks 等CAx软件,Teamcenter,3D Experience等PLM软件,工业4.0数字化软件的实施\二次开发\培训相关业务,详情QQ 939801026 Tel 18301858168 网址 doTeam.tech
回复

使用道具 举报

发表回复

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

返回列表 本版积分规则

  • 发布新帖

  • 在线客服

  • 微信

  • 客户端

  • 返回顶部

  • x
    温馨提示

    本网站(plmhome.com)为PLM之家工业软件学习官网站

    展示的视频材料全部免费,需要高清和特殊技术支持请联系 QQ: 939801026

    PLM之家NX CAM二次开发专题模块培训报名开始啦

    我知道了