示例#1
0
        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);
        }
            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);
                }
            }