Beispiel #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="layerInfo"></param>
        public static void UpdateUserLayerMetadata(UserDbLayerInfo layerInfo)
        {
            if (string.IsNullOrEmpty(layerInfo.m_Name) || layerInfo.m_Id == Guid.Empty)
            {
                throw new ArgumentException(Resources.gis_UserDbLayersManager_UpdateUserLayerMetadataException);
            }

            using (var conn = new SqlConnection(ConnectionString))
            {
                conn.Open();

                var style = (layerInfo.m_Style == null) ? (Object)DBNull.Value : StyleSerializer.SerializeAsDocument(layerInfo.m_Style).InnerXml;
                var theme = (layerInfo.m_Theme == null) ? (Object)DBNull.Value : ThemeSerializer.SerializeAsDocument(layerInfo.m_Theme).InnerXml;

                using (var updCommand = new SqlCommand("spGisUpdateUserLayerMetadata", conn))
                {
                    updCommand.CommandType = CommandType.StoredProcedure;

                    updCommand.Parameters.AddWithValue("@LAYERID", layerInfo.m_Id);
                    updCommand.Parameters.AddWithValue("@Name", layerInfo.m_Name);
                    updCommand.Parameters.AddWithValue("@STYLE", style);
                    updCommand.Parameters.AddWithValue("@THEME", theme);
                    updCommand.Parameters.AddWithValue("@DESC", string.IsNullOrEmpty(layerInfo.m_Description) ? DBNull.Value : (object)layerInfo.m_Description);

                    updCommand.ExecuteNonQuery();
                }

                conn.Close();
            }
        }
Beispiel #2
0
        /// <summary>
        /// Insert new user layer metadata
        /// </summary>
        /// <param name="newLayerInfo">LayerInfo. REQUERED: Id, name, UserID, LayerType</param>
        /// <param name="conn"> </param>
        /// <param name="trans">Transaction</param>
        public static void InsertUserLayerMetadata(UserDbLayerInfo newLayerInfo, SqlConnection conn, SqlTransaction trans = null)
        {
            if (string.IsNullOrEmpty(newLayerInfo.m_Name))
            {
                throw new ArgumentException(Resources.gis_UserDbLayersManager_InsertUserLayerMetadataException);
            }



            var style = (newLayerInfo.m_Style == null)?string.Empty:StyleSerializer.SerializeAsDocument(newLayerInfo.m_Style).InnerXml;
            var theme = (newLayerInfo.m_Theme == null) ? string.Empty : ThemeSerializer.SerializeAsDocument(newLayerInfo.m_Theme).InnerXml;

            //TODO[enikulin]: make with SqlHelper
            using (var addCommand = new SqlCommand("spGisInsertUserLayerMetadata", conn, trans))
            {
                addCommand.CommandType = CommandType.StoredProcedure;

                addCommand.Parameters.AddWithValue("@ID", newLayerInfo.m_Id);
                addCommand.Parameters.AddWithValue("@Name", newLayerInfo.m_Name);
                addCommand.Parameters.AddWithValue("@UserID", newLayerInfo.m_UserId);
                addCommand.Parameters.AddWithValue("@LayerType", (int)newLayerInfo.m_LayerType);
                addCommand.Parameters.AddWithValue("@STYLE", style);
                addCommand.Parameters.AddWithValue("@THEME", theme);
                addCommand.Parameters.AddWithValue("@DESC", string.IsNullOrEmpty(newLayerInfo.m_Description) ? DBNull.Value : (object)newLayerInfo.m_Description);
                addCommand.Parameters.AddWithValue("@PIVOTALLAYER", newLayerInfo.m_PivotalLayer);

                addCommand.ExecuteNonQuery();
            }
        }