Aras Innovator二次开发的一些常用代码段。(笔记)
分类: Aras Innovator 2013-08-02 01:19 473人阅读 评论(0) 收藏 举报
///每个关系类对应一张表
例如part和BOM关系表为Part BOM javascript方法可以不写return this; ///Innovator连接服务器 Example:
HttpServerConnection connection=IOMFactory.CreateHttpServerConnecton(\服务器名\数据库名\用户名\密码\大部分版本可以。 Item login_result = connection.Login(); Aras执行存储过程,注意区分大小写:
Item resItem = inn.newItem(\ resItem.setProperty(\ resItem.setProperty(\ resItem.setProperty(\ resItem.setProperty(\ resItem.setProperty(\ resItem = resItem.apply();
////Innovator查询,查询中的字段应严格注意大小写,属性一般都为小写 Example:
Item MyItem = MyInnovator.newItem(\MyItem.setAttribute(\Item MyResult = MyItem.apply();
for (int i=0; i msgBox.AppendText(\\\ MyResult.getItemByIndex(i).getProperty(\MyResult.getItemByIndex(i).getProperty(\ } ///Document实例的添加 注:必填项属性必须设置,属性名一般为小写,若为大写将不可识别, 属性的空格用_代替, 若属性值为系统已有的内置属性,则必须与系统内置属性值相等,区分大小写 Example: Innovator innovator = new Innovator(connection); Item item = innovator.newItem(\ item.setProperty(\ item.setProperty(\ item.setProperty(\ item.setProperty(\ item.setProperty(\ item = item.apply(); ///修改多语言字段 注:itemtype为对象类名称,lang为多语言字段缩写,name为字段名 Example: string lang=\ Item resultitem = innovator.newItem(itemtype, \ resultitem.setAttribute(\ resultitem.setProperty(name, value, lang); resultitem = resultitem.apply(); ///提升版本 方法1: Item resultitem = innovator.newItem(itemtype, \ resultitem.setAttribute(\ resultitem.promote(\ resultitem = resultitem.apply(); 方法2: q.setAttribute(\ q.setAttribute(\ q.setID(thisItem.getID()); q.setProperty(\ r = q.apply(); ///Innovator RelationShip的添加 注:添加RelationShip时,relationshipType需指定一个联系的对象(item) 添加关系时应特别注意,向文档中添加文件时的关系添加, 如向Part中添加BOM的关系操作不同,不同对象的关系添加方式不同 Example: 此例子为向文档中添加已存在的文件 Innovator innovator = new Innovator(connection); Item item = innovator.newItem(\ item.setProperty(\ item.setProperty(\ item.setProperty(\ item.setProperty(\ item.setProperty(\ ///获取关联文件 Item file = innovator.newItem(\ file.setProperty(\ file.setProperty(\ file = file.apply(); ///Document File表存储了文档和文件的关系 Item docfile = innovator.newItem(\ docfile.setProperty(\ docfile.setPropertyAttribute(\item.getProperty(\ docfile.getPropertyAttribute(\ docfile.setProperty(\ docfile.setPropertyAttribute(\ docfile.setPropertyAttribute(\ item.addRelationship(docfile); item.apply(); 判断当前窗体对象是否被锁定: if (!document.thisItem.isNew() && document.thisItem.getAttribute(\ document.thisItem.isLocked() != 1 ) {return top.aras.newError(\请先锁定窗体!\方法简化:为Document添加File关系为: Item relationship=innovator.newItem(\ relationship.setRelatedItem(file); item.addRelationship(relationship); item.apply(); ///C# 连接excel string strconn = \Properties='Excel 8.0;HDR=Yes;IMEX=1;'\连接字符串中的空格不可去掉 string command = string.Format(\不可去掉 using (OleDbConnection oleconnection = new OleDbConnection(string.Format(strconn, filepath))) { oleconnection.Open(); DataTable st = oleconnection.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, null); OleDbDataAdapter oleadapter = new OleDbDataAdapter(command, oleconnection); DataSet ds = new DataSet(); oleadapter.Fill(ds); return ds; } ///小知识点 activity表的message为显示在Inbasket中的介绍(introduction) ///关于Item.apply()方法的说明 当Item.apply()提交的数据与数据库中数据产生冲突时,会自动不予提交 ///上传文件 path文件路径 Item item = innovator.newItem(\ int index=path.LastIndexOf(\ string filename=path.subString(index+1); item.setProperty(\ item.attachPhysicalFile(path); item = item.apply(); 提升生命周期状态: actionitem=innovator.newItem(\ actionitem.setAttribute(\actionitem.promote(\actionitem=actionitem.apply(); AML关系查找示例: ///javascript操作页面元素 var results=document.thisItem;///获取页面元素 var element=results.getItemsByXpath('//Item[@type=\document.thisItem.isLocked()=1表示页面元素被锁定 document.thisItem.isNew() 判断页面对象是否为新建对象 document.thisItem.getAttribute(\判断当前的操作是否为add ///获取属性的子属性 string newitem = resulitem.getPropertyAttribute(\///赋予权限,applySQL只有当前用户为Administrator或super user身份时可用,Aras PLM也具有applySQL的权限,一般在系统内部使用 其他身份若要使用applySQL需要先赋予权限 Aras.Server.Security.Identity plmIdentity = Aras.Server.Security.Identity.GetByName(\ bool PermissionWasSet = Aras.Server.Security.Permissions.GrantIdentity(plmIdentity); if (PermissionWasSet) Aras.Server.Security.Permissions.RevokeIdentity(plmIdentity); /// 工作流实例间的关系,当工作流实例根据模板建立后,基本与模板没有关系, (a.source_type=itemtype.id a.source_id=item.id) Workflow(a)----1:1---->Workflow Process(b)----1:N---->Workflow Process Activity(c)-----1:1----->Activity(d)---1:N-->Activity Assignment(e) a.related_id=b.id, c.source_id=b.id c.source_id=b.id, c.related_id=d.id e.source_id=d.id,e.related_id=identity.id Workflow Process Path:source_id(源activity),related_id(关联activity) 当为工作流添加权限时,它会自动从activity处获得权限。如果是动态添加activity则必须