Hi, I am working with the mobile SDK and cannot get my ArcMap document to update using 'syncronize'. I had this working before, stepped away for a few months, and am back to it. My code is no longer working. I get no errors, no exceptions, I just go to ArcMap and my changes are not there. I'm thinking maybe I am forgetting to assign some attribute to the ArcMap document, MapService, or something. I have this:
MobileCache serverCache = new MobileCache();
serverCache.StoragePath = path;
MobileServiceConnection mobileServConn = new MobileServiceConnection();
mobileServConn.Url = @"http://den-web-002/arcgis/services/Construction/USALonghorn/MapServer/MobileServer";
mobileServConn.CreateCache(serverCache);
serverCache.Open();
MobileCacheSyncAgent agent = new MobileCacheSyncAgent(serverCache);
agent.MapDocumentConnection = mobileServConn;
agent.DownloadExtent(serverCache.GetExtent(), 0, 0);
to create the cache.
I then update various attributes of the cache. After editing in one process, I check to make sure they are there by using:
FeatureDataTable deviceTbl = serverCache.FeatureLayers["Turbines"].GetDataTable(new QueryFilter(), EditState.Modified, null);
foreach (System.Data.DataRow dataRow2 in deviceTbl.Rows)
{
string nameChnged = dataRow2["Name"].ToString();
string completeChng = dataRow2["Completed"].ToString();
}
The mapcache is correctly updated. I then use:
MobileServiceConnection mobileServConn = new MobileServiceConnection();
mobileServConn.Url = @"http://MyMapService/MapServer/MobileServer";
mobileServConn.WebClientProtocolType = WebClientProtocolType.BinaryWebService;
MobileCacheSyncAgent mobileSync = new MobileCacheSyncAgent(serverCache, mobileServConn);
FeatureLayer theLyr = serverCache.FeatureLayers["TheLayer"];
FeatureLayerSyncAgent flSyncAgent = new FeatureLayerSyncAgent(theLyr, mobileSync.MapDocumentConnection);
if (flSyncAgent.IsValid)
{
flSyncAgent.SynchronizationDirection = SyncDirection.Bidirectional;
SyncResults featLayerResults = flSyncAgent.Synchronize();
Exception flExc = featLayerResults.Exception;
if (flExc != null)
{
tw.AppendText("Error synchronizing Mobile Cache: " + flExc.Message);
return false;
}
}
flExc is null and there are no problems or flags. However, when I look at my arcMap document no changes have occurred. If I manually use the "Synchronize Mobile Cache" tool in ArcToolbox, the cache is correctly syncd back up.
Can anyone tell me what I may be doing wrong? Why is it not syncing? ANY pointers would be helpful.