// Validates the form values bool ValidatePolicyValues() { // Name if (string.IsNullOrWhiteSpace(nameTextBox.Text)) { AppForm.DisplayError("Retention Policy name cannot be blank."); return(false); } // Duration var duration = durationTextBox.Text; if (string.IsNullOrWhiteSpace(duration)) { AppForm.DisplayError("Duration cannot be blank. It should be an InfluxDB time interval value such as: 1d, 2h, 10m, 30s, etc."); return(false); } duration = duration.Trim(); if (!InfluxDbHelper.IsTimeIntervalValid(duration)) { AppForm.DisplayError("Duration value is invalid. It should be an InfluxDB time interval value such as: 1d, 2h, 10m, 30s, etc."); return(false); } return(true); }
// Validates the current form values bool ValidateCqValues() { try { // Validate values var cqName = nameTextBox.Text; // CQ Name if (string.IsNullOrWhiteSpace(cqName)) { AppForm.DisplayError("Continuous Query name cannot be blank."); return(false); } // Source & Destination var destination = destinationComboBox.SelectedItem as string; if (string.IsNullOrWhiteSpace(destination)) { destination = destinationComboBox.Text; } var source = sourceComboBox.SelectedItem as string; if (string.IsNullOrWhiteSpace(source)) { source = sourceComboBox.Text; } if (string.IsNullOrWhiteSpace(destination)) { AppForm.DisplayError("Destination cannot be blank."); return(false); } if (string.IsNullOrWhiteSpace(source)) { AppForm.DisplayError("Source cannot be blank."); return(false); } if (destination == source) { if (MessageBox.Show("Source is the same as the Destination. These are typically different values for a Continous Query. Are you sure that you want to have duplicate values?", "Confirm", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.No) { return(false); } } // Interval var interval = intervalTextBox.Text; if (string.IsNullOrWhiteSpace(interval)) { AppForm.DisplayError("Interval cannot be blank. It should be an InfluxDB time interval value such as: 1d, 2h, 10m, 30s, etc."); return(false); } interval = interval.Trim(); if (!InfluxDbHelper.IsTimeIntervalValid(interval)) { AppForm.DisplayError("Interval value is invalid. It should be an InfluxDB time interval value such as: 1d, 2h, 10m, 30s, etc."); return(false); } // Resample Every if (resampleCheckBox.Checked) { var resampleEvery = resampleEveryTextBox.Text; if (!string.IsNullOrWhiteSpace(resampleEvery)) { resampleEvery = resampleEvery.Trim(); if (!InfluxDbHelper.IsTimeIntervalValid(resampleEvery)) { AppForm.DisplayError("Resample Every interval value is invalid. It should be an InfluxDB time interval value such as: 1d, 2h, 10m, 30s, etc."); return(false); } } } // Resample For if (resampleCheckBox.Checked) { var resampleFor = resampleForTextBox.Text; if (!string.IsNullOrWhiteSpace(resampleFor)) { resampleFor = resampleFor.Trim(); if (!InfluxDbHelper.IsTimeIntervalValid(resampleFor)) { AppForm.DisplayError("Resample For interval value is invalid. It should be an InfluxDB time interval value such as: 1d, 2h, 10m, 30s, etc."); return(false); } } } // Subquery if (queryEditor.Text == null || queryEditor.Text.Length == 0 || queryEditor.Text == QueryEditorPlaceholderText) { AppForm.DisplayError("SubQuery cannot be blank."); return(false); } return(true); } catch (Exception ex) { AppForm.DisplayException(ex); return(false); } }
// Validates the current form values bool ValidateBackfillValues() { try { // Source & Destination var destination = destinationComboBox.SelectedItem as string; if (string.IsNullOrWhiteSpace(destination)) { destination = destinationComboBox.Text; } var source = sourceComboBox.SelectedItem as string; if (string.IsNullOrWhiteSpace(source)) { source = sourceComboBox.Text; } if (string.IsNullOrWhiteSpace(destination)) { AppForm.DisplayError("Destination cannot be blank."); return(false); } if (string.IsNullOrWhiteSpace(source)) { AppForm.DisplayError("Source cannot be blank."); return(false); } if (destination == source) { if (MessageBox.Show("Source is the same as the Destination. These are typically different values for a Backfill Query. Are you sure that you want to have duplicate values?", "Confirm", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.No) { return(false); } } // Interval var interval = intervalTextBox.Text; if (string.IsNullOrWhiteSpace(interval)) { AppForm.DisplayError("Interval cannot be blank. It should be an InfluxDB time interval value such as: 1d, 2h, 10m, 30s, etc."); return(false); } interval = interval.Trim(); if (!InfluxDbHelper.IsTimeIntervalValid(interval)) { AppForm.DisplayError("Interval value is invalid. It should be an InfluxDB time interval value such as: 1d, 2h, 10m, 30s, etc."); return(false); } // From/To time var fromTime = fromDateTimePicker.Value; var toTime = toDateTimePicker.Value; if (fromTime >= toTime) { AppForm.DisplayError("'From Time' is later than 'To Time'. 'From Time' should come before 'To Time'."); return(false); } // Subquery if (queryEditor.Text == null || queryEditor.Text.Length == 0 || queryEditor.Text == QueryEditorPlaceholderText) { AppForm.DisplayError("SubQuery cannot be blank."); return(false); } return(true); } catch (Exception ex) { AppForm.DisplayException(ex); return(false); } }