Beispiel #1
0
 public IDatasetElement this[string title]
 {
     get
     {
         SE_LAYERINFO layerInfo = new SE_LAYERINFO();
         try
         {
             SdeFeatureClass fc = null;
             //SdeConnection connection = _sConnection.AllocConnection();
             using (ArcSdeConnection connection = new ArcSdeConnection(_connStr))
             {
                 if (connection.Open())
                 {
                     if (Wrapper92.SE_layerinfo_create(new SE_COORDREF(), ref layerInfo) != 0)
                     {
                         return(null);
                     }
                     if (Wrapper92.SE_layer_get_info(connection.SeConnection, title, "", layerInfo) != 0)
                     {
                         return(null);
                     }
                     fc = new SdeFeatureClass(this, connection.SeConnection, layerInfo);
                 }
                 connection.Close();
             }
             //_sConnection.FreeConnection();
             return(new DatasetElement(fc));
         }
         finally
         {
             if (layerInfo.handle != 0)
             {
                 Wrapper92.SE_layerinfo_free(layerInfo);
             }
         }
     }
 }
Beispiel #2
0
        /*
         * internal SdeConnection AllocConnection()
         * {
         *  if (_sConnection == null) return null;
         *  return _current = _sConnection.AllocConnection();
         * }
         *
         * internal void FreeConnection()
         * {
         *  if (_sConnection == null) return;
         *  _current = null;
         *  _sConnection.FreeConnection();
         * }
         */

        internal SE_COORDREF GetSeCoordRef(ArcSdeConnection connection, string table, string spatialColumnName, ref SE_ENVELOPE envelope)
        {
            _errMsg = "";
            if (connection == null || connection.SeConnection.handle == 0)
            {
                _errMsg = "GetSeCoordRef:\n No Connection allocated!";
                return(new SE_COORDREF());
            }

            SE_COORDREF  coordRef  = new SE_COORDREF();
            SE_LAYERINFO layerInfo = new SE_LAYERINFO();
            Int32        _err_no   = 0;

            try
            {
                _err_no = Wrapper92.SE_coordref_create(ref coordRef);
                if (_err_no != 0)
                {
                    return(new SE_COORDREF());
                }

                _err_no = Wrapper92.SE_layerinfo_create(coordRef, ref layerInfo);
                if (_err_no != 0)
                {
                    return(new SE_COORDREF());
                }

                _err_no = Wrapper92.SE_layer_get_info(connection.SeConnection, table, spatialColumnName, layerInfo);
                if (_err_no != 0)
                {
                    return(new SE_COORDREF());
                }

                _err_no = Wrapper92.SE_layerinfo_get_coordref(layerInfo, coordRef);
                if (_err_no != 0)
                {
                    return(new SE_COORDREF());
                }

                _err_no = Wrapper92.SE_coordref_get_xy_envelope(coordRef, ref envelope);
                if (_err_no != 0)
                {
                    return(new SE_COORDREF());
                }

                return(coordRef);
            }
            catch (Exception ex)
            {
                _errMsg = "GetSeCoordRef:\n " + ex.Message + "\n" + ex.StackTrace;
                return(new SE_COORDREF());
            }
            finally
            {
                if (layerInfo.handle != 0)
                {
                    Wrapper92.SE_layerinfo_free(layerInfo);
                }

                if (_err_no != 0)
                {
                    if (coordRef.handle != 0)
                    {
                        Wrapper92.SE_coordref_free(coordRef);
                    }
                    _errMsg = Wrapper92.GetErrorMsg(new SE_CONNECTION(), _err_no);
                }
            }
        }