Exemplo n.º 1
0
        public static EdifactInterchange GenerateEdifact <T>(string sample)
        {
            var message = ParseEdifact(sample);
            var group   = new EdifactGroup <T>(message.GroupHeader);

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

            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 mInvoic = EdifactHelper.CreateMessage();
            var interchangeHeader = EdifactHelper.CreateUnb();

            var ediGroup = new EdifactGroup<M_INVOIC>(null);
            ediGroup.AddItem(mInvoic);
            var ediInterchange = new EdifactInterchange(interchangeHeader);
            ediInterchange.AddItem(ediGroup);

            IEnumerable<string> ediSegments = ediInterchange.GenerateEdi();
            // The segments can be concatenated with postfix (new line, etc.)
        }
        /// <summary>
        /// Generate EDI message with no postfix.
        /// </summary>
        public static void GenerateToString()
        {
            var mInvoic = EdifactHelper.CreateMessage();
            var interchangeHeader = EdifactHelper.CreateUnb();

            var ediGroup = new EdifactGroup<M_INVOIC>(null);
            ediGroup.AddItem(mInvoic);
            var ediInterchange = new EdifactInterchange(interchangeHeader);
            ediInterchange.AddItem(ediGroup);

            IEnumerable<string> ediSegments = ediInterchange.GenerateEdi();
            string edi = ediSegments.Aggregate("",
                (current, segment) => current + segment);
        }
Exemplo n.º 4
0
        public static EdifactInterchange GenerateEdifact <T>(string sample)
        {
            var items = ParseEdifact(sample).ToList();

            var ung   = items.OfType <S_UNG>().SingleOrDefault();
            var group = new EdifactGroup <T>(ung);

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

            interchange.AddItem(group);

            return(interchange);
        }
        /// <summary>
        /// Generates EDI with custom separators.
        /// </summary>
        public static void GenerateWithCustomSeparators()
        {
            var mInvoic = EdifactHelper.CreateMessage();
            var interchangeHeader = EdifactHelper.CreateUnb();

            var ediGroup = new EdifactGroup<M_INVOIC>(null);
            ediGroup.AddItem(mInvoic);
            var ediInterchange = new EdifactInterchange(interchangeHeader);
            ediInterchange.AddItem(ediGroup);

            var defaultSep = Separators.DefaultEdifact();
            var newSep = new Separators('>', ':',
                defaultSep.DataElement,
                defaultSep.RepetitionDataElement,
                defaultSep.Escape);

            IEnumerable<string> ediSegments = ediInterchange.GenerateEdi(newSep);
        }