private void GoButtonClick(object sender, EventArgs e) { var options = new SearchGuids.Options { ConnectionString = _connectionString, Consecutive = consecutiveCheckBox.Checked, Count = (int)GuidCountUpDown.Value, Minimum = (int)minNumericUpDown.Value, Table = TableComboBox.Text }; IEnumerable <int> guids; try { guids = SearchGuids.Search(options); } catch (Exception ex) { MessageBox.Show(ex.Message); return; } var resultForm = new ResultForm(guids); resultForm.Show(); }
private void GoButtonClick(object sender, EventArgs e) { var options = new SearchGuids.Options { ConnectionString = _connectionString, Consecutive = consecutiveCheckBox.Checked, Count = (int) GuidCountUpDown.Value, Minimum = (int) minNumericUpDown.Value, Table = TableComboBox.Text }; IEnumerable<int> guids; try { guids = SearchGuids.Search(options); } catch (Exception ex) { MessageBox.Show(ex.Message); return; } var resultForm = new ResultForm(guids); resultForm.Show(); }
private void GoButtonClick(object sender, EventArgs e) { var selectedTable = TableComboBox.Text; var existingGuids = new List <int>(); try { using (var connection = new MySqlConnection(_connectionString)) { connection.Open(); using (var query = new MySqlCommand(string.Format("SELECT {0} FROM {1}", _supportedTables[selectedTable], selectedTable), connection)) using (var reader = query.ExecuteReader()) while (reader != null && reader.Read()) { existingGuids.Add(reader.GetInt32(0)); } } } catch (Exception ex) { MessageBox.Show(ex.Message); return; } var possibleGuids = Enumerable.Range(1, existingGuids.Last()); var missingGuids = possibleGuids.Except(existingGuids); IEnumerable <int> selectedMissingGuids = null; if (!missingGuids.Any()) { selectedMissingGuids = Enumerable.Range(existingGuids.Last() + 1, (int)GuidCountUpDown.Value); } else if (RandomRadio.Checked) { selectedMissingGuids = missingGuids.Take((int)GuidCountUpDown.Value); } else if (ConsecutiveRadio.Checked) { selectedMissingGuids = GetConsecutiveGuids(missingGuids.ToArray(), (int)GuidCountUpDown.Value) ?? Enumerable.Range(existingGuids.Last() + 1, (int)GuidCountUpDown.Value); } var resultForm = new ResultForm(selectedMissingGuids); resultForm.Show(); }
private void GoButtonClick(object sender, EventArgs e) { var selectedTable = TableComboBox.Text; MySqlDataReader reader = null; try { var connection = new MySqlConnection(_connectionString); connection.Open(); var query = new MySqlCommand(string.Format("SELECT {0} FROM {1}", _supportedTables[selectedTable], selectedTable), connection); reader = query.ExecuteReader(); } catch (Exception ex) { MessageBox.Show(ex.Message); } var existingGuids = new List<int>(); while (reader != null && reader.Read()) existingGuids.Add(reader.GetInt32(0)); var possibleGuids = Enumerable.Range(1, existingGuids.Last()); IEnumerable<int> missingGuids = possibleGuids.Except(existingGuids); IEnumerable<int> selectedMissingGuids = null; if (RandomRadio.Checked) selectedMissingGuids = missingGuids.Take((int)GuidCountUpDown.Value); else if (ConsecutiveRadio.Checked) selectedMissingGuids = GetConsecutiveGuids(missingGuids.ToArray(), (int)GuidCountUpDown.Value); var resultForm = new ResultForm(selectedMissingGuids); resultForm.Show(); }