One of the things that makes Innovator so flexible is the ability to all your own code internally and externally.
Internal code is good for small code snippets and relatively simple or at least restricted methods. The ability to add complete classes via a .dll can be a very powerful tool.
Following is a description of how to create a .dll tool using Visual Studio Express for C#.
Server Side class libraries:
This is an example of a simple class in c#.
First the BOM class:
using System;
using System.Collections.Generic;
namespace MyNamespace
{
public class BOM
{
private Dictionary<string, BOMItem> m_bomItems = new Dictionary<string, BOMItem>();
public BOM(){}
public BOM(Dictionary<string, BOMItem> bom) { m_bomItems = bom; }
~BOM(){}
public bool addBomItem( BOMItem bomItem, out string errorText )
{
// attempt to find the BOMItem in the dictionary
// the item should not be in there twice
BOMItem bomOut = new BOMItem();
if (m_bomItems.TryGetValue(bomItem.getItemNumber(), out bomOut) == true)
{
errorText = "Duplicate Item Number " + bomItem.getItemNumber( );
return false;
}
else
{
m_bomItems.Add(bomItem.getItemNumber(), bomItem);
errorText = "Success";
return true;
}
}
public BOMItem getBOMItem(string itemNumber)
{
BOMItem tmpBOM = new BOMItem();
if (m_bomItems.TryGetValue(itemNumber, out tmpBOM) == true)
{
return tmpBOM;
}
else
{
return null;
}
}
}
}
Then the BOMItem class:
using System;
using System.Collections.Generic;
namespace MyNamespace
{
public class BOMItem
{
public BOMItem(string itemNumber, string description, int qty)
{
m_itemNumber = itemNumber;
m_description = description;
m_qty = qty;
}
public BOMItem() { }
~BOMItem() { }
public string getItemNumber() { return m_itemNumber; }
public string getDescription() { return m_description; }
public int getQty() { return m_qty; }
public bool isItemNumber(string itemNumber) {return (m_itemNumber.Equals(itemNumber)); }
public bool isQty(int qty) { return (m_qty == qty); }
public bool isDescription(string description) { return (m_description.Equals(description)); }
public bool equals(BOMItem bomItem)
{
bool result = true;
result = result & isItemNumber(bomItem.getItemNumber());
result = result & isQty(bomItem.getQty());
result = result & isDescription(bomItem.getDescription());
return result;
}
private string m_itemNumber;
private string m_description;
private int m_qty;
}
}
These classes create a BOM and a BOM Item which I could re-use in any method inside Innovator.
Compile the classes into a .dll class library. (There is a lot of documentation on the web to advise how to do this in Visual Studio Express. Google "Add dll template to Visual Studio express" to see how to do this. If you have the full Visual Studio there will already be a template installed.
IMPORTANT NOTE: The class library must be strongly named so that it can be installed in the Global Assembly Cache (GAC). If it isn't strongly named the gacutil.exe tool will not install the .dll. If the .dll is not installed in the GAC Innovator will not find it. FURTHER NOTE: I'm not sure if this is a Vista/Windows 7 security feature. I am operating on Windows 7 and found this was the only way to install the dll.
This is the method code in a server side method in Innovator:
Innovator inn = this.getInnovator();
Matrix.BOM bom = new Matrix.BOM();
Matrix.BOMItem bomItem = new Matrix.BOMItem("12345","An interesting description", 5);
string errorText;
if (!bom.addBomItem(bomItem, out errorText))
{
errorText = errorText + "Add BOM Item failed <'BR'> ";
}
errorText += (bomItem.getDescription());
errorText += (bomItem.getItemNumber());
errorText += (bomItem.getQty());
Matrix.BOMItem bomItem2 = new Matrix.BOMItem("12345", "An interesting description", 5);
if (bomItem.equals(bomItem2))
{
errorText += ("Bom items are equal");
}
else
{
errorText += ("Bom items are not equal");
}
Matrix.BOMItem bomItem3 = new Matrix.BOMItem("12346", "An interesting description", 5);
if (bomItem.equals(bomItem3))
{
errorText += ("Bom items are equal");
}
else
{
errorText += ("Bom items are not equal");
}
return inn.newResult(errorText);
In order to use this method code we need to install the .dll in the Innovator code tree and edit the method-config.xml file to include a reference to the dll.
I copied the dll into:
c:\Aras\Innovator\Innovator\Server\bin\mydll
I tried installing the dll directly in the /bin folder and found that adding another dll file to this directory caused an unusual error in Innovator. It would not load the "databases" into the login screen which in turn stopped you from logging on.
I put the dll file into a sub directory, mydll in this case put an entry into "method-config.xml" like:
<MethodConfig>
<ReferencedAssemblies>
<name>System.dll</name>
<name>System.XML.dll</name>
<name>System.Web.dll</name>
<name>System.Data.dll</name>
<name>$(binpath)/IOM.dll</name>
<name>$(binpath)/InnovatorCore.dll</name>
<name>$(binpath)/CoreCS.dll</name>
<name>$(binpath)/SPConnector.dll</name>
<name>$(binpath)/mydll/BOMTools.dll</name>
</ReferencedAssemblies>
"method-config.xml" is located in Aras\Innovator\Innovator\server\
Then I installed the file into the GAC using "gacutil.exe /i bomtools.dll"
The GAC tool can be found in:
Program Files\Microsoft .NET\SDK\v2.0\Bin\gacutil.exe
Just in case it is not part of your path (and it probably isn't).
Code example and instructions provided by Brian Pye. Information is based on my investigations into using custom classes in Innovator.