写这篇主要是提供那些动不动会改错料号
需要回复前一版料号,首先要知道如果关联是用float时
子阶料号单独变更,被连结的其他物件也会跟着更新
所以要回复前一版,其他的连结也要一并更新,风险很大评估後再来修正
正常功能在编辑->清除Purge
以下程序用在DCO用执行按钮,回复受影响物件
Aras.Server.Security.Identity plmIdentity = Aras.Server.Security.Identity.GetByName("Innovator Admin");
Boolean PermissionWasSet = Aras.Server.Security.Permissions.GrantIdentity(plmIdentity);
Innovator inn = this.getInnovator();
string form_id = this.getProperty("id");
string aml = @"<AML>
<Item action='get' type='Express DCO Affected Item' select='source_id,related_id(affected_id,new_item_id)'>
<source_id>
<Item type='Express DCO' action='get' select='item_number'>
<id>{0}</id>
</Item>
</source_id>
</Item>
</AML>";
aml = string.Format(aml,form_id);
Item itms = inn.applyAML(aml);
if(itms.isError()==false){
for(int i=0;i<itms.getItemCount();i++){
Item itm = itms.getItemByIndex(i);
Item relatedItem = itm.getPropertyItem("related_id");
string affect_id = relatedItem.getProperty("affected_id","");
string new_item_id = relatedItem.getProperty("new_item_id","");
relatedItem.setProperty("new_item_id","");
Item result = relatedItem.apply("edit");
if(affect_id!=""){
string affect_type = "Part";
Item controlItem = inn.getItemById(affect_type,affect_id);
if(controlItem!=null){
if(controlItem.getProperty("state")=="In Change"){
controlItem.promote("Released","");
}
}
string bulkchangeAML = @"<AML>
<Item action='get' type='Bulk Change'>
<parent_partno>
<Item type='Part' action='get'>
<id>{0}</id>
</Item>
</parent_partno>
</Item>
</AML>";
bulkchangeAML = string.Format(bulkchangeAML,new_item_id);
Item bulkItems = inn.applyAML(bulkchangeAML);
if(bulkItems.isError()==false){
List<string> delItems = new List<string>();
for(int row=0;row < bulkItems.getItemCount();row++){
Item itmB = bulkItems.getItemByIndex(row);
delItems.Add(itmB.getID());
}
foreach(string id in delItems){
string delAML = @"<AML>
<Item action='delete' type='Bulk Change' id='{0}'>
</Item>
</AML>";
delAML = string.Format(delAML,id);
Item itmD = inn.applyAML(delAML);
}
}
string bom_AML = @"";
Item new_part = inn.newItem("part","get");
new_part.setProperty("id",new_item_id);
new_part = new_part.apply();
//找最後变更前的版本
string sqlFindOldRevPart = @"select id
from
(
select id,item_number,MAJOR_REV,GENERATION,state from innovator.part
where config_id = '{0}'
and is_current='0'
and (
select MAX(MAJOR_REV)
from innovator.part
where config_id = '{0}'
and is_current='0'
) = MAJOR_REV
) as t
where t.GENERATION = (
select Max(GENERATION) from innovator.part
where config_id = '{0}'
and is_current='0'
and (
select MAX(MAJOR_REV)
from innovator.part
where config_id = '{0}'
and is_current='0'
) = MAJOR_REV
)";
sqlFindOldRevPart = string.Format(sqlFindOldRevPart,new_part.getProperty("config_id",""));
Item oldPart = inn.applySQL(sqlFindOldRevPart);
//return inn.newError(oldPart.ToString());
if(oldPart.isError()==false){
string oldPartId = oldPart.getProperty("id","");
Item boms = inn.newItem("Part BOM","get");
boms.setProperty("related_id",new_item_id);
boms = boms.apply();
if(boms.isError()==false){
for(int k=0;k<boms.getItemCount();k++){
Item bom = boms.getItemByIndex(k);
string bom_id = bom.getProperty("id");
string sqlUpdate = @"update innovator.part_bom set RELATED_ID = '{0}' where part_bom.id='{1}'";
sqlUpdate = string.Format(sqlUpdate,oldPartId,bom_id);
inn.applySQL(sqlUpdate);
}
}
Item altBom = inn.newItem("BOM Substitute","get");
altBom.setProperty("related_id",new_item_id);
altBom = altBom.apply();
if(altBom.isError()==false){
for(int k=0;k<altBom.getItemCount();k++){
Item abom = altBom.getItemByIndex(k);
string bom_id = abom.getProperty("id");
string sqlUpdate = @"update innovator.bom_substitute set RELATED_ID = '{0}' where bom_substitute.id='{1}'";
sqlUpdate = string.Format(sqlUpdate,oldPartId,bom_id);
inn.applySQL(sqlUpdate);
}
}
string affAML = @"<AML>
<Item action='get' type='Affected Item'>
<affected_id>{0}</affected_id>
</Item>
</AML>";
affAML = string.Format(affAML,new_item_id);
Item affItems = inn.applyAML(affAML);
if(affItems.isError()==false){
for(int a=0;a<affItems.getItemCount();a++){
Item affItem = affItems.getItemByIndex(a);
string updateAffSQL = @"Update innovator.Affected_Item set affected_id='{0}' where id='{1}'";
updateAffSQL = string.Format(updateAffSQL,oldPartId,affItem.getID());
inn.applySQL(updateAffSQL);
}
}
}
string purgeAML = @"<AML>
<Item action='purge' type='Part' id='{0}'>
</Item>
</AML>";
purgeAML = string.Format(purgeAML,new_item_id);
Item purgeItem = inn.applyAML(purgeAML);
if(purgeItem.isError()){
return inn.newError("AML="+purgeAML);
}
}
}
}
if (PermissionWasSet) Aras.Server.Security.Permissions.RevokeIdentity(plmIdentity);
return this;
>>: [day-6] 在正式开始写程序之前,先来认识电脑本身吧!(Part .1)
将模型设置在图卡上 先将ImageTarget下的子物件删除 在Project找到从商店下载的模型...
Resources 在 OpenTelemetry 中,服务由资源描述,资源是在应用程序启动期间初始...
本篇文章同步发表在 HKT 线上教室 部落格,线上影音教学课程已上架至 Udemy 和 Youtu...
今天要跟大家介绍 Zabbix 架构 Zabbix 基本资讯 官网 https://www.zabb...
Blazor WebAssembly 新手入门会碰上的问题也讲得差不多了,最後的最後我们来讲讲如何在...