コード例 #1
0
 /// <summary>
 /// Get system code for language
 /// </summary>
 /// <param name="lang"></param>
 /// <param name="connString">DB comm str</param>
 /// <returns></returns>
 public static long GetLanguageCode(string lang, string connString)
 {
     using (var connection = new SqlConnection(connString))
     {
         connection.Open();
         var id = (long)SqlExecHelper.SqlExecScalar(connection, string.Format("select dbo.fnGetLanguageCode('{0}')", lang));
         return(id);
     }
 }
コード例 #2
0
        public void DeleteZone(long bufId)
        {
            using (var conn = new SqlConnection((DataSource as EidssSqlServer2008).ConnectionString))
            {
                conn.Open();

                var sql = string.Format(@"DELETE {0} WHERE idfsGeoObject = {1}", (DataSource as EidssSqlServer2008).Table, bufId);
                SqlExecHelper.SqlExecNonQuery(conn, sql);

                conn.Close();
            }
        }
コード例 #3
0
 /// <summary>
 /// Load translation table from DB
 /// </summary>
 /// <param name="connString">DB Conn Str</param>
 /// <param name="gisReferenceType">GisReference type </param>
 /// <param name="langId">Lang Id</param>
 /// <returns></returns>
 private static DataTable LoadTranslation(string connString, long gisReferenceType, string langId)
 {
     using (var connection = new SqlConnection(connString))
     {
         connection.Open();
         var spParams = new Dictionary <string, object> {
             { "@LangID", langId }, { "@type", gisReferenceType }
         };
         var table = SqlExecHelper.SqlExecSp(connection, "spGisLocalizedLabels", spParams);
         table.PrimaryKey = new[] { table.Columns[0] };
         return(table);
     }
 }
コード例 #4
0
        static public string GetUserName(long id)
        {
            object result;

            using (var conn = new SqlConnection(m_ConnectionString))
            {
                var strSQL = string.Format("SELECT TOP 1 strAccountName FROM tstUserTable WHERE idfUserID = {0}", id);
                conn.Open();
                result = SqlExecHelper.SqlExecScalar(conn, strSQL);
                conn.Close();
            }

            return(result.ToString());
        }
コード例 #5
0
        void MapImage_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            if (m_ToolPhase == ToolPhase.WaitFirst)
            {
                return;
            }
            //if (DataProvider == null) NoDataProvider();

            //compleate polygon
            if (m_Vertices.Count < 3)
            {
                return;
            }

            m_Vertices.Add(m_Vertices[0]);

            var      linearRing = new LinearRing(m_Vertices);
            Geometry polygon    = new Polygon(linearRing);

            //polygon = GeometryTransform.TransformGeometry(polygon, CoordinateSystems.SphericalMercatorCS,
            //                                                      CoordinateSystems.WGS84);
            m_ToolPhase = ToolPhase.WaitFirst;

            var connectionString = ConnectionManager.DefaultInstance.ConnectionString;
            var connection       = new SqlConnection(connectionString);

            var valid = SqlExecHelper.SqlGeometryValidation(connection, polygon);

            if (!valid)
            {
                MessageForm.Show(Resources.gis_MtIndependentPolygonBufferZone_CheckValidityMsg);
            }
            else
            {
                //show form
                var frm = new PolygonBufZone();
                //frm.ZoneLayer = string.Empty;

                if (frm.ShowDialog() == DialogResult.OK)
                {
                    if (m_TargetLayerGuid == Guid.Empty)
                    {
                        return;
                    }

                    var eidssUserBufZoneLayer =
                        (EidssUserBufZoneLayer)UserDbLayersManager.GetUserLayer(m_TargetLayerGuid);

                    if (eidssUserBufZoneLayer == null)
                    {
                        return;
                    }


                    var userBufZone = new EidssUserBufZoneLayer.UserBufZone
                    {
                        Geometry    = polygon,
                        Description = frm.Description,
                        Name        = frm.ZoneName,
                        //Center = new Point(0, 0)
                    };

                    eidssUserBufZoneLayer.AddNewZone(userBufZone);
                }
            }
            MapImage.Refresh();

            m_Vertices.Clear();
            m_Points.Clear();
            m_LastMousePosition = System.Drawing.Point.Empty;
        }
