This article is applicable only to trials downloaded before December 21, 2020, and EdiFabric versions before 10.0.0.
-
Uninstall all trial NuGet packages (all NuGet packages from nuget.org are trials and will expire in ~14 days) from all projects and solutions:
- EdiFabric.Core
- EdiFabric.Framework
- EdiFabric.Plugins.Ack.Edifact
- EdiFabric.Plugins.Ack.X12
- EdiFabric.Templates.Edifact
- EdiFabric.Templates.X12
- EdiFabric.Templates.Hipaa
- EdiFabric.Templates.Padis
- EdiFabric.Templates.Vda
- Download EdiFabric.Tools.Enterprise/EdiFabric.Tools.Professional and EdiFabric.Templates.Enterprise/EdiFabric.Templates.Professional by using the download link in the order email.
- Unzip EdiFabric.Tools.Enterprise/EdiFabric.Tools.Professional and either publish the full NuGet packages to your internal NuGet server (How to setup internal NuGet Hosting), or reference the DLLs directly from your startup project:
- EdiFabric.Core.Full
- EdiFabric.Framework.Full
- EdiFabric.Plugins.Ack.Edifact.Full
- EdiFabric.Plugins.Ack.X12.Full
- Unzip EdiFabric.Templates.Enterprise/EdiFabric.Templates.Professional, select the transactions\versions you want to work with, and pack them together in a new project(s).
- Add project reference(s) to the project(s) created in the previous step in the startup project. Skip this step if you are adding the templates to the startup project instead of a separate library project(s).
Please ensure that all previous installations of the trial packages were successfully removed from all packages folders. In .NET Core the packages location is: %UserProfile%\.nuget\packages
Below is a step by step guide on how to design your projects from scratch. It is assumed that you have removed all references/packages from nuget.org before starting it.
-
Place all NuGet packages (the .nupkg files) in your internal NuGet server/folder. If you don't have one, use any folder:
-
Create a class library project, regardless of whether it is .NET Core or .NET Framework, the NuGet package will resolve itself to the correct target.
-
Add only the EDI templates you plan to use (in this example it is IFTMIN, version D95B, standard EDIFACT), together with the common files to that project as existing files:
The common files are the 5 files always ending with:
_Codes.cs
_ComplexElementInterfaces.cs
_ComplexElements.cs
_SegmentInterfaces.cs
_Segments.cs
-
Optional, for .NET Framework only
Add references to:
System.Runtime.Serialization and System.Xml.Serialization.
-
(Optional) this step is not required if you have already configured one.
Create a new package source in Visual Studio.
Select Manage NuGet Packages:
then Package source settings:
then click the "plus" button to add a new one:
then change the Name, and then the source to the folder you placed the .nupkg files in the first step:
then click OK, you should now have your new NuGet package source available:
-
Install EdiFabric.Core.Full package to the class library project:
Select Manage NuGet Packages:
Select the package source, then the EdiFabric.Core.Full package, and finally click Install:
Check if it was installed correctly:
Rebuild the project, there should be no errors.
This is the pattern to create EDI templates projects, you can have as many as you wanted, and each can have duplicate templates. This allows you to amend the templates according to your partner-specific requirements without introducing unwanted or breaking changes.
-
Create a console app project (or add to your existing executable project), regardless of whether it is .NET Core or .NET Framework, the NuGet package will resolve itself to the correct target. This is where your EDI operations will be executed, such as reading/writing/validating, etc.
-
Install EdiFabric.Framework.Full package to the console app project.
Select the package source, then the EdiFabric.Framework.Full package, and finally click Install:
Check if it was installed correctly:
-
Add a project reference to the class library project, the final project structure should look like:
-
Open Program.cs file, and paste the following code, and change the path to point to an existing file:
using EdiFabric.Framework.Readers;
using System.IO;
namespace ConsoleApp1
{
class Program
{
static void Main(string[] args)
{
var edi = File.OpenRead(@"C:\test.txt"); // use X12Reader for X12 files, and VdaReader for VDA files, instead of // EdifactReader using (var ediReader = new EdifactReader(edi, "ClassLibrary1"))
{
var result = ediReader.ReadToEnd();
}
}
}
}
Notes:
-
Note that the second parameter of the EdifactReader is the name of the class library project, therefore change it to the name of your class library project. This allows you to change this name per trading partner and load the corresponding class library for each partner, assuming that there is a correlation between the source of the EDI file to be read, and the name of the EDI templates project that matches that source (trading partner).
- It is possible to move all EDI templates into the console app project, and completely omit the second reader parameter, however, this is only recommended for small POC projects. If you don't specify the templates project, the framework will look for the EDI templates in the executing project.
- The example above is for EDIFACT, if you use X12 or VDA, use X12Reader or VdaReader instead of EdifactReader.
- When you are using the DLLs instead of the NuGet packages, the steps are the same, simply use the DLL files instead of packages. The only additional bit is to also add a reference to EdiFabric.Core.Full in your console app (executable) project, which is otherwise automatically installed by the package.
Comments
0 comments
Please sign in to leave a comment.