Пример #1
0
        public EsentGeometryInitialiser(EsentGeometryStore esentGeometryStore, EsentShapeGeometryCursor shapeGeometryCursor, EsentShapeInstanceCursor shapeInstanceCursor)
        {
            try
            {
                _esentGeometryStore  = esentGeometryStore;
                _shapeGeometryCursor = shapeGeometryCursor;
                _shapeInstanceCursor = shapeInstanceCursor;
                _geometryContextId   = new IntPtr(_shapeGeometryCursor.GetHashCode());
                _instanceContextId   = new IntPtr(_shapeInstanceCursor.GetHashCode());
                SetGeometryContext();
                try
                {
                    _shapeGeometryTransaction = _shapeGeometryCursor.BeginLazyTransaction();
                }
                finally { ResetGeometryContext(); }

                SetInstanceContext();
                try
                {
                    _shapeInstanceTransaction = _shapeInstanceCursor.BeginLazyTransaction();
                }
                finally{ ResetInstanceContext(); }

                _geometryCount = 0;
                _instanceCount = 0;
            }
            catch (Exception e)
            {
                throw new Exception("Error creating transactions", e);
            }
        }
        public EsentGeometryStoreReader(EsentModel esentModel)
        {
            _esentModel               = esentModel;
            _shapeGeometryCursor      = _esentModel.GetShapeGeometryTable();
            _shapeInstanceCursor      = _esentModel.GetShapeInstanceTable();
            _shapeGeometryTransaction = _shapeGeometryCursor.BeginReadOnlyTransaction();
            _shapeInstanceTransaction = _shapeInstanceCursor.BeginReadOnlyTransaction();
            _regionsList              = new XbimContextRegionCollection();
            IXbimShapeGeometryData regions = new XbimRegionCollection();

            if (_shapeGeometryCursor.TryMoveFirstRegion(ref regions))
            {
                do
                {
                    _regionsList.Add((XbimRegionCollection)regions);
                    regions = new XbimRegionCollection();
                } while (_shapeGeometryCursor.TryMoveNextRegion(ref regions));
            }
            if (!_regionsList.Any()) //we might have an old xbim database regions were stored in the geometry table
            {
                var legacyCursor = _esentModel.GetGeometryTable();
                using (var txn = legacyCursor.BeginReadOnlyTransaction())
                {
                    foreach (var regionData in legacyCursor.GetGeometryData(Xbim.Common.Geometry.XbimGeometryType.Region))
                    {
                        _regionsList.Add(XbimRegionCollection.FromArray(regionData.ShapeData));
                    }
                }
                _esentModel.FreeTable(legacyCursor);
            }
            _contextIds = new HashSet <int>(ContextIds);
        }
Пример #3
0
 public IGeometryStoreInitialiser BeginInit()
 {
     try
     {
         if (_currentTransaction == null) //we can start a new one
         {
             //dispose of any tables because we are going to clear them
             if (_shapeGeometryCursor != null)
             {
                 _shapeGeometryCursor.Dispose();
                 _shapeGeometryCursor = null;
             }
             if (_shapeInstanceCursor != null)
             {
                 _shapeInstanceCursor.Dispose();
                 _shapeInstanceCursor = null;
             }
             //delete any geometries in the database
             _esentModel.ClearGeometryTables();
             _shapeGeometryCursor = _esentModel.GetShapeGeometryTable();
             _shapeInstanceCursor = _esentModel.GetShapeInstanceTable();
             _currentTransaction  = new EsentGeometryInitialiser(this, _shapeGeometryCursor, _shapeInstanceCursor);
             return(_currentTransaction);
         }
         throw new Exception("A transaction is in operation on the geometry store");
     }
     catch (Exception e)
     {
         if (_shapeGeometryCursor != null)
         {
             _esentModel.FreeTable(_shapeGeometryCursor);
         }
         if (_shapeInstanceCursor != null)
         {
             _esentModel.FreeTable(_shapeInstanceCursor);
         }
         _currentTransaction = null;
         throw new Exception("Begin initialisation failed on Geometry Store", e);
     }
 }
Пример #4
0
 /// <summary>
 /// Returns the table to the cache for reuse
 /// </summary>
 /// <param name="table"></param>
 public void FreeTable(EsentShapeGeometryCursor table)
 {
     InstanceCache.FreeTable(table);
 }