Best practice for code in Aras Innovator 11 SP12

I have recently joined a team that uses Aras Innovator 11 SP12, so I'm quite new to this. I see that my predecessors have written some custom C# methods, but I am not happy with the way they are written. The formatting is not great (indentation etc.), which isn't surprising, given the code was probably typed right into the Innovator admin interface. A copy of the code exists in our version control system, but this is most likely just a copy and I am not even sure if it reflects the code currently running on the server. To me this looks like a less than ideal setup, so I am wondering what the recommended practice for custom code is. Ideally, all custom Innovator code would be in our versioning control system and deployed to the Innovator server from a build server. But what's the best way to debug code that is under active development? I would like to use Visual Studio with Resharper etc. for development, with external logging libraries like Serilog etc. etc. Or would it make sense to implement a custom webservice that implements the actual logic and only have very short methods in Innovator that interact with the webservice? How do you guys do this?
Parents
  • As I understand it, there's a couple of options.  However, all code customized or otherwise is maintained in the Aras database, with full version history - major rev, generations, etc.   I think this is important because, on the server it's Aras that compiles the server code into executable libraries for IIS.    I don't think deploying code or builds from another server is possible. I may be wrong.

    I've used the Visual Studio add in with success for maintaining code outside of the database, the drawback being it only supports c# - which I prefer, but we have old code in VB, and other methods using JavaScript.

    https://marketplace.visualstudio.com/items?itemName=ArasCorporation.ArasInnovatorVisualStudioMethodPlugin

    I think what makes this a good solution is that it brings in references for all the Aras libraries (IOM, etc.), which give you intellisense in Visual Studio.

    Another option is, if you open the Aras database SSMS, look at the innovator.Method table - this seems to contain all code for server and client methods, along with their history - you can see which is the most recent up to date record by checking the Is_Current field:

    SELECT  id,
    KEYED_NAME,
    METHOD_TYPE,
    MAJOR_REV,
    GENERATION,
    METHOD_CODE FROM innovator.METHOD WHERE IS_CURRENT = 1

    This will show you all the code for methods, omitting the Is_Current will include each methods history.

Reply
  • As I understand it, there's a couple of options.  However, all code customized or otherwise is maintained in the Aras database, with full version history - major rev, generations, etc.   I think this is important because, on the server it's Aras that compiles the server code into executable libraries for IIS.    I don't think deploying code or builds from another server is possible. I may be wrong.

    I've used the Visual Studio add in with success for maintaining code outside of the database, the drawback being it only supports c# - which I prefer, but we have old code in VB, and other methods using JavaScript.

    https://marketplace.visualstudio.com/items?itemName=ArasCorporation.ArasInnovatorVisualStudioMethodPlugin

    I think what makes this a good solution is that it brings in references for all the Aras libraries (IOM, etc.), which give you intellisense in Visual Studio.

    Another option is, if you open the Aras database SSMS, look at the innovator.Method table - this seems to contain all code for server and client methods, along with their history - you can see which is the most recent up to date record by checking the Is_Current field:

    SELECT  id,
    KEYED_NAME,
    METHOD_TYPE,
    MAJOR_REV,
    GENERATION,
    METHOD_CODE FROM innovator.METHOD WHERE IS_CURRENT = 1

    This will show you all the code for methods, omitting the Is_Current will include each methods history.

