Beispiel #1
0
        private async void beginTestingButton_Click(object sender, RoutedEventArgs e)
        {
            DisableButtons();

            try
            {
                List <string>   URLs            = new List <string>();
                int             virtualUsers    = int.Parse(virtualUsersControl.Text);
                int             timeout         = int.Parse(timeoutControl.Text);
                int             requestDuration = int.Parse(betweenControl.Text);
                int             duration        = int.Parse(durationControl.Text);;
                TestingStrategy strategy        = (TestingStrategy)strategyControl.SelectedIndex;

                foreach (var item in urlListControl.Items)
                {
                    URLs.Add((string)item);
                }

                if (URLs.Count == 0)
                {
                    MessageBox.Show("Список URL-адресов пустой.", "Ошибка");
                    EnableButtons();
                    return;
                }

                if (virtualUsers < 1 || timeout < 1 || requestDuration < 1 || duration < 1)
                {
                    throw new FormatException();
                }

                TaskData data = new TaskData()
                {
                    _URLs           = URLs,
                    VirtualUsers    = virtualUsers,
                    Timeout         = timeout,
                    RequestDuration = requestDuration,
                    Duration        = duration,
                    Strategy        = strategy
                };

                await DataStorage.RequestData(data);

                TaskCreationResult result = DataStorage.GetData <TaskCreationResult>();

                if (result != null && result.GroupNumber != 0)
                {
                    MonitoringWindow window = new MonitoringWindow();
                    window.ShowDialog();
                }
                else
                {
                    MessageBox.Show("Сервер отказал в выполнении задания.", "Ошибка");
                }

                EnableButtons();
            }
            catch (FormatException)
            {
                MessageBox.Show("Данные введены не верно.", "Ошибка");
                EnableButtons();
            }
            catch (TimeoutException)
            {
                MessageBox.Show("Сервер не ответил вовремя.", "Ошибка");
                Close();
                return;
            }
            catch (SocketException)
            {
                MessageBox.Show("Сервер не ответил вовремя.", "Ошибка");
                Close();
                return;
            }
        }
Beispiel #2
0
        private async void saveProfileButton_Click(object sender, RoutedEventArgs e)
        {
            DisableButtons();

            try
            {
                List <string>   URLs            = new List <string>();
                int             virtualUsers    = int.Parse(virtualUsersControl.Text);
                int             timeout         = int.Parse(timeoutControl.Text);
                int             requestDuration = int.Parse(betweenControl.Text);
                int             duration        = int.Parse(durationControl.Text);;
                TestingStrategy strategy        = (TestingStrategy)strategyControl.SelectedIndex;
                string          name            = profileNameControl.Text;

                foreach (var item in urlListControl.Items)
                {
                    URLs.Add((string)item);
                }

                if (URLs.Count == 0)
                {
                    MessageBox.Show("Список URL-адресов пустой.", "Ошибка");
                    EnableButtons();
                    return;
                }

                if (virtualUsers < 1 || timeout < 1 || requestDuration < 1 || duration < 1 || name.Length < 1)
                {
                    throw new FormatException();
                }

                TaskData data = new TaskData()
                {
                    _URLs           = URLs,
                    VirtualUsers    = virtualUsers,
                    Timeout         = timeout,
                    RequestDuration = requestDuration,
                    Duration        = duration,
                    Strategy        = strategy
                };

                SaveProfileRequest request = new SaveProfileRequest()
                {
                    Name = name,
                    Data = data
                };

                await DataStorage.RequestData(request);

                var response = DataStorage.GetData <SaveProfileResponse>();

                if (response != null && response.Result == SaveProfileResult.NAME_EXISTS)
                {
                    MessageBox.Show("Введенное имя профиля уже существует.", "Ошибка");
                }
            }
            catch (FormatException)
            {
                MessageBox.Show("Данные введены не верно.", "Ошибка");
            }
            catch (TimeoutException)
            {
                MessageBox.Show("Сервер не ответил вовремя.", "Ошибка");
                Close();
                return;
            }
            catch (SocketException)
            {
                MessageBox.Show("Сервер не ответил вовремя.", "Ошибка");
                Close();
                return;
            }

            EnableButtons();
        }