private static TimeRange GetDateRange(NameValueCollection collection) { var start = ""; if (collection.AllKeys.Contains("start")) { start = collection["start"]; } var end = ""; if (collection.AllKeys.Contains("end")) { end = collection["end"]; } int y1 = 0, y2 = 0; if (!int.TryParse(start, out y1) || !int.TryParse(end, out y2)) { StopWithError("Error with year range"); } //creates a water year time range between the selected dates y1, y2 var rval = new TimeRange( WaterYear.BeginningOfWaterYear(new DateTime(y1, 1, 1)), WaterYear.EndOfWaterYear(new DateTime(y2, 1, 1))); return rval; }
/// <summary> /// Gets the queried series and generates simple text output /// </summary> /// <param name="query"></param> /// <returns></returns> private void WriteSeries(SeriesList list) { m_formatter.WriteSeriesHeader(list); int daysStored = 30; if (m_formatter.Interval == TimeInterval.Daily) daysStored = 3650; // 10 years if (m_formatter.Interval == TimeInterval.Monthly) daysStored = 36500; TimeRange timeRange = new TimeRange(start, end); foreach (TimeRange item in timeRange.Split(daysStored)) { var interval = m_formatter.Interval; var tbl = Read(list, item.StartDate, item.EndDate, interval,m_formatter.OrderByDate); m_formatter.PrintDataTable(list, tbl); } m_formatter.WriteSeriesTrailer(); }
/// <summary> /// Imports instant data from Hydromet into TimeSeriesDatabase /// </summary> /// <param name="db"></param> private static void ImportHydrometInstant(TimeSeriesDatabase db,DateTime start, DateTime end, string filter,string propertyFilter) { // TO DO.. the outer loop of Date ranges (t,t3) could // be generated as a separate task. Console.WriteLine("ImportHydrometInstant"); TimeRange timeRange = new TimeRange(start, end); foreach (TimeRange item in timeRange.Split(30)) { int block = 1; foreach (string query in GetBlockOfQueries(db, TimeInterval.Irregular, filter, propertyFilter)) { Console.WriteLine("Reading " + item.StartDate + " to " + item.EndDate); var table = HydrometDataUtility.DayFilesTable(HydrometHost.PN, query, item.StartDate, item.EndDate, 0); Console.WriteLine("Block " + block + " has " + table.Rows.Count + " rows "); Console.WriteLine(query); SaveTableToSeries(db, table, TimeInterval.Irregular); block++; } } Console.WriteLine("Finished importing 15-minute data"); }