Exemple #1
0
        public static List <UserDbLayerInfo> GetLayersMetadates(UserDbLayerType userDbLayerType = UserDbLayerType.None)
        {
            var infos = new List <UserDbLayerInfo>();
            var query = string.Format("SELECT * FROM gisUserLayer WHERE intDeleted=0");

            if (userDbLayerType != UserDbLayerType.None)
            {
                query += string.Format(" AND intType={0}", (int)userDbLayerType);
            }
            using (var conn = new SqlConnection(ConnectionString))
            {
                conn.Open();
                var dt = SqlExecHelper.SqlExecTable(new SqlConnection(ConnectionString), query);
                foreach (DataRow row in dt.Rows)
                {
                    var style = new VectorStyle();
                    if (row["xmlStyle"] != DBNull.Value &&
                        !string.IsNullOrEmpty(row["xmlStyle"] as string))
                    {
                        XmlDocument doc = new XmlDocument();
                        doc.LoadXml((string)row["xmlStyle"]);
                        style = StyleSerializer.DeserializeFromDocument(doc) as VectorStyle;
                    }

                    ITheme theme = null;
                    if (row["xmlTheme"] != DBNull.Value &&
                        !string.IsNullOrEmpty(row["xmlTheme"] as string))
                    {
                        XmlDocument doc = new XmlDocument();
                        doc.LoadXml((string)row["xmlTheme"]);
                        theme = ThemeSerializer.DeserializeFromDocument(doc);
                    }

                    infos.Add(new UserDbLayerInfo
                    {
                        m_Id               = (Guid)row["guidLayer"],
                        m_Name             = (String)row["strName"],
                        m_UserId           = (long)row["idfUser"],
                        m_CreationDate     = (DateTime)row["CreationDate"],
                        m_LastModifiedDate = (DateTime)row["LastModifiedDate"],
                        m_Description      = row["strDescription"] as string,
                        m_LayerType        = (UserDbLayerType)row["intType"],
                        m_PivotalLayer     = (PivotLayerType)row["intPivotalLayer"],
                        m_Style            = style,
                        m_Theme            = theme
                    });
                }
                return(infos);
            }
        }
Exemple #2
0
        public static IDictionary <Guid, String> GetLayersNames(UserDbLayerType userDbLayerType = UserDbLayerType.None)
        {
            var names = new Dictionary <Guid, string>();
            var query = "SELECT guidLayer, strName FROM gisUserLayer WHERE intDeleted=0";

            if (userDbLayerType != UserDbLayerType.None)
            {
                query += string.Format(" AND intType={0}", (int)userDbLayerType);
            }
            var dt = SqlExecHelper.SqlExecTable(new SqlConnection(ConnectionString), query);

            foreach (DataRow row in dt.Rows)
            {
                names.Add((Guid)row[0], (String)row[1]);
            }
            return(names);
        }