private async void StopEditTransaction(object sender, EventArgs e)
        {
            // Ask the user if they want to commit or rollback the transaction (or cancel to keep working in the transaction)
            string choice = await((Page)Parent).DisplayActionSheet("Transaction", "Cancel", null, "Commit", "Rollback");

            if (choice == "Commit")
            {
                // See if there is a transaction active for the geodatabase
                if (_localGeodatabase.IsInTransaction)
                {
                    // If there is, commit the transaction to store the edits (this will also end the transaction)
                    _localGeodatabase.CommitTransaction();
                    MessageTextBlock.Text = "Edits were committed to the local geodatabase.";
                }
            }
            else if (choice == "Rollback")
            {
                // See if there is a transaction active for the geodatabase
                if (_localGeodatabase.IsInTransaction)
                {
                    // If there is, rollback the transaction to discard the edits (this will also end the transaction)
                    _localGeodatabase.RollbackTransaction();
                    MessageTextBlock.Text = "Edits were rolled back and not stored to the local geodatabase.";
                }
            }
            else
            {
                // For 'cancel' don't end the transaction with a commit or rollback
            }
        }
        private void StopEditTransaction(object sender, RoutedEventArgs e)
        {
            // Ask the user if they want to commit or rollback the transaction (or cancel to keep working in the transaction)
            MessageBoxResult commitAnswer = MessageBox.Show("Commit your edits? ('No' to discard)", "Stop Editing", MessageBoxButton.YesNoCancel);

            if (commitAnswer == MessageBoxResult.Yes)
            {
                // See if there is a transaction active for the geodatabase
                if (_localGeodatabase.IsInTransaction)
                {
                    // If there is, commit the transaction to store the edits (this will also end the transaction)
                    _localGeodatabase.CommitTransaction();
                    MessageTextBlock.Text = "Edits were committed to the local geodatabase.";
                }
            }
            else if (commitAnswer == MessageBoxResult.No)
            {
                // See if there is a transaction active for the geodatabase
                if (_localGeodatabase.IsInTransaction)
                {
                    // If there is, rollback the transaction to discard the edits (this will also end the transaction)
                    _localGeodatabase.RollbackTransaction();
                    MessageTextBlock.Text = "Edits were rolled back and not stored to the local geodatabase.";
                }
            }
            else
            {
                // For 'cancel' don't end the transaction with a commit or rollback
            }
        }
        private void StopEditTransaction(object sender, EventArgs e)
        {
            // Create an alert to ask the user if they want to commit or rollback the transaction (or cancel to keep working in the transaction)
            UIAlertController endTransactionAlertController = UIAlertController.Create("Stop Editing", "Commit your edits or roll back?", UIAlertControllerStyle.Alert);

            // Action when user chooses to commit
            endTransactionAlertController.AddAction(UIAlertAction.Create("Commit", UIAlertActionStyle.Default,
                                                                         alert => {
                // See if there is a transaction active for the geodatabase
                if (_localGeodatabase.IsInTransaction)
                {
                    // If there is, commit the transaction to store the edits (this will also end the transaction)
                    _localGeodatabase.CommitTransaction();
                    _messageTextBlock.Text = "Edits were committed to the local geodatabase.";
                }
            }));

            // Action when user chooses to rollback
            endTransactionAlertController.AddAction(UIAlertAction.Create("Rollback", UIAlertActionStyle.Default,
                                                                         alert => {
                // See if there is a transaction active for the geodatabase
                if (_localGeodatabase.IsInTransaction)
                {
                    // If there is, rollback the transaction to discard the edits (this will also end the transaction)
                    _localGeodatabase.RollbackTransaction();
                    _messageTextBlock.Text = "Edits were rolled back and not stored to the local geodatabase.";
                }
            }));

            // Action for cancel (ignore)
            endTransactionAlertController.AddAction(UIAlertAction.Create("Cancel", UIAlertActionStyle.Cancel, null));

            // Present the alert to the user
            PresentViewController(endTransactionAlertController, true, null);
        }
