예제 #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);
        }
            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 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 virtual siteInfoDataSet.sitesDataTable GetDataBySiteID(int siteID) {
     this.Adapter.SelectCommand = this.CommandCollection[3];
     this.Adapter.SelectCommand.Parameters[0].Value = ((int)(siteID));
     siteInfoDataSet.sitesDataTable dataTable = new siteInfoDataSet.sitesDataTable();
     this.Adapter.Fill(dataTable);
     return dataTable;
 }
 public virtual siteInfoDataSet.sitesDataTable GetDataBySiteCode(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));
     }
     siteInfoDataSet.sitesDataTable dataTable = new siteInfoDataSet.sitesDataTable();
     this.Adapter.Fill(dataTable);
     return dataTable;
 }
 public virtual siteInfoDataSet.sitesDataTable GetDataByBox(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));
     siteInfoDataSet.sitesDataTable dataTable = new siteInfoDataSet.sitesDataTable();
     this.Adapter.Fill(dataTable);
     return dataTable;
 }
 public virtual siteInfoDataSet.sitesDataTable GetData() {
     this.Adapter.SelectCommand = this.CommandCollection[0];
     siteInfoDataSet.sitesDataTable dataTable = new siteInfoDataSet.sitesDataTable();
     this.Adapter.Fill(dataTable);
     return dataTable;
 }