indice.Edi 1.11.0

dotnet add package indice.Edi --version 1.11.0
NuGet\Install-Package indice.Edi -Version 1.11.0
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="indice.Edi" Version="1.11.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add indice.Edi --version 1.11.0
#r "nuget: indice.Edi, 1.11.0"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install indice.Edi as a Cake Addin
#addin nuget:?package=indice.Edi&version=1.11.0

// Install indice.Edi as a Cake Tool
#tool nuget:?package=indice.Edi&version=1.11.0

EDI.Net alt text

Build status NuGet Downloads

EDI Serializer/Deserializer. Used to read & write EDI streams.

This is a ground up implementation and does not make use of XML Serialization in any step of the process. This reduces the overhead of converting into multiple formats allong the way of getting the desired Clr object. This makes the process quite fast.

Tested with Tradacoms, EDIFact and ANSI ASC X12 (X12) formats.

Using attributes you can express all EDI rules like Mandatory/Conditional Segments, Elements & Components as well as describe component values size length and precision with the picture syntax (e.g 9(3), 9(10)V9(2) and X(3)).

Installation

To install Edi.Net, run the following command in the Package Manager Console. Or download it here

PM> Install-Package "indice.Edi"

Attributes.

The general rules of thumb are :

Attribute Description
EdiValue Any value inside a segment. (ie the component value 500 in bold)
UCI+001342651817+9907137000005:500+9912022000002:500+7
EdiElement Elements are considered to be groups of values otherwise known as groups of components. One can use this attribute to deserialize into a complex class that resides inside a segment. For example this can usually be used to deserialize more than one value between + into a ComplexType (ie the whole element into a new class 9912022000002:500 in bold)
UCI+001342651817+9907137000005:500+9912022000002:500+7
EdiPath To specify the path
EdiSegment Marks a propery/class to be deserialized for a given segment. Used in conjunction with EdiPath
EdiSegmentGroup Marks a propery/class as a logical container of segments. This allows a user to decorate a class whith information regarding the starting and ending segments that define a virtual group other than the standard ones (Functional Group etc). Can be applied on Lists the same way that [Message] or [Segment] attributes work
EdiMessage Marks a propery/class to be deserialized for any message found.
EdiGroup Marks a propery/class to be deserialized for any group found.
EdiCondition In case multiple MessageTypes or Segment types with the same name. Used to discriminate the classes based on a component value

Example usage:

There are available configurations (EdiGrammar) for EDIFact, Tradacoms and X12. Working examples for all supported EDI formats can be found in the source code under tests.

Note that all examples may be partialy implemented transmissions for demonstration purposes although they are a good starting point. If someone has complete poco classes for any transmition please feel free to contribute a complete test.

Deserialization (EDI to POCOs)

The following example makes use of the Tradacoms grammar and deserializes the sample.edi file to the Interchange class.

var grammar = EdiGrammar.NewTradacoms();
var interchange = default(Interchange);
using (var stream = new StreamReader(@"c:\temp\sample.edi")) {
    interchange = new EdiSerializer().Deserialize<Interchange>(stream, grammar);
}

Serialization (POCOs to EDI)

In this case we are instantiating our POCO class Interchange and then fill-it up with values before finally serializing to out.edi.

var grammar = EdiGrammar.NewTradacoms();
var interchange = new Interchange();
// fill properies 
interchange.TransmissionDate = DateTime.Now;
...
// serialize to file.
using (var textWriter = new StreamWriter(File.Open(@"c:\temp\out.edi", FileMode.Create))) {
    using (var ediWriter = new EdiTextWriter(textWriter, grammar)) { 
        new EdiSerializer().Serialize(ediWriter, interchange);
    }
}

Model

Annotated POCOS example using part of Tradacoms UtilityBill format:

public class Interchange
{
    [EdiValue("X(14)", Path = "STX/1/0")]
    public string SenderCode { get; set; }

    [EdiValue("X(35)", Path = "STX/1/1")]
    public string SenderName { get; set; }

    [EdiValue("9(6)", Path = "STX/3/0", Format = "yyMMdd", Description = "TRDT - Date")]
    [EdiValue("9(6)", Path = "STX/3/1", Format = "HHmmss", Description = "TRDT - Time")]
    public DateTime TransmissionStamp { get; set; }

    public InterchangeHeader Header { get; set; }

    public InterchangeTrailer Trailer { get; set; }

    public List<UtilityBill> Invoices { get; set; }
}

[EdiMessage, EdiCondition("UTLHDR", Path = "MHD/1")]
public class InterchangeHeader
{
    [EdiValue("9(4)"), EdiPath("TYP")]
    public string TransactionCode { get; set; }