コード例 #6
0
        public static string GetWebPointInfo1(string connectionString, string strLng, double lon, double lat, string[] mInfoRegion, string[] mInfoRayon, ref string mInfoSettlement)
        {
            //var fds = new FeatureDataSet();
            DataTable tbl;
            var       lPoint         = new Point(lon, lat);
            var       projectedPoint = GeometryTransform.TransformPoint(lPoint, CoordinateSystems.WGS84,
                                                                        CoordinateSystems.SphericalMercatorCS);
            //var connectionString = ConnectionManager.DefaultInstance.ConnectionString;
            var sqlConnection = new SqlConnection(connectionString);

            string lRegion = null;
            long   id      = 0;

            lRegion = GetGeoName(connectionString, strLng, "gisWKBRegion", projectedPoint.X, projectedPoint.Y) + "  ";
            if (lRegion == null)
            {
                return("");
            }
            else
            {
                mInfoRegion[0] = lRegion;
                //// Region
                id  = GetGeoId(connectionString, "gisWKBRegion", projectedPoint.X, projectedPoint.Y);
                tbl = SqlExecHelper.SqlExecTable(sqlConnection,
                                                 string.Format("SELECT * FROM dbo.fn_GetRegionStatInfo(dbo.fnGetLanguageCode('{0}'), {1})", strLng, id));
                tbl.Columns.Add("varPopDens", Type.GetType("System.Double"));
                foreach (DataRow row in tbl.Rows)
                {
                    if (row["varPopulation"] is DBNull || row["varArea"] is DBNull)
                    {
                        continue;
                    }

                    double population = (double)row["varPopulation"];
                    double area       = (double)row["varArea"];

                    if (area != 0)
                    {
                        row["varPopDens"] = population / area;
                    }
                    else
                    {
                        row["varPopDens"] = null;
                    }

                    mInfoRegion[1] = GetStatValue(row["varArea"]);
                    mInfoRegion[2] = GetStatValue(row["varPopulation"]);
                    mInfoRegion[3] = GetStatValue(row["varPopDens"]);
                }
            }

            mInfoRayon[0] = GetGeoName(connectionString, strLng, "gisWKBRayon", projectedPoint.X, projectedPoint.Y) + "  ";
            id            = GetGeoId(connectionString, "gisWKBRayon", projectedPoint.X, projectedPoint.Y);
            tbl           = SqlExecHelper.SqlExecTable(sqlConnection, string.Format("SELECT * FROM dbo.fn_GetRayonStatInfo(dbo.fnGetLanguageCode('{0}'), {1})", strLng, id));
            tbl.Columns.Add("varPopDens", Type.GetType("System.Double"));
            foreach (DataRow row in tbl.Rows)
            {
                if (row["varPopulation"] is DBNull || row["varArea"] is DBNull)
                {
                    continue;
                }
                double population = (double)row["varPopulation"];
                double area       = (double)row["varArea"];
                //double density;
                if (area != 0)
                {
                    row["varPopDens"] = population / area;
                }
                else
                {
                    row["varPopDens"] = null;
                }

                mInfoRayon[1] = GetStatValue(row["varArea"]);
                mInfoRayon[2] = GetStatValue(row["varPopulation"]);
                mInfoRayon[3] = GetStatValue(row["varPopDens"]);
            }


            mInfoSettlement = GetGeoName(connectionString, strLng, "gisWKBSettlement", projectedPoint.X, projectedPoint.Y);


            /*
             * varArea
             * varPopulation
             * varPopDens
             */

            return("");
        }
