Aras Innovator二次开发的一些常用代码段文档格式.docx

上传人:b****6 文档编号:16544475 上传时间:2022-11-24 格式:DOCX 页数:15 大小:24.82KB
下载 相关 举报
Aras Innovator二次开发的一些常用代码段文档格式.docx_第1页
第1页 / 共15页
Aras Innovator二次开发的一些常用代码段文档格式.docx_第2页
第2页 / 共15页
Aras Innovator二次开发的一些常用代码段文档格式.docx_第3页
第3页 / 共15页
Aras Innovator二次开发的一些常用代码段文档格式.docx_第4页
第4页 / 共15页
Aras Innovator二次开发的一些常用代码段文档格式.docx_第5页
第5页 / 共15页
点击查看更多>>
下载资源
资源描述

Aras Innovator二次开发的一些常用代码段文档格式.docx

《Aras Innovator二次开发的一些常用代码段文档格式.docx》由会员分享,可在线阅读,更多相关《Aras Innovator二次开发的一些常用代码段文档格式.docx(15页珍藏版)》请在冰豆网上搜索。

Aras Innovator二次开发的一些常用代码段文档格式.docx

User"

get"

MyItem.setAttribute("

select"

first_name,last_name"

ItemMyResult=MyItem.apply();

for(inti=0;

i<

MyResult.getItemCount();

i++)

{

msgBox.AppendText("

\n 

"

+i+"

+MyResult.getItemByIndex(i).getProperty("

first_name"

na"

)+"

last_name"

));

}

///Document实例的添加

注:

必填项属性必须设置,属性名一般为小写,若为大写将不可识别,属性的空格用_代替,

若属性值为系统已有的内置属性,则必须与系统内置属性值相等,区分大小写

Example:

Innovatorinnovator=newInnovator(connection);

