Example #1
0
        /// <summary>
        /// Given a site id, this method returns the site's information including
        ///  all the variables measured at the site
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public HydroPoint GetSiteInfo(int id)
        {
            string     sql = "select * from " + Configuration.StationsTableName + " where SiteID =" + id;
            DataTable  dt  = mDbase.QueryDataTable(sql);
            DataRow    dr  = dt.Rows[0];
            HydroPoint p   = new HydroPoint(id)
            {
                Name      = dr["SiteName"].ToString(),
                Code      = dr["SiteCode"].ToString(),
                Latitude  = Convert.ToDouble(dr["Latitude"].ToString()),
                Longitude = Convert.ToDouble(dr["Longitude"].ToString()),
                Comments  = dr["Comments"].ToString()
            };

            sql = "select * from " + Configuration.SeriesCatalogTableName + " where SiteID =" + id;
            dt  = mDbase.QueryDataTable(sql);
            if (dt != null)
            {
                foreach (DataRow r in dt.Rows)
                {
                    int      vid = Convert.ToInt32(r["VariableID"].ToString());
                    Variable v   = GetVariableInfo(vid);
                    v.BeginDate  = DateTime.Parse(r["BeginDateTime"].ToString());
                    v.EndDate    = DateTime.Parse(r["EndDateTime"].ToString());
                    v.ValueCount = Int32.Parse(r["ValueCount"].ToString());
                    v.SiteID     = id;
                    p.MeasuredVariables.Add(v);
                }
            }
            return(p);
        }
        /// <summary>
        ///  Add all sub-features to the parent feature recursively.
        /// </summary>
        /// <param name="parent"></param>
        public void CreateTopDownNetwork(HydroFeature parent)
        {
            string    sql = "select * from " + Configuration.HydroFeaturesTableName + " where ParentFeatureID=" + parent.ID;
            DataTable dt  = mDBase.QueryDataTable(sql);

            if (dt != null)
            {
                foreach (DataRow dr in dt.Rows)
                {
                    int              id      = Convert.ToInt32(dr["FeatureID"].ToString());
                    string           type    = dr["FeatureType"].ToString();
                    string           name    = dr["FeatureName"].ToString();
                    string           des     = dr["Descriptions"].ToString();
                    HydroFeatureType htype   = HydroFeatureFactory.GetHydroFeaturetype(type);
                    HydroFeature     feature = HydroFeatureFactory.CreateHydroFeature(id, name, des, htype);
                    if (feature.HydroFeatureType == HydroFeatureType.HydroPoint)
                    {
                        feature = mODMDataAdaptor.GetSiteInfo(id);
                    }
                    parent.SubFeatures.Add(feature);
                    feature.ParentFeatures.Add(parent);
                    if (feature.HydroFeatureType != HydroFeatureType.HydroPoint)
                    {
                        CreateTopDownNetwork(feature);
                    }
                }
            }
        }
Example #3
0
        public static HydroFeature GetHydroFeature(int id, IDBase dBase)
        {
            string    sql = "select * from " + Configuration.HydroFeaturesTableName + " where FeatureID=" + id;
            DataTable dt  = dBase.QueryDataTable(sql);

            if (dt != null)
            {
                DataRow          dr    = dt.Rows[0];
                string           type  = dr["FeatureType"].ToString();
                string           name  = dr["FeatureName"].ToString();
                string           des   = dr["Descriptions"].ToString();
                HydroFeatureType htype = HydroFeatureFactory.GetHydroFeaturetype(type);
                return(CreateHydroFeature(id, name, des, htype));
            }
            else
            {
                return(null);
            }
        }