Beispiel #1
0
        /// <summary>
        /// Event delegate method fired when the <see cref="InstanceMonitorIntervalUOMComboBox"/> selected index changes.
        /// </summary>
        /// <param name="sender">Sender object.</param>
        /// <param name="e">Event arguments.</param>
        private void InstanceMonitorIntervalUOMComboBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (_selectedItem == null || !(_selectedItem is MySqlInstance))
            {
                return;
            }

            MySqlInstance selectedInstance = _selectedItem as MySqlInstance;

            selectedInstance.MonitoringIntervalUnitOfMeasure = (TimeUtilities.IntervalUnitOfMeasure)InstanceMonitorIntervalUOMComboBox.SelectedIndex;
            _instancesHaveChanges = true;
        }
Beispiel #2
0
        /// <summary>
        /// Event delegate method fired when the <see cref="InstanceMonitorIntervalNumericUpDown"/> value changes.
        /// </summary>
        /// <param name="sender">Sender object.</param>
        /// <param name="e">Event arguments.</param>
        private void InstanceMonitorIntervalNumericUpDown_ValueChanged(object sender, EventArgs e)
        {
            if (_selectedItem == null || !(_selectedItem is MySqlInstance))
            {
                return;
            }

            MySqlInstance selectedInstance = _selectedItem as MySqlInstance;

            selectedInstance.MonitoringInterval = (uint)InstanceMonitorIntervalNumericUpDown.Value;
            _instancesHaveChanges = true;
        }
Beispiel #3
0
        /// <summary>
        /// Adds an instance to the list of instances.
        /// </summary>
        /// <param name="instance">Instance to add.</param>
        /// <param name="setPage">Flag indicating if the Instances tab must be focused.</param>
        private void AddInstance(MySqlInstance instance, bool setPage)
        {
            var newItem = new ListViewItem(instance.DisplayConnectionSummaryText)
            {
                Tag = instance
            };

            newItem.SubItems.Add(instance.WorkbenchConnection.ConnectionMethod.GetDescription());
            newItem.SubItems.Add(instance.ConnectionStatusText);
            MonitoredInstancesListView.Items.Add(newItem);
            if (!setPage)
            {
                return;
            }

            ItemsTabControl.SelectedIndex = 1;
            newItem.Selected = true;
        }
Beispiel #4
0
        /// <summary>
        /// Event delegate method fired when the <see cref="UpdateTrayIconCheckBox"/> checked status changes.
        /// </summary>
        /// <param name="sender">Sender object.</param>
        /// <param name="e">Event arguments.</param>
        private void UpdateTrayIconCheckBox_CheckedChanged(object sender, EventArgs e)
        {
            if (_selectedItem == null)
            {
                return;
            }

            if (_selectedItem is MySqlService)
            {
                MySqlService selectedService = _selectedItem as MySqlService;
                selectedService.UpdateTrayIconOnStatusChange = UpdateTrayIconCheckBox.Checked;
                _servicesHaveChanges = true;
            }
            else if (_selectedItem is MySqlInstance)
            {
                MySqlInstance selectedInstance = _selectedItem as MySqlInstance;
                selectedInstance.UpdateTrayIconOnStatusChange = UpdateTrayIconCheckBox.Checked;
                _instancesHaveChanges = true;
            }
        }
Beispiel #5
0
        /// <summary>
        /// Event delegate method fired when the <see cref="NotifyOnStatusChangeCheckBox"/> checked status changes.
        /// </summary>
        /// <param name="sender">Sender object.</param>
        /// <param name="e">Event arguments.</param>
        private void NotifyOnStatusChangeCheckBox_CheckedChanged(object sender, EventArgs e)
        {
            if (_selectedItem == null)
            {
                return;
            }

            if (_selectedItem is MySqlService)
            {
                MySqlService selectedService = _selectedItem as MySqlService;
                selectedService.NotifyOnStatusChange = NotifyOnStatusChangeCheckBox.Checked;
                _servicesHaveChanges = true;
            }
            else if (_selectedItem is MySqlInstance)
            {
                MySqlInstance selectedInstance = _selectedItem as MySqlInstance;
                selectedInstance.MonitorAndNotifyStatus = NotifyOnStatusChangeCheckBox.Checked;
                _instancesHaveChanges = true;
            }
        }
Beispiel #6
0
        /// <summary>
        /// Sets the availability of controls related to services or instances based on the selected item.
        /// </summary>
        private void SetDialogControlsAvailability()
        {
            DeleteButton.Enabled = _selectedItem != null;
            NotifyOnStatusChangeCheckBox.Enabled = DeleteButton.Enabled;
            UpdateTrayIconCheckBox.Enabled       = DeleteButton.Enabled;

            if (_selectedItem == null)
            {
                NotifyOnStatusChangeCheckBox.Checked         = false;
                UpdateTrayIconCheckBox.Checked               = false;
                InstanceMonitorIntervalNumericUpDown.Value   = 0;
                InstanceMonitorIntervalNumericUpDown.Enabled = false;
                InstanceMonitorIntervalUOMComboBox.Text      = string.Empty;
                InstanceMonitorIntervalUOMComboBox.Enabled   = false;
            }
            else if (_selectedItem is MySqlService)
            {
                MySqlService service = _selectedItem as MySqlService;
                NotifyOnStatusChangeCheckBox.Checked         = service.NotifyOnStatusChange;
                UpdateTrayIconCheckBox.Checked               = service.UpdateTrayIconOnStatusChange;
                InstanceMonitorIntervalNumericUpDown.Value   = 0;
                InstanceMonitorIntervalNumericUpDown.Enabled = false;
                InstanceMonitorIntervalUOMComboBox.Text      = string.Empty;
                InstanceMonitorIntervalUOMComboBox.Enabled   = false;
            }
            else if (_selectedItem is MySqlInstance)
            {
                MySqlInstance instance = _selectedItem as MySqlInstance;
                NotifyOnStatusChangeCheckBox.Checked             = instance.MonitorAndNotifyStatus;
                UpdateTrayIconCheckBox.Checked                   = instance.UpdateTrayIconOnStatusChange;
                InstanceMonitorIntervalNumericUpDown.Enabled     = true;
                InstanceMonitorIntervalNumericUpDown.Value       = instance.MonitoringInterval;
                InstanceMonitorIntervalUOMComboBox.Enabled       = true;
                InstanceMonitorIntervalUOMComboBox.SelectedIndex = (int)instance.MonitoringIntervalUnitOfMeasure;
            }
        }