Itemitem=innovator.newItem("

Document"

add"

item.setProperty("

item_number"

0002"

Example1"

classification"

/Document/Software"

authoring_tool"

Other"

effective_date"

2010-01-21"

item=item.apply();

///修改多语言字段

itemtype为对象类名称,lang为多语言字段缩写,name为字段名

stringlang="

zh"

;

Itemresultitem=innovator.newItem(itemtype,"

edit"

resultitem.setAttribute("

id"

id);

resultitem.setProperty(name,value,lang);

resultitem=resultitem.apply();

///提升版本

方法1:

resultitem.promote("

active"

Pleasereview"

方法2:

q.setAttribute("

action"

PromoteItem"

typeId"

thisItem.getProperty("

itemtype"

"

));

q.setID(thisItem.getID());

q.setProperty("

state"

toState);

r=q.apply();

///InnovatorRelationShip的添加

添加RelationShip时,relationshipType需指定一个联系的对象(item)

添加关系时应特别注意,向文档中添加文件时的关系添加,

如向Part中添加BOM的关系操作不同,不同对象的关系添加方式不同

此例子为向文档中添加已存在的文件

First"

///获取关联文件

Itemfile=innovator.newItem("

File"

file.setProperty("

keyed_name,id,filename"

8FA86396EDDA493481BF0A3AA6F15D44"

file=file.apply();

///DocumentFile表存储了文档和文件的关系

Itemdocfile=innovator.newItem("

DocumentFile"

docfile.setProperty("

source_id"

item.getID());

docfile.setPropertyAttribute("

keyed_name"

item.getProperty("

docfile.getPropertyAttribute("

type"

related_id"

file.getID());

file.getProperty("

Type"

item.addRelationship(docfile);

item.apply();

判断当前窗体对象是否被锁定:

if(!

document.thisItem.isNew()&

&

document.thisItem.getAttribute("

)!

="

&

document.thisItem.isLocked()!

=1){returntop.aras.newError("

请先锁定窗体!

}

方法简化:

为Document添加File关系为:

Itemrelationship=innovator.newItem("

relationship.setRelatedItem(file);

item.addRelationship(relationship);

item.apply();

///C#连接excel

stringstrconn="

Provider=Microsoft.Jet.OLEDB.4.0;

DataSource={0};

ExtendedProperties='

Excel8.0;

HDR=Yes;

IMEX=1;

'

///连接字符串中的空格不可去掉

stringcommand=string.Format("

select*from[{0}$]"

sheetname);

///$不可去掉

using(OleDbConnectionoleconnection=newOleDbConnection(string.Format(strconn,filepath)))

oleconnection.Open();

DataTablest=oleconnection.GetOleDbSchemaTable(OleDbSchemaGuid.Tables,null);

OleDbDataAdapteroleadapter=newOleDbDataAdapter(command,oleconnection);

DataSetds=newDataSet();

oleadapter.Fill(ds);

returnds;

///小知识点

activity表的message为显示在Inbasket中的介绍(introduction)

///关于Item.apply()方法的说明

当Item.apply()提交的数据与数据库中数据产生冲突时,会自动不予提交

///上传文件path文件路径

Itemitem=innovator.newItem("

intindex=path.LastIndexOf("

\\"

stringfilename=path.subString(index+1);

item.setProperty("

filename"

filename);

item.attachPhysicalFile(path);

item=item.apply();

提升生命周期状态:

actionitem=innovator.newItem("

ActionItem"

actionitem.setAttribute("

where"

string.Format("

id='

{0}'

actid));

actionitem.promote("

Pleasereview...."

actionitem=actionitem.apply();

AML关系查找示例:

<

Itemtype="

MyPart"

action="

select="

id,name"

>

<

part_number>

1<

/part_number>

Relationships>

MyBOM"

related_id>

2<

/Item>

/related_id>

/Relationships>

///javascript操作页面元素

varresults=document.thisItem;

///获取页面元素

varelement=results.getItemsByXpath('

//Item[@type="

TPK_Millstone"

]'

document.thisItem.isLocked()=1表示页面元素被锁定

document.thisItem.isNew()判断页面对象是否为新建对象

document.thisItem.getAttribute("

判断当前的操作是否为add

///获取属性的子属性

string 

newitem=resulitem.getPropertyAttribute("

current_state"

///赋予权限,applySQL只有当前用户为Administrator或superuser身份时可用,ArasPLM也具有applySQL的权限,一般在系统内部使用

其他身份若要使用applySQL需要先赋予权限

Aras.Server.Security.IdentityplmIdentity=Aras.Server.Security.Identity.GetByName("

ArasPLM"

boolPermissionWasSet 

=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---->

WorkflowProcess(b)----1:

N---->

WorkflowProcessActivity(c)-----1:

1----->

Activity(d)---1:

N-->

ActivityAssignment(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

WorkflowProcessPath:

source_id(源activity),related_id(关联activity)

当为工作流添加权限时,它会自动从activity处获得权限。

如果是动态添加activity则必须在Activity添加后再为添加path,这样权限会自动添加。

手工设置权限将无效(applySQL除外)。

更新缓存在页面中填写值完毕后通过此方法更新缓存中的值,否则依然为原数据

handleItemChange(字段id,字段值);

打开某个对象的方法:

functionshoworkflowprocess()

varitemNd=top.aras.getItemById("

对象类名称"

对象类id"

0);

varmyLock=false;

top.aras.uiShowItemEx(itemNd,top.aras.getPreferenceItemProperty("

Core_GlobalLayout"

null,"

core_view_mode"

),top.aras.getVariable('

TearOff'

)=='

true'

隐藏Pr页签中的Files页签:

top.hideIssueTabs=function(){

if(!

parent.relationships||!

parent.relationships.relTabbarReady||parent.relationships.relTabbar.GetTabOrder("

|"

)==="

setTimeout("

top.hideIssueTabs()"

30);

return;

vartabbar=parent.relationships.relTabbar;

vartabID=tabbar.getTabId("

Files"

///得到Files的tabId

if(tabID!

="

undifined"

){tabbar.SetTabVisible(tabID,false);

}///将Visible设置为false

};

快速获取数据库连接字符串的方法:

建一个后缀名为udl的文件

///项目模板的存储

ProjectTemplate的存储:

project_template.wbs_id=wbs_element.id 

project_template.wbs_id=sub_wbs.source_id 

sub_wbs.related_id=wbs_element.id

wbs_element和Activity2的对应关系为WBS_Activity2

打开workflow签核页需要传递的参数:

1varparams=newObject();

params.aras=top.aras;

params.activity=top.aras.getItemById("

activity"

activityId,1);

params.wflName=wflName;

///workflowprocess的名称

params.wflId=workflowProcessID;

///workflowprocess的id

params.assignmentId=assignmentId;

///activityassignment的id

params.itemId=itemId;

///item的id

showModalDialogWithDelay("

InBasket-VoteDialog.html"

params,'

resizable:

1;

scroll:

dialogHeight:

400px;

dialogWidth:

700px;

status:

help:

0'

true);

打开Project签核页需要传递的参数:

varparams=newArray();

params[0]=window;

params[1]=activityID;

///activity2的ID

showModalDialog('

../../Solutions/Project/scripts/ActivityCompletionWorksheet/ACWDialog.html'

dialogHeight:

320px;

0;

resizable:

1'

javascript获取对象类关系:

top.aras.getItemRelationShips("

Project"

projectid,"

ProjectTeam"

Inbasket中workflowactivities的数据来自Activity和ActivityAssignment.

Inbasket中ProjectActivities的数据来自Activity2和Activity2Assignment.

当前状态(Pending-Active-Complate)由Activity2.state字段标识。

activity2的date_start_sched,date_due_sched分别表示计划开始时间和计划结束时间。

9.2版本下notification_control在中文模式下报错:

修改aras\Innovator\Innovator\Client\javascript\user_notifications.js中

if(!

notification_control)

thrownewError(1,"

ArgumentException:

notification_controlcan'

tbeundefined"

这不是最好的办法,只是暂时不报错

///获取网格中的选中对象

mainTreeApplet=parent.tree.treeApplet;

varselectedRowId=mainTreeApplet.getSelectedId();

熟悉[STAThread]

javascript操作gridApplet:

gridApplet.cells(relationshipID,'

列数'

).GetValue()获取某行某列的值

).setEditType

(1)将单元格设置为编辑状态

javascirpt禁用元素:

disabled=true,设置元素为只读:

readOnly=true(注意大小写)

Javascript获取时间日期的各种格式

varmyDate=newDate();

myDate.getYear();

//获取当前年份(2位)

myDate.getFullYear();

//获取完整的年份(4位,1970-?

?

myDate.getMonth();

//获取当前月份(0-11,0代表1月)

myDate.getDate();

//获取当前日(1-31)

myDate.getDay();

//获取当前星期X(0-6,0代表星期天)

myDate.getTime();

//获取当前时间(从1970.1.1开始的毫秒数)

myDate.getHours();

//获取当前小时数(0-23)

myDate.getMi

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 考试认证 > 其它考试

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1