Can you "Get Data" for only select fields?

614
5
12-20-2011 07:23 AM
DavidCarpenter
Occasional Contributor
We are beginning to test the idea of capturing photos using ArcGIS Mobile / use of the Raster field for an upcoming inspection program. 

Is there any way to restrict the fields (in code or otherwise) that are retrieved when users "Get Data" for an ArcGIS Mobile application?  Specifically, we want the user to post their updates which will include photos stored in the raster field, but when they "Get Data" we don't necessarily want then to download all the photos that have been captured.  We do however want the users to have the latest most complete inventory of assets (streetlights).

We plan on using ArcGIS Mobile build 2525 or most recent on Trimble Juno SC's with integrated camera.

Thanks
0 Kudos
5 Replies
MartinCopping
Esri Contributor
According to our Dev Team, that�??s possible. On FeatureLayerSyncAgent, you can set a DownloadFilter, which can include a QueryFilter. The query filter can contain an optional list of columns to be included.

Cheers,
Martin Copping
Product Manager, ArcGIS Online - Dashboards
0 Kudos
JohnWilkinson1
New Contributor
Hello,

I see from Martin's response that this is possible, though I'm not certain if David had any success.  Has anyone had success filtering the contents of a download (i.e., the result of clicking on the "Get Data" button on the Manage Edits form)?  I've seen threads in the forum discuss "from scratch" customized downloads, but I'm trying to customize the existing process rather than build from scratch. 

