Пример #1
0
        // Handles test connection button click
        private async void testButton_Click(object sender, EventArgs e)
        {
            try
            {
                // Create a new InfluxDB client
                var client = InfluxDbClientFactory.Create(CreateConnection());

                // Test the connection by requesting a list of databases
                if (!string.IsNullOrWhiteSpace(client.Connection.Database))
                {
                    // If a single database was specified, query the database
                    var response = await client.GetMeasurementNamesAsync(client.Connection.Database);

                    MessageBox.Show("Connection Successful!", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    // If no single database was specified, query all databases
                    var response = await client.GetDatabaseNamesAsync();

                    MessageBox.Show("Connection Successful!", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            catch (Exception ex)
            {
                AppForm.DisplayException(ex, "Failure");
            }
        }
Пример #2
0
        // Handles ping connection button click
        private async void pingButton_Click(object sender, EventArgs e)
        {
            try
            {
                // Create a new InfluxDB client
                var client = InfluxDbClientFactory.Create(CreateConnection());

                // Test the connection by pinging the server
                var response = await client.PingAsync();

                if (!response.Success)
                {
                    throw new Exception("There was an error connecting to the server.");
                }
                var message = string.Format("Response Time: {0:0} ms\nInfluxDB Version: {1}", response.ResponseTime.TotalMilliseconds, response.Version);
                MessageBox.Show(message, "Pong", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            catch (Exception ex)
            {
                AppForm.DisplayException(ex, "Failure");
            }
        }