public static siteInfoDataSet GetSiteInfoDataSet(int siteID) { siteInfoDataSet ds = new siteInfoDataSet(); SpatialReferencesTableAdapter spatialTableAdapter = new SpatialReferencesTableAdapter(); sitesTableAdapter sitesTableAdapter = new sitesTableAdapter(); spatialTableAdapter.Connection.ConnectionString = odws.Config.ODDB(); sitesTableAdapter.Connection.ConnectionString = odws.Config.ODDB(); spatialTableAdapter.Fill(ds.SpatialReferences); sitesTableAdapter.FillBySiteID(ds.sites, siteID); return ds; }
public static siteInfoDataSet GetSiteInfoDataSet() { siteInfoDataSet ds = new siteInfoDataSet(); SpatialReferencesTableAdapter spatialTableAdapter = new SpatialReferencesTableAdapter(); sitesTableAdapter sitesTableAdapter = new sitesTableAdapter(); spatialTableAdapter.Connection.ConnectionString = odws.Config.ODDB(); sitesTableAdapter.Connection.ConnectionString = odws.Config.ODDB(); try { spatialTableAdapter.Fill(ds.SpatialReferences); sitesTableAdapter.Fill(ds.sites); } catch (Exception e) { log.Fatal("Cannot retrieve information from connection " + e.Message);//+ spatialTableAdapter.Connection.DataSource throw new WaterOneFlowServerException("Database error", e); } return ds; }
private static siteInfoDataSet CreateBaseSiteInfoDataset() { siteInfoDataSet ds = new siteInfoDataSet(); SpatialReferencesTableAdapter spatialTableAdapter = new SpatialReferencesTableAdapter(); sitesTableAdapter sitesTableAdapter = new sitesTableAdapter(); spatialTableAdapter.Connection.ConnectionString = odws.Config.ODDB(); sitesTableAdapter.Connection.ConnectionString = odws.Config.ODDB(); try { spatialTableAdapter.Fill(ds.SpatialReferences); } catch (Exception e) { log.Fatal("Cannot connect to database " + e.Message); // + spatialTableAdapter.Connection.DataSource throw new WaterOneFlowServerException(e.Message); } return ds; }
public static SiteInfoType row2SiteInfoElement(siteInfoDataSet.sitesRow row, siteInfoDataSet ds) { SiteInfoType sit = CuahsiBuilder.CreateASiteInfoTypeWithLatLongPoint(); sit.siteName = row.SiteName; // sit created with a single siteCode sit.siteCode[0].siteID = row.SiteID; sit.siteCode[0].siteIDSpecified = true; sit.siteCode[0].Value = row.SiteCode; string siteNetwork = System.Configuration.ConfigurationManager.AppSettings["network"]; sit.siteCode[0].network = siteNetwork; // we ALWAYS have a point in ODM 1.1 /* just check to make sure that they are not the defaults * Should validate thet they are inwithin +-180/+-90 * */ if (!row.Longitude.Equals(0) && !row.Latitude.Equals(0)) { ((LatLonPointType)sit.geoLocation.geogLocation).latitude = row.Latitude; ((LatLonPointType)sit.geoLocation.geogLocation).longitude = row.Longitude; if (row.LatLongDatumID.Equals(0)) { ((LatLonPointType)sit.geoLocation.geogLocation).srs = ConfigurationManager.AppSettings["defaultSpatialReferenceSystemSRS"]; } else { siteInfoDataSet.SpatialReferencesRow[] datum = (siteInfoDataSet.SpatialReferencesRow[])ds.SpatialReferences.Select("SpatialReferenceID = " + row.LatLongDatumID); if (datum.Length > 0 ) { if (!datum[0].IsSRSIDNull() ) { ((LatLonPointType)sit.geoLocation.geogLocation).srs = ConfigurationManager.AppSettings["SRSPrefix"] + datum[0].SRSID; } else if (!string.IsNullOrEmpty(datum[0].SRSName)) { ((LatLonPointType) sit.geoLocation.geogLocation).srs = datum[0].SRSName; } } } } else { sit.geoLocation.geogLocation = null; } if (!row.IsElevation_mNull()) { sit.elevation_m = row.Elevation_m; sit.elevation_mSpecified = true; if (!row.IsVerticalDatumNull()) { sit.verticalDatum = row.VerticalDatum; } } if (!row.IsLocalXNull() && !row.IsLocalYNull() && !row.IsLocalProjectionIDNull()) { sit.geoLocation.localSiteXY = new SiteInfoTypeGeoLocationLocalSiteXY[1]; SiteInfoTypeGeoLocationLocalSiteXY xy = new SiteInfoTypeGeoLocationLocalSiteXY(); xy.X = row.LocalX; xy.Y = row.LocalY; //@TODO local XY siteInfoDataSet.SpatialReferencesRow[] datum = (siteInfoDataSet.SpatialReferencesRow[])ds.SpatialReferences.Select("SpatialReferenceID = " + row.LocalProjectionID); if (datum.Length > 0) { if (!String.IsNullOrEmpty(datum[0].SRSName)) { xy.projectionInformation = datum[0].SRSName; } else { xy.projectionInformation = "Not Specified"; } } sit.geoLocation.localSiteXY[0] = xy; } if (!row.IsCountyNull()) { PropertyType aNote = CuahsiBuilder.createProperty(row.County, "County", null); sit.siteProperty = CuahsiBuilder.addProperty(sit.siteProperty, aNote); } if (!row.IsStateNull()) { PropertyType aNote = CuahsiBuilder.createProperty(row.State, "State", null); sit.siteProperty = CuahsiBuilder.addProperty(sit.siteProperty, aNote); } if (!row.IsCommentsNull()) { PropertyType aNote = CuahsiBuilder.createProperty(row.Comments, "Site Comments", null); sit.siteProperty = CuahsiBuilder.addProperty(sit.siteProperty, aNote); } if (!row.IsPosAccuracy_mNull()) { PropertyType aNote = CuahsiBuilder.createProperty(row.PosAccuracy_m.ToString(), "PosAccuracy_m", null); sit.siteProperty = CuahsiBuilder.addProperty(sit.siteProperty, aNote); } return sit; }
public static SiteInfoType row2SiteInfoElement(siteInfoDataSet.sitesRow row, siteInfoDataSet ds) { SiteInfoType sit = CuahsiBuilder.CreateASiteInfoTypeWithLatLongPoint(); sit.siteName = row.SiteName; // sit created with a single siteCode sit.siteCode[0].siteID = row.SiteID; sit.siteCode[0].siteIDSpecified = true; sit.siteCode[0].Value = row.SiteCode; string siteNetwork = System.Configuration.ConfigurationManager.AppSettings["network"]; sit.siteCode[0].network = siteNetwork; // we ALWAYS have a point in ODM 1.1 /* just check to make sure that they are not the defaults * Should validate thet they are inwithin +-180/+-90 * */ if (!row.Longitude.Equals(0) && !row.Latitude.Equals(0)) { ((LatLonPointType)sit.geoLocation.geogLocation).latitude = row.Latitude; ((LatLonPointType)sit.geoLocation.geogLocation).longitude = row.Longitude; if (row.LatLongDatumID.Equals(0)) { ((LatLonPointType)sit.geoLocation.geogLocation).srs = ConfigurationManager.AppSettings["defaultSpatialReferenceSystemSRS"]; } else { siteInfoDataSet.SpatialReferencesRow[] datum = (siteInfoDataSet.SpatialReferencesRow[])ds.SpatialReferences.Select("SpatialReferenceID = " + row.LatLongDatumID); if (datum.Length > 0) { if (!datum[0].IsSRSIDNull()) { ((LatLonPointType)sit.geoLocation.geogLocation).srs = ConfigurationManager.AppSettings["SRSPrefix"] + datum[0].SRSID; } else if (!string.IsNullOrEmpty(datum[0].SRSName)) { ((LatLonPointType)sit.geoLocation.geogLocation).srs = datum[0].SRSName; } } } } else { sit.geoLocation.geogLocation = null; } if (!row.IsElevation_mNull()) { sit.elevation_m = row.Elevation_m; sit.elevation_mSpecified = true; if (!row.IsVerticalDatumNull()) { sit.verticalDatum = row.VerticalDatum; } } if (!row.IsLocalXNull() && !row.IsLocalYNull() && !row.IsLocalProjectionIDNull()) { sit.geoLocation.localSiteXY = new SiteInfoTypeGeoLocationLocalSiteXY[1]; SiteInfoTypeGeoLocationLocalSiteXY xy = new SiteInfoTypeGeoLocationLocalSiteXY(); xy.X = row.LocalX; xy.Y = row.LocalY; //@TODO local XY siteInfoDataSet.SpatialReferencesRow[] datum = (siteInfoDataSet.SpatialReferencesRow[])ds.SpatialReferences.Select("SpatialReferenceID = " + row.LocalProjectionID); if (datum.Length > 0) { if (!String.IsNullOrEmpty(datum[0].SRSName)) { xy.projectionInformation = datum[0].SRSName; } else { xy.projectionInformation = "Not Specified"; } } sit.geoLocation.localSiteXY[0] = xy; } if (!row.IsCountyNull()) { PropertyType aNote = CuahsiBuilder.createProperty(row.County, "County", null); sit.siteProperty = CuahsiBuilder.addProperty(sit.siteProperty, aNote); } if (!row.IsStateNull()) { PropertyType aNote = CuahsiBuilder.createProperty(row.State, "State", null); sit.siteProperty = CuahsiBuilder.addProperty(sit.siteProperty, aNote); } if (!row.IsCommentsNull()) { PropertyType aNote = CuahsiBuilder.createProperty(row.Comments, "Site Comments", null); sit.siteProperty = CuahsiBuilder.addProperty(sit.siteProperty, aNote); } if (!row.IsPosAccuracy_mNull()) { PropertyType aNote = CuahsiBuilder.createProperty(row.PosAccuracy_m.ToString(), "PosAccuracy_m", null); sit.siteProperty = CuahsiBuilder.addProperty(sit.siteProperty, aNote); } return(sit); }
private static void GetSiteInfoDataSet(box geomBox, siteInfoDataSet ds) { sitesTableAdapter sitesTableAdapter = CreateSitesTableAdapter(); try { sitesTableAdapter.FillByBox(ds.sites, geomBox.South, geomBox.North, geomBox.West, geomBox.East); } catch (Exception e) { log.Fatal("Cannot connect to database " + e.Message); //+ sitesTableAdapter.Connection.DataSource throw new WaterOneFlowServerException(e.Message); } }
public static global::System.Xml.Schema.XmlSchemaComplexType GetTypedDataSetSchema(global::System.Xml.Schema.XmlSchemaSet xs) { siteInfoDataSet ds = new siteInfoDataSet(); global::System.Xml.Schema.XmlSchemaComplexType type = new global::System.Xml.Schema.XmlSchemaComplexType(); global::System.Xml.Schema.XmlSchemaSequence sequence = new global::System.Xml.Schema.XmlSchemaSequence(); global::System.Xml.Schema.XmlSchemaAny any = new global::System.Xml.Schema.XmlSchemaAny(); any.Namespace = ds.Namespace; sequence.Items.Add(any); type.Particle = sequence; global::System.Xml.Schema.XmlSchema dsSchema = ds.GetSchemaSerializable(); if (xs.Contains(dsSchema.TargetNamespace)) { global::System.IO.MemoryStream s1 = new global::System.IO.MemoryStream(); global::System.IO.MemoryStream s2 = new global::System.IO.MemoryStream(); try { global::System.Xml.Schema.XmlSchema schema = null; dsSchema.Write(s1); for (global::System.Collections.IEnumerator schemas = xs.Schemas(dsSchema.TargetNamespace).GetEnumerator(); schemas.MoveNext(); ) { schema = ((global::System.Xml.Schema.XmlSchema)(schemas.Current)); s2.SetLength(0); schema.Write(s2); if ((s1.Length == s2.Length)) { s1.Position = 0; s2.Position = 0; for (; ((s1.Position != s1.Length) && (s1.ReadByte() == s2.ReadByte())); ) { ; } if ((s1.Position == s1.Length)) { return type; } } } } finally { if ((s1 != null)) { s1.Close(); } if ((s2 != null)) { s2.Close(); } } } xs.Add(dsSchema); return type; }
public static global::System.Xml.Schema.XmlSchemaComplexType GetTypedTableSchema(global::System.Xml.Schema.XmlSchemaSet xs) { global::System.Xml.Schema.XmlSchemaComplexType type = new global::System.Xml.Schema.XmlSchemaComplexType(); global::System.Xml.Schema.XmlSchemaSequence sequence = new global::System.Xml.Schema.XmlSchemaSequence(); siteInfoDataSet ds = new siteInfoDataSet(); global::System.Xml.Schema.XmlSchemaAny any1 = new global::System.Xml.Schema.XmlSchemaAny(); any1.Namespace = "http://www.w3.org/2001/XMLSchema"; any1.MinOccurs = new decimal(0); any1.MaxOccurs = decimal.MaxValue; any1.ProcessContents = global::System.Xml.Schema.XmlSchemaContentProcessing.Lax; sequence.Items.Add(any1); global::System.Xml.Schema.XmlSchemaAny any2 = new global::System.Xml.Schema.XmlSchemaAny(); any2.Namespace = "urn:schemas-microsoft-com:xml-diffgram-v1"; any2.MinOccurs = new decimal(1); any2.ProcessContents = global::System.Xml.Schema.XmlSchemaContentProcessing.Lax; sequence.Items.Add(any2); global::System.Xml.Schema.XmlSchemaAttribute attribute1 = new global::System.Xml.Schema.XmlSchemaAttribute(); attribute1.Name = "namespace"; attribute1.FixedValue = ds.Namespace; type.Attributes.Add(attribute1); global::System.Xml.Schema.XmlSchemaAttribute attribute2 = new global::System.Xml.Schema.XmlSchemaAttribute(); attribute2.Name = "tableTypeName"; attribute2.FixedValue = "sitesDataTable"; type.Attributes.Add(attribute2); type.Particle = sequence; global::System.Xml.Schema.XmlSchema dsSchema = ds.GetSchemaSerializable(); if (xs.Contains(dsSchema.TargetNamespace)) { global::System.IO.MemoryStream s1 = new global::System.IO.MemoryStream(); global::System.IO.MemoryStream s2 = new global::System.IO.MemoryStream(); try { global::System.Xml.Schema.XmlSchema schema = null; dsSchema.Write(s1); for (global::System.Collections.IEnumerator schemas = xs.Schemas(dsSchema.TargetNamespace).GetEnumerator(); schemas.MoveNext(); ) { schema = ((global::System.Xml.Schema.XmlSchema)(schemas.Current)); s2.SetLength(0); schema.Write(s2); if ((s1.Length == s2.Length)) { s1.Position = 0; s2.Position = 0; for (; ((s1.Position != s1.Length) && (s1.ReadByte() == s2.ReadByte())); ) { ; } if ((s1.Position == s1.Length)) { return type; } } } } finally { if ((s1 != null)) { s1.Close(); } if ((s2 != null)) { s2.Close(); } } } xs.Add(dsSchema); return type; }
public virtual int Update(siteInfoDataSet.SpatialReferencesDataTable dataTable) { return this.Adapter.Update(dataTable); }
public virtual int Update(siteInfoDataSet dataSet) { return this.Adapter.Update(dataSet, "SpatialReferences"); }
public virtual int Fill(siteInfoDataSet.SpatialReferencesDataTable dataTable) { this.Adapter.SelectCommand = this.CommandCollection[0]; if ((this.ClearBeforeFill == true)) { dataTable.Clear(); } int returnValue = this.Adapter.Fill(dataTable); return returnValue; }
public virtual int FillBySiteID(siteInfoDataSet.sitesDataTable dataTable, int siteID) { this.Adapter.SelectCommand = this.CommandCollection[3]; this.Adapter.SelectCommand.Parameters[0].Value = ((int)(siteID)); if ((this.ClearBeforeFill == true)) { dataTable.Clear(); } int returnValue = this.Adapter.Fill(dataTable); return returnValue; }
public virtual int FillBySiteCode(siteInfoDataSet.sitesDataTable dataTable, string SiteCode) { this.Adapter.SelectCommand = this.CommandCollection[2]; if ((SiteCode == null)) { throw new global::System.ArgumentNullException("SiteCode"); } else { this.Adapter.SelectCommand.Parameters[0].Value = ((string)(SiteCode)); } if ((this.ClearBeforeFill == true)) { dataTable.Clear(); } int returnValue = this.Adapter.Fill(dataTable); return returnValue; }
public virtual int FillByBox(siteInfoDataSet.sitesDataTable dataTable, double SOUTH, double NORTH, double WEST, double EAST) { this.Adapter.SelectCommand = this.CommandCollection[1]; this.Adapter.SelectCommand.Parameters[0].Value = ((double)(SOUTH)); this.Adapter.SelectCommand.Parameters[1].Value = ((double)(NORTH)); this.Adapter.SelectCommand.Parameters[2].Value = ((double)(WEST)); this.Adapter.SelectCommand.Parameters[3].Value = ((double)(EAST)); if ((this.ClearBeforeFill == true)) { dataTable.Clear(); } int returnValue = this.Adapter.Fill(dataTable); return returnValue; }
public TimeSeriesResponseType getValues(string SiteNumber, string Variable, string StartDate, string EndDate) { // convert dates // get site info // get site ID // return value dataset TimeSeriesResponseType response; W3CDateTime? BeginDateTime; W3CDateTime? EndDateTime; int?variableId = null; int?siteID; VariableInfoType varInfoType = null; SiteInfoType siteType = null; if (!String.IsNullOrEmpty(StartDate)) { try { BeginDateTime = W3CDateTime.Parse(StartDate); } catch { throw new WaterOneFlowException("Improper BeginDate '" + StartDate + "' Must be YYYY-MM-DD"); } } else { BeginDateTime = null; } if (!String.IsNullOrEmpty(EndDate)) { try { EndDateTime = W3CDateTime.Parse(EndDate); } catch { throw new WaterOneFlowException("Improper EndDate '" + EndDate + "' Must be YYYY-MM-DD"); } } else { EndDateTime = null; } VariableParam vp; if (Variable != null) { vp = new VariableParam(Variable); VariableInfoType[] v = ODvariables.getVariable(vp, variableDs); if (v != null && v.Length > 0) { variableId = Convert.ToInt16(v[0].variableCode[0].variableID); varInfoType = v[0]; } else { throw new WaterOneFlowException("Variable parameter not found: " + Variable); } } else { throw new WaterOneFlowException("Variable parameter is required "); } locationParam sq; sq = new locationParam(SiteNumber); if (sq.isGeometry) { throw new WaterOneFlowException("Location by Geometry not accepted: " + SiteNumber); } siteInfoDataSet sitDs = ODSiteInfo.GetSiteInfoDataSet(sq); if (sitDs != null && sitDs.sites.Count > 0) { siteID = sitDs.sites[0].SiteID; ValuesDataSet valuesDs = getValuesDataset(siteID, variableId, BeginDateTime, EndDateTime, vp); response = getValues(valuesDs, vp); // above is the values, add the site, and variables response.timeSeries.variable = varInfoType; if (varInfoType != null) { if (varInfoType.units != null) { response.timeSeries.values.unitsAbbreviation = varInfoType.units.unitsAbbreviation; response.timeSeries.values.unitsCode = varInfoType.units.unitsCode; if (varInfoType.units.unitsType != null) { response.timeSeries.values.unitsType = varInfoType.units.unitsType; response.timeSeries.values.unitsTypeSpecified = true; } response.timeSeries.values.unitsAreConverted = false; } } response.timeSeries.sourceInfo = ODSiteInfo.row2SiteInfoElement(sitDs.sites[0], sitDs); } else { response = CuahsiBuilder.CreateTimeSeriesObject(); } // add query info response.queryInfo.creationTime = DateTime.UtcNow; //response.queryInfo.creationTime = DateTimeOffset.UtcNow; response.queryInfo.creationTimeSpecified = true; response.queryInfo.criteria.locationParam = SiteNumber; response.queryInfo.criteria.variableParam = Variable; response.queryInfo.criteria.timeParam = CuahsiBuilder.createQueryInfoTimeCriteria(StartDate, EndDate); NoteType sourceNote = CuahsiBuilder.createNote("OD Web Service"); response.queryInfo.note = CuahsiBuilder.addNote(response.queryInfo.note, sourceNote); return(response); }