    [EdiValue("9(1)", Path = "MHD/1/1")]
    public int Version { get; set; }
}

[EdiMessage, EdiCondition("UTLTLR", Path = "MHD/1")]
public class InterchangeTrailer
{

    [EdiValue("9(1)", Path = "MHD/1/1")]
    public int Version { get; set; }
}

[EdiMessage, EdiCondition("UTLBIL", Path = "MHD/1")]
public class UtilityBill
{
    [EdiValue("9(1)", Path = "MHD/1/1")]
    public int Version { get; set; }

    [EdiValue("X(17)", Path = "BCD/2/0", Description = "INVN - Date")]
    public string InvoiceNumber { get; set; }

    public MetetAdminNumber Meter { get; set; }
    public ContractData SupplyContract { get; set; }

    [EdiValue("X(3)", Path = "BCD/5/0", Description = "BTCD - Date")]
    public BillTypeCode BillTypeCode { get; set; }

    [EdiValue("9(6)", Path = "BCD/1/0", Format = "yyMMdd", Description = "TXDT - Date")]
    public DateTime IssueDate { get; set; }

    [EdiValue("9(6)", Path = "BCD/7/0", Format = "yyMMdd", Description = "SUMO - Date")]
    public DateTime StartDate { get; set; }

    [EdiValue("9(6)", Path = "BCD/7/1", Format = "yyMMdd", Description = "SUMO - Date")]
    public DateTime EndDate { get; set; }

    public UtilityBillTrailer Totals { get; set; }
    public UtilityBillValueAddedTax Vat { get; set; }
    public List<UtilityBillCharge> Charges { get; set; }

    public override string ToString() {
        return string.Format("{0} TD:{1:d} F:{2:d} T:{3:d} Type:{4}", InvoiceNumber, IssueDate, StartDate, EndDate, BillTypeCode);
    }
}

[EdiSegment, EdiPath("CCD")]
public class UtilityBillCharge
{
    [EdiValue("9(10)", Path = "CCD/0")]
    public int SequenceNumber { get; set; }

    [EdiValue("X(3)", Path = "CCD/1")]
    public ChargeIndicator? ChargeIndicator { get; set; }

    [EdiValue("9(13)", Path = "CCD/1/1")]
    public int? ArticleNumber { get; set; }

    [EdiValue("X(3)", Path = "CCD/1/2")]
    public string SupplierCode { get; set; }

    [EdiValue("9(10)V9(3)", Path = "CCD/10/0", Description = "CONS")]
    public decimal? UnitsConsumedBilling { get; set; }
}

Contributions

The following is a set of guidelines for contributing to EDI.Net.

Did you find a bug?
  • Ensure the bug was not already reported by searching on GitHub under Issues.
  • If you're unable to find an open issue addressing the problem, open a new one. Be sure to include a title and clear description, as much relevant information as possible, and a code sample or an executable test case demonstrating the expected behavior that is not occurring.
Did you write a patch that fixes a bug?

Open a new GitHub pull request with the patch. Ensure the PR description clearly describes the problem and solution. Include the relevant issue number if applicable.

Build the sourcecode

As of v1.0.7 the solution was adapted to support the dotnet core project system. Then it was adapted again since the dotnet core tooling was officialy relased (March 7th 2017 at the launch of Visual studio 2017). In order to build and test the source code you will need either one of the following.

  • Visual studio 2017 + the dotnet core workload (for v1.1.3 onwards)
  • Visual studio 2015 Update 3 & .NET Core 1.0.0 - VS 2015 Tooling (for versions v1.0.7 - v1.1.2)
  • VS Code + .NET Core SDK

for more information check .Net Core official page.

The Picture clause

The Picture Clause is taken from COBOL laguage and the way it handles expressing numeric and alphanumric data types. It is used throughout tradacoms.

Symbol Description Example Picture Component c# result
9 Numeric 9(3) 013 int v = 13;
A Alphabetic not used - -
X Alphanumeric X(20) This is alphanumeric string v = "This is alphanumeric";
V Implicit Decimal 9(3)V9(2) 01342 decimal v = 13.42M;
S Sign not used - -
P Assumed Decimal not used - -

Roadmap (TODO)

  • Implement serializer Serialize to write Clr classes to edi format (Using attributes). (planned for v1.1)
  • Start github wiki page and begin documentation.
  • Create a seperate package (or packages per EDI Format) to host well known interchange transmitions (ie Tradacoms Utitlity Bill). Then anyone can fork and contribute his own set of POCO classes.

