Implicit/Explict Save of Feature Data (WPF/v100.0)

952
4
12-20-2016 08:23 AM
KeithGemeinhart1
New Contributor III

I have generated a runtime geodatabase from a sync-enabled feature service as described on this page ... Create an offline map—ArcGIS Runtime SDK for .NET | ArcGIS for Developers . That works OK, but is somewhat unreliable in that I had to try multiple times to get it to download. Maybe I'll post a separate question on that.

In code I do something like this to setup my map ...

var gdb = await Geodatabase.OpenAsync(master.GeodatabasePath);

foreach (var table in gdb.GeodatabaseFeatureTables)
{
    await table.LoadAsync();

    var layer = new FeatureLayer(table);
    layer.Id = table.TableName;

    mapView.Map.OperationalLayers.Add(layer);
}

Then later ...

var attributes = new Dictionary<string, object>();
attributes.Add("PlanId", 1);
attributes.Add("PlanGuid", Guid.NewGuid());

var layer = Mapview.Map.OperationalLayers["Aoi"] as FeatureLayer;
var newFeature = layer.FeatureTable.CreateFeature(attributes, _aoiGeometry);

await layer.FeatureTable.AddFeatureAsync(newFeature);

...

That works fine too.

However, I noticed that the feature is written immediately to the attached geodatabase. Is there a way to delay writing to the database until I make an explicit call?

I suppose I could initially create graphics, and then when I want to persist them, create features from the graphics. That's a simple enough concept but seems convoluted in that I would also have to created a bunch of graphics from existing features every time my query criteria changes.

Or is there a better workflow instead? My goal is to work offline only. We will never sync back to the server after creating the initial (empty) geodatabase. I do need to be able to perform all of the basic create, update, insert, select operations on the feature data. Would FeatureCollection be a viable alternative?

0 Kudos
4 Replies
KeithGemeinhart1
New Contributor III

Alternatively, if there was a way to rollback changes, that would work too.

0 Kudos
AnttiKajanus1
Occasional Contributor III

At the moment you cannot `delay` the add to the local geodatabase. Could you describe the workflow a bit more in detail? There are methods to find out what has been added to the FeatureTable after last sync, you might need to use FeatureCollectionTable / GraphicsOverlays / temp Geodataabse to save that information temporarily or do something else.

0 Kudos
KeithGemeinhart1
New Contributor III

My application is a map-based planning tool. The user can create a "plan" using the same kind of workflow you might use for something like MS Word, where our "plan" is similar to a Word document.

User creates a new plan, adds or edits features and can save the plan. The key is if the user quits or opens a new plan before saving, we don't want to keep any of the changes he's made in the interim  (e.g. edits, new features or deleting existing features). 

Ideally, a transaction mechanism on the geodb would be the best thing if it existed. Then we can just commit or rollback changes as needed.

Since that doesn't exist, my current solution is to use graphics as temporary "work in progress" items. When the user saves, graphics are converted to features. When the user opens a new plan, existing features are queried and displayed as graphics.

Other ideas I have include:

  • Using a local server and re-syncing the geodb, but I don't know if that's possible. If so, how might I do that?
  • I don't want to user a temp geodb since that is something we did once with ArcObjects, and it was a very unstable.

What are the methods to find changes on FeatureTable? Is there a property I can change or other way to reset that sync point without actually re-syncing?

Thanks!

0 Kudos
AnttiKajanus1
Occasional Contributor III

Ah, that makes sense. I probably would approach with following flow:

- When original geodatabase is downloaded, make a copy of it xxxxTemporary.geodatabase

- When working with new plan commit changes to the that geodatabase, this will give you support for query and other FeatureTable functionality such as templates.

- When you are committing features / saving the plan just get all the features from the temporary geodatabase, copy to the real one and clear the temporary one.

- If the plan is not committed, then you can clear all features from the geodatabase

- This would also give you option to make `continue from last plan` if needed

Another good point with this would be that you can be sure that the features are created with correct schema and they are visualized correctly because the features would get the rendering directly from the geodatabase definitions. This might come in handy especially if you need to do any changes in the future to the underlying attributes / symbology.

You could also think that you would create separate local geodatabase (copy of the original / empty) for every plan that they start to do and when finish, just delete it.

Does that make any sense?

Happy holidays and new year!

0 Kudos