Beispiel #1
0
        public static void Run()
        {
            Debug.WriteLine("******************************");
            Debug.WriteLine(MethodBase.GetCurrentMethod().Name);
            Debug.WriteLine("******************************");

            //  1.  Construct the first document
            var deliveryInstruction1 = TS4905Builder.BuildDeliveryInstruction(22, 23);

            //  2.  Construct the second document
            var deliveryInstruction2 = TS4905Builder.BuildDeliveryInstruction(23, 24);

            using (var stream = new MemoryStream())
            {
                using (var writer = new VdaWriter(stream, Environment.NewLine))
                {
                    //  3. Write them out
                    writer.Write(deliveryInstruction1);
                    writer.Write(deliveryInstruction2);
                }

                Debug.Write(stream.LoadToString());
            }
        }
Beispiel #2
0
        public static string Generate(List <EdiItem> items, string postFix = null,
                                      Encoding encoding = null)
        {
            using (var stream = new MemoryStream())
            {
                var writer = new VdaWriter(stream, postFix, encoding);
                foreach (var item in items)
                {
                    var message = item as EdiMessage;
                    if (message != null)
                    {
                        writer.Write(message);
                    }
                }
                writer.Flush();

                return(CommonHelper.LoadString(stream));
            }
        }
Beispiel #3
0
        /// <summary>
        /// Generate and write EDI document to a stream
        /// </summary>
        static void Write4905()
        {
            Debug.WriteLine("******************************");
            Debug.WriteLine(MethodBase.GetCurrentMethod().Name);
            Debug.WriteLine("******************************");

            //  1.  Construct the 4905 message with data from database, service or domain objects\logic.
            var vda4905 = Create4905();

            using (var stream = new MemoryStream())
            {
                //  2.  Use CRLF(new line) as segment postfix for clarity
                //  Always agree postfixes and separators with the trading partner
                var writer = new VdaWriter(stream, Environment.NewLine, Encoding.UTF8);
                //  3.  Write all transactions
                writer.Write(vda4905);
                //  4.  Always flush at the end to release the cache
                writer.Flush();
            }
        }
Beispiel #4
0
        /// <summary>
        /// Generate and write EDI document to a stream
        /// </summary>
        public static void Write4905()
        {
            Debug.WriteLine("******************************");
            Debug.WriteLine(MethodBase.GetCurrentMethod().Name);
            Debug.WriteLine("******************************");

            //  1.  Construct the 4905 message with data from database, service or domain objects\logic.
            var vda4905 = TransactionBuilders.BuildDeliveryInstruction();

            //  2.  Validate it
            MessageErrorContext errorContext;

            if (vda4905.IsValid(out errorContext))
            {
                using (var stream = new MemoryStream())
                {
                    //  2.  Use CRLF(new line) as segment postfix for clarity
                    //  Always agree postfixes and separators with the trading partner
                    using (var writer = new VdaWriter(stream, Environment.NewLine, Encoding.UTF8))
                    {
                        //  3.  Write all transactions
                        writer.Write(vda4905);
                    }

                    Debug.Write(stream.LoadToString());
                }
            }
            else
            {
                //  The 4905 is invalid
                Debug.WriteLine("Message {0} with control number {1} is invalid with errors:", errorContext.Name,
                                errorContext.ControlNumber);

                //  List all error messages
                var errors = errorContext.Flatten();
                foreach (var error in errors)
                {
                    Debug.WriteLine(error);
                }
            }
        }
Beispiel #5
0
        /// <summary>
        /// Generate and write EDI document to a stream
        /// </summary>
        public static void Write4905()
        {
            Debug.WriteLine("******************************");
            Debug.WriteLine(MethodBase.GetCurrentMethod().Name);
            Debug.WriteLine("******************************");

            //  1.  Construct the 4905 message with data from database, service or domain objects\logic.
            var vda4905 = TransactionBuilders.BuildDeliveryInstruction();

            using (var stream = new MemoryStream())
            {
                //  2.  Use CRLF(new line) as segment postfix for clarity
                //  Always agree postfixes and separators with the trading partner
                using (var writer = new VdaWriter(stream, Environment.NewLine, Encoding.UTF8))
                {
                    //  3.  Write all transactions
                    writer.Write(vda4905);
                }

                Debug.Write(stream.LoadToString());
            }
        }