Пример #1
0
 internal void Execute(string query, QueryParams parameters)
 {
     EnableUi(false);
     parameters.Hash = ((TabPageHolder)tabControl1.SelectedTab).GetDataView().GetHashCode();
     if (parameters.Sql == null)
     {
         if (!string.IsNullOrWhiteSpace(query))
         {
             this.queryExecutor.Execute(core.sql.Utils.convert(Firedump.core.sql.Utils.GetDbTypeEnum(base.GetSqlConnection()), query),
                                        this.GetSqlConnection(), parameters, this.GetMainHome().IsContinueExecutingOnFail());
         }
         else
         {
             StatementExecuted?.Invoke(this, new ExecutionQueryEvent(Status.FINISHED));
         }
     }
     else
     {
         //case of lazy fetch
         this.queryExecutor.Execute(new List <string>()
         {
             parameters.Sql
         }, this.GetSqlConnection(), parameters, this.GetMainHome().IsContinueExecutingOnFail());
     }
 }
Пример #2
0
 internal void OnStatementExecuted(object t, ExecutionQueryEvent e)
 {
     StatementExecuted?.Invoke(t, e);
     if (e.Status != Status.RUNNING && this.queryThread != null)
     {
         lock (this.queryThread)
         {
             this.queryThread.StatementExecuted -= OnStatementExecuted;
             this.queryThread = null;
         }
     }
 }
Пример #3
0
        internal void ExecuteCurrent(bool moveToNext = false)
        {
            var tb = GetSelectedTabEditor();

            core.sql.Utils.selectCurrent(tb, moveToNext);
            if (tb != null && !string.IsNullOrEmpty(tb.SelectedText))
            {
                ExecuteScript(null);
            }
            else
            {
                StatementExecuted?.Invoke(this, new ExecutionQueryEvent(Status.FINISHED));
            }
        }
Пример #4
0
        internal void OpenFile()
        {
            OpenFileDialog ofd = new OpenFileDialog();

            if (ofd.ShowDialog() == DialogResult.OK)
            {
                var fileInfo = FileIO.FileInfo(ofd.FileName);
                if (fileInfo != null)
                {
                    long bytes = fileInfo.Length;
                    if (bytes > 10_000_000)
                    {
                        var form = new LargeFileForm(bytes, ofd.FileName);
                        form.ShowDialog();
                        if (form.openExecute == OpenExecute.OPEN)
                        {
                            AddQueryTab(" ", ofd.FileName, true);
                            try
                            {
                                GetSelectedTabEditor().OpenBindingFile(ofd.FileName, System.Text.Encoding.UTF8);
                            }
                            catch (IOException ex) { /*case try to re open same binding file again or a locked opened file*/ }
                        }
                        else if (form.openExecute == OpenExecute.EXECUTE)
                        {
                            if (DB.IsConnectedToDatabaseAndAfterReconnect(this))
                            {
                                new ExecuteScriptForm(GetSqlConnection(), ofd.FileName).Show();
                            }
                            else
                            {
                                StatementExecuted?.Invoke(this, new ExecutionQueryEvent(Status.FINISHED));
                            }
                        }
                    }
                    else
                    {
                        var text = FileIO.ReadAllText(ofd.FileName);
                        if (text != null)
                        {
                            AddQueryTab(text, ofd.FileName, true);
                        }
                    }
                }
            }
        }
Пример #5
0
 internal void Start(List <string> statements, DbConnection con, QueryParams parameters)
 {
     if (this._thread == null || (this._thread != null && this._thread.ThreadState == ThreadState.Stopped))
     {
         this.QueryParams = parameters;
         this.statements  = statements;
         this._con        = con;
         this._thread     = new Thread(new ThreadStart(run));
         this._thread.Start();
     }
     else
     {
         StatementExecuted?.Invoke(this, new ExecutionQueryEvent(models.dbinfo.Status.HIDDEN)
         {
         });
     }
 }
Пример #6
0
 internal void Abort()
 {
     if (this.queryThread != null)
     {
         var    queryParams = this.queryThread.QueryParams;
         string query       = this.queryThread.CurrentQuery;
         lock (this.queryThread)
         {
             this.queryThread.StatementExecuted -= OnStatementExecuted;
             this.queryThread.Abort();
             this.queryThread = null;
         }
         StatementExecuted?.Invoke(this, new ExecutionQueryEvent(Status.ABORTED)
         {
             QueryParams = queryParams, TAG = queryParams.Hash, query = query
         });
     }
 }
Пример #7
0
        internal void ExecuteScript(QueryParams parameters)
        {
            var tb = GetSelectedTabEditor();

            if (tb != null && DB.IsConnectedToDatabaseAndAfterReconnect(this))
            {
                if (parameters == null)
                {
                    parameters = new QueryParams()
                    {
                        Limit  = GetMainHome().GetLimitFromToolStripComboBoxLimit(),
                        Offset = 0,
                    };
                }
                Execute(StringUtils.SelectedTextOrTabText(tb.SelectedText, tb.Text), parameters);
            }
            else
            {
                StatementExecuted?.Invoke(this, new ExecutionQueryEvent(Status.FINISHED));
            }
        }
Пример #8
0
        private void OnStatementExecuted(object sender, ExecutionQueryEvent e)
        {
            StatementExecuted?.Invoke(sender, e);
            if (e.Status == Status.HIDDEN)
            {
                return;
            }
            else if (e.Status == Status.ABORTED)
            {
                this.Invoke((MethodInvoker) delegate
                {
                    base.GetMainHome().AbandonAndOpenNewConnection();
                });
            }
            foreach (TabPageHolder dv in tabControl1.Controls)
            {
                if (dv.GetDataView().GetHashCode() == e.TAG)
                {
                    this.Invoke((MethodInvoker) delegate
                    {
                        if (e.Status == Status.FINISHED && e.QueryParams.Sql == null)
                        {
                            dv.GetDataView().SetData(e.data, e.query);
                        }
                        else if (e.Status == Status.FINISHED && e.QueryParams.Sql != null)
                        {
                            dv.GetDataView().AppendData(e.data);
                        }

                        if (e.QueryParams.Sql == null || e.Status == Status.ABORTED || e.Status == Status.CANCELED)
                        {
                            dv.GetDataView().SetHistory(e);
                        }
                    });
                    break;
                }
            }
        }
Пример #9
0
 protected virtual void OnStatementExecuted(object t, ExecutionQueryEvent e)
 {
     StatementExecuted?.Invoke(t, e);
 }