...

using EdiFabric.Framework.InterchangeEnvelopes.X12;
using EdiFabric.Framework.Parsers;
using EdiFabric.Framework.Exceptions;

...

// get the EDI message as a stream
var sampleX12Stream = ...

// create a new instance of the parser
IEdiParser ediParser = new EdiParser();

try

{

  // translate to .NET object
  var interchange = ediParser.ToInterchange<INTERCHANGE>(sampleX12Stream, null);

  // validate interchange
  var validationResults = interchange.Validate();

    // one validation result for each message in the interchange
  foreach (var validationResult in validationResults)
  {
    if (!validationResult.IsValid)
    {
      foreach (var brokenRule in validationResult.BrokenRules)
      {
        Debug.Print(brokenRule);
      }
    }
  }

}

catch(ParserException ex)

{

  // the exception gives you information for the line in the EDI message, which failed to    process
 ...


}

Last edited May 3, 2014 at 6:49 AM by DonZoeggerle, version 3

Comments

No comments yet.