Documentation

How to start a new VS project

Article author
Admin
  • Updated

This is an easy-to-follow step-by-step guide on how to create a new Visual Studio project from scratch, and begin to translate EDI files. It covers both the trial and the paid version of EDI Tools for .NET.

Download Free Trial

 

Difference between the trial and the paid version

The main difference between the trial and the paid version of EDI Tools for .NET is the EDI templates. The trial uses the following prebuilt set of templates:

  • EdiFabric.Templates.X12.dll
  • EdiFabric.Templates.Hipaa.dll
  • EdiFabric.Templates.Edifact.dll
  • EdiFabric.Templates.Hl7.dll
  • EdiFabric.Templates.Ncpdp.dll
  • EdiFabric.Templates.Padis.dll
  • EdiFabric.Templates.Vda.dll

The paid version provides all EDI templates as C# files, which allows developers to combine templates and build their own projects. For more information on EDI templates go to the EDI Templates section.

 

Trial - Create a New Project

  1. Create a new Console Project in Visual Studio.
  2. Follow the steps in the Install EDI Tools for .NET article to install the EdiFabric EDI C# library to the project you created in the previous step.
  3. Install the EDI templates.

    Add a reference to the templates DLL for the EDI standard you are interested in, e.g., if you want to translate from X12/HIPAA files, then add a reference to EdiFabric.Templates.X12.dll, if you want to translate from EDIFACT/EANCOM files, then add a reference to EdiFabric.Templates.Edifact.dll.

    Let's translate an X12 file:

    Your project references should look like this:

    edi-project-references-2.png

  4. Open Program.cs and paste the following code, overwriting the existing one:

    using EdiFabric.Core.Model.Edi;
    using EdiFabric.Framework.Readers;
    using System.Collections.Generic;
    using System.IO;
    using System.Linq;
    
    namespace ConsoleApp
    {
        class Program
        {
            static void Main(string[] args)
            {
    var x12File = File.OpenRead(@"{Path to X12 file}"); var serialKey = File.ReadAllText(@"{Path to serial.key file}").Trim();

    EdiFabric.SerialKey.Set(serialKey); List<IEdiItem> ediItems; using (var reader = new X12Reader(x12File, "EdiFabric.Templates.X12", new X12ReaderSettings {ContinueOnError = true })) { ediItems = reader.ReadToEnd().ToList(); } } } }

    Change variable serialKey to point to the file serial.key in folder edifabric-trial.

  5. Rebuild the solution to install the rest of the dependencies. If there are any build errors, contact us for assistance.
  6. Change variable x12File to point to the EDI file you want to translate.
  7. Add a breakpoint and run the console app in debug mode to inspect ediItems:

    edi-project-debug.png

 

Paid - Create a New Project

  1. Create a new Console Project in Visual Studio.
  2. Follow the steps in the Install EDI Tools for .NET article to install the EdiFabric EDI C# library to the project you created in the previous step.
  3. Install the EDI templates.

    1. Create a new Class Library project.
    2. Remove the default Class1.cs.
    3. For .NET Framework only: Add references to System.Runtime.Serialization and System.Xml.Serialization.

    4. Navigate to the EdiFabric.Enterprise or the EdiFabric.Subscription folder you downloaded. Add the EDI templates (C# files) you need to use (in this example it is - transaction: 850, version: 4010, standard: X12), together with all the files in the Common folder to the class library project as existing files:

      edi template x12 4010

      The common files are the 5 files ending with: _Codes.cs _ComplexElementInterfaces.cs _ComplexElements.cs _SegmentInterfaces.cs _Segments.cs

    5. Add a project reference in the Console Project to the Class Library project.

      Your project references should look like this:

      edi-project-references.png

  4. Open Program.cs and paste the following code, overwriting the existing one:

    using EdiFabric.Core.Model.Edi;
    using EdiFabric.Framework.Readers;
    using System.Collections.Generic;
    using System.IO;
    using System.Linq;
    
    namespace ConsoleApp
    {
        class Program
        {
            static void Main(string[] args)
            {
    var x12File = File.OpenRead(@"{Path to X12 file}");

    EdiFabric.SerialKey.Set("{Your serial key}"); List<IEdiItem> ediItems; using (var reader = new X12Reader(x12File, "ClassLibrary1", new X12ReaderSettings {ContinueOnError = true })) { ediItems = reader.ReadToEnd().ToList(); } } } }

    Set the serial key to the serial key you received when you ordered a plan.

  5. Rebuild the solution to install the rest of the dependencies. If there are any build errors, contact us for assistance.
  6. Change variable x12File to point to the EDI file you want to translate.
  7. Add a breakpoint and run the console app in debug mode to inspect ediItems.

Share this:

Was this article helpful?

Comments

0 comments

Please sign in to leave a comment.