//======================================================================================== // GetStatementCollection() //======================================================================================== /// <summary> /// Builds a statement collection from the selected text and formats it according /// to user options. If there are more one statement, the user may be prompted /// to select a specific parse mode. /// </summary> /// <param name="parseMode">The default or explicit parse mode.</param> /// <param name="text">The text to parse into statements.</param> /// <returns>A StatementCollection of one or more formatted statements.</returns> private StatementCollection GetStatementCollection(ParseMode parseMode, string text) { var parser = new StatementParser(); StatementCollection statements = parser.Parse(text); if ((parseMode == ParseMode.None) && (statements.Count > 1)) { parseMode = (ParseMode)UserOptions.GetEnumeration( "connections/parseMode", typeof(ParseMode)); if (parseMode == ParseMode.Prompt) { var dialog = new Dialogs.AlgorithmDialog(statements.Count, false); DialogResult result = dialog.ShowDialog(this); if (result == DialogResult.Cancel) { return(null); } parseMode = dialog.Mode; if (dialog.StoreSelection) { UserOptions.SetValue("connections/parseMode", dialog.Mode.ToString()); UserOptions.Save(); } } } if (parseMode == ParseMode.Wrapped) { statements.Wrap(dbase.DefaultSchema); } else if (parseMode == ParseMode.Block) { statements.Combine(); } return(statements); }
private void Ok_OnClick(object sender, RoutedEventArgs e) { string module = $"{_product}.{_class}.{MethodBase.GetCurrentMethod().Name}()"; try { if (!_loading) { if (_saveSettings) { UserOptions.Save(); } WpfEventArgs args = new WpfEventArgs(); // Set defaults if fetch fails args.OutputValue = ""; args.Button = "Cancel"; object obj = ExecuteJavaScript("GetJSON"); if (obj != null) { string mol = obj.ToString(); if (!string.IsNullOrEmpty(mol)) { args.OutputValue = mol; args.Button = "OK"; OnButtonClick?.Invoke(this, args); } } } } catch (Exception ex) { new ReportError(Telemetry, TopLeft, module, ex).ShowDialog(); } }
//======================================================================================== // Connect() //======================================================================================== private bool Connect() { this.Cursor = Cursors.WaitCursor; this.Capture = true; EnableControls(false); var settings = new XElement("lastConnection"); string userID = userIDBox.Text.Trim(); string password = passwordBox.Text.Trim(); settings.Add(new XElement("userID", userID)); settings.Add(new XElement("mode", modeBox.Text)); if (modeBox.SelectedIndex > 0) { userID += ";DBA Privilege=" + modeBox.Text; //password += " as " + modeBox.Text; } if (localButton.Checked) { if (status != null) { status.Text = String.Format( translator.GetString("ConnectingToLocalMsg"), userID, password ); } connection = new DatabaseConnection(userID, password); settings.Add(new XElement("method", "local")); } else if (tnsButton.Checked) { string tns = tnsBox.Text.Trim(); if (status != null) { status.Text = String.Format( translator.GetString("ConnectingToTNSMsg"), tns ); } connection = new DatabaseConnection(userID, password, tns); settings.Add(new XElement("method", "tns")); settings.Add(new XElement("tns", tns)); } else { string host = hostBox.Text.Trim(); int port = int.Parse(portBox.Text.Trim()); string service = serviceBox.Text.Trim(); if (status != null) { status.Text = String.Format( translator.GetString("ConnectingToRemoteMsg"), host, port, service ); } connection = new DatabaseConnection(userID, password, host, port, service); settings.Add(new XElement("method", "remote")); settings.Add(new XElement("host", host)); settings.Add(new XElement("port", port)); settings.Add(new XElement("service", service)); } if (status != null) { status.Text = String.Empty; } if (connection != null) { try { object con = connection.OraConnection; } catch (Exception exc) { ExceptionDialog.ShowException(exc); connection = null; } } this.Capture = false; this.Cursor = Cursors.Default; if (connection != null) { UserOptions.SetValue("general/lastConnection", settings); UserOptions.Save(); return(true); } EnableControls(true); return(false); }