Children
  • These are great points, David. Thank you.

    I wanted to add on to this answer with some suggestions for testing code while it's in development. What our users typically do is run multiple instances (at least 3) of Aras Innovator for the express purpose of developing new functionality.

    • One of these instances serves as the development server. This is a server with limited access that is used for the development of new features. This could include things like adding a new property to an ItemType, writing a new Method and server event, creating a new Form, etc. As these new features are written, they are packaged and exported
    • Next, there's typically a QA server which is used to test the packages from the development server. This is also a limited access server that is just used to test the new features to ensure that there is no loss of functionality or unexpected bugs introduced.
    • Lastly, we have the production server. This is the actual server that your end users will use to interact with your business data. Once a package has been approved on the QA server, it is then imported into production typically during some down, so that it can be tested and validated one last time.

    This is just a general guideline for one possible way to manage your development. There's typically also some practice of regularly backing up the production database and syncing the new data with the development and QA servers.


    Chris

    Christopher Gillis

    Aras Labs Software Engineer

  • Thank you David and Christopher.

    I come from a technical background as I was a developer (C#) previously.
    I have been reading the "Aras Development Process Student Guide Version 11".

    If I resume the development process:

    - GIT for version control

    - Visual Studio as the IDE

    - NUnit as the testing framework
    Is this an option? Could I use the test framework from Microsoft? I have been using it with then opensource framework Moq (https://github.com/moq/moq) in the past

    - I don't understand the conversion also, why converting method from C# to AML from the Method project, and then back from AML to C# into the test project? Why the extra step?

    - For conversion also, is it possible to create C# object and use a library to convert them to AML when whe need to provide AML?

    - For debugging using breakpoint, I saw this: //System.Diagnostics.Debugger.Break();
    Is it possible to use the debugger built in Visual Studio? By just clicking on the side of the line wanted?

    I'm trying to understand how to develop with Aras Innovator, thank you for your understanding if some question are really basic.

    And also, is all this different with V12?

    Best Regards,

    Sacha Bertschi

  • Hi Sacha,

    I'll try address the points that I can below. To begin with, would you be able to provide a link to the "Aras Development Process Student Guide Version 11"? I'm unfamiliar with this document myself and I'd be interested to see what advice it offers.

    I don't understand the conversion also, why converting method from C# to AML from the Method project, and then back from AML to C# into the test project? Why the extra step?

    Everything inside of Aras Innovator is an Item. This is true of things like Parts and Documents just as it's true with Methods. For most methods of querying Innovator (the REST API being an exception), the data that we get is returned as AML. Once the Method item is retrieved, the AML then needs to be parsed to extract the specific method code associated with that item.

    For conversion also, is it possible to create C# object and use a library to convert them to AML when whe need to provide AML?

    If you're using the Item class inside of the IOM.dll, it is possible to get the AML that represents that item. However, if you're trying to convert a generic C# object to AML, there's no Aras-specific code to support this. That being said, AML is just a flavor of XML, and there's a number of C# libraries that handle serializing data to XML. (an example)

    For debugging using breakpoint, I saw this: //System.Diagnostics.Debugger.Break();
    Is it possible to use the debugger built in Visual Studio? By just clicking on the side of the line wanted?

    I'm not very familiar with the Visual Studio add-in, so it may be possible to just manually add a breakpoint outside of the code as you're suggesting. However, adding the System.Diagnostics.Debugger.Break(); line is a more full-proof way to ensure that you can debug into your code. Using this line is also supported with Aras OOTB, and you can read more about it in our blog post on debugging.

    And also, is all this different with V12?

    The same development process you use for v11 should be fine when used with v12. 

    Chris

  • Hi Christopher,

    Thank you for your detailed answer.

    The "Aras Development Process Student Guide Version 11" is not available here: https://www.aras.com/support/documentation/
    I
     was provided with it during a training session.
    I cannot upload it unfortunately (my company's policy), I can however send it by email if you want (5 mo, 275 pages).

    Regarding the conversion of methods to AML, I understand that we do to push the package to Aras.
    I see that as an advantage, since pushing packages doesn't need to stop the server. We tested another tool/PLM were we could develop packages, but since it was the same programming language, we needed to stop the server to do any operation regarding packages manipulation.

    What I don't understand from the guide, is why converting a method to AML, and then convert back the AML to C#?

    I provide an extract of the guide regarding this particular point below:

    "Reviewing Components of a Unit Test
    In the Aras Innovator environment, a unit test is constructed in several steps.
    1. A C# Method is created and saved in the Aras Innovator database.
    2. The Method is then exported using the Aras Packaging Export utility as an .XML file.
    3. The .XML Method file is then converted using a provided script file to a C# source file (.cs) and automatically placed in a Visual Studio solution named UnitTests in the repository Tests directory.
    4. The Visual Studio project is then used to build a test against the converted Method.
    5. The Method is then tested using the NUnit.exe program or a repository script file."

    Regarding the visual studio add-in, I was able to extract a method from the server, modify it in Visual Studio and then push it to the server.

    There's also a possibility to debug a method directly, Right click on the method, Debug (picture below).

    This is quite nice.

    However, the guide advise to have an instance of Aras on the same machine to do so. I tried with a server on another machine, and I was almost able to do it. In the end my local Visual Studio was unable to access the PDB from the server. I saw that there's a workaround by making the folder where the PDB are a share directory so we can access it locally. But I stopped at this step, because using a server that is not local to debug is not a good idea, since I'm not the only one to work on it, and when I debug and put a breakpoint, it stop everything for every users.

    I'm now trying to use NUnit with NSubstitute to mock a unit test. I have some difficulty, there's some errors. I tried to do the same thing with MsTest and Moq, but I got different error messages. I will persevere.

    Best Regards,

    Sacha Bertschi