Esempio n. 1
0
        protected override void ReadXmlBase(System.Xml.XmlReader reader)
        {
            base.ReadXmlBase(reader);

            if (reader.LocalName == "alternate_text")
                this.alternateText = reader.ReadElementString("alternate_text", RmXmlSerializer.OpenEhrNamespace);
            reader.MoveToContent();

            if (reader.LocalName == "uri")
            {
                string uriType = reader.GetAttribute("type", RmXmlSerializer.XsiNamespace);
                if (uriType != null)
                {
                    Check.Assert(uriType.IndexOf("DV_EHR_URI")>0, "uriType must be DV_EHR_URI, but it is "+uriType);
                    this.uri = new OpenEhr.RM.DataTypes.Uri.DvEhrUri();
                }
                this.uri = new OpenEhr.RM.DataTypes.Uri.DvUri();
                this.uri.ReadXml(reader);
            }

            if (reader.LocalName == "data")
            {
                reader.MoveToContent();
                reader.ReadStartElement();
                byte[] buffer = new byte[1024];
                System.IO.MemoryStream stream = new System.IO.MemoryStream();
                System.IO.BinaryWriter writer = new System.IO.BinaryWriter(stream);
                int bytesRead = reader.ReadContentAsBase64(buffer, 0, 1024);
                while (bytesRead > 0)
                {
                    writer.Write(buffer, 0, bytesRead);
                    bytesRead = reader.ReadContentAsBase64(buffer, 0, 1024);
                }
                writer.Close();
                reader.MoveToContent();
                reader.ReadEndElement();
                this.data = stream.ToArray();
            }
            reader.MoveToContent();

            if (reader.LocalName == "media_type")
            {
                this.mediaType = new OpenEhr.RM.DataTypes.Text.CodePhrase();
                this.mediaType.ReadXml(reader);
            }

            if (reader.LocalName == "compression_algorithm")
            {
                this.compressionAlgorithm = new OpenEhr.RM.DataTypes.Text.CodePhrase();
                this.compressionAlgorithm.ReadXml(reader);
            }

            if (reader.LocalName == "integrity_check")
            {
                reader.ReadElementContentAsBase64(this.integrityCheck, 0, this.integrityCheck.Length);
            }
            reader.MoveToContent();

            if (reader.LocalName == "integrity_check_algorithm")
            {
                this.integrityCheckAlgorithm = new OpenEhr.RM.DataTypes.Text.CodePhrase();
                this.integrityCheckAlgorithm.ReadXml(reader);
            }

            Check.Assert(reader.LocalName=="size", "Expected LocalName is 'size', not " + reader.LocalName);
            this.size = reader.ReadElementContentAsInt("size", RmXmlSerializer.OpenEhrNamespace);
            reader.MoveToContent();

            if (reader.LocalName == "thumbnail")
            {
                this.thumbnail = new DvMultimedia();
                this.thumbnail.ReadXml(reader);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Parse the extract response.
        /// </summary>
        /// <param name="oReader">The GeosoftXML response</param>
        /// <param name="oStream">The extracted data in a stream</param>
        public void ExtractData(System.Xml.XmlReader oReader, System.IO.Stream oStream)
        {
            byte[] bExtract = new byte[4096];
            if (oReader.ReadToFollowing(Constant.Tag.EXTRACT_DATA_TAG))
            {
                int iCount = 0;

                do
                {
                    iCount = oReader.ReadElementContentAsBase64(bExtract, 0, 4096);
                    oStream.Write(bExtract, 0, iCount);
                } while (iCount != 0);
            }
        }