Interfacing Visual Studio to E10


(Chris Conn) #1

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!


Visual Studio compatible with 10.1.600.x
Getting EmailAddress of Logged in User
Anyone created any C# MES programs
(Jose C Gomez) #2

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)


(Haso Keric) #3

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…


(Chris Conn) #4

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.


(Adrian Mepham) #5

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

Regards

Adrian.


(Jose C Gomez) #6

You can make your own EpiDatViews I’ve posted on this topic before. It’s pretty easy


(Chris Conn) #7

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


(Jose C Gomez) #8

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


(Jose C Gomez) #9

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

“Wrapper Project”


(Jose C Gomez) #10

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:


(Chris Conn) #11

Haha image


(Adrian Mepham) #12

Thank you
@josecgomez


(Chris Conn) #13

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


(Toni D) #14

@hasokeric 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


(Jose C Gomez) #15

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


(Aaron Moreng) #16

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.


(Andrew Fagan) #17

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


(Jose C Gomez) #18

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


(Haso Keric) #19

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.


(Jose C Gomez) #20

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

-Jose