Microsoft.VisualStudio.R.Package.DataInspect.DataImport.ImportDataWindow.DoDefaultAction C# (CSharp) Method

DoDefaultAction() private method

private DoDefaultAction ( ) : System.Threading.Tasks.Task
return System.Threading.Tasks.Task
        private async Task DoDefaultAction() {
            await VsAppShell.Current.SwitchToMainThreadAsync();
            RunButton.IsEnabled = CancelButton.IsEnabled = false;
            var result = false;

            try {
                int cp = GetSelectedValueAsInt(EncodingComboBox);

                var nRowsString = NRowsTextBox.Text;
                int nrows = Int32.MaxValue;
                if (!string.IsNullOrWhiteSpace(nRowsString)) {
                    if (!Int32.TryParse(nRowsString, out nrows) || nrows <= 0) {
                        VsAppShell.Current.ShowErrorMessage(Package.Resources.ImportData_NRowsError);
                        return;
                    }
                    nrows++; // for possible header
                }

                await ConvertToUtf8(FilePathBox.Text, cp, true, nrows);
                ProgressBarText.Text = Package.Resources.Importing;

                var expression = BuildCommandLine(false);
                if (expression != null) {
                    // TODO: this may take a while and must be cancellable
                    result = Execute(expression);
                }
            } finally {
                if (result) {
                    Close();
                } else {
                    RunButton.IsEnabled = CancelButton.IsEnabled = true;
                }
            }
        }