Interfacing Visual Studio to E10

There have been several requests for info on this so I figured I’d share how I do it. Note, this may not be the right\best way but it works very well for my use of writing and testing custom code for E10.

First I do all of this in a type of implementation called a Singleton. This just means that one and only one instance can exist. I did this so I could have one living connection \ oTrans for my entire app. It’s not necessary, especially for smaller scope testing. This method requires no special permission\access to the server just in case your company doesn’t trust you - like mine does me.

In my object I make vars for the session, all of my adapters (so I am not constantly creating\destroying them), etc. Here are a few:

   public static ILauncher oTrans = null;
        public static UD38Adapter a = null;
        public static InvTransferAdapter invAdapter = null;
        public static LotSelectUpdateAdapter lotAdapter = null;
        public static WhseBinAdapter binAdapter = null;

        public static Ice.Core.Session epiSession;
        public static bool Connected = false;

I had to create an ILauncher to use:

    public class MyILaunch : ILaunch
    {
        public object Session { get; set; }
        public string WhoAmI { get; set; }

    }

Then for connecting you can do something like this:

  public static bool Connect(string username, string password)
        {
            try
            {
                epiSession = new Ice.Core.Session(username, password, Ice.Core.Session.LicenseType.GlobalUser, @"C:\Epicor\ERP10.1Client\Client\config\E10LiveDB2.sysconfig");

                oTrans = new ILauncher(epiSession);
                a = new UD38Adapter(oTrans);
                a.BOConnect();

                invAdapter = new InvTransferAdapter(oTrans);
                invAdapter.BOConnect();

                lotAdapter = new LotSelectUpdateAdapter(oTrans);
                lotAdapter.BOConnect();

                binAdapter = new WhseBinAdapter(oTrans);
                binAdapter.BOConnect();

                Connected = true;
                currentUser = ((Session)oTrans.Session).UserID;
            }
            catch (System.UnauthorizedAccessException e)
            {
                MessageBox.Show("Login failed - Check your username\\password");
                return false;
            }

            
            return true;

        }

Once the framework is in place you can test your adapter stuff (for example)

  public static bool baseCreateRecord(string pn, string bin, string lot, decimal count)
        {
            if(!Connected)
            {
                throw new Exception("You are not connected. Cancelled.");
            }

            a.ClearData(); //clear the serial record
            if (a.GetaNewUD38())
            {
                a.UD38Data.Tables[0].Rows[0]["Key1"] = pn.ToUpper();
                a.UD38Data.Tables[0].Rows[0]["Key2"] = bin.ToUpper();
                a.UD38Data.Tables[0].Rows[0]["Key3"] = lot.ToUpper();
                a.UD38Data.Tables[0].Rows[0][GetField("User1")] = currentUser.ToUpper();
                a.UD38Data.Tables[0].Rows[0][GetField("Date1")] = DateTime.Now ;
                a.UD38Data.Tables[0].Rows[0][GetField("Count1")] = count;

             
                a.Update();

            }
            else 
           {
                 MessageBox.Show("Failed to create record");
                 return false;
           }

            GetUD38(); //refresh the grid
            return true;
}

Very important - You will have to add references to all of the DLL’s needed (for your needs) this includes adapter and contract dlls as well as the core stuff like:
image
image

If anybody has a better way - I’d love for you to share it!

12 Likes

Great post @Chris_Conn,
Only thing I would caution about doing “custom dlls” like this, is that it causes a version dependency issue, so that every time there is an update you have to re-compile / re-deploy your libraries. That may be ok for some, and not for others it depends on your company, so keep that in mind.

Generally my preference is to put all custom code directly in the Epicor via Standard customizations or BPMs. You can use visual studio to a certain extent to write these, there is a BPM Template for visual studio available at EpicWeb, and for Customizations, you layout your screen with your buttons, labels, textboxes etc… and then, it’s just a matter of hitting Control S (Save) in Epicor to get a copy of the customization.cs file and then create a class project with said file and the required dependencies (most outlined above) for each screen

