Aras Innovator PLM二次开发简单实例

1 环境搭建

1.1、创建一个控制台程序

1.2、参考中加入 IOM.dll文件 ,路径在这里 C:\Program Files (x86)\Aras\Innovator\Innovator\Server\bin

2、使用IomFactory创建连接登陆 

3、创建一个新的innovator实例

4、用户查询

5、创建对象Document 

1 环境搭建
本人安装的是目前最新版本的 Aras Innovator Version 11.0 SP12  Build: 6920
开发环境下载 Microsoft Visual Studio 2017 即可。 使用C#进行开发。
1.1、创建一个控制台程序


1.2、参考中加入 IOM.dll文件 ,路径在这里 C:\Program Files (x86)\Aras\Innovator\Innovator\Server\bin


2、使用IomFactory创建连接登陆 

//connect innovator
string serverurl = "http://localhost/InnovatorServer";
string databasename = "InnovatorSolutions";
string username = "admin";
string password = "innovator";
HttpServerConnection connection = IomFactory.CreateHttpServerConnection(serverurl, databasename, username, password);
Item loginItem = connection.Login();

Console.WriteLine("1 =============Login Information ======================");
if (loginItem.isError())
{
    Console.WriteLine("error to login the system!");
}
else
{
    Console.WriteLine("Login the system successfully!");
}

3、创建一个新的innovator实例

Innovator newInnovator = IomFactory.CreateInnovator(connection);
string userId = newInnovator.getUserID();
string geTConnection = newInnovator.getConnection().ToString();
string newID = newInnovator.getNewID();
Console.WriteLine("2 =============Create New Innovator Instance Information ======================");
Console.WriteLine("userID:{0}\nConnectionStr:{1}\nnewID:{1}",userId,getConnection,newID);

4、用户查询
注意: 所有的属性都是小写,空格改成下划线_

Console.WriteLine("3 =============Create a query for all the users ======================");
 
Item getUserItem = newInnovator.newItem("User", "get");
getUserItem.setAttribute("select", "first_name,last_name");
Item getUserResult = getUserItem.apply();
for(int i =0;i < getUserResult.getItemCount();i++)
{
string userFirstName = getUserResult.getItemByIndex(i).getProperty("first_name");
string userLastName = getUserResult.getItemByIndex(i).getProperty("last_name");
Console.WriteLine("{0}"+ " " + "{1}" + " "+ "{2}", i,userFirstName,userLastName);
}


5、创建对象Document 
使用代码创建对象:
可以结合SQL去查询下对应对象的表和字段,set property实际上就是去设置这些值。ok后,apply即可!

Console.WriteLine("4 =============Add a item  ======================");
//we select the information from sql 
//select item_number,name,classification,authoring_tool,effective_date from innovator.DOCUMENT
//ITEM_NUMBER        NAME        CLASSIFICATION        AUTHORING_TOOL        EFFECTIVE_DATE
// testDoc NULL    Process Text Editor 2018 - 07 - 05 02:25:27.000
Item newDocItem = newInnovator.newItem("Document", "add");
newDocItem.setProperty("item_number", "plmhomeTestDoc2222");
newDocItem.setProperty("name", "plmhomeDocument");
newDocItem.setProperty("classification", "Process");
newDocItem.setProperty("authoring_tool", "Text_Editor");
newDocItem.setProperty("effective_date", "2018-07-06");
 
newDocItem.apply();
if (newDocItem.isError())
{
    Console.WriteLine("Create error !");
}
else
{
    Console.WriteLine("works fine to create the docuement");
}

————————————————
版权声明:本文为优快云博主「Leroi_Liu」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.youkuaiyun.com/Leroi_Liu/article/details/87263374

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值