Skip to content

Commit

Permalink
Added quick EDI translating demo to the sdk solution
Browse files Browse the repository at this point in the history
  • Loading branch information
DonZoeggerle committed Jul 30, 2018
1 parent 37093c1 commit fbc0a6d
Show file tree
Hide file tree
Showing 12 changed files with 486 additions and 4 deletions.
6 changes: 6 additions & 0 deletions EdiFabric.Sdk.Demo/App.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
</configuration>
73 changes: 73 additions & 0 deletions EdiFabric.Sdk.Demo/EdiFabric.Sdk.Demo.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{9AFF9B6C-36D2-407E-9676-844F8C8011E5}</ProjectGuid>
<OutputType>Exe</OutputType>
<RootNamespace>EdiFabric.Sdk.Demo</RootNamespace>
<AssemblyName>EdiFabric.Sdk.Demo</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="EdiFabric.Core, Version=1.0.0.0, Culture=neutral, PublicKeyToken=30198c5f4974e51a, processorArchitecture=MSIL">
<HintPath>..\packages\EdiFabric.Core.9.7.4\lib\net45\EdiFabric.Core.dll</HintPath>
</Reference>
<Reference Include="EdiFabric.Framework, Version=1.0.0.0, Culture=neutral, PublicKeyToken=30198c5f4974e51a, processorArchitecture=MSIL">
<HintPath>..\packages\EdiFabric.Framework.9.7.4\lib\net45\EdiFabric.Framework.dll</HintPath>
</Reference>
<Reference Include="EdiFabric.Templates.Edifact, Version=1.0.0.0, Culture=neutral, PublicKeyToken=30198c5f4974e51a, processorArchitecture=MSIL">
<HintPath>..\packages\EdiFabric.Templates.Edifact.1.0.0\lib\net45\EdiFabric.Templates.Edifact.dll</HintPath>
</Reference>
<Reference Include="EdiFabric.Templates.Hipaa, Version=1.0.0.0, Culture=neutral, PublicKeyToken=30198c5f4974e51a, processorArchitecture=MSIL">
<HintPath>..\packages\EdiFabric.Templates.Hipaa.1.0.0\lib\net45\EdiFabric.Templates.Hipaa.dll</HintPath>
</Reference>
<Reference Include="EdiFabric.Templates.Padis, Version=1.0.0.0, Culture=neutral, PublicKeyToken=30198c5f4974e51a, processorArchitecture=MSIL">
<HintPath>..\packages\EdiFabric.Templates.Padis.1.0.0\lib\net45\EdiFabric.Templates.Padis.dll</HintPath>
</Reference>
<Reference Include="EdiFabric.Templates.Vda, Version=1.0.0.0, Culture=neutral, PublicKeyToken=30198c5f4974e51a, processorArchitecture=MSIL">
<HintPath>..\packages\EdiFabric.Templates.Vda.1.0.0\lib\net45\EdiFabric.Templates.Vda.dll</HintPath>
</Reference>
<Reference Include="EdiFabric.Templates.X12, Version=1.0.0.0, Culture=neutral, PublicKeyToken=30198c5f4974e51a, processorArchitecture=MSIL">
<HintPath>..\packages\EdiFabric.Templates.X12.1.0.0\lib\net45\EdiFabric.Templates.X12.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
<None Include="packages.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
67 changes: 67 additions & 0 deletions EdiFabric.Sdk.Demo/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
using EdiFabric.Core.Model.Edi;
using EdiFabric.Framework;
using EdiFabric.Framework.Readers;
using EdiFabric.Templates.Edifact;
using EdiFabric.Templates.Hipaa5010;
using EdiFabric.Templates.X12;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Text;

