public ResponseSerializer Put(int id, [FromBody] ThemeSerializer themeSerializer)
 {
     return(new ResponseSerializer(
                200,
                "success",
                this._themeBus.UpdateTheme(id, themeSerializer)));
 }
Ejemplo n.º 2
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();
            }
        }
 public ResponseSerializer Post([FromBody] ThemeSerializer themeSerializer)
 {
     return(new ResponseSerializer(
                200,
                "success",
                this._themeBus.CreateNewTheme(themeSerializer)));
 }
Ejemplo n.º 4
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();
            }
        }
Ejemplo n.º 5
0
        public String CreateNewTheme(ThemeSerializer themeSerializer)
        {
            ThemeModel themeModel = new ThemeModel();

            themeModel.Name   = themeSerializer.name;
            themeModel.First  = themeSerializer.first;
            themeModel.Second = themeSerializer.second;
            themeModel.Third  = themeSerializer.third;
            return(this._themeDao.Create(themeModel));
        }
Ejemplo n.º 6
0
        public String UpdateTheme(int id, ThemeSerializer themeSerializer)
        {
            ThemeModel themeModel = new ThemeModel();

            themeModel.Id     = id;
            themeModel.Name   = themeSerializer.name;
            themeModel.First  = themeSerializer.first;
            themeModel.Second = themeSerializer.second;
            themeModel.Third  = themeSerializer.third;
            return(this._themeDao.Update(id, themeModel));
        }
Ejemplo n.º 7
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);
            }
        }
Ejemplo n.º 8
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
                });
            }
        }
Ejemplo n.º 9
0
        /// <summary>
        /// Serialize VectorLayer
        /// </summary>
        /// <param name="vectorLayer">VectorLayer to serialize</param>
        /// <param name="vectorLayerElement">Root element to serialize</param>
        public static void Serialize(EidssUserDbLayer vectorLayer, XmlElement vectorLayerElement)
        {
            XmlElement xmlElement;

            LayerSerializer.SerializeLayerFields(vectorLayer, vectorLayerElement);

            #region << Serialization >>

            //TODO[enikulin]: need refactoring. only one property (LayerDBguid) and type of layer is changed from VectorLayer

            //LayerDbGuid
            xmlElement           = vectorLayerElement.OwnerDocument.CreateElement("LayerDbGuid");
            xmlElement.InnerText = vectorLayer.LayerDbGuid.ToString();
            vectorLayerElement.AppendChild(xmlElement);

            //LabelLayerGuid
            xmlElement           = vectorLayerElement.OwnerDocument.CreateElement("LabelLayerGuid");
            xmlElement.InnerText = vectorLayer.LabelLayerGuid.ToString();
            vectorLayerElement.AppendChild(xmlElement);

            //ClippingEnabled
            xmlElement           = vectorLayerElement.OwnerDocument.CreateElement("ClippingEnabled");
            xmlElement.InnerText = vectorLayer.ClippingEnabled.ToString();
            vectorLayerElement.AppendChild(xmlElement);

            //SmoothingMode
            xmlElement           = vectorLayerElement.OwnerDocument.CreateElement("SmoothingMode");
            xmlElement.InnerText = vectorLayer.SmoothingMode.ToString("D");
            vectorLayerElement.AppendChild(xmlElement);

            //SRID
            xmlElement           = vectorLayerElement.OwnerDocument.CreateElement("SRID");
            xmlElement.InnerText = vectorLayer.SRID.ToString("F0");
            vectorLayerElement.AppendChild(xmlElement);


            //Style
            try
            { StyleSerializer.SerializeAsNode(vectorLayer.Style, vectorLayerElement); }
            catch (Exception ex)
            { throw new VectorLayerSerializationException("Style can't be serialized: " + ex.Message, ex); }

            //Theme
            try
            { ThemeSerializer.SerializeAsNode(vectorLayer.Theme, vectorLayerElement); }
            catch (Exception ex)
            { throw new VectorLayerSerializationException("Theme can't be serialized: " + ex.Message, ex); }



            //Marker size
            xmlElement           = vectorLayerElement.OwnerDocument.CreateElement("MarkerSize");
            xmlElement.InnerText = vectorLayer.MarkerSize.ToString();
            vectorLayerElement.AppendChild(xmlElement);

            //Marker color
            try
            {
                ColorSerializer.SerializeAsNode(vectorLayer.MarkerColor, vectorLayerElement, "MarkerColor");
            }
            catch (Exception ex)
            {
                throw new VectorLayerSerializationException("'MarkerColor' can't be serialized: " + ex.Message, ex);
            }

            //Polygon Fill Style
            xmlElement           = vectorLayerElement.OwnerDocument.CreateElement("PolygonFillStyle");
            xmlElement.InnerText = vectorLayer.PolygonFillStyle;
            vectorLayerElement.AppendChild(xmlElement);

            //Polygon Fill Color
            try
            {
                ColorSerializer.SerializeAsNode(vectorLayer.PolygonFillColor, vectorLayerElement, "PolygonFillColor");
            }
            catch (Exception ex)
            {
                throw new VectorLayerSerializationException("'PolygonFillColor' can't be serialized: " + ex.Message, ex);
            }

            #endregion
        }
