static bool InsertOneSite(OD_1_1_DataSet.SitesDataTable sitesTable, WaterML11.SiteInfoType stinfo, SqlConnection sqlConn) { OD_1_1_DataSet.SitesRow row = sitesTable.NewSitesRow(); row.SiteCode = stinfo.siteCode[0].Value; string cond = "SiteCode = '" + row.SiteCode + "'"; if (OD_Utils.Exists(row.Table.TableName, cond, sqlConn)) { return(false); } row.SiteName = stinfo.siteName; WaterML11.LatLonPointType glt = (WaterML11.LatLonPointType)stinfo.geoLocation.geogLocation; row.Latitude = glt.latitude; row.Longitude = glt.longitude; row.LatLongDatumID = 0; row.Elevation_m = stinfo.elevation_m; row.VerticalDatum = stinfo.verticalDatum; //row.LocalX = 0; //row.LocalY = 0; //row.LocalProjectionID = 0; //row.PosAccuracy_m = 0; for (int i = 0; i < stinfo.note.Count(); i++) { NoteType note = stinfo.note[i]; switch (note.title) { case "State": row.State = note.Value; break; case "County": row.County = note.Value; break; case "agency": row.Comments = note.Value; break; } } sitesTable.AddSitesRow(row); return(true); }
// The seriesCatalogID is not found in hiscental database, create one here before // hiscental database adopts the new variable. public int GetOrCreateSeriesID(string siteCode, string varCode, WaterML11.seriesCatalogTypeSeries scts) { int scID; string query; int undefined = -99; // Console.WriteLine(@"....No SeriesCatalog from hiscentral for site {0} and var {1}, // dataType '{2}' methodID {3} sourcdID {4} qualityID {5}.", // siteCode, varCode, scts.dataType, scts.method.methodID, // scts.source.sourceID, // scts.qualityControlLevel.qualityControlLevelID); if (scts.method.methodID < 0) { scts.method.methodID = undefined; } if (scts.qualityControlLevel.qualityControlLevelID < 0) { scts.qualityControlLevel.qualityControlLevelID = undefined; } if (scts.source.sourceID < 0) { scts.source.sourceID = undefined; } query = string.Format(@"SiteCode='{0}' and VariableCode='{1}' and MethodID = {2} and QualityControlLevelID = {3} and SourceID = {4}", siteCode, varCode, scts.method.methodID, scts.qualityControlLevel.qualityControlLevelID, scts.source.sourceID); scID = OD_Utils.GetPrimaryKey("dbo.SeriesCatalog", "SeriesID", query, Adapter.Connection); if (scID >= 0) { return(scID); } HealthQueryDataSet.SeriesCatalogRow row = Table.NewSeriesCatalogRow(); row.SiteCode = siteCode; row.VariableCode = varCode; row.MethodID = scts.method.methodID; row.SourceID = scts.source.sourceID; row.QualityControlLevelID = scts.qualityControlLevel.qualityControlLevelID; if (scts.variable.dataType != null) { row.DataType = scts.variable.dataType; } row.ValueCount = scts.valueCount.Value; WaterML11.TimeIntervalType ti = (WaterML11.TimeIntervalType)scts.variableTimeInterval; row.BeginDateTimeUTC = ti.beginDateTime.ToUniversalTime(); row.EndDateTimeUTC = ti.endDateTime.ToUniversalTime(); Table.AddSeriesCatalogRow(row); Adapter.Update(Table); Table.Clear(); scID = OD_Utils.GetPrimaryKey("dbo.SeriesCatalog", "SeriesID", query, Adapter.Connection); Console.WriteLine( "....Site {0} and variable {1} with ID {2} is saved in a private catalog table.", siteCode, varCode, scID); return(scID); }