iT邦幫忙

2018 iT 邦幫忙鐵人賽
DAY 12
0
自我挑戰組

Aras PLM開發練功30天系列 第 12

[Aras Day12] Poly Item物件- DCO變更流程

如何讀取變更流程的受影響物件
受影響物件

poly item就像是一個箱子,可以讓我把蘋果物件或香蕉物件放進去。也就一個容器可以存入不同物件類型(itemtype)的物件。

Affected Item受影響物件中,舊物件欄位、新物件欄位的屬性定義為Change Controlled Item也就屬於poly item。
poly item

程式碼如下

Innovator inn = this.getInnovator();
// return inn.newError(this.getID());
Item DCO_Affected_Item = inn.newItem("Express DCO Affected Item", "get");
DCO_Affected_Item.setAttribute("select", "source_id,related_id");
DCO_Affected_Item.setProperty("source_id", this.getID());
DCO_Affected_Item = DCO_Affected_Item.apply();

string res="";

for(int i=0;i<DCO_Affected_Item.getItemCount();i++){
    Item temp=DCO_Affected_Item.getItemByIndex(i);
    temp=temp.getItemsByXPath("related_id/Item");
    if(temp.getProperty("action")=="Add")
    {
        string new_item_id=temp.getProperty("new_item_id");
        Item ChCtrI = inn.newItem("Change Controlled Item","get");
        ChCtrI.setAttribute("select","id,classification,itemtype,item_number");
        ChCtrI.setProperty("id",new_item_id);
        ChCtrI=ChCtrI.apply();
        string itm_classfication=ChCtrI.getProperty("classification");
        string itm_itemtype=ChCtrI.getPropertyAttribute("id","type");
        string itm_item_number=ChCtrI.getProperty("item_number");
       
    }
    else if(temp.getProperty("action")=="Change")
    {
        // string[] action_itm={"new_item_id","affected_id"};
        string[] action_itm={"affected_id"};
        for(int j=0;j<action_itm.Count();j++){
            string new_item_id=temp.getProperty(action_itm[j]);
            Item ChCtrI = inn.newItem("Change Controlled Item","get");
            ChCtrI.setProperty("id",new_item_id);
            ChCtrI=ChCtrI.apply();
            string itm_classfication=ChCtrI.getProperty("classification");
            string itm_itemtype=ChCtrI.getPropertyAttribute("id","type");
            string itm_item_number=ChCtrI.getProperty("item_number");
            
        }
    }
    else if(temp.getProperty("action")=="Delete")
    {
        string affected_id=temp.getProperty("affected_id");
        Item ChCtrI = inn.newItem("Change Controlled Item","get");
        ChCtrI.setProperty("id",affected_id);
        ChCtrI=ChCtrI.apply();
        string itm_classfication=ChCtrI.getProperty("classification");
        string itm_itemtype=ChCtrI.getPropertyAttribute("id","type");
        string itm_item_number=ChCtrI.getProperty("item_number");
        
    }
}

return this;

上一篇
[Aras Day11] 前端物件top.aras
下一篇
[Aras Day13] SystemEvent-系統事件
系列文
Aras PLM開發練功30天30
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友留言

立即登入留言