public static siteInfoDataSet GetSiteInfoDataSet(locationParam[] LocationParameters) { siteInfoDataSet ds = new siteInfoDataSet(); SpatialReferencesTableAdapter spatialTableAdapter = new SpatialReferencesTableAdapter(); sitesTableAdapter sitesTableAdapter = new sitesTableAdapter(); spatialTableAdapter.Connection.ConnectionString = Config.ODDB(); sitesTableAdapter.Connection.ConnectionString = 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); } if (LocationParameters[0].isGeometry) { if (LocationParameters[0].Geometry.GetType().Equals(typeof(box))) { box queryBox = (box)LocationParameters[0].Geometry; sitesTableAdapter.FillByBox(ds.sites, queryBox.South, queryBox.North, queryBox.West, queryBox.East); } } else { siteInfoDataSet.sitesDataTable aSitetable = new siteInfoDataSet.sitesDataTable(); foreach (locationParam s in LocationParameters) { try { if (s.IsId) { int siteID = int.Parse(s.SiteCode); sitesTableAdapter.FillBySiteID(aSitetable, siteID); } else { sitesTableAdapter.FillBySiteCode(aSitetable, s.SiteCode); } ds.sites.Merge(aSitetable); } catch (Exception e) { log.Fatal("Cannot connect to database " + e.Message); //+ sitesTableAdapter.Connection.DataSource throw new WaterOneFlowServerException(e.Message); } } } return(ds); }
public static siteInfoDataSet GetSiteInfoDataSet(locationParam[] LocationParameters) { siteInfoDataSet ds = CreateBaseSiteInfoDataset(); if (LocationParameters[0].isGeometry) { if (LocationParameters[0].Geometry.GetType().Equals(typeof(box))) { box queryBox = (box)LocationParameters[0].Geometry; GetSiteInfoDataSet(queryBox, ds); } } else { sitesTableAdapter sitesTableAdapter = CreateSitesTableAdapter(); foreach (locationParam s in LocationParameters) { try { siteInfoDataSet.sitesDataTable aSitetable = new siteInfoDataSet.sitesDataTable(); if (s.IsId) { int siteID = int.Parse(s.SiteCode); sitesTableAdapter.FillBySiteID(aSitetable, siteID); } else { sitesTableAdapter.FillBySiteCode(aSitetable, s.SiteCode); } ds.sites.Merge(aSitetable); } catch (Exception e) { log.Fatal("Cannot connect to database " + e.Message); //+ sitesTableAdapter.Connection.DataSource throw new WaterOneFlowServerException(e.Message); } } } return(ds); }
public SiteInfoType[] GetSites(locationParam[] lp) { List <SiteInfoType> sites = new List <SiteInfoType>(); UsgsDbDailyValues.sitesDataTable sDs = new UsgsDbDailyValues.sitesDataTable(); UsgsDbDailyValuesTableAdapters.sitesTableAdapter tableAdaptor = new sitesTableAdapter(); if (lp == null || lp.Length == 0) { // get all sites tableAdaptor.Fill(sDs); } else { foreach (locationParam loc in lp) { tableAdaptor.FillBySiteCode(sDs, loc.SiteCode); } } foreach (UsgsDbDailyValues.sitesRow row in sDs.Rows) { SiteInfoType sit = row2SiteInfoType(row); if (sit != null) { sites.Add(sit); } } if (sites.Count > 0) { return(sites.ToArray()); } else { throw new WaterOneFlowException("No Sites Found"); } }