Ejemplo n.º 1
0
        private ReadingDto ReadLastReading()
        {
            ReadingDto readingDto = null;

            if (this.reader.IsEmptyElement != true)
            {
                this.reader.Read();

                readingDto = new ReadingDto();

                // Value
                this.reader.ReadStartElement("Value");
                readingDto.Value = this.reader.ReadContentAsDouble();
                this.reader.ReadEndElement();

                // Timestamp
                this.reader.ReadStartElement("Timestamp");
                readingDto.Timestamp = this.reader.ReadContentAsDateTime();
                this.reader.ReadEndElement();

                this.reader.ReadEndElement();
            }
            else
            {
                this.reader.Read();
            }

            return(readingDto);
        }
Ejemplo n.º 2
0
        internal ReadingDto CreateDto()
        {
            ReadingDto Dto = new ReadingDto();

            Dto.Dao       = this.dao;
            Dto.Value     = this.value;
            Dto.Timestamp = this.timestamp;
            return(Dto);
        }
Ejemplo n.º 3
0
        private void WriteLastReading(ReadingDto readingDto)
        {
            // Last reading
            this.writer.WriteStartElement("LastReading");

            if (readingDto != null)
            {
                // Value
                this.writer.WriteStartElement("Value");
                this.writer.WriteValue(readingDto.Value);
                this.writer.WriteEndElement();
                // Timestamp
                this.writer.WriteStartElement("Timestamp");
                this.writer.WriteValue(readingDto.Timestamp);
                this.writer.WriteEndElement();
            }
            this.writer.WriteEndElement();
        }
Ejemplo n.º 4
0
        private ReadingCollectionDto ReadAccumulatedReadings()
        {
            ReadingCollectionDto dto = new ReadingCollectionDto();

            if (this.reader.IsEmptyElement != true)
            {
                this.reader.Read();

                do
                {
                    this.reader.Read();

                    ReadingDto reading = new ReadingDto();

                    // Value
                    this.reader.ReadStartElement("Value");
                    reading.Value = this.reader.ReadContentAsDouble();
                    this.reader.ReadEndElement();

                    // Timestamp
                    this.reader.ReadStartElement("Timestamp");
                    reading.Timestamp = this.reader.ReadContentAsDateTime();
                    this.reader.ReadEndElement();

                    dto.Add(reading);
                } while (this.reader.ReadToNextSibling("Reading"));

                this.reader.ReadEndElement();
            }
            else
            {
                this.reader.Read();
            }

            return(dto);
        }
Ejemplo n.º 5
0
 internal void FixupFromDto(ReadingDto dto)
 {
     this.dao       = dto.Dao;
     this.value     = dto.Value;
     this.timestamp = dto.Timestamp;
 }
Ejemplo n.º 6
0
 /// <summary>
 /// Add a reading to the queue
 /// </summary>
 /// <param name="dto">New reading to add</param>
 public void Add(ReadingDto newReadingDto)
 {
     this.readings.Add(newReadingDto);
 }