This will allow you to write all your custom code in visual studio, but when you are ready to test / deploy you simply copy it back into Epicor and use the standard Customization Debugging tools.

This in my opinion is the best of both words because you don’t cause any dependencies issues and it should always upgrade cleanly (with the exception of when Epicor changes signatures on methods)

7 Likes

The only time I used to do it was when I needed to have a “Special” Dialog popup with more options to feed the Base Form… So it was easier to design it in Drag/Drop and then read the Design .cs file and paste into my using {} =)

But Jose is right… We atleast have 1 external BPM and we have to recompile it typically during major upgrades .400 to .500 to .600 and when Epicor changes their dll’s from .NET 4.5 to 4.6 etc…

3 Likes

Much thanks for the feedback. For clarification, I typically only use this to write (intellisense) and test (debugger) custom code for E10. Ultimately, unless it’s a load of work, I’ll paste it back into my customization.

I have, in two instances, written beasts so large and complicated, that they will live as an external executable outside of epicor.

Probably the biggest thing I feel I lack with my method, is working with the EpiDataViews. I could recreate them for testing from the reflected source but that’s a lot of work and my time is already stretched. Also, I use all standard NET controls instead of EpiTextBox, EpiCombo etc - while you can import and reference all of the library, I have yet to find a good enough reason to bother doing so.

1 Like

@ josecgomez do you have a link for the BPM template? I searched but could
not find it.

Regards

Adrian.

You can make your own EpiDatViews I’ve posted on this topic before. It’s pretty easy
http://trigemco.com/add-a-custom-epidataview-in-an-epicor-customization/

1 Like

Sure but it wont have all of the form specific info - unless you recreate it

What do you mean?
When you create your own EpiDataView and add it to oTrans it becomes a regular EpiDataView like any other , you can us the events, the row rules, the notifications… the bindings and anything else.
Give it a shot, it’s super nice

1 Like

@Adrian_Mepham it’s at the bottom of this page
https://scrs.epicor.com/ABLConversionweb/About.aspx

“Wrapper Project”

1 Like

Moved this topic to Expert’s Corner… I know I am going to regret this… @Chris_Conn don’t get a big head LoL, thank you for sharing this with the community :slight_smile:

1 Like

Haha image

Thank you
@josecgomez

Don’t forget this little gem. If you only want to do debugging on a customization, in developer mode on the customization select screen simply check Debug in Visual Studio

1 Like

@hkeric.wci I saw that you have winform project with Epicor control. Could you share how to create that project? I’ve made winform project but it doesn’t wok with epicor.

Note: I’m using Epicor 10.1.600

Thanks

@tonid,
To do this legitimately, you’ll need the SDK and an Infragistics License.

For “custom” winforms-like projects, I’ve had good luck creating an empty BAQ (no tables referenced), creating a dashboard from that BAQ, deleting the grid and adding a tracker panel, then deploying. I use the empty dashboard, which is essentially just a blank form template at this point to customize and create custom logic from the ground up.

1 Like

We have done the same thing using UD01 app as a baseline, and just building
all custom code off of that as a customization.

Andrew Fagan
Sonas Group, LLC
617-335-0505
afagan@sonasgrp.com

1 Like

That is really the best way, doing a completely custom DLL is painful and hard to maintain.

1 Like

I added the Epicor Toolbox DLL I can’t even recall which one from Client Directory and Jose is right we have Infragistics so once i dropped the licx file in I could use it… But since this was just base Epicor no SDK - I just used it to build some basic Forms which were more like popups and then i pasted in the code from the .cs file the Designer created, because dealing with x, y positions from memory was no fun =)

It’s also nice to use it to play around with Infragistics / Epicor Controls and Prototype.

It starts with right clicking on the toolbox in VS and just finding other controls… If i get a moment i can tell you which DLL - but that was E9 above.

It’s EpiClientLib Dll but you definitely need the infragistics lic

-Jose

2 Likes