Ejemplo n.º 10
0
        /// <summary>
        /// Deserialize VectorLayer
        /// </summary>
        /// <param name="vectorLayerElement">Root element to deserialize</param>
        /// <returns>VectorLayer</returns>
        public static EidssUserDbLayer Deserialize(XmlElement vectorLayerElement)
        {
            EidssUserDbLayer resultVectorLayer = null;
            XmlNode          tempNode;

            LayerSerializer.LayerInfo lyrInfo;
            bool tempBool;
            int  tempInt;

            #region <<Deserialize LayerFields >>

            try
            { lyrInfo = LayerSerializer.DeserializeLayerFields(vectorLayerElement); }
            catch (Exception ex)
            { throw new VectorLayerDeserializationException("VectorLayer can't be deserialized: " + ex.Message, ex); }

            //LayerDbGuid
            tempNode = vectorLayerElement.SelectSingleNode("LayerDbGuid");
            if (tempNode == null)
            {
                throw new VectorLayerDeserializationException("VectorLayer can't be deserialized: 'LayerElement' don't have element 'LayerDbGuid'!");
            }
            var layerDbGuid = new Guid(tempNode.InnerText);


            //LabelLayer Guid
            tempNode = vectorLayerElement.SelectSingleNode("LabelLayerGuid");
            if (tempNode == null)
            {
                throw new VectorLayerDeserializationException("VectorLayer can't be deserialized: 'LayerElement' don't have element 'LabelLayerGuid'!");
            }
            var labelLayerGuid = new Guid(tempNode.InnerText);

            //create layer
            switch (vectorLayerElement.Attributes["Type"].Value)
            {
            case "eidss.gis.Layers.EidssUserDbLayer":
                resultVectorLayer = new EidssUserDbLayer(layerDbGuid, lyrInfo.LayerName, lyrInfo.Guid, labelLayerGuid);
                break;

            case "eidss.gis.Layers.EidssUserBufZoneLayer":
                resultVectorLayer = new EidssUserBufZoneLayer(layerDbGuid, lyrInfo.LayerName, lyrInfo.Guid, labelLayerGuid);
                break;
            }


            resultVectorLayer.ControledByUser = lyrInfo.ControledByUser;
            resultVectorLayer.Enabled         = lyrInfo.Enabled;
            resultVectorLayer.MaxVisible      = lyrInfo.MaxVisible;
            resultVectorLayer.MinVisible      = lyrInfo.MinVisible;
            //resultVectorLayer.SRID = lyrInfo.SRID; - тут бля косяк в провайдере! нет проверки!
            resultVectorLayer.VisibleInTOC = lyrInfo.VisibleInTOC;
            resultVectorLayer.Transparency = lyrInfo.Transparency;
            #endregion

            #region << Deserialize >>

            //ClippingEnabled
            tempNode = vectorLayerElement.SelectSingleNode("ClippingEnabled");
            if (tempNode == null)
            {
                throw new VectorLayerDeserializationException("'VectorLayerElement' don't have element 'ClippingEnabled'!");
            }
            if (!bool.TryParse(tempNode.InnerText, out tempBool))
            {
                throw new VectorLayerDeserializationException("Can't parse node 'ClippingEnabled'!");
            }
            resultVectorLayer.ClippingEnabled = tempBool;


            //SmoothingMode
            tempNode = vectorLayerElement.SelectSingleNode("SmoothingMode");
            if (tempNode == null)
            {
                throw new VectorLayerDeserializationException("'VectorLayerElement' don't have element 'SmoothingMode'!");
            }
            if (!Int32.TryParse(tempNode.InnerText, out tempInt) || !Enum.IsDefined(typeof(SmoothingMode), tempInt))
            {
                throw new VectorLayerDeserializationException("Can't parse node 'SmoothingMode'!");
            }
            resultVectorLayer.SmoothingMode = (SmoothingMode)tempInt;

            //SRID
            tempNode = vectorLayerElement.SelectSingleNode("SRID");
            if (tempNode == null)
            {
                throw new VectorLayerDeserializationException("'VectorLayerElement' don't have element 'SRID'!");
            }
            if (!Int32.TryParse(tempNode.InnerText, out tempInt))
            {
                throw new VectorLayerDeserializationException("Can't parse node 'SRID'!");
            }
            resultVectorLayer.SRID = tempInt;

            //Style
            try
            { resultVectorLayer.Style = (VectorStyle)StyleSerializer.DeserializeFromNode(vectorLayerElement); }
            catch (Exception ex)
            { throw new VectorLayerSerializationException("Style can't be deserialized: " + ex.Message, ex); }

            //Theme
            try
            { resultVectorLayer.Theme = ThemeSerializer.DeserializeFromNode(vectorLayerElement); }
            catch (Exception ex)
            { throw new VectorLayerSerializationException("Theme can't be deserialized: " + ex.Message, ex); }


            //Marker size
            tempNode = vectorLayerElement.SelectSingleNode("MarkerSize");
            if (tempNode == null)
            {
                throw new VectorLayerDeserializationException("'VectorLayerElement' don't have element 'MarkerSize'!");
            }
            if (!Int32.TryParse(tempNode.InnerText, out tempInt))
            {
                throw new VectorLayerDeserializationException("Can't parse node 'MarkerSize'!");
            }
            resultVectorLayer.MarkerSize = tempInt;

            //Marker color
            try
            {
                resultVectorLayer.MarkerColor = ColorSerializer.DeserializeFromNode(vectorLayerElement, "MarkerColor");
            }
            catch (Exception ex)
            {
                throw new VectorLayerSerializationException("MarkerColor can't be deserialized: " + ex.Message, ex);
            }

            //Polygon Fill Style
            tempNode = vectorLayerElement.SelectSingleNode("PolygonFillStyle");
            if (tempNode == null)
            {
                throw new VectorLayerDeserializationException("'VectorLayerElement' don't have element 'PolygonFillStyle'!");
            }
            resultVectorLayer.PolygonFillStyle = tempNode.InnerText;

            //Polygon Fill Color
            try
            {
                resultVectorLayer.PolygonFillColor = ColorSerializer.DeserializeFromNode(vectorLayerElement, "PolygonFillColor");
            }
            catch (Exception ex)
            {
                throw new VectorLayerSerializationException("PolygonFillColor can't be deserialized: " + ex.Message, ex);
            }

            #endregion

            return(resultVectorLayer);
        }