Disclaimer. The project was inspired and influenced by the work done in the excellent library JSON.Net by James Newton King. Some utility parts for reflection string parsing etc. are used as is

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp1.0 was computed.  netcoreapp1.1 was computed.  netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard1.0 is compatible.  netstandard1.1 was computed.  netstandard1.2 was computed.  netstandard1.3 is compatible.  netstandard1.4 was computed.  netstandard1.5 was computed.  netstandard1.6 was computed.  netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net45 was computed.  net451 is compatible.  net452 was computed.  net46 was computed.  net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen30 was computed.  tizen40 was computed.  tizen60 was computed. 
Universal Windows Platform uap was computed.  uap10.0 was computed. 
Windows Phone wp8 was computed.  wp81 was computed.  wpa81 was computed. 
Windows Store netcore was computed.  netcore45 was computed.  netcore451 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on indice.Edi:

Package Downloads
Cyss.Core.Helper

Package Description

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.11.0 226,429 11/13/2021
1.10.0 2,246 11/4/2021
1.9.18 20,508 5/17/2021
1.9.17 90,285 10/9/2020
1.9.16 14,327 10/8/2020
1.9.15 478 10/8/2020
1.9.14 486 10/8/2020
1.9.13 622 10/7/2020
1.9.12 36,652 7/20/2020
1.9.11 917 7/6/2020
1.9.10 526 7/6/2020
1.9.9 13,185 5/19/2020
1.9.8 6,608 3/19/2020
1.9.7 12,332 12/11/2019
1.9.6 1,662 12/5/2019
1.9.5 2,551 10/31/2019
1.9.4 6,489 10/15/2019
1.9.3 704 10/10/2019
1.9.2 856 10/2/2019
1.9.1 12,097 6/19/2019
1.9.0 17,960 2/14/2019
1.8.5 9,322 9/25/2018
1.8.4 814 9/24/2018
1.8.3 824 9/21/2018
1.8.2 828 9/21/2018
1.8.1 947 9/18/2018
1.8.0 868 9/13/2018
1.7.0 11,136 6/26/2018
1.6.4 1,337 6/22/2018
1.6.3 3,137 6/18/2018
1.6.2 1,271 6/13/2018
1.6.1 2,476 6/6/2018
1.6.0 871 6/4/2018
1.5.0 2,734 5/14/2018
1.4.1 1,290 4/10/2018
1.4.0 1,329 4/7/2018
1.3.3 42,977 1/19/2018
1.3.2 4,348 11/3/2017
1.3.1 10,774 5/2/2017
1.3.0 1,209 4/21/2017
1.2.1 1,023 4/13/2017
1.2.0 997 4/12/2017
1.1.2 2,194 12/20/2016
1.1.1 1,247 11/24/2016
1.1.0 1,432 10/11/2016
1.1.0-beta 1,316 9/30/2016
1.0.10 2,925 9/6/2016
1.0.9 1,351 8/4/2016
1.0.8 1,311 8/1/2016
1.0.7 1,599 7/21/2016
1.0.6 1,829 9/21/2015
1.0.5 1,332 9/17/2015
1.0.4 1,334 9/17/2015
1.0.3 1,325 9/16/2015
1.0.2 1,327 9/16/2015
1.0.1 1,347 9/16/2015
1.0.0 1,230 9/16/2015

- Support deserializing message fragment without interchange #137
     - deserialize Functional group headers and trailers into a separate class #138
     - Revisited Element List deserialization and serialization #121
     - Fixed paths with wildcard fragments (segment and element) now serialize fine.
     - Fixed writer serializing boolean values #141.
     - Fixed EdiSerializer bug when using Serialize overload that passes a plain `TextWriter` the internal EdiTextWriter was never closed thus not autocompleteing/terminating the current active structure #142.
     - Fixed EdiReader when empty segment was found without segment name delimiter #152.
     - Introduced new `SuppressBadEscapeSequenceErrors` option on the serializer. it is used to suppress the exception error thrown when a malformed escape sequence is encountered #157.
     - Rolledback v1.9.10 `EscapeCharacters` change #160.
     - Introduced new `EscapeDecimalMarkInText`. It is used by the EdiTextWriter to escape the decimal mark character inside text values #160.
     - Added new path fragment notation for ranges. This allows for element ranges inside of a segment to be mapped to one structure while others to be mapped to  #170.
     - Bug fix related to nested segment group structures with the same segment name  #172.
     - Bug fix for Wildcard paths working only for collections #170.
     - Fix for segment collection serialization. When some collection items where being serialized as elements instead #168.
     - Fix missing path (non existing) on condition attirute should not enter infinite loop #188
     - Fix whith the EdiFragment IComparer implementation. When there is an index vs a range. #190
     - Fix Failing to deserialize when segments and segment group begin with the same segment and use condition. #196
     - Control counts now autogenerated on Serialization :)  Use EdiCountAttribute. #17, #113, #161