public InputFields GetInputFields() { InputFields inputFields = new InputFields(); inputFields.AgencyId = _RunReportRequest.Parameters.GetString("AgencyId"); inputFields.SiteIdType = _RunReportRequest.Parameters.GetString("SiteIdType"); inputFields.SiteId = _RunReportRequest.Parameters.GetString("SiteId"); inputFields.SensorDataType = _RunReportRequest.Parameters.GetString("SensorDataType"); inputFields.SensorTypeParam1 = _RunReportRequest.Parameters.GetString("SensorTypeParam1"); inputFields.SensorTypeParam2 = _RunReportRequest.Parameters.GetString("SensorTypeParam2"); return(inputFields); }
public string WriteValuesToFile(InputFields inputFields) { var timeSeriesPoints = GetPoints(); var fileName = GetOutputFileName(); var file = File.AppendText(fileName); WriteFileHeader(file, inputFields, timeSeriesPoints.Count); WritePoints(file, inputFields, timeSeriesPoints); file.Close(); return(fileName); }
public void WriteFileHeader(StreamWriter file, InputFields inputFields, int numberOfRecords) { var tsOffset = TimeSpan.FromHours(_TimeSeriesDescription.UtcOffset); var offset = ((tsOffset < TimeSpan.Zero) ? "-" : "") + tsOffset.ToString(@"hh\:mm"); file.WriteLine(string.Format("# HEADER: Agency Id: {0}", inputFields.AgencyId)); file.WriteLine(string.Format("# HEADER: File Generation Date: {0}", DateTimeOffset.Now.ToString(_DateFormat))); file.WriteLine("# HEADER: File Format: BOM-HCS"); file.WriteLine("# HEADER: File Format Version: 2.0"); file.WriteLine("# HEADER: Generated by (system): AQUARIUS"); file.WriteLine(string.Format("# HEADER: Number of Records: {0}", numberOfRecords)); file.WriteLine(string.Format("# HEADER: Local ObsTime Offset: {0}", offset)); file.WriteLine("# HEADER: Data Fields: IndexNo, SensorType, " + "SensorDataType, SiteIdType, SiteId, ObservationTimestamp, " + "RealValue, Unit, SensorTypeParam1, SensorTypeParam2, Quality, Comment"); }
public void WritePoints(StreamWriter file, InputFields inputFields, List <TimeAlignedPoint> timeSeriesPoints) { var quality = "1"; var unit = MapUnit(); for (int i = 0; i < timeSeriesPoints.Count; i++) { var timeSeriesPoint = timeSeriesPoints[i]; var line = string.Format("{0},\"{1}\",{2},\"{3}\",\"{4}\",\"{5}\",{6},\"{7}\",\"{8}\",{9},{10},\"{11}\"", i + 1, _SensorType, inputFields.SensorDataType, inputFields.SiteIdType, inputFields.SiteId, timeSeriesPoint.Timestamp.ToString(_DateFormat), (timeSeriesPoint.NumericValue1.HasValue) ? FormatValue(timeSeriesPoint.NumericValue1.Value) : "", unit, inputFields.SensorTypeParam1, inputFields.SensorTypeParam2, quality, ""); file.WriteLine(line); } }