Example #1
0
        // Synchronize edits in the local geodatabase with the service.
        private async void SynchronizeEdits(object sender, EventArgs e)
        {
            // Show the progress bar while the sync is working.
            _progressBar.Hidden = false;

            try
            {
                // Create a sync task with the URL of the feature service to sync.
                GeodatabaseSyncTask syncTask = await GeodatabaseSyncTask.CreateAsync(new Uri(SyncServiceUrl));

                // Create sync parameters.
                SyncGeodatabaseParameters taskParameters = await syncTask.CreateDefaultSyncGeodatabaseParametersAsync(_localGeodatabase);

                // Create a synchronize geodatabase job, pass in the parameters and the geodatabase.
                SyncGeodatabaseJob job = syncTask.SyncGeodatabase(taskParameters, _localGeodatabase);

                // Handle the JobChanged event for the job.
                job.JobChanged += (s, arg) =>
                {
                    InvokeOnMainThread(() =>
                    {
                        // Update the progress bar.
                        UpdateProgressBar(job.Progress);

                        switch (job.Status)
                        {
                        // Report changes in the job status.
                        case JobStatus.Succeeded:
                            _statusLabel.Text   = "Synchronization is complete!";
                            _progressBar.Hidden = true;
                            break;

                        case JobStatus.Failed:
                            // Report failure.
                            _statusLabel.Text   = job.Error.Message;
                            _progressBar.Hidden = true;
                            break;

                        default:
                            _statusLabel.Text = "Sync in progress ...";
                            break;
                        }
                    });
                };

                // Await the completion of the job.
                await job.GetResultAsync();
            }
            catch (Exception ex)
            {
                // Show the message if an exception occurred.
                _statusLabel.Text = "Error when synchronizing: " + ex.Message;
            }
        }
Example #2
0
        // Synchronize edits in the local geodatabase with the service
        public async void SynchronizeEdits(object sender, EventArgs e)
        {
            // Show the progress bar while the sync is working
            _progressBar.Visibility = Android.Views.ViewStates.Visible;

            try
            {
                // Create a sync task with the URL of the feature service to sync
                GeodatabaseSyncTask syncTask = await GeodatabaseSyncTask.CreateAsync(new Uri(SyncServiceUrl));

                // Create sync parameters
                SyncGeodatabaseParameters taskParameters = await syncTask.CreateDefaultSyncGeodatabaseParametersAsync(_localGeodatabase);

                // Create a synchronize geodatabase job, pass in the parameters and the geodatabase
                SyncGeodatabaseJob job = syncTask.SyncGeodatabase(taskParameters, _localGeodatabase);

                // Handle the JobChanged event for the job
                job.JobChanged += (s, arg) =>
                {
                    RunOnUiThread(() =>
                    {
                        // Update the progress bar
                        UpdateProgressBar(job.Progress);

                        // Report changes in the job status
                        if (job.Status == JobStatus.Succeeded)
                        {
                            _messageTextBlock.Text  = "Synchronization is complete!";
                            _progressBar.Visibility = Android.Views.ViewStates.Gone;
                        }
                        else if (job.Status == JobStatus.Failed)
                        {
                            // Report failure ...
                            _messageTextBlock.Text  = job.Error.Message;
                            _progressBar.Visibility = Android.Views.ViewStates.Gone;
                        }
                        else
                        {
                            // Report that the job is in progress ...
                            _messageTextBlock.Text = "Sync in progress ...";
                        }
                    });
                };

                // Await the completion of the job
                await job.GetResultAsync();
            }
            catch (Exception ex)
            {
                // Show the message if an exception occurred
                _messageTextBlock.Text = "Error when synchronizing: " + ex.Message;
            }
        }
