/// <summary> /// An event handler called when a new server was added. /// </summary> /// <param name="sender">The sender object.</param> /// <param name="e">The event arguments.</param> private void OnServerAdded(object sender, DbServerEventArgs e) { // Execute the code on the UI thread. this.Invoke(() => { // Add the server. this.AddServer(e.Server as DbServerSql); // Log the change. this.log.Add(this.crawler.Log.Add( LogEventLevel.Verbose, LogEventType.Success, ControlServersSql.logSource, "Database server with ID \'{0}\' and name \'{1}\' added. The server is {2}.", new object[] { e.Server.Id, e.Server.Name, this.crawler.Database.Sql.IsPrimary(e.Server) ? "primary" : "backup" })); // Hide the message. this.HideMessage(); }); }
/// <summary> /// An event handler called when a server configuration has changed. /// </summary> /// <param name="sender">The sender object.</param> /// <param name="e">The event arguments.</param> private void OnServerChanged(object sender, DbServerEventArgs e) { // Execute the code on the UI thread. this.Invoke(() => { // Update the server information. // Get the controls corresponding to this server. ServerControls controls = this.items[e.Server.Id]; // Update the server information. controls.Item.SubItems[0].Text = e.Server.Name; controls.Item.SubItems[2].Text = e.Server.State.ToString(); controls.Item.SubItems[3].Text = e.Server.Version; controls.Node.Text = this.GetServerTreeName(e.Server); // Call the selected item change event to update the buttons. this.OnServerSelectionChanged(this, e); }); }
// Private methods. /// <summary> /// An event handler called when a server configuration has changed. /// </summary> /// <param name="sender">The sender object.</param> /// <param name="e">The event arguments.</param> private void OnServerChanged(object sender, DbServerEventArgs e) { // Update the server properties. this.labelName.Text = e.Server.Name; this.labelPrimary.Text = this.crawler.Database.Sql.IsPrimary(e.Server) ? "Primary database server" : "Backup database server"; }