Synchronizing Table Data with Runtime.Net

2223
2
Jump to solution
08-20-2015 05:06 AM
HolgerSchade2
New Contributor

Hi,

I am trying to synchronize a normal table with the Runtime.NET and FeatureService SYNC capabilities. What I have been achieving so far is the following:

1.) I could create a feature service with sync capabilities. This FeatureService contains a feature class ("fcl_point") and a (unrelated) table ("table1")

2.) I could synchronize Feature Data from the feature class ("fcl_point") to a local SQLite Geodatabase (This part works as expected)

3.) When calling the GenerateGeodatabaseAsync  Task from Runtime .NET also the schema for the table ("table1) was properly created in the local SQLite Geodatabase.

However the table which was created does not contain any data. I also could not find any reasonable documentation for such a scenario. Also what confuses me is that in the  GenerateGeodatabaseParameters you must provide an extent. This extent is not helpful when synchronizing pure table data.

Can anyone give me an indication of how such a synchronization of table data is done with Runtime.NET?

Tags (3)
0 Kudos
1 Solution

Accepted Solutions
by Anonymous User
Not applicable

For tables, I usually end up using the LayerQuery class like this:

            Dictionary<int, LayerQuery> lqs = new Dictionary<int, LayerQuery>();

            GeodatabaseSyncTask gdbTask = new GeodatabaseSyncTask(new Uri(_featureServiceUrl));

            FeatureServiceInfo fsi = await gdbTask.GetServiceInfoAsync();

            GenerateGeodatabaseParameters gdbParams = new GenerateGeodatabaseParameters(fsi, fsi.FullExtent);                   

            // For all of the tables, get all of the data for them

            foreach (Table t in fsi.Tables)

            {

                lqs.Add(t.ID, new LayerQuery() { QueryOption = QueryOption.All });

            }

            gdbParams.LayerQueries = lqs;

            Progress<GeodatabaseStatusInfo> p = new Progress<GeodatabaseStatusInfo>(SyncTask_Progress);

            _syncCancellationTokenSource = new CancellationTokenSource();

            var cancelToken = _syncCancellationTokenSource.Token;

            GenerateGeodatabaseResult res = await gdbTask.GenerateGeodatabaseAsync(gdbParams,

                                                                                  (status, ex) => SyncTask_Complete(status, ex),

                                                                                  TimeSpan.FromSeconds(10.0),

                                                                                  p,

                                                                                  cancelToken);

QueryOption.All will return everything for that table, but you can also use a filter if that made sense for your situation.  I believe the reason none of the data is returned is because the default behavior is to return records based on the extent defined in the GenerateGeodatabaseParameters object and since tables have no geometry, you get nothing back except the schema.  Anyway, hope this helps.

View solution in original post

2 Replies
by Anonymous User
Not applicable

For tables, I usually end up using the LayerQuery class like this:

            Dictionary<int, LayerQuery> lqs = new Dictionary<int, LayerQuery>();

            GeodatabaseSyncTask gdbTask = new GeodatabaseSyncTask(new Uri(_featureServiceUrl));

            FeatureServiceInfo fsi = await gdbTask.GetServiceInfoAsync();

            GenerateGeodatabaseParameters gdbParams = new GenerateGeodatabaseParameters(fsi, fsi.FullExtent);                   

            // For all of the tables, get all of the data for them

            foreach (Table t in fsi.Tables)

            {

                lqs.Add(t.ID, new LayerQuery() { QueryOption = QueryOption.All });

            }

            gdbParams.LayerQueries = lqs;

            Progress<GeodatabaseStatusInfo> p = new Progress<GeodatabaseStatusInfo>(SyncTask_Progress);

            _syncCancellationTokenSource = new CancellationTokenSource();

            var cancelToken = _syncCancellationTokenSource.Token;

            GenerateGeodatabaseResult res = await gdbTask.GenerateGeodatabaseAsync(gdbParams,

                                                                                  (status, ex) => SyncTask_Complete(status, ex),

                                                                                  TimeSpan.FromSeconds(10.0),

                                                                                  p,

                                                                                  cancelToken);

QueryOption.All will return everything for that table, but you can also use a filter if that made sense for your situation.  I believe the reason none of the data is returned is because the default behavior is to return records based on the extent defined in the GenerateGeodatabaseParameters object and since tables have no geometry, you get nothing back except the schema.  Anyway, hope this helps.

HolgerSchade2
New Contributor

How cool is this - Works like a charm Thank you very much!!!!!

0 Kudos