Monday 16 March 2015

Aras Innovator call C# dll

Create a class library from C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace MyClass
{
    public class DemoClass
    {

        public string strMy = "";
        public DemoClass(string s)
        {
            this.strMy = s;
        }

        public string GetMethod()
        {
            return "Hell world" + strMy;
        }

    }
}
Note: your class should be public.
Build
Copy the dll.
Go to Aras Server.
Paste your dll in this path: C:\Program Files (x86)\Aras\Innovator\Innovator\Server\bin
Now go to this path and open method-config.xml file.
C:\Program Files (x86)\Aras\Innovator\Innovator\Server\method-config.xml
In the xml file, go to this tag:
<MethodConfig> <ReferencedAssemblies>
Add new tag similar to : <name>$(binpath)/Conversion.Base.dll</name>
Now change dll name: ex: <name>$(binpath)/MyClass.dll</name>
Now in the same file, scroll down.
You will see name space section, where all .net name spaces are added.
Add your dll name space.
Ex: using MyClass;
Do for all references.
Save.
Now Open Aras Innovator from web UI.
Go to Administration
Methods
Right click: New Method
Enter method name,
Select Server-side
Select C#















Now use below IOM code.
IOM Code.
MyClass obj=new MyClass ("Welcome from aras");
Innovator innovator = this.getInnovator();
return innovator.newResult( obj.GetMethod());
Check the syntax.








Run the code using.
ActionsàRun Server Method.
You will get output.

How to set above code to a Item?
First create an Action.
In the action àIt will ask name, enter name.
It will ask method, Enter method name which you have created in earlier.
Save.
Now go to item.
Search for any item ex: “Parts”
Now open part.
Unlock
Under actions, add new action.
Search for your action which you have created.
Save.
Now go to Design
Parts
Search for any part.
Right click on the part you will see your action name.

Click it.