Ejemplo n.º 1
0
        public void DeserializeHeaderTest()
        {
            List <BaseColumnModel> resultHeader;

            using (var manager = new DbManager(new SqlDataProvider(), Config.GetSetting("TestConnectionString")))
            {
                using (IDbCommand command = manager.Connection.CreateCommand())
                {
                    command.CommandText = @"select  * from dbo.AVR_HumanCaseReport";
                    using (IDataReader reader = command.ExecuteReader())
                    {
                        List <BaseColumnModel> columnModels = BinarySerializer.GetSchemaColumnModels(reader.GetSchemaTable());
                        BinarySerializer.SerializeBodyPacket(reader, columnModels, false);
                        QueryTablePacketDTO header = BinarySerializer.SerializeHeader(columnModels, false);
                        resultHeader = BinarySerializer.DeserializeHeader(header);
                    }
                }
            }

            Assert.IsTrue(resultHeader.Exists(c => c.Name == "sflHC_PatientDOB"));
            Assert.IsTrue(resultHeader.Exists(c => c.Name == "sflHC_PatientSex_ID"));
            Assert.IsTrue(resultHeader.Exists(c => c.Name == "sflHC_LabDiagBasis"));
            Assert.IsTrue(resultHeader.Exists(c => c.Name == "sflHC_CS__10034010__9253110000000"));
            Assert.AreEqual(typeof(DateTime), resultHeader.Find(c => c.Name == "sflHC_PatientDOB").FinalType);
            Assert.AreEqual(typeof(long), resultHeader.Find(c => c.Name == "sflHC_PatientSex_ID").FinalType);
            Assert.AreEqual(typeof(string), resultHeader.Find(c => c.Name == "sflHC_LabDiagBasis").FinalType);
            Assert.AreEqual(typeof(DateTime), resultHeader.Find(c => c.Name == "sflHC_CS__10034010__9253110000000").FinalType);
        }
Ejemplo n.º 2
0
        public QueryTableHeaderModel(QueryTableHeaderDTO headerDTO)
        {
            QueryCacheId = headerDTO.QueryCacheId;
            PacketCount  = headerDTO.PacketCount;

            QueryTablePacketDTO    unzipedHeader      = BinaryCompressor.Unzip(headerDTO.BinaryHeader);
            List <BaseColumnModel> deserializedHeader = BinarySerializer.DeserializeHeader(unzipedHeader);

            ColumnTypeByName = deserializedHeader;
            ColumnTypes      = deserializedHeader.Select(c => c.FinalType).ToArray();
        }
Ejemplo n.º 3
0
        public void SerializeIntegrationTest()
        {
            QueryTableModel tableModel;

            using (var manager = new DbManager(new SqlDataProvider(), Config.GetSetting("TestConnectionString")))
            {
                using (DbManager command = manager.SetCommand(@"select  * from dbo.AVR_HumanCaseReport"))
                {
                    tableModel = BinarySerializer.SerializeFromCommand(command, 123, "en", false, 10);
                }
            }

            Assert.AreEqual(54, tableModel.Header.RowCount);
            Assert.AreEqual(false, tableModel.UseArchivedData);
            Assert.AreEqual(false, tableModel.Header.IsArchive);

            QueryTablePacketDTO zippedHeader = BinaryCompressor.Zip(tableModel.Header);

            Assert.AreEqual(false, zippedHeader.IsArchive);
            List <QueryTablePacketDTO> zippedBody = tableModel.BodyPackets.Select(BinaryCompressor.Zip).ToList();

            Assert.IsFalse(zippedBody.Any(p => p.IsArchive));

            QueryTablePacketDTO unzipedHeader = BinaryCompressor.Unzip(zippedHeader);

            Assert.AreEqual(false, unzipedHeader.IsArchive);
            List <QueryTablePacketDTO> unzippedBody = zippedBody.Select(BinaryCompressor.Unzip).ToList();

            Assert.IsFalse(unzippedBody.Any(p => p.IsArchive));

            List <BaseColumnModel> resultHeader = BinarySerializer.DeserializeHeader(unzipedHeader);

            Assert.IsTrue(resultHeader.Exists(c => c.Name == "sflHC_PatientDOB"));
            Assert.IsTrue(resultHeader.Exists(c => c.Name == "sflHC_PatientSex_ID"));
            Assert.IsTrue(resultHeader.Exists(c => c.Name == "sflHC_LabDiagBasis"));
            Assert.AreEqual(typeof(DateTime), resultHeader.Find(c => c.Name == "sflHC_PatientDOB").FinalType);
            Assert.AreEqual(typeof(long), resultHeader.Find(c => c.Name == "sflHC_PatientSex_ID").FinalType);
            Assert.AreEqual(typeof(string), resultHeader.Find(c => c.Name == "sflHC_LabDiagBasis").FinalType);

            Type[] types = resultHeader.Select(c => c.FinalType).ToArray();

            AvrDataTable resultBody = new AvrDataTable(new DataTable());

            foreach (var packetDTO in unzippedBody)
            {
                BinarySerializer.DeserializeBodyPacket(packetDTO, types, resultBody);
            }

            Assert.AreEqual(31, resultBody.Count);
            Assert.AreEqual(54, resultBody[0].Count);

            AvrDataRowEx row = (AvrDataRowEx)resultBody[30];

            Assert.AreEqual(new DateTime(1990, 02, 01), row[0]);
            Assert.AreEqual(23, row[1]);
            Assert.AreEqual(DBNull.Value, row[3]);
            Assert.AreEqual("xxx", row[4]);
            Assert.AreEqual("Male", row[6]);
            Assert.AreEqual(DBNull.Value, row[7]);
            Assert.AreEqual(DateTime.Now.Year, ((DateTime)row[50]).Year);
            Assert.AreEqual(DateTime.Now.Year, row[51]);
            Assert.AreEqual(25460000000m, row[52]);
            Assert.AreEqual("Yes", row[53]);
        }