/// <summary> /// Deserialize MsSql layer /// </summary> /// <param name="providerElement">xml element</param> /// <returns></returns> public static EidssSqlServer2008 Deserialize(XmlElement providerElement) { EidssSqlServer2008 resultSqlLayer; XmlNode tempNode; string defquery; string table; bool validateGeometries; #region <<Deserialization>> ////ConnectionID //tempNode = providerElement.SelectSingleNode("ConnectionID"); //if (tempNode == null) // throw new MsSqlProviderDeserializationException("'ptroviderElement' don't have element 'ConnectionID'!"); //if (!int.TryParse(tempNode.InnerText, out connectionID)) // throw new MsSqlProviderDeserializationException("Can't parse node 'ConnectionID'!"); //DefinitionQuery tempNode = providerElement.SelectSingleNode("DefinitionQuery"); if (tempNode == null) { throw new EidssSqlServerProviderDeserializationException("'ptroviderElement' don't have element 'DefinitionQuery'!"); } defquery = tempNode.InnerText; //Table tempNode = providerElement.SelectSingleNode("Table"); if (tempNode == null) { throw new EidssSqlServerProviderDeserializationException("'ptroviderElement' don't have element 'Table'!"); } table = tempNode.InnerText; //ValidateGeometries tempNode = providerElement.SelectSingleNode("ValidateGeometries"); if (tempNode == null) { throw new EidssSqlServerProviderDeserializationException("'ptroviderElement' don't have element 'ValidateGeometries'!"); } if (!bool.TryParse(tempNode.InnerText, out validateGeometries)) { throw new EidssSqlServerProviderDeserializationException("Can't parse node 'ValidateGeometries'!"); } try { resultSqlLayer = new EidssSqlServer2008(table) { DefinitionQuery = defquery }; } catch (Exception ex) { throw new EidssSqlServerProviderDeserializationException("EidssSqlServer2008 Provider can't be create: " + ex.Message, ex); } #endregion return(resultSqlLayer); }
/// <summary> /// Serialize MsSql layer /// </summary> /// <param name="sqlLayer">MsSql layer to serialize</param> /// <param name="providerElement">xml element</param> public static void Serialize(EidssSqlServer2008 sqlLayer, XmlElement providerElement) { //DefinitionQuery XmlElement xmlElement = providerElement.OwnerDocument.CreateElement("DefinitionQuery"); xmlElement.InnerText = sqlLayer.DefinitionQuery; providerElement.AppendChild(xmlElement); //Table xmlElement = providerElement.OwnerDocument.CreateElement("Table"); xmlElement.InnerText = sqlLayer.Table; providerElement.AppendChild(xmlElement); //ValidateGeometries xmlElement = providerElement.OwnerDocument.CreateElement("ValidateGeometries"); xmlElement.InnerText = sqlLayer.ValidateGeometries.ToString(); providerElement.AppendChild(xmlElement); }
protected override void OnToolActivated() { switch (PivotalType) { case PivotLayerType.Districts: m_PivotalProvider = new EidssSqlServer2008(SystemLayerNames.Rayons); LoadTranslations(); break; case PivotLayerType.Regions: m_PivotalProvider = new EidssSqlServer2008(SystemLayerNames.Regions); LoadTranslations(); break; default: m_PivotalProvider = null; break; } MapImage.Cursor = Cursors.Cross; MapImage.MouseDown += MapImage_MouseDown; }
void MapImage_MouseDown(Point worldPos, MouseEventArgs e) { switch (PivotalType) { case PivotLayerType.Settlements: m_PivotalProvider = new EidssSqlServer2008(SystemLayerNames.Settlements); break; case PivotLayerType.AvrPoints: if (Content.AVRLayer != null) { m_PivotalProvider = Content.AVRLayer.DataSource; } break; default: m_PivotalProvider = null; break; } string strName; var nearestPoint = GetNearestPoint(worldPos, out strName); if (nearestPoint == null) { return; } //show form var frm = new CircleBufZone { ZoneName = strName }; if (frm.ShowDialog() == DialogResult.OK) { if (m_PivotalProvider == null) { return; } var projectedCenter = nearestPoint; //var projectedCenter = GeometryTransform.TransformGeometry(nearestPoint, CoordinateSystems.WGS84, // CoordinateSystems.SphericalMercatorCS); var projectedBufGeom = GIS_V4.Utils.GeometryUtils.CreateBuffer(projectedCenter, frm.Radius); //var geom = GeometryTransform.TransformGeometry(projectedBufGeom, CoordinateSystems.SphericalMercatorCS, // CoordinateSystems.WGS84); //var center = GeometryTransform.TransformGeometry(projectedCenter, CoordinateSystems.SphericalMercatorCS, // CoordinateSystems.WGS84); if (m_TargetLayerGuid == Guid.Empty) { return; } var eidssUserBufZoneLayer = (EidssUserBufZoneLayer)UserDbLayersManager.GetUserLayer(m_TargetLayerGuid); if (eidssUserBufZoneLayer == null) { return; } var userBufZone = new EidssUserBufZoneLayer.UserBufZone { Geometry = projectedBufGeom, //geom, Description = frm.Description, Name = frm.ZoneName, Center = projectedCenter, //center, Radius = frm.Radius }; eidssUserBufZoneLayer.AddNewZone(userBufZone); MapImage.Refresh(); } }