namespace EdiFabric.Sdk.Demo
{
class Program
{
static void Main(string[] args)
{
// To translate your own EDI files, simply change the path to point to your file
// The Demo supports all transactions for X12 004010, HIPAA 005010 and EDIFACT D96A

// Read X12 file
// var x12Stream = File.OpenRead(Directory.GetCurrentDirectory() + @"\..\..\..\Files.Demo\X12004010PurchaseOrders.txt");
var x12Stream = File.OpenRead(Directory.GetCurrentDirectory() + @"\..\..\..\Files.Demo\X12004010Invoice.txt");
List<IEdiItem> x12Items;
using (var ediReader = new X12Reader(x12Stream, LoadFactory, Encoding.UTF8, true))
x12Items = ediReader.ReadToEnd().ToList();

var x12Transactions = x12Items.OfType<TS810>();

// Read HIPAA file
// var hipaaStream = File.OpenRead(Directory.GetCurrentDirectory() + @"\..\..\..\Files.Demo\Hipaa005010BenefitEnrollment.txt");
var hipaaStream = File.OpenRead(Directory.GetCurrentDirectory() + @"\..\..\..\Files.Demo\Hipaa005010ClaimPayment.txt");
List<IEdiItem> hipaaItems;
using (var ediReader = new X12Reader(hipaaStream, LoadFactory, Encoding.UTF8, true))
hipaaItems = ediReader.ReadToEnd().ToList();

var hipaaTransactions = hipaaItems.OfType<TS837P>();

// Read EDIFACT files
// var edifactStream = File.OpenRead(Directory.GetCurrentDirectory() + @"\..\..\..\Files.Demo\EdifactD96APurchaseOrder.txt");
var edifactStream = File.OpenRead(Directory.GetCurrentDirectory() + @"\..\..\..\Files.Demo\EdifactD96AInvoic.txt");
List<IEdiItem> edifactItems;
using (var ediReader = new EdifactReader(edifactStream, LoadFactory, Encoding.UTF8, true))
edifactItems = ediReader.ReadToEnd().ToList();

var edifactTransactions = edifactItems.OfType<TSINVOIC>();
}

static Assembly LoadFactory(MessageContext mc)
{
if (mc.Format.Equals("X12", StringComparison.Ordinal))
{
if (mc.Version.StartsWith("005010X2", StringComparison.Ordinal))
return Assembly.Load("EdiFabric.Templates.Hipaa");

return Assembly.Load("EdiFabric.Templates.X12");
}

if (mc.Format.Equals("EDIFACT", StringComparison.Ordinal))
return Assembly.Load("EdiFabric.Templates.Edifact");

throw new Exception(string.Format("Transaction is not supported: Format {0} Version {1} Transaction ID {2} .", mc.Format, mc.Version, mc.Name));
}
}
}
36 changes: 36 additions & 0 deletions EdiFabric.Sdk.Demo/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("EdiFabric.Sdk.Demo")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("EdiFabric.Sdk.Demo")]
[assembly: AssemblyCopyright("Copyright © 2018")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]

// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("9aff9b6c-36d2-407e-9676-844f8c8011e5")]

// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
10 changes: 10 additions & 0 deletions EdiFabric.Sdk.Demo/packages.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="EdiFabric.Core" version="9.7.4" targetFramework="net45" />
<package id="EdiFabric.Framework" version="9.7.4" targetFramework="net45" />
<package id="EdiFabric.Templates.Edifact" version="1.0.0" targetFramework="net45" />
<package id="EdiFabric.Templates.Hipaa" version="1.0.0" targetFramework="net45" />
<package id="EdiFabric.Templates.Padis" version="1.0.0" targetFramework="net45" />
<package id="EdiFabric.Templates.Vda" version="1.0.0" targetFramework="net45" />
<package id="EdiFabric.Templates.X12" version="1.0.0" targetFramework="net45" />
</packages>
34 changes: 30 additions & 4 deletions EdiFabric.Sdk.sln
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.27130.2036
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "2. Edifact and Eancom", "2. Edifact and Eancom", "{78842466-1FBD-415D-9A31-B3A1A3963585}"
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "4. Edifact and Eancom", "4. Edifact and Eancom", "{78842466-1FBD-415D-9A31-B3A1A3963585}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "EDI Files", "EDI Files", "{608868B5-FD2E-4B4E-B8BA-D5E872D0D7C9}"
EndProject
Expand Down Expand Up @@ -37,11 +37,11 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EdiFabric.Sdk.Edifact.ORDER
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EdiFabric.Sdk.Edifact.INVOIC", "EdiFabric.Sdk.Edifact.INVOIC\EdiFabric.Sdk.Edifact.INVOIC.csproj", "{1F94DAF1-43DA-4D4B-8D28-843F4F2F4AB4}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "4. Common", "4. Common", "{9638AF1F-EE0D-4F0F-9E01-64C9F17C0438}"
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "2. Common", "2. Common", "{9638AF1F-EE0D-4F0F-9E01-64C9F17C0438}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EdiFabric.Sdk.Helpers", "EdiFabric.Sdk.Helpers\EdiFabric.Sdk.Helpers.csproj", "{4C09FEE1-DECB-42EC-9B0A-DAD7E7232005}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "1. X12 and Hipaa", "1. X12 and Hipaa", "{872F5ACF-78B5-439B-994E-E09FD5874793}"
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "3. X12 and Hipaa", "3. X12 and Hipaa", "{872F5ACF-78B5-439B-994E-E09FD5874793}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Export Examples", "Export Examples", "{75700E13-1CE7-4C70-B060-A9929BED47F8}"
EndProject
Expand Down Expand Up @@ -132,7 +132,7 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EdiFabric.Sdk.Helpers.Edifa
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EdiFabric.Sdk.Helpers.X12", "EdiFabric.Sdk.Helpers.X12\EdiFabric.Sdk.Helpers.X12.csproj", "{E5B51FF3-E600-4773-839C-38DF7C1038A0}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "3. Vda", "3. Vda", "{B9C8C327-0210-40D2-8146-0F2BAAAF5AB3}"
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "5. Vda", "5. Vda", "{B9C8C327-0210-40D2-8146-0F2BAAAF5AB3}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Hipaa", "Hipaa", "{1CEC0FD5-5E73-4980-990D-8B37A15A1BFB}"
ProjectSection(SolutionItems) = preProject
Expand Down Expand Up @@ -257,6 +257,20 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EdiFabric.Sdk.X12.T214", "E
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EdiFabric.Sdk.X12.T404", "EdiFabric.Sdk.X12.T404\EdiFabric.Sdk.X12.T404.csproj", "{CC278648-4CF0-4E7F-A37A-983D6B4F7E7F}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "1. EDI Translation Demo", "1. EDI Translation Demo", "{66296C4D-4128-47E8-B76D-E807310E522C}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EdiFabric.Sdk.Demo", "EdiFabric.Sdk.Demo\EdiFabric.Sdk.Demo.csproj", "{9AFF9B6C-36D2-407E-9676-844F8C8011E5}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "EDI Files", "EDI Files", "{15984429-7DAB-443D-8A50-BCC3E2E41F1B}"
ProjectSection(SolutionItems) = preProject
Files.Demo\EdifactD96AInvoic.txt = Files.Demo\EdifactD96AInvoic.txt
Files.Demo\EdifactD96APurchaseOrder.txt = Files.Demo\EdifactD96APurchaseOrder.txt
Files.Demo\Hipaa005010BenefitEnrollment.txt = Files.Demo\Hipaa005010BenefitEnrollment.txt
Files.Demo\Hipaa005010ClaimPayment.txt = Files.Demo\Hipaa005010ClaimPayment.txt
Files.Demo\X12004010Invoice.txt = Files.Demo\X12004010Invoice.txt
Files.Demo\X12004010PurchaseOrders.txt = Files.Demo\X12004010PurchaseOrders.txt
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -896,6 +910,16 @@ Global
{CC278648-4CF0-4E7F-A37A-983D6B4F7E7F}.test|Any CPU.Build.0 = Release|Any CPU
{CC278648-4CF0-4E7F-A37A-983D6B4F7E7F}.Trial|Any CPU.ActiveCfg = Release|Any CPU
{CC278648-4CF0-4E7F-A37A-983D6B4F7E7F}.Trial|Any CPU.Build.0 = Release|Any CPU
{9AFF9B6C-36D2-407E-9676-844F8C8011E5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{9AFF9B6C-36D2-407E-9676-844F8C8011E5}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9AFF9B6C-36D2-407E-9676-844F8C8011E5}.Lite|Any CPU.ActiveCfg = Release|Any CPU
{9AFF9B6C-36D2-407E-9676-844F8C8011E5}.Lite|Any CPU.Build.0 = Release|Any CPU
{9AFF9B6C-36D2-407E-9676-844F8C8011E5}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9AFF9B6C-36D2-407E-9676-844F8C8011E5}.Release|Any CPU.Build.0 = Release|Any CPU
{9AFF9B6C-36D2-407E-9676-844F8C8011E5}.test|Any CPU.ActiveCfg = Release|Any CPU
{9AFF9B6C-36D2-407E-9676-844F8C8011E5}.test|Any CPU.Build.0 = Release|Any CPU
{9AFF9B6C-36D2-407E-9676-844F8C8011E5}.Trial|Any CPU.ActiveCfg = Release|Any CPU
{9AFF9B6C-36D2-407E-9676-844F8C8011E5}.Trial|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -987,6 +1011,8 @@ Global
{364F92CA-4194-4853-8F82-3D65AB8612E7} = {5A3328B7-8853-4E78-B641-D8360AB538B0}
{E2BE226B-4BB0-43BA-A434-6D424EA33E20} = {5A3328B7-8853-4E78-B641-D8360AB538B0}
{CC278648-4CF0-4E7F-A37A-983D6B4F7E7F} = {5A3328B7-8853-4E78-B641-D8360AB538B0}
{9AFF9B6C-36D2-407E-9676-844F8C8011E5} = {66296C4D-4128-47E8-B76D-E807310E522C}
{15984429-7DAB-443D-8A50-BCC3E2E41F1B} = {66296C4D-4128-47E8-B76D-E807310E522C}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {EB447360-6410-4AB0-8984-1454D5AAEA49}
Expand Down
57 changes: 57 additions & 0 deletions Files.Demo/EdifactD96AInvoic.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
UNB+UNOB:1+SENDER1:1+RECEIVER1:1+071101:1701+131++INVOIC++1++1'
UNG+INVOIC+2:1+3:4+971013:1040+5+UN+D:96A:UN+PASSPORT'
UNH+509010117+INVOIC:D:96A:UN'
BGM+380+IN432097'
DTM+137:20020308:102'
PAI+::42'
RFF+ON:ORD9523'
DTM+171:20020212:102'
RFF+PL:PL99523'
DTM+171:20020101:102'
RFF+DQ:53662'
DTM+171:20020215:102'
NAD+BY+5412345000013::9'
RFF+VA:4146023'
NAD+SU+4012345500004::9'
RFF+VA:VR12345'
NAD+DP+5412345678908::9'
CUX+2:EUR:4'
PAT+1++5:3:M:2'
PAT+22++5:3:D:10'
PCD+12:2.5:13'
ALC+C++6++FC'
MOA+23:120'
TAX+7+VAT+++:::19+S'
MOA+124:22.80'
LIN+1++4000862141404:SRS'
QTY+47:40'
MOA+203:2160'
PRI+AAB:60:CA'
TAX+7+VAT+++:::21+S'
MOA+124:453.60'
ALC+A'
PCD+1:10'
LIN+2++5412345111115:SRS'
QTY+46:5'
QTY+47:12.65:KGM'
MOA+203:2530'
PRI+AAA:200:CA::1:KGM'
TAX+7+VAT+++:::19+S'
MOA+124:480.70'
UNS+S'
CNT+2:2'
MOA+86:5767.10'
MOA+79:4690'
MOA+129:5767.10'
MOA+125:4810'
MOA+176:957.10'
MOA+131:120'
TAX+7+VAT+++:::19+S'
MOA+124:503.50'
TAX+7+VAT+++:::21+S'
MOA+124:453.60'
ALC+C++++FC'
MOA+131:120'
UNT+53+509010117'
UNE+1+5'
UNZ+2+131'
Loading

0 comments on commit fbc0a6d

Please sign in to comment.