-
Notifications
You must be signed in to change notification settings - Fork 44
Expand file tree
/
Copy pathWriteEDIToStream.cs
More file actions
39 lines (35 loc) · 1.21 KB
/
Copy pathWriteEDIToStream.cs
File metadata and controls
39 lines (35 loc) · 1.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
using System.Diagnostics;
using System.IO;
using System.Reflection;
using EdiFabric.Examples.X12.Common;
using EdiFabric.Framework.Writers;
namespace EdiFabric.Examples.X12.WriteEDI
{
class WriteEDIToStream
{
/// <summary>
/// Generate and write EDI document to a stream
/// </summary>
public static void Run()
{
Debug.WriteLine("******************************");
Debug.WriteLine(MethodBase.GetCurrentMethod().Name);
Debug.WriteLine("******************************");
// 1. Construct the invoice
var invoice = SegmentBuilders.BuildInvoice("1");
using (var stream = new MemoryStream())
{
using (var writer = new X12Writer(stream))
{
// 2. Begin with ISA segment
writer.Write(SegmentBuilders.BuildIsa("1"));
// 3. Follow up with GS segment
writer.Write(SegmentBuilders.BuildGs("1"));
// 4. Then write the invoice(s)
writer.Write(invoice);
}
Debug.Write(stream.LoadToString());
}
}
}
}