Beispiel #4
0
        private async void StopEditTransaction(object sender, RoutedEventArgs e)
        {
            // Create a new dialog that prompts for commit, rollback, or cancel
            MessageDialog promptDialog    = new MessageDialog("Commit your edits to the local geodatabase or rollback to discard them.", "Stop Editing");
            UICommand     commitCommand   = new UICommand("Commit");
            UICommand     rollbackCommand = new UICommand("Rollback");
            UICommand     cancelCommand   = new UICommand("Cancel");

            promptDialog.Options = MessageDialogOptions.None;
            promptDialog.Commands.Add(commitCommand);
            promptDialog.Commands.Add(rollbackCommand);
            promptDialog.Commands.Add(cancelCommand);

            // Ask the user if they want to commit or rollback the transaction (or cancel to keep working in the transaction)
            IUICommand cmd = await promptDialog.ShowAsync();

            if (cmd == commitCommand)
            {
                // See if there is a transaction active for the geodatabase
                if (_localGeodatabase.IsInTransaction)
                {
                    // If there is, commit the transaction to store the edits (this will also end the transaction)
                    _localGeodatabase.CommitTransaction();
                    MessageTextBlock.Text = "Edits were committed to the local geodatabase.";
                }
            }
            else if (cmd == rollbackCommand)
            {
                // See if there is a transaction active for the geodatabase
                if (_localGeodatabase.IsInTransaction)
                {
                    // If there is, rollback the transaction to discard the edits (this will also end the transaction)
                    _localGeodatabase.RollbackTransaction();
                    MessageTextBlock.Text = "Edits were rolled back and not stored to the local geodatabase.";
                }
            }
            else
            {
                // For 'cancel' don't end the transaction with a commit or rollback
            }
        }
Beispiel #5
0
        private void StopEditTransaction(object sender, EventArgs e)
        {
            // Create a dialog to prompt the user to commit or rollback
            AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(this);

            // Create the layout
            LinearLayout dialogLayout = new LinearLayout(this)
            {
                Orientation = Orientation.Vertical
            };

            // Create a button to commit edits
            Button commitButton = new Button(this)
            {
                Text = "Commit"
            };

            // Handle the click event for the Commit button
            commitButton.Click += (s, args) =>
            {
                // See if there is a transaction active for the geodatabase
                if (_localGeodatabase.IsInTransaction)
                {
                    // If there is, commit the transaction to store the edits (this will also end the transaction)
                    _localGeodatabase.CommitTransaction();
                    _messageTextBlock.Text = "Edits were committed to the local geodatabase.";
                }

                _stopEditDialog.Dismiss();
            };

            // Create a button to rollback edits
            Button rollbackButton = new Button(this)
            {
                Text = "Rollback"
            };

            // Handle the click event for the Rollback button
            rollbackButton.Click += (s, args) =>
            {
                // See if there is a transaction active for the geodatabase
                if (_localGeodatabase.IsInTransaction)
                {
                    // If there is, rollback the transaction to discard the edits (this will also end the transaction)
                    _localGeodatabase.RollbackTransaction();
                    _messageTextBlock.Text = "Edits were rolled back and not stored to the local geodatabase.";
                }

                _stopEditDialog.Dismiss();
            };

            // Create a button to cancel and return to the transaction
            Button cancelButton = new Button(this)
            {
                Text = "Cancel"
            };

            // Handle the click event for the Cancel button
            rollbackButton.Click += (s, args) => _stopEditDialog.Dismiss();

            // Add the controls to the dialog
            dialogLayout.AddView(cancelButton);
            dialogLayout.AddView(rollbackButton);
            dialogLayout.AddView(commitButton);
            dialogBuilder.SetView(dialogLayout);
            dialogBuilder.SetTitle("Stop Editing");

            // Show the dialog
            _stopEditDialog = dialogBuilder.Show();
        }