private DailyReport GetDailyReport(DateTimeOffset day, SQLiteConnection conn) { Attribute attr = new Attribute(); string software_version = attr.Get("software.version", conn); SiteName site_name = new SiteName(); CountryCode country_code = new CountryCode(); DailyReport report = new DailyReport(country_code.GetValue(conn), site_name.GetValue(conn), day, software_version); string sql = string.Format("SELECT C.Name, C.CollectorType, D.Value, D.Timestamp FROM Data D INNER JOIN Collectors C ON D.CollectorID = C.CollectorID WHERE D.Timestamp BETWEEN '{0}' AND '{1}' ORDER BY D.TimeStamp ASC;", day.DayBeginAs8601(), day.DayEndAs8601()); string first_of_month = string.Format("{0:D4}-{1:D2}-01T00:00:00.000", day.Year, day.Month); try { if (day.DayBeginAs8601() == first_of_month) { DailyReport.Record config_record = GetConfigurationRecord(day, conn); if (config_record != null) { report.records.Add(config_record); } } SQLiteCommand command = new SQLiteCommand(sql, conn); using (command) using (SQLiteDataReader reader = command.ExecuteReader()) { while (reader.Read()) { DailyReport.Record record = new DailyReport.Record() { collector = reader.GetString(0), type = (ECollectorType)reader.GetInt32(1), value = reader.GetString(2), timestamp = DateTimeOffset.Parse(reader.GetString(3)) }; report.records.Add(record); } } } catch (Exception ex) { ILog log = LogManager.GetLogger(typeof(Retriever)); log.Error("GetDailyReport: " + sql); log.Error(ex); } return(report); }