[服务器端开发] 【Aras二次开发】通过Item查询关系Item信息

2018-8-1 13:41:14 241 0

[复制链接]
admin 发表于 2018-8-1 13:41:14 | 显示全部楼层 |阅读模式

admin 楼主

2018-8-1 13:41:14

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

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

x
Technique  
To query for an Item and retrieve its structure you build the query as the structure
you want returned.  Use the IOM methods to add the relationships you want and
build the structure in the Item.  The server will return the structure that follows the
request structure.
This recipe illustrates several related concepts together, which are how to get a set
of Items from an Item and how to iterate over the set, plus how to get the related
Item from the relationship Item.
JavaScript  
var innovator = this.newInnovator();

// Set up the query Item.
var qryItem = this.newItem("Part","get");
qryItem.setAttribute("select","item_number,description,cost");
qryItem.setID(myId);

// Add the BOM structure.
var bomItem = this.newItem("Part BOM","get");
bomItem.setAttribute("select","quantity,related_id(item_number,description,cost)");
qryItem.addRelationship(bomItem);

// Perform the query.
var results = qryItem.apply();

// Test for an error.
if (results.isError()) {
  top.aras.AlertError("Item not found: " + results.getErrorDetail());
  return;
}

// Get a handle to the BOM Items.
var bomItems = results.getRelationships();
var count = bomItems.getItemCount();

// Create the results content.
var content = "<table border='1'>" +
  "<tr>" +
    "<td>Part Number</td>" +
    "<td>Description</td>" +
    "<td>Cost</td>" +
    "<td>Quantity</td>" +
  "</tr>";

// Iterate over the BOM Items.
for (var i=0; i<count; ++i)
{
// Get a handle to the relationship Item by index.
  var bom = bomItems.getItemByIndex(i);
// Get a handle to the related Item for this relationship Item.
  var bomPart = bom.getRelatedItem();

  content += "<tr>" +
      "<td>" + bomPart.getProperty("item_number") + "</td>" +
      "<td>" + bomPart.getProperty("description") + "</td>" +
      "<td>" + bomPart.getProperty("cost") + "</td>" +
      "<td>" + bom.getProperty("quantity") + "</td>" +
    "</tr>";
}
return content + "</table>";




C#  
Innovator innovator = this.newInnovator();

// Set up the query Item.
Item qryItem = this.newItem("Part","get");
qryItem.setAttribute("select","item_number,description,cost");
qryItem.setID(myId);

// Add the BOM structure.
Item bomItem = this.newItem("Part BOM","get");
bomItem.setAttribute("select","quantity, related_id(item_number,description,cost)");
qryItem.addRelationship(bomItem);

// Perform the query.
Item results = qryItem.apply();

// Test for an error.
if (results.isError()) {
  return innovator.newError("Item not found: " + results.getErrorDetail());
}

// Get a handle to the BOM Items.
Item bomItems = results.getRelationships();
int count = bomItems.getItemCount();
int i;

// Create the results content.
string content = "<table border='1'>" +
  "<tr>" +
    "<td>Part Number</td>" +
    "<td>Description</td>" +
    "<td>Cost</td>" +
    "<td>Quantity</td>" +
  "</tr>";

// Iterate over the BOM Items.
for (i=0; i<count; ++i)
{
// Get a handle to the relationship Item by index.
  Item bom = bomItems.getItemByIndex(i);
// Get a handle to the related Item for this relationship Item.
  Item bomPart = bom.getRelatedItem();

  content += "" +
    "<tr>" +
      "<td>" + bomPart.getProperty("item_number") + "</td>" +
      "<td>" + bomPart.getProperty("description") + "</td>" +
      "<td>" + bomPart.getProperty("cost") + "</td>" +
      "<td>" + bom.getProperty("quantity") + "</td>" +
    "</tr>";
}
content += "</table>";

return innovator.newResult(content);







    Page 46

Copyright   2007
Aras Corporation.  
All Rights Reserved.
VB.Net  
Dim innovator As Innovator = Me.newInnovator()

' Set up the query Item.
Dim qryItem As Item = Me.newItem("Part","get")
qryItem.setAttribute("select","item_number,description,cost")
qryItem.setID(myId)

' Add the BOM structure.
Dim bomItem As Item = Me.newItem("Part BOM","get")
bomItem.setAttribute("select","quantity,related_id(item_number,description,cost)")
qryItem.addRelationship(bomItem)

' Perform the query.
Dim results As Item = qryItem.apply()

' Test for an error.
If results.isError() Then
  Return innovator.newError(results.getErrorDetail())
End If

' Get a handle to the BOM Items.
Dim bomItems As Item = results.getRelationships()
Dim count As Integer = bomItems.getItemCount()
Dim i As Integer

' Create the results content.
Dim content As String = "<table border='1'>" + _
  "<tr>" + _
    "<td>Part Number</td>" + _
    "<td>Description</td>" + _
    "<td>Cost</td>" + _
    "<td>Quantity</td>" + _
  "</tr>"

' Iterate over the BOM Items
For i = 0 To count - 1
' Get a handle to the relationship Item by index.
  Dim bom As Item = bomItems.getItemByIndex(i)

' Get a handle to the related Item for this relationship Item.
  Dim bomPart As Item = bom.getRelatedItem()

  content += _
    "<tr>" + _
      "<td>" + bomPart.getProperty("item_number") + "</td>" + _
      "<td>" + bomPart.getProperty("description") + "</td>" + _
      "<td>" + bomPart.getProperty("cost") + "</td>" + _
      "<td>" + bom.getProperty("quantity") + "</td>" + _
    "</tr>"
Next
content += "</table>"

Return innovator.newResult(content)

上海点团信息科技有限公司,承接UG NX,CATIA,CREO,Solidworks 等CAx软件,Teamcenter,3D Experience等PLM软件,工业4.0数字化软件的实施\二次开发\培训相关业务,详情QQ 939801026 Tel 18301858168 网址 www.diantuankj.com/ doTeam.tech
回复

使用道具 举报

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

返回列表 本版积分规则

用户组 : 管理员
邮   箱 :xduniverse@qq.com
手   机 :VIP用户可查看[申请]
Q   Q : 点击这里给我发消息
性别 : 就不告诉你
主页 :http://www.plmhome.com
个人介绍 :原西门子NX高级教务员,10多年NX培训,开发咨询,Teamcenter培训实施等

主题2126

帖子3334

积分62589

  • NX版本发布Roadmap 路

    NX版本发布Roadmap 路线图,没有NX13, NX1847将

  • NX1847 和 NX12 相关

    https://www.plm.automation.siemens.com/glob

  • Asp.net站点实现Aras

    1、创建Web站点: 2、添加dll引用: 三

  • NX12.0.2 升级或安装

    NX12.0.2 升级或安装图文教程 (1)下载安装包

  • Aras一个Web站点下创

    创建多个Instance,其实就是创建多个Database,用

  • 发布新帖
  • 在线客服1
  • 在线客服2
  • 微信
  • 客户端
  • 返回顶部
  • NX讨论
    Catia
    TC讨论
    Tecno
    云课堂
    业务合作
    快速回复 返回顶部 返回列表