Tag: Aras

  • Aras Innovator – 安裝後造成IIS無法啟動的解決方式

    若發生安裝完Aras Innovator後,出現IIS無法啟動的狀況,請參閱下圖修改IIS的applicationHost.config檔案,刪除整個<system.web>區段的內容即可。

  • Aras Innovator – Update parent ItemType Property by Relationship 透過單身欄位的 JavaScript 更新單頭欄位

    // Sample: Update custom Part field [total_qty] by edit relationship item property [qty] on CellChange event.
    var itmPart = typeof(parent.document.thisItem) == "object" ? parent.document.thisItem : parent.thisItem;
    var rels = itmPart.getRelationships("Part BOM");
    var count = rels.getItemCount();
    var inn = itmPart.getInnovator();

    var totalQty = 0;
    for (var i = 0; i < count; i++) {
    var rel = rels.getItemByIndex(i);
    totalQty = totalQty + parseInt(rel.getProperty("qty", "0"));
    }

    var qty = getRelationshipProperty(relationshipID, "qty");
    itmPart.setProperty("total_qty", totalQty);
    setTimeout(function(){ aras.uiReShowItem(itmPart.getID(), itmPart.getID()); }, 100);
  • Aras Innovator – Show Tab By Classification 透過javascript控制頁籤的顯示

    於Form表單開啟時或是特定欄位值變更後,觸發Client Method。

    function showTabByClassification() {
    	if (!parent.relationships) {
    		setTimeout(showTabByClassification, 30);
    		return;
    	}
    	var tabbar = parent.relationships.relTabbar;
    	if (parent.relationships.document.readyState !== "complete" 
    	|| !parent.relationships.relTabbarReady
    	|| parent.relationships.relTabbar.GetTabOrder("|")===""
    	|| !parent.relationships.currTabID) {
    		setTimeout(showTabByClassification, 30);
    	} else {
    		var tabID = null;
    		tabID0 = tabbar.GetTabId("Workflow Sign-Offs");
    		tabID1 = tabbar.GetTabId("Parts");
    		tabID2 = tabbar.GetTabId("Documents");
    		tabID3 = tabbar.GetTabId("Attachments");
    		if (classification === "Class A") {
    			tabbar.SetTabVisible(tabID1, true);
    			tabbar.SetTabVisible(tabID2, true);
    			tabbar.SetTabVisible(tabID3, false);
    		}
    		else if (classification === "Class B") {
    			tabbar.SetTabVisible(tabID1, true);
    			tabbar.SetTabVisible(tabID2, true);
    			tabbar.SetTabVisible(tabID3, true);
    		}
    		else {
    		    tabbar.selectTab(tabID0);
    			tabbar.SetTabVisible(tabID1, false);
    			tabbar.SetTabVisible(tabID2, false);
    			tabbar.SetTabVisible(tabID3, false);
    		}
    	}
    } 
    setTimeout(showTabByClassification, 30);
  • Aras Innovator – 透過外部程式實現排程Scheduler自動化執行作業

    排程(Scheduler)為付費訂閱(Subscription)才能啟用的功能,但也可透過自行開發簡易程式的方式實現。

    作法為透過引用 IOM.dll、Aras.Net.dll 來呼叫 Aras Innovator Server 上要定時執行的Method,並透過 Windows 內建的工作排程器來實現排程。

    以下為外部程式呼叫 Method 的 C# 程式:

    using System;
    using Aras.IOM;
    
    class ArasAdapter
    {
        HttpServerConnection _serverConn;
    
        public ArasAdapter(string url, string db, string user, string password)
        {
            _serverConn = IomFactory.CreateHttpServerConnection(url, db, user, password);
        }
    
        public void ApplyMethod(string method)
        {
            //Login
            Item login_result = _serverConn.Login();
            if (login_result.isError())
                throw new Exception($"Login failed");
    
            //Initial
            Innovator inno = IomFactory.CreateInnovator(conn);
    
            //ApplyMethod
            Item applyMethod_result = inno.applyMethod(method, "");
            if (applyMethod_result.isError())
                throw new Exception($"Apply [{method}] method failed");
    
            //Logout
            _serverConn.Logout();
        }
    }

  • Aras Innovator – 手動重置流程關卡到第一關

    0. 注意事項
    * 重置單據流程到第1個關卡的動作建議使用在單據不小心被'Cancel'的狀況。
    * 請務必確認目標單據在簽核過程中是否已經異動到其他ItemType如料件Part的新增或修改,如果有的話請勿進行操作。

    1. WORKFLOW_PROCESS
    * [STATE]: 'Active'
    * [CURRENT_STATE]: 參考其他[STATE]為'Active'的資料來修改
    * [CLOSED_DATE]: NULL

    2. ACTIVITY
    (Activity.ID=WORKFLOW_PROCESS_ACTIVITY.RELATED_ID, WORKFLOW_PROCESS_ACTIVITY.SOURCE_ID=WORKFLOW_PROCESS.ID)
    * 以下異動排除[NAME]為'START'的資料
    * [STATE]: 先將所有資料改成'Pending',再將第1個關卡改成'Active'
    * [CURRENT_STATE]: 參考其他[CURRENT_STATE]為'Pending'和'Active'的資料來修改
    * [CLOSED_DATE]: NULL

    3. ACTIVITY_ASSIGNMENT
    (ACTIVITY_ASSIGNMENT.SOURCE_ID=Activity.ID)
    * 以下異動針對2.所異動的資料
    * [PATH]=NULL
    * CLOSED_BY=NULL
    * CLOSED_ON=NULL

    4. 修改目標單據ItemType
    * 推升Lifecycle到初始狀態,如果無法推升可直接修改[STATE]和[CURRENT_STATE]
    * 如果Lifecycle沒有設定權限連動的話,請修改[PERMISSION_ID]
  • Aras Innovator – Server Method for Client

    /*
    Use parameters that send from other method and Aras PLM permission to query the sql server.
    */

    var inn = this.getInnovator();
    var classification = this.getPropertyAttribute("Item","classification");
    var item_number = this.getPropertyAttribute("Item","item_number");

    Aras.Server.Security.Identity plmIdentity = Aras.Server.Security.Identity.GetByName("Aras PLM");
    bool permissionWasSet = Aras.Server.Security.Permissions.GrantIdentity(plmIdentity);
    try {
    var callframe = inn.newItem("SQL", "SQL PROCESS");
    callframe.setProperty("name", "GetLatestVersion");
    callframe.setProperty("PROCESS", "CALL");
    callframe.setProperty("ARG1", classification);
    callframe.setProperty("ARG2", item_number);
    callframe.setProperty("ARG3", year);
    var specialNumber = callframe.apply();
    return specialNumber;
    }
    finally {
    if (permissionWasSet) {
    Aras.Server.Security.Permissions.RevokeIdentity(plmIdentity);
    }
    }

  • Aras Innovator – Client Side Call Server Method

    /*
    Use server side method to solve sql query issue that client side method do not have permission.
    (Server side method could use Aras.Server.Security to grant Aras PLM permission)
    */

    // Create server side method query
    var queryDOM = top.aras.createXMLDocument();

    queryDOM.loadXML("<Item/>");
    queryDOM.documentElement.setAttribute("classification", classification.value);
    queryDOM.documentElement.setAttribute("item_number", item_number.value);
    var returnXML = top.aras.applyMethod("GetLatestVersion", queryDOM.xml);

    // Parse return xml data
    var docReturn = top.aras.createXMLDocument();

    docReturn.loadXML(specialNumber);
    var partMajorRev = docReturn.selectSingleNode("Item/major_rev").text;
    var partGeneration = docReturn.selectSingleNode("Item/generation").text;

    alert(partMajorRev + partGeneration);
    
    
  • Aras Innovator – 表單流程簽核架構

    ItemType—>Workflow—>Workflow Process—>Workflow Process Activity—>Activity—>Activity Assignment—>Identity

  • Aras Innovator – Dynamic Add Assignment By Property 以表單欄位做為簽核人員

    在 activity 的 on activate server event 建立對應的 server side method。該 method 的思路是從Activity Id 一路找到 ItemType 中目標簽核人員 (Identity) 的 property,再以此新增 Activity Assignment 到當前的 Activity。

    
    /*
    This method used for activity's on activate event.
    */
    
    // Target itemtype, property
    const string itemName = "Test ItemType";
    const string propertyName = "pm_id";
    
    // Target assignment parameters
    const bool assignRequired = false;
    const bool assignAllMember = true;
    const int assignVoteWeight = 100;
    
    Innovator inn = this.getInnovator();
    string actId = this.getID();
    string aidId = String.Empty;
    
    // Get assign identity
    Item itemType = inn.newItem(itemName, "get");
    Item wflItem = itemType.createRelationship("Workflow", "get");
    Item wpcItem = wflItem.createRelatedItem("Workflow Process", "get");
    Item wpaItem = wpcItem.createRelationship("Workflow Process Activity", "get");
    wpaItem.setProperty("related_id", actId);
    itemType = itemType.apply();
    aidId = itemType.getProperty(propertyName);
    if(aidId == null) {
    return inn.newError("Could not get assignment identity!");
    }
    
    // Create assignment to activity (need Aras PLM permission)
    Aras.Server.Security.Identity plmIdentity = Aras.Server.Security.Identity.GetByName("Aras PLM");
    
    bool permissionWasSet = Aras.Server.Security.Permission.GrantIdentity(plmIdentity);
    try {
    // Make sure assigned identity is not exist in activity
    Item assItem = inn.newItem("Activity Assignment", "get");
    assItem.setProperty("source_id", actId);
    assItem.setProperty("related_id", aidId);
    bool noExistIdentity = assItem.apply().getItemCount() == 0;
    if(noExistIdentity) {
    // Add
    assItem.setAction("add");
    assItem.setProperty("is_required", assignRequired ? "1" : "0");
    assItem.setProperty("for_all_members", assignAllMember? "1" : "0");
    assItem.setProperty("voting_weight", assignVoteWeight.ToString());
    assItem.apply();
    }
    }
    finally {
    if (permissionWasSet) {
    Aras.Server.Security.Permissions.RevokeIdentity(plmIdentity);
    }
    }
    
    return this;