You can set your mobile service extend for editable area while publishing your service and then you can syncronize just this area.
also you can download custom extend with "downloadExtend" Method. But I suppose that there is no "new extend" limitation while syncronization.
... MobileCacheSyncAgent agent = new MobileCacheSyncAgent(currentMobileCache, conn); agent.DownloadExtent(envelope); //agent.Synchronize(); ...
Elerot,
Have you found that at 10.2 there is tremendous instability when building custom sync tasks - 10.0 was stable, but this method with the agent
var con = new MobileServiceConnection();
con.Url = mi.MobileServiceConnection.Url;
con.CreateCache(mc);
mc.Open();
MobileCacheSyncAgent agent = new MobileCacheSyncAgent(mc, con);
agent.DownloadExtent(qf.Extent);
SyncResults sr = agent.Synchronize();
MessageBox.Show("Sync results " + sr.DataSizeReceived.ToString());
Takes an extraordinary length of time to complete and if using FeatureSourceInfos it crashes as soon as one goes back to the map
IEnumerable<CacheMapLayerInfo> emi = MobileApplication.Current.Project.EnumerateCacheMapLayerInfos();
foreach (MobileCacheMapLayerInfo mi in emi)
{
MobileCache mc = new MobileCache(mi.MobileCache.StoragePath);
if (mc.CacheExists && mc.IsOpen)
{
mc.Close();
}
try
{
var con = new MobileServiceConnection();
con.Url = mi.MobileServiceConnection.Url;
con.CreateCache(mc);
mc.Open();
ICollection<FeatureSource> fSources = mc.FeatureSources;
foreach (FeatureSource fs in fSources)
{
try
{
var fsSyncAgent = new FeatureSyncAgent(fs, con);
fsSyncAgent.SynchronizationDirection = SyncDirection.DownloadOnly;
fsSyncAgent.DownloadFilter = qf;
//fSyncAgent.StateChanged += new EventHandler(fSyncAgent_StateChanged);
if (fsSyncAgent.IsValid)
{
fsSyncAgent.Synchronize();
}
else
{
MessageDialog.Show("Feature Sync " + fs.Name + " is not valid and cannot be synced", "Sync Error", MessageBoxButtons.OK);
}
// lstDataChanged.Items.Add(fs.Name.ToString() + " downloaded");
//MessageBox.Show("Valid " + fs.Name.ToString());
}
catch (Exception err)
{
logTools.logWrite("SyncPage->btnGetData_Click(): Exception " + err.Message.ToString());
MessageDialog.Show(err.Message, "Sync Error", MessageBoxButtons.OK);
}
}
}
catch (Exception err)
{
logTools.logWrite("SyncPage->btnGetData_Click(): Exception " + err.Message.ToString());
MessageDialog.Show(err.Message, "Sync Error", MessageBoxButtons.OK);
}
finally
{
Cursor.Current = Cursors.Default;
if (mc != null && mc.CacheExists && mc.IsOpen)
{
mc.Close();
}
}
}
try
{
Map map = MobileApplication.Current.Project.Map as Map;
map.Refresh();
}
catch (Exception err)
{
logTools.logWrite("SyncPage->btnGetData_Click(): Exception " + err.Message.ToString());
MessageDialog.Show(err.Message, "Refresh Error", MessageBoxButtons.OK);
}
MobileApplication.Current.Transition(MobileApplication.Current.Project.SelectTaskPage);
Any thoughts would be greatly appreciated. - The tool completes, but when one goes to ViewMap task the system crashes