Beispiel #7
0
 /// <summary>
 /// Initializes a new instance of the <see cref="InstanceStatusChangedArgs"/> class.
 /// </summary>
 /// <param name="instance">MySQL instance whose status changed.</param>
 /// <param name="oldInstanceStatus">Old instance status.</param>
 public InstanceStatusChangedArgs(MySqlInstance instance, MySqlWorkbenchConnection.ConnectionStatusType oldInstanceStatus)
 {
     Instance          = instance;
     OldInstanceStatus = oldInstanceStatus;
 }
Beispiel #8
0
        /// <summary>
        /// Event delegate method fired when the <see cref="MySQLInstanceToolStripMenuItem"/> context menu item is clicked.
        /// </summary>
        /// <param name="sender">Sender object.</param>
        /// <param name="e">Event arguments.</param>
        private void MySQLInstanceToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Cursor.Current = Cursors.WaitCursor;
            MonitoredServicesListView.BeginUpdate();
            MySqlWorkbenchConnection selectedConnection = null;

            using (var monitorInstancesDialog = new MonitorMySqlServerInstancesDialog(MachinesList, InstancesList))
            {
                if (monitorInstancesDialog.ShowDialog() == DialogResult.OK)
                {
                    selectedConnection = monitorInstancesDialog.SelectedWorkbenchConnection;
                    if (selectedConnection != null)
                    {
                        bool connectionAlreadyInInstance = false;

                        // If the selected connection exists for an already monitored instance but it is not its main connection, replace the main connection with this one.
                        foreach (var instance in InstancesList.Where(inst => inst.RelatedConnections.Exists(conn => conn.Id == selectedConnection.Id)))
                        {
                            if (selectedConnection.ConnectionStatus == MySqlWorkbenchConnection.ConnectionStatusType.Unknown)
                            {
                                Exception ex;
                                selectedConnection.TestConnectionSilently(out ex);
                            }

                            instance.WorkbenchConnection = selectedConnection;
                            connectionAlreadyInInstance  = true;
                            foreach (ListViewItem lvi in MonitoredInstancesListView.Items)
                            {
                                MySqlInstance existingInstance = lvi.Tag as MySqlInstance;
                                if (existingInstance != instance)
                                {
                                    continue;
                                }

                                lvi.Text             = instance.HostIdentifier;
                                lvi.SubItems[1].Text = instance.WorkbenchConnection.ConnectionMethod.GetDescription();
                                lvi.SubItems[2].Text = instance.ConnectionStatusText;
                                break;
                            }

                            break;
                        }

                        if (!connectionAlreadyInInstance)
                        {
                            MySqlInstance newInstance = new MySqlInstance(selectedConnection);
                            InstancesList.Add(newInstance);
                            AddInstance(newInstance, true);
                            InstancesList.SaveToFile();
                        }
                    }
                }

                // Workbench connections may have been edited so we may need to refresh the items in the list.
                foreach (ListViewItem lvi in MonitoredInstancesListView.Items)
                {
                    var existingInstance = lvi.Tag as MySqlInstance;
                    if (existingInstance == null || (selectedConnection != null && existingInstance.WorkbenchConnection.Id == selectedConnection.Id))
                    {
                        continue;
                    }

                    var connectionInDisk = MySqlWorkbench.Connections.GetConnectionForId(existingInstance.WorkbenchConnection.Id);
                    if (connectionInDisk == null || connectionInDisk.Equals(existingInstance.WorkbenchConnection))
                    {
                        continue;
                    }

                    lvi.Text             = connectionInDisk.HostIdentifier;
                    lvi.SubItems[1].Text = connectionInDisk.ConnectionMethod.GetDescription();
                    lvi.SubItems[2].Text = connectionInDisk.ConnectionStatusText;
                }

                InstancesListChanged = monitorInstancesDialog.InstancesListChanged;
            }

            MonitoredServicesListView.EndUpdate();
            Cursor.Current = Cursors.Default;
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="InstanceConnectionStatusTestErrorThrownArgs"/> class.
 /// </summary>
 /// <param name="instance">MySQL instance whose status changed.</param>
 /// <param name="ex">Exception thrown during a connection status test.</param>
 public InstanceConnectionStatusTestErrorThrownArgs(MySqlInstance instance, Exception ex)
 {
     Instance       = instance;
     ErrorException = ex;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="InstanceStatusChangedArgs"/> class.
 /// </summary>
 /// <param name="instance">MySQL instance that caused the list change.</param>
 /// <param name="listChange">Type of change done to the list.</param>
 public InstancesListChangedArgs(MySqlInstance instance, ListChangedType listChange)
 {
     Instance   = instance;
     ListChange = listChange;
 }