コード例 #1
0
        async private Task <bool> Refresh()
        {
            if (SdeLayers.Count != 0)  // DoTo: Refresh if older than 1 min...
            {
                return(true);
            }

            SdeLayers.Clear();
            SdeSpatialReferences.Clear();
            SdeColumns.Clear();
            SdeGeometryColumns.Clear();
            SdeLayerMultiversionViewNames.Clear();

            var providerFactory = System.Data.SqlClient.SqlClientFactory.Instance;

            string sdeSchemaName = TableSchemaName("sde_layers");

            if (String.IsNullOrWhiteSpace(sdeSchemaName))
            {
                throw new Exception("Can't determine sde db-schema");
            }

            using (DbConnection connection = providerFactory.CreateConnection())
            {
                connection.ConnectionString = _connectionString;
                await connection.OpenAsync();

                var command = providerFactory.CreateCommand();
                command.Connection = connection;


                command.CommandText = "select * from " + sdeSchemaName + ".sde_table_registry";
                using (var reader = await command.ExecuteReaderAsync())
                {
                    while (await reader.ReadAsync())
                    {
                        string mv_view_name = reader["imv_view_name"]?.ToString();
                        if (!String.IsNullOrWhiteSpace(mv_view_name))
                        {
                            SdeLayerMultiversionViewNames[(reader["owner"]?.ToString() + "." + reader["table_name"]?.ToString()).ToLower()] = mv_view_name;
                        }
                    }
                }

                command.CommandText = "select * from " + sdeSchemaName + ".sde_layers";
                using (var reader = await command.ExecuteReaderAsync())
                {
                    while (await reader.ReadAsync())
                    {
                        SdeLayers.Add(new SdeLayer(reader, SdeLayerMultiversionViewNames));
                    }
                }

                command.CommandText = "select * from " + sdeSchemaName + ".sde_spatial_references";
                using (var reader = await command.ExecuteReaderAsync())
                {
                    while (await reader.ReadAsync())
                    {
                        SdeSpatialReferences.Add(new SdeSpatialReference(reader));
                    }
                }

                command.CommandText = "select * from " + sdeSchemaName + ".sde_column_registry";
                using (var reader = await command.ExecuteReaderAsync())
                {
                    while (await reader.ReadAsync())
                    {
                        SdeColumns.Add(new SdeColumn(reader));
                    }
                }

                command.CommandText = "select * from " + sdeSchemaName + ".sde_geometry_columns";
                using (var reader = await command.ExecuteReaderAsync())
                {
                    while (await reader.ReadAsync())
                    {
                        SdeGeometryColumns.Add(new SdeGeometryColumn(reader));
                    }
                }

                return(true);
            }
        }
コード例 #2
0
        private void Refresh()
        {
            if (SdeLayers.Count != 0)  // DoTo: Refresh if older than 1 min...
            {
                return;
            }

            SdeLayers.Clear();
            SdeSpatialReferences.Clear();
            SdeColumns.Clear();
            SdeGeometryColumns.Clear();

            var providerFactory = System.Data.SqlClient.SqlClientFactory.Instance;

            string sdeSchemaName = TableSchemaName("sde_layers");

            if (String.IsNullOrWhiteSpace(sdeSchemaName))
            {
                throw new Exception("Can't determine sde db-schema");
            }

            using (DbConnection connection = providerFactory.CreateConnection())
            {
                connection.ConnectionString = _connectionString;
                connection.Open();

                var command = providerFactory.CreateCommand();
                command.Connection = connection;

                command.CommandText = "select * from " + sdeSchemaName + ".sde_layers";
                using (var reader = command.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        SdeLayers.Add(new SdeLayer(reader));
                    }
                }

                command.CommandText = "select * from " + sdeSchemaName + ".sde_spatial_references";
                using (var reader = command.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        SdeSpatialReferences.Add(new SdeSpatialReference(reader));
                    }
                }

                command.CommandText = "select * from " + sdeSchemaName + ".sde_column_registry";
                using (var reader = command.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        SdeColumns.Add(new SdeColumn(reader));
                    }
                }

                command.CommandText = "select * from " + sdeSchemaName + ".sde_geometry_columns";
                using (var reader = command.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        SdeGeometryColumns.Add(new SdeGeometryColumn(reader));
                    }
                }
            }
        }