コード例 #7
0
        private void InfoRoutine(Point worldPos)
        {
            m_CurrentLayer = m_MapContent.CurrentLayer;

            if (m_CurrentLayer == null)
            {
                return;
            }
            if (!m_CurrentLayer.Enabled)
            {
                return;
            }

            var featureDataRow = GetNearestFeature(worldPos);

            if (featureDataRow == null)
            {
                return;
            }

            var id = (long)featureDataRow.ItemArray[0];

            // Check type of selected layer

            if (m_CurrentLayer is EidssSystemDbLayer)
            {
                var strTableName = ((SqlServer2008)(((EidssSystemDbLayer)m_CurrentLayer).DataSource)).Table;
                if (strTableName == "gisWKBRegion")
                {
                    #region Regional statistic
                    var sqlConnection = new SqlConnection(ConnectionManager.DefaultInstance.ConnectionString);
                    var tbl           = SqlExecHelper.SqlExecTable(sqlConnection,
                                                                   string.Format(
                                                                       "SELECT * FROM dbo.fn_GetRegionStatInfo(dbo.fnGetLanguageCode('{0}'), {1})",
                                                                       EidssUserContext.CurrentLanguage, id));
                    tbl.Columns.Add("varPopDens", Type.GetType("System.Double"));
                    foreach (DataRow row in tbl.Rows)
                    {
                        if (row["varPopulation"] is DBNull || row["varArea"] is DBNull)
                        {
                            continue;
                        }

                        double population = (double)row["varPopulation"];
                        double area       = (double)row["varArea"];

                        //double density;
                        if (area != 0)
                        {
                            row["varPopDens"] = population / area;
                        }
                        else
                        {
                            row["varPopDens"] = null;
                        }
                    }

                    if (m_InfoForm == null)
                    {
                        m_InfoForm = new InfoForm {
                            IsAVR = false, Text = CurrentFeatureName, Feature = null, StatTable = tbl
                        }
                    }
                    ;
                    else
                    {
                        m_InfoForm.IsAVR     = m_IsAVR;
                        m_InfoForm.Text      = CurrentFeatureName;
                        m_InfoForm.Feature   = null;
                        m_InfoForm.StatTable = tbl;
                    }
                    #endregion
                }
                else if (strTableName == "gisWKBRayon")
                {
                    #region Rayon statistic
                    var sqlConnection = new SqlConnection(ConnectionManager.DefaultInstance.ConnectionString);
                    var tbl           = SqlExecHelper.SqlExecTable(sqlConnection,
                                                                   string.Format(
                                                                       "SELECT * FROM dbo.fn_GetRayonStatInfo(dbo.fnGetLanguageCode('{0}'), {1})",
                                                                       EidssUserContext.CurrentLanguage, id));

                    tbl.Columns.Add("strRayon", Type.GetType("System.String"));
                    tbl.Columns.Add("strRegion", Type.GetType("System.String"));



                    tbl.Columns.Add("varPopDens", Type.GetType("System.Double"));
                    foreach (DataRow row in tbl.Rows)
                    {
                        var name  = row["strName"].ToString();
                        var reg   = name.Substring(0, name.IndexOf(",", System.StringComparison.Ordinal));
                        var distr = name.Substring(name.IndexOf(",", System.StringComparison.Ordinal) + 2);

                        row["strRegion"] = reg;
                        row["strRayon"]  = distr;

                        if (row["varPopulation"] is DBNull || row["varArea"] is DBNull)
                        {
                            continue;
                        }

                        double population = (double)row["varPopulation"];
                        double area       = (double)row["varArea"];

                        //double density;
                        if (area != 0)
                        {
                            row["varPopDens"] = population / area;
                        }
                        else
                        {
                            row["varPopDens"] = null;
                        }
                    }

                    if (m_InfoForm == null)
                    {
                        m_InfoForm = new InfoForm {
                            IsAVR = false, Text = CurrentFeatureName, Feature = null, StatTable = tbl
                        }
                    }
                    ;
                    else
                    {
                        m_InfoForm.IsAVR     = m_IsAVR;
                        m_InfoForm.Text      = CurrentFeatureName;
                        m_InfoForm.Feature   = null;
                        m_InfoForm.StatTable = tbl;
                    }
                    #endregion
                }
                else if (strTableName == "gisWKBSettlement")
                {
                    #region Settlement statistic

                    var sqlConnection = new SqlConnection(ConnectionManager.DefaultInstance.ConnectionString);
                    var tbl           = SqlExecHelper.SqlExecTable(sqlConnection,
                                                                   string.Format(
                                                                       "SELECT * FROM dbo.fn_GetSettlementStatInfo(dbo.fnGetLanguageCode('{0}'), {1})",
                                                                       EidssUserContext.CurrentLanguage, id));

                    if (m_InfoForm == null)
                    {
                        m_InfoForm = new InfoForm {
                            IsAVR = false, Text = CurrentFeatureName, Feature = null, StatTable = tbl
                        }
                    }
                    ;
                    else
                    {
                        m_InfoForm.IsAVR     = m_IsAVR;
                        m_InfoForm.Text      = CurrentFeatureName;
                        m_InfoForm.Feature   = null;
                        m_InfoForm.StatTable = tbl;
                    }

                    #endregion
                }
                else if (strTableName == "gisWKBCountry")
                {
                    if (m_InfoForm == null)
                    {
                        m_InfoForm = new InfoForm {
                            IsAVR = m_IsAVR, Text = CurrentFeatureName, StatTable = null, Feature = featureDataRow
                        }
                    }
                    ;
                    else
                    {
                        m_InfoForm.IsAVR     = m_IsAVR;
                        m_InfoForm.Text      = CurrentFeatureName;
                        m_InfoForm.StatTable = null;
                        m_InfoForm.Feature   = featureDataRow;
                    }
                }
                //m_InfoForm.Show();
            }
            else
            {
                // for other type of layers

                //m_InfoForm = new InfoForm {IsAVR = m_IsAVR, Text = CurrentFeatureName, Feature = featureDataRow};
                if (m_InfoForm == null)
                {
                    m_InfoForm = new InfoForm {
                        IsAVR = m_IsAVR, Text = CurrentFeatureName, StatTable = null, Feature = featureDataRow
                    }
                }
                ;
                else
                {
                    m_InfoForm.IsAVR     = m_IsAVR;
                    m_InfoForm.Text      = CurrentFeatureName;
                    m_InfoForm.StatTable = null;
                    m_InfoForm.Feature   = featureDataRow;
                }

                // Dialog();
                //infoForm.ShowDialog();
            }
            m_InfoForm.Show();
        }