Sync using map document in mobile SDK

3126
3
05-19-2014 01:27 AM
JohnFannon
Occasional Contributor III
Hi

I'm looking at developing a more flexible and robust tool for creating large mobile caches as we have seen lots of issues with the GP tools with large caches at v10. I'm looking at using the SDK and using a map document (mxd) as input (as per the GP tools), but have looked at the SDK and can't see a way sync using a map document.

The MapDocumentConnection class seems to be what I need, but this is Abstract and therefore not creatable. So how do you use a map document (not a URL to server) to sync using the SDK.

I'm thinking it must be possible as the GP tools surely use the SDK behind the scenes.

Any ideas most welcome.

John
0 Kudos
3 Replies
AkhilParujanwala
New Contributor III
HI John,

I am a little confused on what you want to do.

Do you want to use the ArcGIS Mobile SDK to sync to the server?

Do you want to use ArcObjects and a MXD and use the GP Tools?

Or something else?


When using the ArcGIS Mobile SDK it is possible to program your own sync code, this is what I do for my own application.

I will quickly give a rough idea.
MobileCache mobileCache = new MobileCache("physical location of your mobilecache on the field computer");
MobileServiceConnection msc = new MobileServiceConnection();
msc.Url = "your arcgisserver name + /arcgis/services/ + name of the service + /MapServer/Mobileserver");
msc.CreateCache(mobileCache.StoragePath);
mobileCache.Open();

foreach (Layer aLayer in mobileCache.Layers)
{
if(aLayer.Name == "the name of the layer you are trying to sync")
{
FeatureLayer aFeatureLayer = (FeatureLayer)aLayer;
FeatureLayerSyncAgent flsa = new FeatureLayerSyncAgent(aFeatureLayer);
flsa.MapDocumentConnection = msc;
flsa.SynchronizationDirection = SyncDirection.Bidirectional;
SyncResults results = new SyncResults();
results = flsa.Synchronize();
}
}


I hope this helps/is what you are looking for.


If you have any other questions feel free to ask on the forums.


Regards,

Akhil P.
0 Kudos
JohnFannon
Occasional Contributor III
Hi

Thanks for the reply. I want to use the Mobile 10 SDK to sync through a Map Document (mxd) - not through Server. I don't want to use the GP tools as we have tried these and they are unreliable when building caches for large datasets at v10.

The GP tools sync using a map document and not server, so I am thinking it should be possible, but the MapDocumentConnection class is abstract and only MobileServiceConnection implements it. MobileServiceConnection only has URL as a parameter.

I was expecting a way to set a path to an mxd file, but can't see anything in the SDK to do that.

I'm now working on similar code to yours to sync with Server via url, but would ideally like to sync using an mxd and not through server, just as the GP tools do.

Regards

John
0 Kudos
AkhilParujanwala
New Contributor III
Hi John,

Ok I understand what you are trying to do but I am not sure why you would like to synchronize to the MXD as opposed to the service URL?

Is there any benefit of using the MXD path?
I am not sure if you can even sync with the MXD path.

If you do get this to work, please post the solution if possible.


Cheers.
0 Kudos