Example #1
0
        public List <Interchange> UnbundleByTransaction(Interchange interchange)
        {
            List <Interchange> interchanges = new List <Interchange>();

            char          terminator = interchange._delimiters.SegmentTerminator;
            var           service    = new UnbundlingService(interchange._delimiters.SegmentTerminator);
            string        isa        = interchange.SegmentString;
            string        iea        = interchange.TrailerSegments.First().SegmentString;
            List <string> list       = new List <string>();

            foreach (FunctionGroup group in interchange.FunctionGroups)
            {
                foreach (Transaction transaction in group.Transactions)
                {
                    StringBuilder x12 = new StringBuilder();
                    x12.AppendFormat("{0}{1}", isa, terminator);
                    x12.AppendFormat("{0}{1}", group.SegmentString, terminator);
                    x12.Append(transaction.SerializeToX12(false));
                    x12.AppendFormat("{0}{1}", group.TrailerSegments.First().SegmentString, terminator);
                    x12.AppendFormat("{0}{1}", iea, terminator);
                    using (MemoryStream mstream = new MemoryStream(Encoding.ASCII.GetBytes(x12.ToString())))
                    {
                        interchanges.AddRange(ParseMultiple(mstream));
                    }
                }
            }

            return(interchanges);
        }
Example #2
0
        public List <Interchange> UnbundleByLoop(Interchange interchange, string loopId)
        {
            char          terminator = interchange._delimiters.SegmentTerminator;
            var           service    = new UnbundlingService(interchange._delimiters.SegmentTerminator);
            string        isa        = interchange.SegmentString;
            string        iea        = interchange.TrailerSegments.First().SegmentString;
            List <string> list       = new List <string>();

            foreach (FunctionGroup group in interchange.FunctionGroups)
            {
                foreach (Transaction transaction in group.Transactions)
                {
                    service.UnbundleHLoops(list, transaction, loopId);
                }
            }

            List <Interchange> interchanges = new List <Interchange>();

            foreach (var item in list)
            {
                StringBuilder x12 = new StringBuilder();
                x12.AppendFormat("{0}{1}", isa, terminator);
                x12.Append(item);
                x12.AppendFormat("{0}{1}", iea, terminator);
                using (MemoryStream mstream = new MemoryStream(Encoding.ASCII.GetBytes(x12.ToString())))
                {
                    interchanges.AddRange(ParseMultiple(mstream));
                }
            }
            return(interchanges);
        }
Example #3
0
        public List<Interchange> UnbundleByTransaction(Interchange interchange)
        {
            List<Interchange> interchanges = new List<Interchange>();

            char terminator = interchange._delimiters.SegmentTerminator;
            var service = new UnbundlingService(interchange._delimiters.SegmentTerminator);
            string isa = interchange.SegmentString;
            string iea = interchange.TrailerSegments.First().SegmentString;
            List<string> list = new List<string>();
            foreach (FunctionGroup group in interchange.FunctionGroups)
            {
                foreach (Transaction transaction in group.Transactions)
                {
                    StringBuilder x12 = new StringBuilder();
                    x12.AppendFormat("{0}{1}", isa, terminator);
                    x12.AppendFormat("{0}{1}", group.SegmentString, terminator);
                    x12.Append(transaction.SerializeToX12(false));
                    x12.AppendFormat("{0}{1}", group.TrailerSegments.First().SegmentString, terminator);
                    x12.AppendFormat("{0}{1}", iea, terminator);
                    using (MemoryStream mstream = new MemoryStream(Encoding.ASCII.GetBytes(x12.ToString())))
                    {
                        interchanges.AddRange(ParseMultiple(mstream));
                    }
                }
            }

            return interchanges;
        }
Example #4
0
        public List<Interchange> UnbundleByLoop(Interchange interchange, string loopId)
        {
            char terminator = interchange._delimiters.SegmentTerminator;
            var service = new UnbundlingService(interchange._delimiters.SegmentTerminator);
            string isa = interchange.SegmentString;
            string iea = interchange.TrailerSegments.First().SegmentString;
            List<string> list = new List<string>();
            foreach (FunctionGroup group in interchange.FunctionGroups)
                foreach (Transaction transaction in group.Transactions)
                {
                    service.UnbundleHLoops(list, transaction, loopId);
                }

            List<Interchange> interchanges = new List<Interchange>();
            foreach (var item in list)
            {
                StringBuilder x12 = new StringBuilder();
                x12.AppendFormat("{0}{1}", isa, terminator);
                x12.Append(item);
                x12.AppendFormat("{0}{1}", iea, terminator);
                using (MemoryStream mstream = new MemoryStream(Encoding.ASCII.GetBytes(x12.ToString())))
                {
                    interchanges.AddRange(ParseMultiple(mstream));
                }
            }
            return interchanges;
        }