Friday, 18 September 2015

Aras Innovator create item using IOM Code

Open Aras server.
Get url of Aras Innovator from C:\Program Files (x86)\Aras\Innovator\VaultServerConfig.xml
<AppServerURL>:
Get Databased name from C:\Program Files (x86)\Aras\Innovator\InnovatorServerConfig.xml
DB-Connection
Now get User ID/Password.
Copy IOM dll from: C:\Program Files (x86)\Aras\Innovator\Innovator\Server\bin

Create a class library.
Add IOM.dll as reference.
Add below code to create a part in Aras Innovator.

   String url = "http://localhost/InnovatorServer/Server/InnovatorServer.aspx";
                        String objBb = "MyDb";
                        String loginName = "admin";
                        String pwd = "innovator";
                        HttpServerConnection conn = IomFactory.CreateHttpServerConnection(url, objBb, loginName, pwd);
                        Item login_result = conn.Login();
                        if (login_result.isError())
                            throw new Exception("Login failed");
                        Innovator myInnovator = login_result.getInnovator();
                        var partItem = myInnovator.newItem("Part", "add");
                        //var partItem = myInnovator.newItem("Part", "merge");

                        partItem.setProperty("item_number", strItemNumber);
                        partItem.setProperty("description", strObjectName);
                        var resultItem = partItem.apply();
                        Console.WriteLine("resultItem " + resultItem);
                        conn.Logout();

                        Console.Read();