private void WriteDataSource(DataSourceDto dto) { this.writer.WriteStartElement("DataSource"); // Name this.writer.WriteStartElement("Name"); this.writer.WriteString(dto.Name); this.writer.WriteEndElement(); // Type this.writer.WriteStartElement("Type"); this.writer.WriteValue(ConvertConversionFunctionToString(dto.ConversionFunction)); this.writer.WriteEndElement(); // Interval this.writer.WriteStartElement("IntervalInSeconds"); this.writer.WriteValue(Convert.ToInt32(dto.PollingInterval.TotalSeconds)); this.writer.WriteEndElement(); // Min threshold this.writer.WriteStartElement("MinThreshold"); this.writer.WriteValue(dto.Range.Min); this.writer.WriteEndElement(); // Max threshold this.writer.WriteStartElement("MaxThreshold"); this.writer.WriteValue(dto.Range.Max); this.writer.WriteEndElement(); WriteLastReading(dto.LastReading); WriteStats(dto.Stats); WriteArchives(dto.Archives); this.writer.WriteEndElement(); }
private DataSourceDto[] ReadDataSources() { List <DataSourceDto> dataSources = new List <DataSourceDto>(); this.reader.Read(); do { this.reader.Read(); DataSourceDto dto = new DataSourceDto(); // Name this.reader.ReadStartElement("Name"); dto.Name = this.reader.ReadString(); this.reader.ReadEndElement(); // Type this.reader.ReadStartElement("Type"); string typeAsString = this.reader.ReadString(); dto.ConversionFunction = ConvertStringToConversionFunction(typeAsString); this.reader.ReadEndElement(); // Interval this.reader.ReadStartElement("IntervalInSeconds"); dto.PollingInterval = new TimeSpan(0, 0, this.reader.ReadContentAsInt()); this.reader.ReadEndElement(); // Min threshold this.reader.ReadStartElement("MinThreshold"); double minThreshold = this.reader.ReadContentAsDouble(); this.reader.ReadEndElement(); // Max threshold this.reader.ReadStartElement("MaxThreshold"); double maxThreshold = this.reader.ReadContentAsDouble(); this.reader.ReadEndElement(); dto.Range = new RangeDto(); dto.Range.Min = minThreshold; dto.Range.Max = maxThreshold; // Last reading dto.LastReading = ReadLastReading(); // Stats dto.Stats = ReadDataSourceStats(); // Archives dto.Archives = ReadArchives(); dataSources.Add(dto); } while (this.reader.ReadToNextSibling("DataSource")); this.reader.ReadEndElement(); return(dataSources.ToArray()); }
private void FixupArchives(DataSourceDto dto) { foreach (ArchiveDto archiveDto in dto.Archives) { Archive newArchive = CreateArchive(archiveDto); newArchive.FixupFromDto(archiveDto); this.archives.Add(newArchive); } }
internal DataSource(TimeSeriesDatabase database, DataSourceDto dto) { this.database = database; this.archives = new Archive.ArchiveCollection(this); this.stats = new DataSourceStats(this); this.range = new Range(); FixupProperties(dto); FixupArchives(dto); }
private void FixupProperties(DataSourceDto dto) { this.Dao = dto.Dao; this.Name = dto.Name; this.ConversionFunction = (ConversionFunctionType)dto.ConversionFunction; this.CreateConversionFunction(); this.PollingInterval = dto.PollingInterval; if (dto.LastReading != null) { if (dto.LastReading.Empty != true) { this.lastReading = new Reading(); this.lastReading.FixupFromDto(dto.LastReading); } } this.range.FixupFromDto(dto.Range); this.Stats.FixupFromDto(dto.Stats); }
internal DataSourceDto CreateDto() { DataSourceDto dto = new DataSourceDto(); dto.Dao = this.dao; dto.Name = this.Name; dto.ConversionFunction = (int)this.conversionFunction; dto.Range = this.range.CreateDto(); dto.PollingInterval = this.PollingInterval; if (this.lastReading != null) { dto.LastReading = this.lastReading.CreateDto(); } dto.Stats = this.stats.CreateDto(); foreach (Archive ar in this.archives) { dto.AddArchive(ar.CreateDto()); } return(dto); }
public void AddDataSource(DataSourceDto newDataSource) { this.dataSources.Add(newDataSource); }
private DataSource CreateDataSourceFromDto(DataSourceDto dto) { return(new DataSource(this, dto)); }