示例#1
0
        internal static Interchange CreateInterchange(Custom810 custom810)
        {
            var message     = Generate810MessageWithCodeMap(custom810);
            var interchange = new Interchange
            {
                Isa    = CreateIsa(),
                Groups = new List <Group> {
                    CreateGroup(message)
                }
            };

            interchange.Iea = CreateIea(interchange.Groups.Count);

            return(interchange);
        }
示例#2
0
        private static Message Generate810MessageWithCodeMap(Custom810 custom810)
        {
            // Map the custom EDI into ediFabric EDI (the instance of the class that represents the transaction set & version)
            // This uses a code map (I use Automapper here, but can be any code\mapper map)
            var ediFabric810 = custom810.Map();

            // Create ediFabric message (this serializes the instance and passes the xml + context (transaction set, version, format))
            var msg = new Message(ediFabric810);

            // Validate to ensure it's a valid EDI message
            var brokenRules = msg.Validate().ToList();

            if (brokenRules.Any())
            {
                // Do something if the message is invalid
                foreach (var br in brokenRules)
                {
                    Debug.WriteLine(br);
                }
            }

            return(msg);
        }