Beispiel #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);
            }
        }
Beispiel #2
0
        public static UserDbLayerInfo GetLayerMetadata(Guid layerId)
        {
            var query = string.Format("SELECT * FROM gisUserLayer WHERE guidLayer='{0}'", layerId);

            using (var conn = new SqlConnection(ConnectionString))
            {
                conn.Open();
                var dataReader = SqlExecHelper.SqlExecReader(conn, query);
                if (!dataReader.HasRows)
                {
                    throw new ApplicationException(Resources.gis_UserDbLayersManager_GetLayerMetadataException + layerId);
                }
                dataReader.Read();


                var style = new VectorStyle();
                if (dataReader["xmlStyle"] != DBNull.Value && !string.IsNullOrEmpty(dataReader["xmlStyle"] as string))
                {
                    XmlDocument doc = new XmlDocument();
                    doc.LoadXml((string)dataReader["xmlStyle"]);
                    style = StyleSerializer.DeserializeFromDocument(doc) as VectorStyle;
                }

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

                return(new UserDbLayerInfo
                {
                    m_Id = (Guid)dataReader["guidLayer"],
                    m_Name = (String)dataReader["strName"],
                    m_UserId = (long)dataReader["idfUser"],
                    m_CreationDate = (DateTime)dataReader["CreationDate"],
                    m_LastModifiedDate = (DateTime)dataReader["LastModifiedDate"],
                    m_Description = dataReader["strDescription"] as string,
                    m_LayerType = (UserDbLayerType)dataReader["intType"],
                    m_PivotalLayer = (PivotLayerType)dataReader["intPivotalLayer"],
                    m_Style = style,
                    m_Theme = theme
                });
            }
        }