async private Task <bool> ImportFiles(string[] data, bool refreshList, Dictionary <string, Guid> providers) { IRasterClass rc = await _exObject.GetInstanceAsync() as IRasterClass; if (rc == null) { return(false); } IRasterDataset rDS = rc.Dataset as IRasterDataset; if (rDS == null || rDS.Database == null) { return(false); } FDBImageDataset operations = new FDBImageDataset(rDS.Database as IImageDB, rDS.DatasetName); // refreshList = false wenn ganzen Verzeichnis durchsucht wird... // dann sollen auch keine Fehler verursacht werden wenn ein bild nicht gereferenziert ist, // in diesem fall bild einfach ignorieren operations.handleNonGeorefAsError = refreshList; ImageImportProgressReporter reporter = new ImageImportProgressReporter(operations, data.Length); ImportArguments args = new ImportArguments(operations, rDS, data, providers); FormTaskProgress progress = new FormTaskProgress(); progress.Text = "Import Images: " + rDS.DatasetName; progress.Mode = ProgressMode.ProgressDisk; progress.ShowProgressDialog(reporter, Import(args)); if (refreshList) { await RefreshList(); } if (!reporter.CancelTracker.Continue) { MessageBox.Show("Cancel..."); return(false); } if (operations.lastErrorMessage != String.Empty) { MessageBox.Show("ERROR: " + operations.lastErrorMessage); return(false); } await rDS.RefreshClasses(); return(true); }
async private Task Import(object arg) { if (!(arg is ImportArguments)) { return; } ImportArguments args = (ImportArguments)arg; await Task.Delay(300); // open reporter UI... bool succeeded = true; foreach (string filename in args.Data) { succeeded = await args.Operator.Import(filename, args.Providers); if (!succeeded) { break; } } AccessFDB fdb = args.dataset.Database as AccessFDB; if (fdb != null) { IFeatureClass fc = await fdb.GetFeatureclass(args.dataset.DatasetName, args.dataset.DatasetName + "_IMAGE_POLYGONS"); if (fc != null) { await fdb.CalculateExtent(fc); } await fdb.ShrinkSpatialIndex(args.dataset.DatasetName + "_IMAGE_POLYGONS"); //if (!fdb.CalculateSpatialIndex(fdb.GetFeatureclass(args.dataset.DatasetName, args.dataset.DatasetName + "_IMAGE_POLYGONS"), 10, 0)) //{ // MessageBox.Show("ERROR: CalculateSpatialIndex - " + fdb.lastErrorMsg); //} } }