public static ValuesDataSet getDataValues(int SiteID, int VariableID, DateTime StartDate, DateTime EndDate) { seriesCatalogDataSet scDS = new seriesCatalogDataSet(); SeriesCatalogTableAdapter seriesTableAdapter = new SeriesCatalogTableAdapter(); seriesTableAdapter.Connection.ConnectionString = odws.Config.ODDB(); seriesTableAdapter.FillBySiteIDVariableID(scDS.SeriesCatalog, SiteID, VariableID); DataSet oDS = new DataSet(); try { // oDS = getValuesWork(scDS.SeriesCatalog, StartDate, EndDate); Thread thread = new Thread(delegate() { oDS = getValuesWork(scDS.SeriesCatalog, StartDate, EndDate); }); thread.Start(); while (thread.IsAlive) { Thread.Sleep(150); } return(newTable(scDS.SeriesCatalog, ref oDS)); } catch (Exception e) { log.Fatal("Cannot retrieve information from database: " + e.Message); //+ valuesTableAdapter.Connection.DataSource } return(basicValuesDataSet()); }
/* * newTable * creates the Data Table required by rest of program to create the XML form */ private ValuesDataSet newTable(string variable, int SID, string Data) { SeriesCatalogTableAdapter scAdapater = new SeriesCatalogTableAdapter(); scAdapater.Connection.ConnectionString = odws.Config.ODDB(); ValuesDataSet ds = basicValuesDataSet(); DataTable variableTable = ds.Tables[0]; int ValueID = 0; foreach (string entry in Data.Split('\n')) { string[] row = entry.Split(','); if (row[0] != "" && row[0] != null) { ValueID++; seriesCatalogDataSet scTable = new seriesCatalogDataSet(); scAdapater.FillBySeriesID(scTable.SeriesCatalog, SID); seriesCatalogDataSet.SeriesCatalogRow sc = scTable.SeriesCatalog[0]; TimeSpan utcOffset = sc.BeginDateTime.Subtract(sc.BeginDateTimeUTC); variableTable.Rows.Add(ValueID, sc.SiteID, sc.VariableID, 0, 0, "nc", 0, sc.MethodID, sc.SourceID, 0, 0, sc.QualityControlLevelID, (row[0] == string.Empty) || row[1] == string.Empty ? -999999 : Convert.ToDouble(row[1]), 0, Convert.ToDateTime(row[0]), Convert.ToDateTime(row[0]).ToUniversalTime(), utcOffset.Hours); /*"ValueID","SiteID","VariableID",offsetvalue, offset type id, "CensorCode","QualifierID","MethodID","SourceID","SampleID","DerivedFromID","QualityControlLevelID", "Value", "AccuracyStdDev", "DateTime","DateTimeUTC", "UTCOffset"*/ } } return(ds); }
public HealthSeriesCatalog(SqlConnection sqlConn) { Adapter = new SeriesCatalogTableAdapter(); Table = new HealthQueryDataSet.SeriesCatalogDataTable(); Adapter.Connection = sqlConn; Adapter.Adapter.UpdateBatchSize = Program.DbUpdateBatchSize; Adapter.Adapter.InsertCommand.UpdatedRowSource = UpdateRowSource.None; // required to do batch insertion }
/// <summary> /// get a series catalog for a site. /// /// </summary> /// <param name="siteID"></param> /// <returns></returns> public static seriesCatalogDataSet GetSeriesCatalogDataSet(int siteID) { seriesCatalogDataSet sDS = new seriesCatalogDataSet(); SeriesCatalogTableAdapter seriesTableAdapter = new SeriesCatalogTableAdapter(); seriesTableAdapter.Connection.ConnectionString = odws.Config.ODDB(); try { seriesTableAdapter.FillBySiteID(sDS.SeriesCatalog, siteID); } catch (Exception e) { log.Fatal("Cannot retrieve information from database: " + e.Message); // + seriesTableAdapter.Connection.DataSource } return sDS; }
private DateTime selectEndDate(DateTime end, int seriesID) { SeriesCatalogTableAdapter scAdapater = new SeriesCatalogTableAdapter(); scAdapater.Connection.ConnectionString = odws.Config.ODDB(); seriesCatalogDataSet sc = new seriesCatalogDataSet(); scAdapater.FillBySeriesID(sc.SeriesCatalog, seriesID); DateTime dbEnd = sc.SeriesCatalog[0].EndDateTime; if (end < dbEnd) { return(end); } else { return(dbEnd); } }
private DateTime selectStartDate(DateTime start, int sID) { SeriesCatalogTableAdapter scAdapater = new SeriesCatalogTableAdapter(); scAdapater.Connection.ConnectionString = odws.Config.ODDB(); seriesCatalogDataSet sc = new seriesCatalogDataSet(); scAdapater.FillBySeriesID(sc.SeriesCatalog, sID); DateTime dbStart = sc.SeriesCatalog[0].BeginDateTime; if (start > dbStart) { return(start); } else { return(dbStart); } }
/// <summary> /// get a series catalog for a site. /// /// </summary> /// <param name="siteID"></param> /// <returns></returns> public static seriesCatalogDataSet GetSeriesCatalogDataSet(int siteID) { seriesCatalogDataSet sDS = new seriesCatalogDataSet(); SeriesCatalogTableAdapter seriesTableAdapter = new SeriesCatalogTableAdapter(); seriesTableAdapter.Connection.ConnectionString = odws.Config.ODDB(); try { seriesTableAdapter.FillBySiteID(sDS.SeriesCatalog, siteID); } catch (Exception e) { log.Fatal("Cannot retrieve information from database: " + e.Message); // + seriesTableAdapter.Connection.DataSource } return(sDS); }
public ValuesDataSet getDataValues(int SiteID, int VariableID, DateTime StartDate, DateTime EndDate) { seriesCatalogDataSet scDS = new seriesCatalogDataSet(); SeriesCatalogTableAdapter seriesTableAdapter = new SeriesCatalogTableAdapter(); seriesTableAdapter.Connection.ConnectionString = odws.Config.ODDB(); seriesTableAdapter.FillBySiteIDVariableID(scDS.SeriesCatalog, SiteID, VariableID); DataSet oDS = new DataSet(); try { oDS = getValuesWork(scDS.SeriesCatalog, StartDate, EndDate); } catch (Exception ex) { return(emptyValues(ex.Message)); } return(newTable(scDS.SeriesCatalog, ref oDS)); }
public ValuesDataSet getDataValues(ValuesDataSet ds, DateTime startDate, DateTime endDate) { SeriesCatalogTableAdapter scAdapater = new SeriesCatalogTableAdapter(); scAdapater.Connection.ConnectionString = odws.Config.ODDB(); seriesCatalogDataSet sc = new seriesCatalogDataSet(); scAdapater.FillBySiteVariable(sc.SeriesCatalog, ds.Sites[0].SiteID, ds.Variables[0].VariableID); string requestData = ""; try { requestData = generateURL(URLSiteName(ds.Sites), URLVariableCode(ds.Variables, ds.Sites), selectStartDate(startDate, sc.SeriesCatalog[0].SeriesID), selectEndDate(endDate, sc.SeriesCatalog[0].SeriesID)); return(newTable(ds.Variables[0].VariableID.ToString(), sc.SeriesCatalog[0].SeriesID, requestData)); } catch (Exception ex) { return(new ValuesDataSet()); } }
public OD_SeriesCatalog(SqlConnection sqlConn) { Adapter = new SeriesCatalogTableAdapter(); Table = new OD_1_1_1DataSet.SeriesCatalogDataTable(); Adapter.Connection = sqlConn; }
public hiscentralSeriesCatalog(SqlConnection sqlConn) { Adapter = new SeriesCatalogTableAdapter(); Table = new hiscentralDataSet.SeriesCatalogDataTable(); Adapter.Connection = sqlConn; }