Beispiel #1
0
        public static X12Interchange GenerateX12 <T>(string sample, string rulesNameSpacePrefix = null)
        {
            var message = ParseX12(sample, null, null, rulesNameSpacePrefix);
            var group   = new X12Group <T>(message.GroupHeader);

            group.AddItem((T)message.Value);
            var interchange = new X12Interchange(message.InterchangeHeader);

            interchange.AddItem(group);

            return(interchange);
        }
Beispiel #2
0
        public static X12Interchange GenerateX12 <T>(string sample, string rulesNameSpacePrefix = null)
        {
            var items = ParseX12(sample, null, null, rulesNameSpacePrefix).ToList();

            var group = new X12Group <T>(items.OfType <S_GS>().Single());

            group.AddItem(items.OfType <T>().Single());
            var interchange = new X12Interchange(items.OfType <S_ISA>().Single());

            interchange.AddItem(group);

            return(interchange);
        }
        /// <summary>
        /// Generate an interchange as a collection of segments.
        /// This is a valid EDI message.
        /// </summary>
        public static void Generate()
        {
            var m810 = X12Helper.CreateMessage();
            var groupHeader = X12Helper.CreateGs();
            var interchangeHeader = X12Helper.CreateIsa();

            var ediGroup = new X12Group<M_810>(groupHeader);
            ediGroup.AddItem(m810);
            var ediInterchange = new X12Interchange(interchangeHeader);
            ediInterchange.AddItem(ediGroup);

            IEnumerable<string> ediSegments = ediInterchange.GenerateEdi();
            // The segments can be concatenated with postfix (new line, etc.)
        }
Beispiel #4
0
        public void TestGenerateWithNoGroup()
        {
            // ARRANGE
            const string sample  = "EdiFabric.Tests.Edi.X12_810_00204.txt";
            var          message = TestHelper.ParseX12(sample);
            var          group   = new X12Group <M_810>(null);

            group.AddItem((M_810)message.Value);
            var interchange = new X12Interchange(message.InterchangeHeader);

            interchange.AddItem(group);

            // ACT
            interchange.GenerateEdi();
        }
        /// <summary>
        /// Generate EDI message with no postfix.
        /// </summary>
        public static void GenerateToString()
        {
            var m810 = X12Helper.CreateMessage();
            var groupHeader = X12Helper.CreateGs();
            var interchangeHeader = X12Helper.CreateIsa();

            var ediGroup = new X12Group<M_810>(groupHeader);
            ediGroup.AddItem(m810);
            var ediInterchange = new X12Interchange(interchangeHeader);
            ediInterchange.AddItem(ediGroup);

            IEnumerable<string> ediSegments = ediInterchange.GenerateEdi();
            string edi = ediSegments.Aggregate("",
                (current, segment) => current + segment);
        }
Beispiel #6
0
        public void TestGenerateWithNoGroup()
        {
            // ARRANGE
            const string sample = "EdiFabric.Tests.Edi.X12_810_00204.txt";
            var          items  = TestHelper.ParseX12(sample).ToList();

            var group = new X12Group <M_810>(null);

            group.AddItem(items.OfType <M_810>().Single());
            var interchange = new X12Interchange(items.OfType <S_ISA>().Single());

            interchange.AddItem(group);

            // ACT
            interchange.GenerateEdi();
        }
        /// <summary>
        /// Generates EDI with custom separators.
        /// </summary>
        public static void GenerateWithCustomSeparators()
        {
            var m810 = X12Helper.CreateMessage();
            var groupHeader = X12Helper.CreateGs();
            var interchangeHeader = X12Helper.CreateIsa();

            var ediGroup = new X12Group<M_810>(groupHeader);
            ediGroup.AddItem(m810);
            var ediInterchange = new X12Interchange(interchangeHeader);
            ediInterchange.AddItem(ediGroup);

            var defaultSep = Separators.DefaultX12();
            var newSep = new Separators('>', ':',
                defaultSep.DataElement,
                defaultSep.RepetitionDataElement, null);
            IEnumerable<string> ediSegments = ediInterchange.GenerateEdi(newSep);
        }