本篇利用品保用的表單來說明
譬如一個問題處理單在工作流程中
會涉及好幾個單位成員
那麼權限的編輯開放給特定幾個人的話
則利用團隊這個模組(team_id欄位)
一般操作
1.手動建立團隊
2.新增團隊成員
3.加入表單
我另外將操作用客製程式改為
1.在問題單頁籤加入名單
2.儲存問題單時,自動建立團隊與成員
其他就是團隊權限設定在問題單中
將以下程式碼建立於Itemtype
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;