Select to view content in your preferred language

ArcGIS Mobile upload for custom app

2697
6
12-08-2010 11:26 AM
garrethmorgan
Emerging Contributor
I'm writing a custom ArcGIS mobile data collection app and don't know where to start regarding uploading changes to the map cache to the Server.

Anyone have a code snippet or link to decent help or just good advice on this subject?
0 Kudos
6 Replies
AkhilParujanwala
Regular Contributor
You should use help, i think almost everything is there and all the samples are located on your computer/server.

http://help.arcgis.com/en/arcgismobile/10.0/apis/ArcGISMobile/webframe.html

Your going to want to look at Customizing Windows Application or Windows Mobile Application depending which one you are using.

Also look at, Building Mobile Applications, read both section fully and you will start to figure things out.

On the forums I have posted code on how to download data, I have yet to attempt Upload data.
0 Kudos
garrethmorgan
Emerging Contributor
Thanks for the reply Akhil.
I have looked through the help a few times and can't find anything specifically referring to uploading data to the Server. To my knowledge, none of the samples provide any help either.
0 Kudos
AkhilParujanwala
Regular Contributor
I have been doing some more development, but I have not tackled the upload data code yet.

I would look at FeatureSyncLayer object/class maybe you can find something there.
0 Kudos
AngelGonzalez
Frequent Contributor
This is the code I use in my mobile app. The user click on a button  and the following code is executed to synch data to the server from your map cache.


                    MobileCacheSyncAgent mobileSync = new MobileCacheSyncAgent(mobileCache1, mobileServiceConnection1);
                    MobileCacheSyncResults mobileResults = new MobileCacheSyncResults();
                    mobileServiceConnection1.CreateCache(mobileCache1.StoragePath);
                    
                    mobileSync.MapDocumentConnection = mobileServiceConnection1;


                    // To sysnch individual layers
                    FeatureLayerSyncAgent agent0 = new FeatureLayerSyncAgent(mobileCache1.FeatureLayers["LayerName1"], mobileServiceConnection1);
                    agent0.Synchronize();
                   
                    FeatureLayerSyncAgent agent1 = new FeatureLayerSyncAgent(mobileCache1.FeatureLayers["LayerName2"], mobileServiceConnection1);
                    agent1.Synchronize();


                    // to synch all layers
                    mobileSync.Synchronize();
0 Kudos
AlexProtyagov
Emerging Contributor
For uploading changes I did the following:

                
foreach(FeatureLayer fl in _cacheData.FeatureLayers)
                    {
                    if(!fl.HasEdits)
                        continue;
                    flSync = new FeatureLayerSyncAgent( fl, _svrConn );
                    flSync.SynchronizationDirection = SyncDirection.UploadOnly;
                    flSync.UploadFilter = new QueryFilter( "MY CONDITION STATEMENT" );

                    sr = flSync.Synchronize( );

                    if(sr.Exception != null)                        
                        throw new ApplicationException( PrepareErrorMessage( fl ) );                        
}
0 Kudos
garrethmorgan
Emerging Contributor
Thanks angleg and Alex56 I appreciate your input. I'll give that code a go asap.
0 Kudos