iT邦幫忙

2021 iThome 鐵人賽

DAY 19
0
自我挑戰組

從Agile PLM 移轉 Aras PLM大小事系列 第 19

19.移轉 Aras PLM大小事-表單團隊權限

  • 分享至 

  • xImage
  •  

本篇利用品保用的表單來說明
譬如一個問題處理單在工作流程中
會涉及好幾個單位成員
那麼權限的編輯開放給特定幾個人的話
則利用團隊這個模組(team_id欄位)
https://ithelp.ithome.com.tw/upload/images/20210919/20106503Fx1FZ2qn6p.png

一般操作
1.手動建立團隊
2.新增團隊成員
3.加入表單

我另外將操作用客製程式改為
1.在問題單頁籤加入名單
2.儲存問題單時,自動建立團隊與成員

其他就是團隊權限設定在問題單中
https://ithelp.ithome.com.tw/upload/images/20210919/20106503k46tkQ98ud.png

將以下程式碼建立於Itemtype
https://ithelp.ithome.com.tw/upload/images/20210919/201065038S1gvnldvG.png

inn = this.getInnovator();
return main(this);
}
private Item GetTeam(string keyed_name){
    Item itmTeam = inn.newItem("Team","get");
    itmTeam.setProperty("name",keyed_name);
    itmTeam = itmTeam.apply();
    return itmTeam;
}
private Item CreateTeam(string keyed_name){
    Item itmTeam = inn.newItem("Team","add");
    itmTeam.setProperty("name",keyed_name);
    itmTeam = itmTeam.apply();
    return itmTeam;
}
private void UpdateTeamMember_QSIssue(string form_id,string team_id){
    Item itmManager = inn.newItem("JPC QS Issue Related Manager","get");
    itmManager.setProperty("source_id",form_id);
    itmManager =  itmManager.apply();
    if(itmManager.isError()==false){
        for(int i=0;i<itmManager.getItemCount();i++){
            Item itmMember = itmManager.getItemByIndex(i);
            Item chkTeam = CheckMember(team_id,itmMember.getProperty("related_id",""));
            if(chkTeam.isError()){
                AddMember(team_id,itmMember.getProperty("related_id",""),true);
            }
        }
    }
    itmManager = inn.newItem("JPC QS Issue Related Owner","get");
    itmManager.setProperty("source_id",form_id);
    itmManager =  itmManager.apply();
    if(itmManager.isError()==false){
        for(int i=0;i<itmManager.getItemCount();i++){
            Item itmMember = itmManager.getItemByIndex(i);
            Item chkTeam = CheckMember(team_id,itmMember.getProperty("related_id",""));
            if(chkTeam.isError()){
                AddMember(team_id,itmMember.getProperty("related_id",""),false);
            }
        }
    }
}
private Item AddMember(string team_id,string ident_id,bool is_manager){
    Item itmTeamIdent = inn.newItem("Team Identity","add");
    itmTeamIdent.setProperty("source_id",team_id);
    itmTeamIdent.setProperty("related_id",ident_id);
    if(is_manager){
        //團隊主管Identity ID
        itmTeamIdent.setProperty("team_role","60EBF9D1BB584921A73FA2F8D74DAF80");
    }else{
        //團隊一般角色Identity ID
        itmTeamIdent.setProperty("team_role","7635594273054F2BA32C1CADB31FD413");
    }
    itmTeamIdent = itmTeamIdent.apply();
    return itmTeamIdent;
}
private Item CheckMember(string team_id,string ident_id){
    Item itmTeamIdent = inn.newItem("Team Identity","get");
    itmTeamIdent.setProperty("source_id",team_id);
    itmTeamIdent.setProperty("related_id",ident_id);
    itmTeamIdent = itmTeamIdent.apply();
    return itmTeamIdent;
}
Innovator inn;
public Item main(Item thisItem){
Aras.Server.Security.Identity plmIdentity = Aras.Server.Security.Identity.GetByName("Aras PLM");
Boolean PermissionWasSet = Aras.Server.Security.Permissions.GrantIdentity(plmIdentity);
try{
    string keyed_name = thisItem.getProperty("keyed_name","");

    if(thisItem.getProperty("team_id","")==""){
        Item itmTeam = GetTeam(thisItem.getProperty("keyed_name",""));
        if(itmTeam.isError()){
            itmTeam = CreateTeam(thisItem.getProperty("keyed_name",""));
            if(itmTeam.isError()==false){
                if(thisItem.getType()=="QS Issue"){
                    UpdateTeamMember_QSIssue(thisItem.getID(),itmTeam.getID());
                }
            }
        }
        string sql = @"update qs_issue set team_id = '"+itmTeam.getID()+"' where id='"+thisItem.getID()+"'";
        
        return inn.applySQL(sql);
    }else{
        if(thisItem.getType()=="QS Issue"){
            UpdateTeamMember_QSIssue(thisItem.getID(),thisItem.getProperty("team_id",""));
        }
    }
}catch(Exception ex){
    return inn.newError("Error:"+ex.ToString());
}
if (PermissionWasSet) Aras.Server.Security.Permissions.RevokeIdentity(plmIdentity);
return thisItem;

上一篇
18.移轉 Aras PLM大小事-快速貼入ECR受影響物件
下一篇
20.移轉 Aras PLM大小事-自製快速新增專案工作產出文件
系列文
從Agile PLM 移轉 Aras PLM大小事30
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友留言

立即登入留言