Basically, I want to filter the data brought down with "Get Data".  I only want inventory items (signs, etc.) from a given layer/feature class from a specific project (e.g., an inspection project) to be brought down to the device (i.e., I don't want the entire inventory brought down - just those for a single project).  This seems like it would be a fairly typical requirement, but I don't see any way to configure this in Mobile Project Center of the .amp file.

Here's what I'm doing:

I'm using ArcGIS Mobile 10, build 2525, delivering on a Windows 7 tablet (Trimble Yuma).  I've built an extension for the SynchronizeTask.  In the OnOwnerInitialized() event, I've added a handler for the PropertyChanged event.  In the PropertyChanged event, I'm trapping when the e.PropertyName = "IsGettingData" and e.PropertyName = "IsSynchronizing" (I've been able successfully do stuff when trapping e.PropertyName = "IsPostingUpdates".)

In IsGettingData (and subsequently I've tried this in IsSynchronizing with the same result), I do the following (sorry, it's in VB.NET):

' first I try getting the FeatureLayerSyncAgent via Feature Layers in the Mobile Cache

Dim mc As New MobileCache("D:\Users\<mobile cache location...>")
mc.Open()
For Each fl As FeatureLayer In mc.FeatureLayers
[INDENT]If fl.Name = "<my layer name...>" Then                           ' Get the layer in question
[INDENT]Dim flsa As New FeatureLayerSyncAgent(fl)
flsa.DownloadFilter = New QueryFilter("ProjectID= 5")    ' set the where clause to check a field value[/INDENT]End If
[/INDENT]Next


' alternatively, I try getting the FeatureLayerSyncAgent via Sync Agents in the MobileCacheSyncAgent

Dim msc As New MobileServiceConnection
Dim msa As New MobileCacheSyncAgent(mc, msc)
For Each sa As SyncAgent In msa.SyncAgents
[INDENT]Dim flsa As FeatureLayerSyncAgent = CType(sa, FeatureLayerSyncAgent)
[INDENT]If flsa.FeatureLayer.Name = "<my layer name...>" Then        ' Get the layer in question
flsa.DownloadFilter = New QueryFilter("ProjectID= 5")       ' set the where clause to check a field value[/INDENT]End If[/INDENT]Next

I verified with debugging that all of these statements execute (i.e., the QueryFilter is set on the FeatureLayerSyncAgent), but "Get Data" still brings down the entire layer.  No filtering is done based on the where clause.  I also tried limiting the FIDs on the QueryFilter with no success.

Am I missing something?  Suggestions?

Thanks,

John
0 Kudos
Andréde_Mattos_Ferraz
Occasional Contributor
Any progress? I have some problem.
0 Kudos
Andréde_Mattos_Ferraz
Occasional Contributor
Works 😄 !!!

mobileCache1.DeleteCache();
MobileCacheSyncAgent mobilesync = new MobileCacheSyncAgent(mobileCache1, mobileServiceConnection1);
MobileCacheSyncResults mobileResults = new MobileCacheSyncResults();
mobileServiceConnection1.CreateCache(mobileCache1);
mobileCache1.Open();

try
{
                FeatureLayerSyncResults featLayerResults = new FeatureLayerSyncResults();

                //layer de parcelas
                FeatureLayerSyncAgent flsa1 = mobilesync.SyncAgents[0] as FeatureLayerSyncAgent;//new FeatureLayerSyncAgent(fl1,mobileServiceConnection1);
                flsa1.SynchronizationDirection = SyncDirection.DownloadOnly;
                flsa1.DownloadFilter = new QueryFilter("(cd_uso_solo in (140161,139115,139134))");
                featLayerResults = flsa1.Synchronize() as FeatureLayerSyncResults;
                //featLayerResults.FeaturesAddedInCache.Count;

                //layer uso solo
                FeatureLayerSyncAgent flsa2 = mobilesync.SyncAgents[1] as FeatureLayerSyncAgent;//new FeatureLayerSyncAgent(fl2, mobileServiceConnection1);
                flsa2.SynchronizationDirection = SyncDirection.DownloadOnly;
                flsa2.DownloadFilter = new QueryFilter("(cd_parcela in (572862,572861,549839))");
                featLayerResults = flsa2.Synchronize() as FeatureLayerSyncResults;
                //featLayerResults.FeaturesAddedInCache.Count;
}
catch (Exception ex)
{
                MessageBox.Show("Cannot synchronize with this service :" + ex.Message);
}
0 Kudos
ChadTaylor
New Contributor
Has anyone else got this working properly? I tried doing what fandre did, however, it errors when I try to create the new cache and gives the the error message of "" which isn't much help...

I also noticed that ESRI says to use the following connection string format for the MobileServiceConnection:
mobileServiceConnection1.Url = @"http://YOURSERVER/arcgis/services/YOURSERVICE/MapServer/MobileServer";
http://help.arcgis.com/en/arcgismobile/10.0/apis/arcgismobile/api/ESRI.ArcGIS.Mobile~ESRI.ArcGIS.Mob...

Should it really be MapServer/MobileServer at the end or just MobileServer?

Here is the code I'm trying to use:
           // Create an instance of MobileCache, and set StoragePath
            MobileCache mc = new MobileCache(@"C:\ArcGIS_Mobile\Projects\MyProject\MobileCache");
            MobileServiceConnection msc = new MobileServiceConnection();
            msc.Url = @"http://MYSERVER/ArcGIS/rest/services/MYSERVICE/MobileServer";
            try
            {
                mc.DeleteCache();
                MobileCacheSyncAgent mobilesync = new MobileCacheSyncAgent(mc, msc);
                MobileCacheSyncResults mobileResults = new MobileCacheSyncResults();
                msc.CreateCache(mc);
                mc.Open();

                FeatureLayerSyncResults featLayerResults = new FeatureLayerSyncResults();

                FeatureLayerSyncAgent flsa1 = mobilesync.SyncAgents[0] as FeatureLayerSyncAgent;
                flsa1.SynchronizationDirection = SyncDirection.DownloadOnly;
                flsa1.DownloadFilter = new QueryFilter("CaseID = " + txtSearchValue.Text.Trim());
                featLayerResults = flsa1.Synchronize() as FeatureLayerSyncResults;
                mobilesync.Synchronize();
                MobileCacheSyncAgent agent = new MobileCacheSyncAgent(mc);
                agent.MapDocumentConnection = msc;
                agent.DownloadExtent(mc.GetExtent(), 0, 0);
                // Load layers from MobileCache to Map control
                ViewMapPage mapPage = UtilityFunctions.GetMapPage() as ViewMapPage;
                mapPage.MapControl.Map.MapLayers.AddRange(mc);
                mc.Close();

This errors when I CreateCache. If I don't delete and create a new cache it seems to work although no data is loaded from the server...

Thanks,

Chad
0 Kudos