Example #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);
             }
         }
     }
 }
Example #2
0
        public SdeFeatureCursor(SdeDataset dataset, ITableClass tc, IQueryFilter filter)
            : base((tc is IFeatureClass) ? ((IFeatureClass)tc).SpatialReference : null,
                   (filter != null) ? filter.FeatureSpatialReference : null)
        {
            try
            {
                if (filter != null && filter.SubFields != "*")
                {
                    filter.AddField(tc.IDFieldName);
                }
                filter.fieldPrefix  = tc.Name + ".";
                filter.fieldPostfix = "";

                Int32 err_no = 0;

                _dataset = dataset;
                if (_dataset == null)
                {
                    return;
                }

                //_connection = _dataset.AllocConnection();
                _connection = new ArcSdeConnection(dataset.ConnectionString);
                if (!_connection.Open())
                {
                    return;
                }

                _queryInfo = new SdeQueryInfo(_connection, tc, filter);
                if (_queryInfo.ErrorMessage != "")
                {
                    Dispose();
                    return;
                }

                //if (Wrapper92.SE_stream_create(_connection.SeConnection, ref _stream) != 0)
                //{
                //    Dispose();
                //    return;
                //}

                _connection.ResetStream();

                // SE_stream_set_state sollte auch aufgerufen werden (siehe mapsde.c von UMN)
                if (Wrapper92.SE_stream_set_state(
                        _connection.SeStream,
                        CONST.SE_DEFAULT_STATE_ID,
                        CONST.SE_DEFAULT_STATE_ID,
                        CONST.SE_STATE_DIFF_NOCHECK) != 0)
                {
                    Dispose();
                    return;
                }

                if ((err_no = Wrapper92.SE_stream_query_with_info(_connection.SeStream, _queryInfo.SeQueryInfo)) != 0)
                {
                    Dispose();
                    return;
                }

                if (_queryInfo.IsSpatial)
                {
                    SE_FILTER se_filter = _queryInfo.Filter_Shape;
                    if ((err_no = Wrapper92.SE_stream_set_spatial_constraints(_connection.SeStream, CONST.SE_SPATIAL_FIRST, false, 1, ref se_filter)) != 0)
                    {
                        _errMsg = Wrapper92.GetErrorMsg(_connection.SeConnection, err_no);
                        Dispose();
                        return;
                    }
                }
                else
                {
                    /*
                     * SE_FILTER se_filter = _queryInfo.Filter_Id;
                     * if (Wrapper92.SE_stream_set_spatial_constraints(_stream, CONST.SE_SPATIAL_FIRST, false, 1, ref se_filter) != 0)
                     * {
                     *  Release();
                     *  return;
                     * }
                     * */
                }

                if (Wrapper92.SE_stream_execute(_connection.SeStream) != 0)
                {
                    Dispose();
                    return;
                }

                _queryFields = _queryInfo.QueryFields;
                _queryInfo.Dispose();
                _queryInfo = null;
            }
            catch (Exception ex)
            {
                _errMsg = ex.Message + "\n" + ex.StackTrace;
                Dispose();
            }
        }