예제 #1
0
        public async Task RunCmd()
        {
            IsRunning = true;
            List <Dictionary <string, object> > res = null;
            string sql = SqlEditor.GetText();

            // clear existing results
            ShowResults(null);

            // run the query
            try
            {
                res = await Exec.RunSqlAsync(sql);
            }
            catch (Exception ex) when(ex?.Message?.Contains("cancel") == true)
            {
                Log.Debug("SQL execution canceled by user");
            }
            catch (Exception ex)
            {
                Log.Warn("Error executing query", ex);
                MessageBox.Show(ex.Message, "Error executing query", MessageBoxButton.OK, MessageBoxImage.Warning);
            }

            ShowResults(res);
            IsRunning = false;
        }
예제 #2
0
 /// <summary>
 /// Occurs when the user performs a double click on the error entry.
 /// </summary>
 /// <param name="entry">The selected entry</param>
 private void SqlErrorControl_OnDoubleClick(ErrorEntry entry)
 {
     // INFO: Do not remove this method. ReSharper doesn't get it, that it's used in the ui
     SqlEditor.Focus();
     SqlEditor.ScrollTo(entry.Line, entry.Column);
     SqlEditor.TextArea.Caret.Line   = entry.Line;
     SqlEditor.TextArea.Caret.Column = entry.Column;
 }
        private void ErrorBox_OnSyntaxProviderChanged(object sender, SelectionChangedEventArgs e)
        {
            var oldSql        = SqlEditor.Text;
            var caretPosition = SqlEditor.CaretIndex;

            QBuilder.SyntaxProvider = (BaseSyntaxProvider)e.AddedItems[0];
            SqlEditor.Text          = oldSql;
            SqlEditor.Focus();
            SqlEditor.CaretIndex = caretPosition;
        }
예제 #4
0
        private void ErrorBox_OnGoToErrorPosition(object sender, EventArgs e)
        {
            SqlEditor.Focus();

            if (_errorPosition == -1)
            {
                return;
            }

            if (SqlEditor.LineCount != 1)
            {
                SqlEditor.ScrollToLine(SqlEditor.GetLineIndexFromCharacterIndex(_errorPosition));
            }
            SqlEditor.CaretIndex = _errorPosition;
        }
예제 #5
0
        public override object EditValue(ITypeDescriptorContext context, System.IServiceProvider provider, object value)
        {
            IWindowsFormsEditorService svc = provider.GetService(typeof(IWindowsFormsEditorService)) as IWindowsFormsEditorService;
            string input = value as string;

            if (svc != null)
            {
                using (SqlEditor form = new SqlEditor())
                {
                    form.InitialTextBoxValue = input;
                    if (svc.ShowDialog(form) == DialogResult.OK)
                    {
                        input = form.TextBoxValue;
                    }
                }
            }
            return(input);
        }
예제 #6
0
        public void InsertTextIntoEditor(string text)
        {
            int cursor = text.IndexOf("%CURSOR%", StringComparison.Ordinal);

            if (cursor != -1)
            {
                text = text.Replace("%CURSOR%", "");
            }

            int start = SqlEditor.SelectionStart;

            SqlEditor.ReplaceSelection(text);

            if (cursor != -1)
            {
                SqlEditor.SelectionStart = start + cursor;
            }

            SqlEditor.Focus();
        }
 private void ErrorBox_OnRevertValidText(object sender, EventArgs e)
 {
     SqlEditor.Text = _lastValidSql;
     SqlEditor.Focus();
 }
 /// <summary>
 /// Sets the text of the avalon editor
 /// </summary>
 /// <param name="text">The desired text</param>
 private void SetSqlText(string text)
 {
     SqlEditor.Text = text;
     SqlEditor.ScrollToHome();
 }
예제 #9
0
        private void SqlEditTol_Click(object sender, EventArgs e)
        {
            if (sender.ToString().Contains("New"))
            {
                SqlEditor.Clear();
            }

            else if (sender.ToString().Contains("Open"))
            {
                string vSql;

                vSql = vCurrTable.QueryTable.CommandText;

                vSql = intSqlVBAEngine.RemoveBetween(vSql, '`', '`');
                vSql = vSql.Replace("/**/", "");

                SqlEditor.Text = vSql;
            }

            else if (sender.ToString().Contains("Save"))
            {
                vCurrTable.QueryTable.CommandText = intSqlVBAEngine.setSqlLimit(intSqlVBAEngine.getOdbcNameFromCell(), SqlEditor.Text);
            }

            else if (sender.ToString().Contains("Cut"))
            {
                SqlEditor.Cut();
            }

            else if (sender.ToString().Contains("Copy"))
            {
                SqlEditor.Copy();
            }

            else if (sender.ToString().Contains("Paste"))
            {
                SqlEditor.Paste();
            }

            else if (sender.ToString().Contains("Execute"))
            {
                SqlEditor.ReadOnly = true;
                SQLEditToolStrip.Focus();

                if (vCTR.TypeConnection.Contains("ODBC"))
                {
                    vCurrTable.QueryTable.CommandText = intSqlVBAEngine.setSqlLimit(intSqlVBAEngine.getOdbcNameFromObject(vCurrTable), SqlEditor.Text);
                    intSqlVBAEngine.objRefreshHistory(vCurrTable);
                }

                if (vCTR.TypeConnection.Contains("CLOUD"))
                {
                    In2SqlVBAEngineCloud.createExTable(
                        vCTR.CurrCloudName
                        , vCTR.TableName
                        , SqlEditor.Text
                        , 1
                        , vCTR.CurrCloudExTName);
                }

                SqlEditor.ReadOnly = false;
            }
        }