public async void Connect(TaosConnectionStringBuilder connectionString) { lblCursor.Text = Resources.Opening + connectionString.DataSource; lblElapsed.Text = Resources.Reading; prgRunning.Style = ProgressBarStyle.Marquee; btnConnect.Enabled = false; try { _db = await this.AsyncConnect(connectionString); // force open database var uv = _db.ServerVersion; } catch (Exception ex) { _db?.Dispose(); _db = null; MessageBox.Show(ex.Message, Resources.Error, MessageBoxButtons.OK, MessageBoxIcon.Error); return; } finally { lblCursor.Text = ""; lblElapsed.Text = ""; prgRunning.Style = ProgressBarStyle.Blocks; btnConnect.Enabled = true; } btnConnect.Enabled = true; lblCursor.Text = ""; prgRunning.Style = ProgressBarStyle.Blocks; _connectionString = connectionString; _codeCompletion.UpdateCodeCompletion(_db); btnConnect.Text = Resources.Disconnect; this.UIState(true); tabSql.TabPages.Add("+", "+"); this.LoadTreeView(); this.AddNewTab("(none)", ""); txtSql.Focus(); }
public MainForm(Maikebing.Data.Taos.TaosConnectionStringBuilder taosConnection) { InitializeComponent(); // For performance https://stackoverflow.com/questions/4255148/how-to-improve-painting-performance-of-datagridview grdResult.DoubleBuffered(true); _synchronizationContext = SynchronizationContext.Current; _codeCompletion = new SqlCodeCompletion(txtSql, imgCodeCompletion); if (taosConnection == null) { this.Disconnect(); } else { this.Connect(taosConnection); } txtSql.ActiveTextAreaControl.TextArea.Caret.PositionChanged += (s, e) => { if (this.ActiveTask == null) { return; } this.ActiveTask.EditorContent = txtSql.Text; this.ActiveTask.SelectedTab = tabResult.SelectedTab.Name; this.ActiveTask.Position = new Tuple <int, int>(txtSql.ActiveTextAreaControl.TextArea.Caret.Line, txtSql.ActiveTextAreaControl.TextArea.Caret.Column); lblCursor.Text = $"Line: {(txtSql.ActiveTextAreaControl.Caret.Line + 1)} - Column: {(txtSql.ActiveTextAreaControl.Caret.Column + 1)}"; }; // stop all threads this.FormClosing += (s, e) => { if (_db != null) { this.Disconnect(); } }; // set assembly version on window title this.Text += $" (v.{typeof(MainForm).Assembly.GetName().Version.ToString()}) - (TDengine v.{typeof(TaosConnection).Assembly.GetName().Version.ToString()})"; }
/// <summary> /// Initializes a new instance of the <see cref="TaosConnection" /> class. /// </summary> /// <param name="connectionString">The string used to open the connection.</param> /// <seealso cref="TaosConnectionStringBuilder" /> public TaosConnection(string connectionString) : this() { ConnectionStringBuilder = new TaosConnectionStringBuilder(connectionString); ConnectionString = connectionString; }