private void startButton_Click(object sender, EventArgs e)
        {
            if (sending == false)
            {
                int timeInterval        = (int)timeIntervalNumericUpDown.Value;
                int maxLogRecordsNumber = (int)numberOfLogRecordsNumericUpDown.Value;

                if (usedLogTypesCheckListBox.CheckedItems.Count > 0)
                {
                    List <LogType> usedLogTypes = new List <LogType>();
                    foreach (var usedLogType in usedLogTypesCheckListBox.CheckedItems)
                    {
                        usedLogTypes.Add(((BoxItem <LogType>)usedLogType).value);
                    }

                    Task task = Task.Run(() => {
                        sending = true;
                        initializeProgressBar(maxLogRecordsNumber);

                        try {
                            for (int i = 0; i < maxLogRecordsNumber; i++)
                            {
                                Thread.Sleep(timeInterval);
                                LogType randomLogType     = getRandomLogType(usedLogTypes);
                                LogRecord randomLogRecord = RandomLogRecordGenerator.logRecord(randomLogType);
                                Program.logServiceClient.insertLogRecord(randomLogRecord);
                                progressBar.Value++;
                                if (sending == false)
                                {
                                    break;
                                }
                            }
                        }
                        catch {
                            MessageBox.Show("Auto record insertion failure.");
                        }
                        this.UseWaitCursor = false;
                        sending            = false;
                    });
                }
                else
                {
                    MessageBox.Show(this, "You must check at least one log type first.");
                }
            }
            else
            {
                sending = false;
            }
        }
Beispiel #2
0
        private void randomizeAllFieldsButton_Click(object sender, EventArgs e)
        {
            BoxItem <LogType> selectedBoxItem = ((BoxItem <LogType>)logTypeComboBox.SelectedItem);

            if (selectedBoxItem != null)
            {
                LogType logType = selectedBoxItem.value;

                LogRecord randomLogRecord = RandomLogRecordGenerator.logRecord(logType);

                try {
                    Program.logServiceClient.insertLogRecord(randomLogRecord);
                }
                catch {
                    MessageBox.Show("Log type " + logType.name + " random record insertion failure.");
                }
            }
            else
            {
                MessageBox.Show(this, "You must choose log type first.");
            }
        }
Beispiel #3
0
 private void randomizeFieldButton_Click(object sender, EventArgs e)
 {
     selectedFieldTextBox.Text = RandomLogRecordGenerator.additionalField();
 }