public override PeriodOfRecord GetPeriodOfRecord() { string sql = "select count(*), min(" + m_dateColumn + "),max(" + m_dateColumn + ") from [" + m_tableName + "]"; string query = "Select * from [" + m_tableName + "] Where 1 = 0"; DataTable schema = AccessDB.Table(m_filename, m_tableName, query); if (m_filterValue != "" && m_filterColumn != "") { if (NeedQuotes(schema.Columns[m_filterColumn])) { sql += " WHERE [" + m_filterColumn + "] = '" + m_filterValue + "'"; } else { sql += " WHERE [" + m_filterColumn + "] = " + m_filterValue; } } DateTime t1 = TimeSeriesDatabase.MinDateTime; //.. DateTime.MinValue; DateTime t2 = TimeSeriesDatabase.MaxDateTime; // DateTime.MinValue; int count = 0; DataTable por = AccessDB.Table(m_filename, "por", sql); count = Convert.ToInt32(por.Rows[0][0]); if (count > 0) { t1 = Convert.ToDateTime(por.Rows[0][1]); t2 = Convert.ToDateTime(por.Rows[0][2]); } PeriodOfRecord rval = new PeriodOfRecord(t1, t2, count); return(rval); }
/// <summary> /// Gets Period of record withing a specified data range (t1,t2). /// Used to determine ranges of dates for updates /// </summary> /// <param name="siteDataTypeID"></param> /// <param name="t1"></param> /// <param name="t2"></param> /// <returns></returns> internal PeriodOfRecord GetPeriodOfRecord(int siteDataTypeID, DateTime t1, DateTime t2) { SeriesCatalogRow si = GetSeriesRow(siteDataTypeID); string sql = "select count(*), min(datetime),max(datetime) from " + m_server.PortableTableName(si.TableName) + " WHERE datetime >= " + m_server.PortableDateString( t1,dateTimeFormat) + " AND " + " datetime <= " + m_server.PortableDateString( t2,dateTimeFormat) ; t1 = TimeSeriesDatabase.MinDateTime;//.. DateTime.MinValue; t2 = TimeSeriesDatabase.MaxDateTime;// DateTime.MinValue; int count = 0; if (m_server.TableExists(si.TableName)) { DataTable por = Server.Table("por", sql); count = Convert.ToInt32(por.Rows[0][0]); if (count > 0) { t1 = Convert.ToDateTime(por.Rows[0][1]); t2 = Convert.ToDateTime(por.Rows[0][2]); } } PeriodOfRecord rval = new PeriodOfRecord(t1, t2, count); return rval; }