public void DisposeSurface() { if (_rasterSurface == null) { return; } _msg.Debug("Disposing raster"); _rasterSurface.Dispose(); _rasterSurface = null; IWorkspace memoryWs = null; if (_memoryRasterDataset != null) { memoryWs = _memoryRasterDataset.Workspace; _memoryRasterDataset.Delete(); ComUtils.ReleaseComObject(_memoryRasterDataset); _memoryRasterDataset = null; } if (memoryWs != null) { ((IDataset)memoryWs).Delete(); ComUtils.ReleaseComObject(memoryWs); } }
public void Dispose() { ComUtils.ReleaseComObject(_construction); _properties = null; _construction = null; }
public void DeleteErrorObjects( [NotNull] IQueryFilter filter, [NotNull] IDeletableErrorRowFilter deletableErrorRowFilter, [NotNull] IDictionary <int, QualityCondition> qualityConditionsById) { Assert.ArgumentNotNull(filter, nameof(filter)); Assert.ArgumentNotNull(deletableErrorRowFilter, nameof(deletableErrorRowFilter)); Assert.ArgumentNotNull(qualityConditionsById, nameof(qualityConditionsById)); Stopwatch watch = _msg.DebugStartTiming(); IQueryFilter tableSpecificFilter = AdaptFilterToErrorTable(filter); var count = 0; const bool recycle = true; ICursor cursor = Table.Update(tableSpecificFilter, recycle); try { for (IRow row = cursor.NextRow(); row != null; row = cursor.NextRow()) { int?qualityConditionId = Get <int>(row, AttributeRole.ErrorConditionId); if (qualityConditionId != null) { QualityCondition qualityCondition; if (!qualityConditionsById.TryGetValue(qualityConditionId.Value, out qualityCondition)) { // the quality condition is not in the specified set, or the id was invalid // -> don't delete // NOTE: if the set of quality conditions is guaranteed to be complete then deletion would be possible continue; } if (!deletableErrorRowFilter.IsDeletable(row, qualityCondition)) { // the error is not deletable continue; } } // The error is deletable for it's quality condition, or it does not have a quality condition id // -> delete it cursor.DeleteRow(); count++; } } finally { ComUtils.ReleaseComObject(cursor); } _msg.DebugStopTiming(watch, "Deleted {0} error(s) in {1} based on deletable row filter", count, DatasetName); }
public void Dispose() { if (_releaseOnDispose) { ComUtils.ReleaseComObject(_segments); } _releaseOnDispose = false; }
public void Dispose() { if (_insertCursor != null) { Flush(); ComUtils.ReleaseComObject(_insertCursor); _insertCursor = null; } _rowBuffer = null; _featureBuffer = null; }
public int DeleteOrphanedErrorObjects([NotNull] IQueryFilter filter, [NotNull] ICollection <int> qualityConditionIds) { Assert.ArgumentNotNull(filter, nameof(filter)); Assert.ArgumentNotNull(qualityConditionIds, nameof(qualityConditionIds)); Stopwatch watch = _msg.DebugStartTiming("Deleting orphaned errors in {0}", DatasetName); IQueryFilter tableSpecificFilter = AdaptFilterToErrorTable(filter); int fieldIndex = GetFieldIndex(AttributeRole.ErrorConditionId); var count = 0; const bool recycle = true; ICursor cursor = Table.Update(tableSpecificFilter, recycle); try { for (IRow row = cursor.NextRow(); row != null; row = cursor.NextRow()) { object qualityConditionId = row.Value[fieldIndex]; bool isOrphaned = qualityConditionId == null || qualityConditionId is DBNull || !qualityConditionIds.Contains( Convert.ToInt32(qualityConditionId)); if (isOrphaned) { count++; cursor.DeleteRow(); } } } finally { ComUtils.ReleaseComObject(cursor); } _msg.DebugStopTiming(watch, "Deleted {0} error(s)", count); return(count); }
private bool Touches([NotNull] IGeometry source, [NotNull] IGeometry target) { IGeometry clippedSource = null; IGeometry clippedTarget = null; try { if (UseEnvelopeIntersection(source, target)) { IEnvelope envelopeIntersection = GetEnvelopeIntersection(source, target); if (envelopeIntersection.IsEmpty) { return(false); } clippedSource = GetClipped(source, envelopeIntersection); if (clippedSource != null) { source = clippedSource; } clippedTarget = GetClipped(target, envelopeIntersection); if (clippedTarget != null) { target = clippedTarget; } } return(GeometryUtils.Touches(source, target)); } finally { if (clippedSource != null) { ComUtils.ReleaseComObject(clippedSource); } if (clippedTarget != null) { ComUtils.ReleaseComObject(clippedTarget); } } }
private static void GetFeaturesInLoop( int count, [NotNull] Func <IFeatureClass, int, IFeature> getFeatureMethod) { IFeatureWorkspace featureWorkspace = (IFeatureWorkspace)TestUtils.OpenSDEWorkspaceOracle(); IFeatureClass featureClass = featureWorkspace.OpenFeatureClass("TOPGIS_TLM.TLM_DTM_MASSENPUNKTE"); IList <int> oids = GetFeatureIDs(featureClass, count); var watch = new Stopwatch(); var memoryUsage = new MemoryUsageInfo(); memoryUsage.Refresh(); watch.Start(); IGdbTransaction gdbTransaction = new GdbTransaction(); gdbTransaction.Execute( (IWorkspace)featureWorkspace, delegate { foreach (int oid in oids) { IFeature feature = getFeatureMethod(featureClass, oid); ComUtils.ReleaseComObject(feature); } memoryUsage.Refresh(); watch.Stop(); Console.WriteLine("Features read: {0}", oids.Count); Console.WriteLine("Memory usage: {0}", memoryUsage); Console.WriteLine("Elapsed: {0:N0} ms", watch.ElapsedMilliseconds); }, "test"); }
private static int ProcessReplacedExceptions( [NotNull] ITable targetTable, [NotNull] IIssueTableFields targetFields, DateTime importDate, [NotNull] ICollection <int> replacedOids, out int fixedStatusCount) { fixedStatusCount = 0; int statusFieldIndex = targetFields.GetIndex(IssueAttribute.ExceptionStatus, targetTable); int versionEndDateFieldIndex = targetFields.GetIndex(IssueAttribute.ManagedExceptionVersionEndDate, targetTable); ICursor cursor = targetTable.Update(null, Recycling: true); var updateCount = 0; const string statusInactive = "Inactive"; try { for (IRow row = cursor.NextRow(); row != null; row = cursor.NextRow()) { object oldEndDate = row.Value[versionEndDateFieldIndex]; bool oldVersionIsClosed = !(oldEndDate == null || oldEndDate is DBNull); string oldStatus = (row.Value[statusFieldIndex] as string)?.Trim(); var anyChanges = false; if (replacedOids.Contains(row.OID)) { if (!statusInactive.Equals(oldStatus, StringComparison.OrdinalIgnoreCase)) { // the row status is different from "Inactive" --> set to "Inactive" row.Value[statusFieldIndex] = statusInactive; anyChanges = true; } if (!oldVersionIsClosed) { // the row does not have an end date set --> set importDate as end date row.Value[versionEndDateFieldIndex] = importDate; anyChanges = true; } if (anyChanges) { updateCount++; } } else { // fix status if not 'inactive' for a closed version if (oldVersionIsClosed && !statusInactive.Equals(oldStatus, StringComparison.OrdinalIgnoreCase)) { row.Value[statusFieldIndex] = statusInactive; anyChanges = true; fixedStatusCount++; } } if (anyChanges) { cursor.UpdateRow(row); } } } finally { ComUtils.ReleaseComObject(cursor); } return(updateCount); }