async private Task <int> CopyFeatures(IFeatureCursor fCursor, long NID, IFeatureUpdater fdb, IFeatureClass dest, FieldTranslation fTrans, int featcounter) { IFeature feat; List <IFeature> features = new List <IFeature>(); while ((feat = await fCursor.NextFeature()) != null) { if (!_cancelTracker.Continue) { break; } feat.Fields.Add(new FieldValue("$FDB_NID", NID)); if (_transformer != null) { feat.Shape = _transformer.Transform2D(feat.Shape) as IGeometry; } if (fTrans != null) { fTrans.RenameFields(feat); } features.Add(feat); if (features.Count >= this.FeatureBufferSize) { if (!await fdb.Insert(dest, features)) { _errMsg = "Fatal error: destdb insert failed...\n" + fdb.LastErrorMessage; return(-1); } features.Clear(); } featcounter++; if ((featcounter % this.FeatureBufferSize) == 0 && ReportProgress != null) { ReportProgress(this, featcounter); } } if (features.Count > 0 && _cancelTracker.Continue) { if (!await fdb.Insert(dest, features)) { _errMsg = "Fatal error: destdb insert failed...\n" + fdb.LastErrorMessage; return(-1); } features.Clear(); } return(featcounter); }
async private Task <bool> CopyFeatures(IFeatureClass source, IFeatureUpdater fdb, IFeatureClass dest, FieldTranslation fTrans, List <IQueryFilter> filters) { if (ReportAction != null) { ReportAction(this, "Copy Features (" + dest.Name + ")"); } int featcounter = 0; List <IFeature> features = new List <IFeature>(); if (filters == null || filters.Count == 0) { QueryFilter filter = new QueryFilter(); filter.SubFields = "*"; filters = new List <IQueryFilter>(); filters.Add(filter); } foreach (IQueryFilter filter in filters) { using (IFeatureCursor fCursor = await source.GetFeatures(filter)) { IFeature feature; while ((feature = await fCursor.NextFeature()) != null) { if (!_cancelTracker.Continue) { break; } if (_transformer != null) { feature.Shape = _transformer.Transform2D(feature.Shape) as IGeometry; } if (fTrans != null) { fTrans.RenameFields(feature); } features.Add(feature); if (features.Count >= this.FeatureBufferSize) { if (!await fdb.Insert(dest, features)) { _errMsg = "Fatal error: destdb insert failed...\n" + fdb.LastErrorMessage; return(false); } features.Clear(); } featcounter++; if ((featcounter % this.FeatureBufferSize) == 0 && ReportProgress != null) { ReportProgress(this, featcounter); } } if (features.Count > 0 && _cancelTracker.Continue) { if (!await fdb.Insert(dest, features)) { _errMsg = "Fatal error: destdb insert failed...\n" + fdb.LastErrorMessage; return(false); } features.Clear(); } } } return(true); }
private bool CopyFeatures(IFeatureClass source, IFeatureUpdater fdb, IFeatureClass dest, FieldTranslation fTrans, List <IQueryFilter> filters) { if (filters == null) { QueryFilter filter = new QueryFilter(); filter.SubFields = "*"; filters = new List <IQueryFilter>(); filters.Add(filter); } int counter = 0; List <IFeature> features = new List <IFeature>(); foreach (IQueryFilter filter in filters) { using (IFeatureCursor cursor = source.GetFeatures(filter)) { IFeature feature; while ((feature = cursor.NextFeature) != null) { if (fTrans != null) { fTrans.RenameFields(feature); } if (_transformer != null) { feature.Shape = _transformer.Transform2D(feature.Shape) as IGeometry; } features.Add(feature); counter++; if ((counter % this.FeatureBufferSize) == 0) { if (!fdb.Insert(dest, features)) { _errMsg = "Fatal error: destdb insert failed...\n" + fdb.lastErrorMsg; return(false); } features.Clear(); if (ReportProgress != null) { ReportProgress(this, counter); } } } } } if (features.Count > 0) { if (!fdb.Insert(dest, features)) { _errMsg = "Fatal error: destdb insert failed..."; return(false); } features.Clear(); if (ReportProgress != null) { ReportProgress(this, counter); } } return(true); }