Example #3
0
        ////////////////////////////////////////////////////////////////
        // 同期
        ////////////////////////////////////////////////////////////////

        /**
         * サーバー(AGOL)と同期する
         * ① 同期タスクを作成する
         * ② 同期パラメータを取得する
         **/
        private async void OnSyncClick(object sender, RoutedEventArgs e)
        {
            // 同期したいレイヤーでタスクオブジェクトを作成する
            geodatabaseSyncTask = await GeodatabaseSyncTask.CreateAsync(new Uri(FEATURELAYER_SERVICE_URL));

            readGeoDatabase();

            // タスクオブジェクトから同期するためのパラメータを作成する
            syncParams = await geodatabaseSyncTask.CreateDefaultSyncGeodatabaseParametersAsync(geodatabase);

            // パラーメータを使用してgeodatabaseを同期する
            syncGeodatabase();
        }
        // Synchronize edits in the local geodatabase with the service
        public async void SynchronizeEdits(object sender, EventArgs e)
        {
            // Show the progress bar while the sync is working
            LoadingProgressBar.IsVisible = true;

            try
            {
                // Create a sync task with the URL of the feature service to sync
                GeodatabaseSyncTask syncTask = await GeodatabaseSyncTask.CreateAsync(new Uri(SyncServiceUrl));

                // Create sync parameters
                SyncGeodatabaseParameters taskParameters = await syncTask.CreateDefaultSyncGeodatabaseParametersAsync(_localGeodatabase);

                // Create a synchronize geodatabase job, pass in the parameters and the geodatabase
                SyncGeodatabaseJob job = syncTask.SyncGeodatabase(taskParameters, _localGeodatabase);

                // Handle the JobChanged event for the job
                job.JobChanged += (s, arg) =>
                {
                    // Report changes in the job status
                    if (job.Status == JobStatus.Succeeded)
                    {
                        // Report success ...
                        Device.BeginInvokeOnMainThread(() => MessageTextBlock.Text = "Synchronization is complete!");
                    }
                    else if (job.Status == JobStatus.Failed)
                    {
                        // Report failure ...
                        Device.BeginInvokeOnMainThread(() => MessageTextBlock.Text = job.Error.Message);
                    }
                    else
                    {
                        // Report that the job is in progress ...
                        Device.BeginInvokeOnMainThread(() => MessageTextBlock.Text = "Sync in progress ...");
                    }
                };

                // Await the completion of the job
                await job.GetResultAsync();
            }
            catch (Exception ex)
            {
                // Show the message if an exception occurred
                MessageTextBlock.Text = "Error when synchronizing: " + ex.Message;
            }
            finally
            {
                // Hide the progress bar when the sync job is complete
                LoadingProgressBar.IsVisible = false;
            }
        }
Example #5
0
        private async Task SyncDataAsync(IEnumerable <Geodatabase> syncGeodatabases, SyncDirection syncDirection)
        {
            foreach (var geodatabase in syncGeodatabases)
            {
                IReadOnlyList <SyncLayerResult> results = null;
                try
                {
                    Log.Debug($"{geodatabase.Path} about to start {syncDirection} sync");

                    if (!geodatabase.HasLocalEdits() && syncDirection == SyncDirection.Upload)
                    {
                        Log.Debug("No edits skipping sync");
                        continue;
                    }

                    Log.Debug($"ServiceUrl: {geodatabase.Source}");
                    GeodatabaseSyncTask syncTask = await GeodatabaseSyncTask.CreateAsync(geodatabase.Source);

                    SyncGeodatabaseParameters syncParameters = await syncTask.CreateDefaultSyncGeodatabaseParametersAsync(geodatabase);

                    syncParameters.GeodatabaseSyncDirection = syncDirection;

                    SyncGeodatabaseJob job = syncTask.SyncGeodatabase(syncParameters, geodatabase);

                    results = await job.GetResultAsync();

                    LogResults(results);
                }
                catch (Exception e)
                {
                    Log.Error(e.Message);
                    Log.Error($"{geodatabase.Path} did not sync");
                    if (results != null)
                    {
                        LogResults(results);
                    }
                }
            }

            if (syncDirection == SyncDirection.Bidirectional || syncDirection == SyncDirection.Download)
            {
                EventAggregator.GetEvent <SyncCompleteEvent>().Publish(SyncCompleteEventArgs.Empty);
            }
        }
        private async Task SyncGeodatabaes(SyncDirection syncDirection)
        {
            foreach (var gdbPath in BidirectionalGdbs)
            {
                Geodatabase geodatabase = null;
                IReadOnlyList <SyncLayerResult> results = null;

                try
                {
                    geodatabase = await Geodatabase.OpenAsync(gdbPath);

                    Log.Debug($"{geodatabase.Path} about to start {syncDirection} sync");

                    if (!geodatabase.HasLocalEdits() && syncDirection == SyncDirection.Upload)
                    {
                        Log.Debug("No edits skipping sync");
                        continue;
                    }

                    Log.Debug($"ServiceUrl: {geodatabase.Source}");
                    GeodatabaseSyncTask syncTask = await GeodatabaseSyncTask.CreateAsync(geodatabase.Source);

                    SyncGeodatabaseParameters syncParameters = await syncTask.CreateDefaultSyncGeodatabaseParametersAsync(geodatabase);

                    syncParameters.GeodatabaseSyncDirection = syncDirection;

                    SyncGeodatabaseJob job = syncTask.SyncGeodatabase(syncParameters, geodatabase);

                    results = await job.GetResultAsync();

                    LogResults(results);
                }
                catch (Exception e)
                {
                    Log.Error(e.Message);
                    Log.Error($"{geodatabase?.Path} did not sync");
                    LogResults(results);
                }
            }
        }