Exemple #1
0
        /// <summary>
        /// Ruft die Meldedatei mit einem bestimmten Dateinamen aus dem Deuev-Ordner ab
        /// </summary>
        /// <param name="fileName">
        /// Dateiname der Meldedatei
        /// </param>
        /// <param name="name">
        /// Name in der Meldungen.xml
        /// </param>
        /// <returns>
        /// Meldedatei als DeuevMessageData-Objekt
        /// </returns>
        private DsraMessageData GetMessageFromFile(string fileName, string name)
        {
            var input = string.Join(string.Empty, File.ReadAllLines(fileName).Select(x => x + Environment.NewLine));

            var output       = new StringWriter();
            var writer       = StreamFactory.CreateWriter(name, output);
            var reader       = StreamFactory.CreateReader(name, new StringReader(input));
            var deuevMessage = new DsraMessageData();

            try
            {
                var streamObject = reader.Read();

                do
                {
                    var vosz = Assert.IsType <VOSZ>(streamObject);
                    deuevMessage.VOSZ.Add(vosz);
                    writer.Write(vosz);
                    streamObject = reader.Read();
                }while (reader.RecordName == "VOSZ" || reader.RecordName == "VOSZ-v01");

                if (reader.RecordName == "DSKO" || reader.RecordName == "DSKO-v04")
                {
                    var dsko = Assert.IsType <DSKO04>(streamObject);
                    writer.Write(dsko);
                    streamObject = reader.Read();
                }

                while (reader.RecordName == "DSRA" || reader.RecordName == "DSRA-v01")
                {
                    var record = Assert.IsType <DSRA01>(streamObject);
                    deuevMessage.DSRA01.Add(record);
                    writer.Write(record);
                    streamObject = reader.Read();
                }

                do
                {
                    var ncsz = Assert.IsType <NCSZ>(streamObject);
                    writer.Write(streamObject);
                    deuevMessage.NCSZ.Add(ncsz);
                    streamObject = reader.Read();
                }while (reader.RecordName != null && (reader.RecordName == "NCSZ" || reader.RecordName == "NCSZ-v01"));

                Assert.Null(reader.RecordName);
                Assert.Equal(deuevMessage.VOSZ.Count, deuevMessage.NCSZ.Count);

                writer.Close();
                string output2 = output.ToString();
                Assert.Equal(input, output2);
                return(deuevMessage);
            }
            finally
            {
                reader.Close();
            }
        }
        /// <summary>
        /// De serializes the specified stream.
        /// </summary>
        /// <param name="stream">The stream.</param>
        /// <returns>The object which deserialize</returns>
        public object Deserialize(Stream stream)
        {
            //Creates internal object model from a stream, which Interpreter will analyze into an object
            BaseDescriptor descriptor = StreamFactory.CreateReader().Read(stream);

            var interperter = new Interpreter();
            var result      = interperter.Analyze(descriptor);

            return(result);
        }
        /// <summary>
        /// Ruft die Meldedatei mit einem bestimmten Dateinamen aus dem Deuev-Ordner ab
        /// </summary>
        /// <param name="input">Die Meldedatei</param>
        /// <param name="name">Name in der Meldungen.xml</param>
        /// <returns>Meldedatei als DeuevMessageData-Objekt</returns>
        private BwnaMessageData GetMessageFromString(string input, string name)
        {
            var output       = new StringWriter();
            var writer       = StreamFactory.CreateWriter(name, output);
            var reader       = StreamFactory.CreateReader(name, new StringReader(input));
            var deuevMessage = new BwnaMessageData();

            try
            {
                var streamObject = reader.Read();

                do
                {
                    var vosz = Assert.IsType <VOSZ>(streamObject);
                    deuevMessage.VOSZ.Add(vosz);
                    writer.Write(vosz);
                    streamObject = reader.Read();
                }while (reader.RecordName == "VOSZ" || reader.RecordName == "VOSZ-v01");

                var dsko = Assert.IsType <DSKO02>(streamObject);
                deuevMessage.DSKO = dsko;
                writer.Write(dsko);
                streamObject = reader.Read();

                while (reader.RecordName == "DSBE" || reader.RecordName == "DSBE-v01")
                {
                    var record = Assert.IsType <DSBE01>(streamObject);
                    deuevMessage.DSBEv01.Add(record);
                    writer.Write(record);
                    streamObject = reader.Read();
                }

                do
                {
                    var ncsz = Assert.IsType <NCSZ>(streamObject);
                    writer.Write(streamObject);
                    deuevMessage.NCSZ.Add(ncsz);
                    streamObject = reader.Read();
                }while (reader.RecordName != null && (reader.RecordName == "NCSZ" || reader.RecordName == "NCSZ-v01"));

                Assert.Null(reader.RecordName);
                Assert.Equal(deuevMessage.VOSZ.Count, deuevMessage.NCSZ.Count);

                writer.Close();
                string output2 = output.ToString();
                Assert.Equal(input, output2);
                return(deuevMessage);
            }
            finally
            {
                reader.Close();
            }
        }
        private DeuevMessageData GetMessageFromString(string input, string streamName)
        {
            var reader       = StreamFactory.CreateReader(streamName, new StringReader(input));
            var deuevMessage = new DeuevMessageData();

            try
            {
                var streamObject = reader.Read();

                do
                {
                    var vosz = Assert.IsType <VOSZ>(streamObject);
                    deuevMessage.VOSZ.Add(vosz);
                    streamObject = reader.Read();
                } while (reader.RecordName == "VOSZ" || reader.RecordName == "VOSZ-v01");

                while (reader.RecordName == "DSKK" || reader.RecordName == "DSKK-v01")
                {
                    var record = Assert.IsType <DSKK01>(streamObject);
                    deuevMessage.DSKK.Add(record);
                    streamObject = reader.Read();
                }

                do
                {
                    var ncsz = Assert.IsType <NCSZ>(streamObject);
                    deuevMessage.NCSZ.Add(ncsz);
                    streamObject = reader.Read();
                } while (reader.RecordName != null && (reader.RecordName == "NCSZ-v01" || reader.RecordName == "NCSZ"));

                Assert.Null(reader.RecordName);
                Assert.Equal(deuevMessage.VOSZ.Count, deuevMessage.NCSZ.Count);

                return(deuevMessage);
            }
            catch (InvalidRecordException ex) when(LogInvalidRecordException(ex))
            {
                Debug.Assert(false, "Darf hier niemals landen");
                throw;
            }
            finally
            {
                reader.Close();
            }
        }
        private DeuevMessageData GetMessageFromString(string input, string streamName)
        {
            var reader       = StreamFactory.CreateReader(streamName, new StringReader(input));
            var deuevMessage = new DeuevMessageData();

            try
            {
                var streamObject = reader.Read();

                do
                {
                    var vosz = Assert.IsType <VOSZ>(streamObject);
                    deuevMessage.VOSZ.Add(vosz);
                    streamObject = reader.Read();
                } while (reader.RecordName == "VOSZ" || reader.RecordName == "VOSZ-v01");

                var dsko = Assert.IsType <DSKO04>(streamObject);
                deuevMessage.DSKO = dsko;
                streamObject      = reader.Read();

                while (reader.RecordName == "DSME" || reader.RecordName == "DSME-v0301")
                {
                    var record = Assert.IsType <DSME0301>(streamObject);
                    deuevMessage.DSME.Add(record);
                    streamObject = reader.Read();
                }

                do
                {
                    var ncsz = Assert.IsType <NCSZ>(streamObject);
                    deuevMessage.NCSZ.Add(ncsz);
                    streamObject = reader.Read();
                } while (reader.RecordName != null && (reader.RecordName == "NCSZ-v01" || reader.RecordName == "NCSZ"));

                Assert.Null(reader.RecordName);
                Assert.Equal(deuevMessage.VOSZ.Count, deuevMessage.NCSZ.Count);

                return(deuevMessage);
            }
            finally
            {
                reader.Close();
            }
        }
