ArcGIS Mobile 10.2 - Synchronize custom extent.

4257
7
01-30-2014 12:27 AM
IvanPobis
New Contributor III
Is in this version possible to do synchronization data just for own or current  extent? In the previous version it was. If no, please return back this possibility. There is no possible to do initial extent for small or smaller area always.

Ivan
0 Kudos
7 Replies
selcukcelik
New Contributor
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.
0 Kudos
IvanPobis
New Contributor III
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.


Yes, I know, that there is possible to set the extent during publishing the project or service. But in the earlier versions In ArcGIS Mobile was possibility to publish project with larger extend of the interesting area. By the synchronization data there was possibilty to synchronize data in Full, Current or user defined extent. It was very, very usefull. I wish to return this possibility into ArcGIS Mobile back.

The reason is:
1. I may have prepared project for workers in larger area. (Base maps, etc.)
2. Field workers will be possible to download necessary data just for area, where they are going to mapping.
3. Synchronization for area of interest for field workers will be more quick.
4. After synchronization I want to clear local cache and download data for another extent.

So, one project for same data will be universal and less data will be  received/sent between mobile service an local modile cache. There is not always possible to use On-line connection.
Ivan
0 Kudos
selcukcelik
New Contributor
So, you can do all you want...

For instance, first download a specific area then synchronize it. After synchronization delete cache and download another extend. So you can synchronize just where you download... this is not enough for you?

...
MobileCacheSyncAgent agent = new MobileCacheSyncAgent(currentMobileCache, conn);
agent.DownloadExtent(envelope);
//agent.Synchronize();
...


Which extend you download so you can synchronize just this extend data...
0 Kudos
KierenTinning2
New Contributor III

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

0 Kudos
IvanPobis
New Contributor III
Yes, you are right. But, I must have my own application (Collector) and I am using standard collector ArcGIS Mobile for Mobile Device.
But I have an idea.
If I write a code as extension of ArcGIS Mobile, can I change the default extent of the project to my own using "envelope"? Original extent I will store somewhere for using initial extent if it will be necessary.

Is there possible to manipulate with original envelope which is coming from project settings, using extension ?
0 Kudos
selcukcelik
New Contributor
Theoretically yes. But I did not try. Actually you would be able to do everything for extension development what you do in normal mobile application development. we can not be sure without try 🙂
0 Kudos
selcukcelik
New Contributor
By the way, you should upload your data with "FeatureSyncAgent" after download and finished the editing. also you should set direction of synchronization with this method as upload.

I mean download with "MobileCacheSyncAgent" for custom extend and then use "FeatureSyncAgent" to upload data back.

Regards...
0 Kudos