Exemplo n.º 1
0
        private static string BuildAck(UNB originalUnb, UNG originalUng, EdiMessage ack, int unbControlNumber = 1, int ungControlNumber = 1)
        {
            var memoryStream = new MemoryStream();
            var writer       = new EdifactWriter(memoryStream, Encoding.Default, Environment.NewLine);

            writer.Write(originalUnb.ToAckUnb(unbControlNumber.ToString()));
            if (originalUng != null)
            {
                writer.Write(originalUng.ToAckUng(ungControlNumber.ToString()));
            }
            writer.Write(ack);
            writer.Flush();
            memoryStream.Position = 0;
            using (var reader = new StreamReader(memoryStream))
                return(reader.ReadToEnd());
        }
Exemplo n.º 2
0
        /// <summary>
        /// Build functional CONTRL acknowledgment using the original UNB and UNG.
        /// </summary>
        public static string BuildAck(UNB originalUnb, UNG originalUng, TSCONTRL ack, int unbControlNumber = 1, int ungControlNumber = 1)
        {
            var memoryStream = new MemoryStream();

            using (var writer = new EdifactWriter(memoryStream, new EdifactWriterSettings()
            {
                Encoding = Encoding.Default, Postfix = Environment.NewLine
            }))
            {
                writer.Write(originalUnb.ToAckUnb(unbControlNumber.ToString()));
                if (originalUng != null)
                {
                    writer.Write(originalUng.ToAckUng(ungControlNumber.ToString()));
                }
                writer.Write(ack);
            }

            memoryStream.Position = 0;
            using (var reader = new StreamReader(memoryStream))
                return(reader.ReadToEnd());
        }