Exemple #6
0
        /// <summary>
        /// Ruft die Meldedatei mit einem bestimmten Dateinamen aus dem Deuev-Ordner ab
        /// </summary>
        /// <param name="input">Die Meldedatei</param>
        /// <param name="name">Name in der Meldungen.xml</param>
        /// <returns>Meldedatei als DeuevMessageData-Objekt</returns>
        private BwnaMessageData GetMessageFromString(string input, string name)
        {
            var reader       = StreamFactory.CreateReader(name, new StringReader(input));
            var deuevMessage = new BwnaMessageData();

            try
            {
                var streamObject = reader.Read();

                do
                {
                    var vosz = Assert.IsType <VOSZ06>(streamObject);
                    deuevMessage.VOSZ.Add(vosz);
                    streamObject = reader.Read();
                }while (reader.RecordName == "VOSZ" || reader.RecordName == "VOSZ-BNA-v06");

                var dsko = Assert.IsType <DSKO02>(streamObject);
                deuevMessage.DSKO = dsko;
                streamObject      = reader.Read();

                while (reader.RecordName == "BW02" || reader.RecordName == "BW02-v11")
                {
                    var record = Assert.IsType <BW0211>(streamObject);
                    deuevMessage.BW02.Add(record);
                    streamObject = reader.Read();
                }

                do
                {
                    var ncsz = Assert.IsType <NCSZ06>(streamObject);
                    deuevMessage.NCSZ.Add(ncsz);
                    streamObject = reader.Read();
                }while (reader.RecordName != null && (reader.RecordName == "NCSZ" || reader.RecordName == "NCSZ-BNA-v06"));

                Assert.Null(reader.RecordName);
                Assert.Equal(deuevMessage.VOSZ.Count, deuevMessage.NCSZ.Count);

                return(deuevMessage);
            }
            finally
            {
                reader.Close();
            }
        }
        internal static VsnrFile Load(StreamFactory factory, TextReader file)
        {
            var reader        = factory.CreateReader("dsvv-deuev-v01", file);
            var vorlaufDsrv   = (VOSZ)reader.Read();
            var vorlaufSender = (VOSZ)reader.Read();
            var dsvv          = new List <DSVV01>();
            var record        = reader.Read();

            while (reader.RecordName == "DSVV")
            {
                dsvv.Add((DSVV01)record);
                record = reader.Read();
            }

            var nachlaufSender = (NCSZ)record;
            var nachlaufDsrv   = (NCSZ)reader.Read();

            return(new VsnrFile(vorlaufDsrv, vorlaufSender, dsvv, nachlaufSender, nachlaufDsrv));
        }
        /// <summary>
        /// Ruft die Meldedatei mit einem bestimmten Dateinamen aus dem Deuev-Ordner ab
        /// </summary>
        /// <param name="fileName">
        /// Dateiname der Meldedatei
        /// </param>
        /// <param name="name">
        /// Name in der Meldungen.xml
        /// </param>
        /// <returns>
        /// Meldedatei als DeuevMessageData-Objekt
        /// </returns>
        private BwnaMessageData GetMessageFromFile(string fileName, string name)
        {
            var input        = LoadData(fileName).ReadToEnd();
            var output       = new StringWriter();
            var writer       = StreamFactory.CreateWriter(name, output);
            var reader       = StreamFactory.CreateReader(name, new StringReader(input));
            var deuevMessage = new BwnaMessageData();

            try
            {
                var streamObject = reader.Read();

                do
                {
                    var vosz = Assert.IsType <VOSZ>(streamObject);
                    deuevMessage.VOSZ.Add(vosz);
                    writer.Write(vosz);
                    streamObject = reader.Read();
                }while (reader.RecordName == "VOSZ" || reader.RecordName == "VOSZ-v01");

                var dsko = Assert.IsType <DSKO02>(streamObject);
                deuevMessage.DSKO = dsko;
                writer.Write(dsko);
                streamObject = reader.Read();

                while (reader.RecordName == "DSER" || reader.RecordName == "DSER-v02" || reader.RecordName == "DSER-v03")
                {
                    switch (name)
                    {
                    case "dser-agger-v02":
                    {
                        var record = Assert.IsType <DSER02>(streamObject);
                        deuevMessage.DSER02.Add(record);
                        writer.Write(record);
                    }
                    break;

                    case "dser-agger-v03":
                    {
                        var record = Assert.IsType <DSER03>(streamObject);
                        deuevMessage.DSER03.Add(record);
                        writer.Write(record);
                    }
                    break;

                    case "super-message":
                        switch (reader.RecordName)
                        {
                        case "DSER-v02":
                        {
                            var record = Assert.IsType <DSER02>(streamObject);
                            deuevMessage.DSER02.Add(record);
                            writer.Write(record);
                        }
                        break;

                        case "DSER-v03":
                        {
                            var record = Assert.IsType <DSER03>(streamObject);
                            deuevMessage.DSER03.Add(record);
                            writer.Write(record);
                        }
                        break;

                        default:
                            throw new InvalidOperationException(string.Format("Unsupported record {0}", reader.RecordName));
                        }
                        break;

                    default:
                        throw new InvalidOperationException(string.Format("Unsupported stream {0}", name));
                    }
                    streamObject = reader.Read();
                }

                do
                {
                    var ncsz = Assert.IsType <NCSZ>(streamObject);
                    writer.Write(streamObject);
                    deuevMessage.NCSZ.Add(ncsz);
                    streamObject = reader.Read();
                }while (reader.RecordName != null && (reader.RecordName == "NCSZ" || reader.RecordName == "NCSZ-v01"));

                Assert.Null(reader.RecordName);
                Assert.Equal(deuevMessage.VOSZ.Count, deuevMessage.NCSZ.Count);

                writer.Close();
                string output2 = output.ToString();
                Assert.Equal(input, output2);
                return(deuevMessage);
            }
            finally
            {
                reader.Close();
            }
        }