/// <summary>
 ///
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void ButtonForecast_Click(object sender, EventArgs e)
 {
     try
     {
         ModelDiagnosticTest mdt = new ModelDiagnosticTest();
         var forecast            = mdt.GetForecast(_parentId);
         MessageBox.Show(string.Format("Результат: {0}", forecast), "Прогноз", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "Прогноз", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
 public void RunExperiment(string path)
 {
     mdt = new ModelDiagnosticTest();
     if (Directory.Exists(path))
     {
         var info  = new DirectoryInfo(path);
         var files = info.GetFiles();
         // log.Info(string.Format("Начали тесты {0}", files.Length));
         List <Task> tasks = new List <Task>();
         foreach (var file in files)
         {
             // tasks.Add(Task.Run(() => MakeTest(file)));
             MakeTest(file);
         }
         //  Task.WaitAll(tasks.ToArray());
     }
 }
 /// <summary>
 ///
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void ButtonForecast_Click(object sender, EventArgs e)
 {
     try
     {
         if (dataGridView.SelectedRows.Count > 0)
         {
             StringBuilder       sb  = new StringBuilder();
             ModelDiagnosticTest mdt = new ModelDiagnosticTest();
             for (int i = 0; i < dataGridView.SelectedRows.Count; ++i)
             {
                 var forecast = mdt.GetForecast(Convert.ToInt32(dataGridView.SelectedRows[i].Cells[0].Value));
                 sb.AppendLine(forecast.ToString());
             }
             MessageBox.Show(string.Format("Результат: {0}", sb.ToString()), "Прогноз", MessageBoxButtons.OK, MessageBoxIcon.Information);
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "Прогноз", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
        private void buttonLoad_Click(object sender, EventArgs e)
        {
            if (textBoxNumber.Text == "")
            {
                MessageBox.Show("Укажите номер теста", "Анализ временных рядов",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            if (listBoxSelected.Items.Count == 0)
            {
                MessageBox.Show("Укажите что считывать", "Анализ временных рядов",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            _list = new List <TypeDataInFile>();
            for (int i = 0; i < listBoxSelected.Items.Count; ++i)
            {
                _list.Add(Converter.ToTypeDataInFile(listBoxSelected.Items[i].ToString()));
            }
            if (comboBoxTypeFile.SelectedIndex == -1)
            {
                MessageBox.Show("Укажите тип файла", "Анализ временных рядов",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            _dialog   = new OpenFileDialog();
            _typeFile = comboBoxTypeFile.Text;
            switch (comboBoxTypeFile.SelectedIndex)
            {
            case 1:
                _dialog.Filter = "Excel files(*.xls)|*.xls|Excel files(*.xlsx)|*.xlsx";
                break;

            case 0:
                _dialog.Filter = "Txt files (*.txt)|*.txt";
                break;
            }
            if (_dialog.ShowDialog() == DialogResult.OK)
            {
                if (checkBoxSaveLog.Checked)
                {
                    _writer = new StreamWriter(_dialog.FileName + "_log.txt");
                }
                richTextBox.Text = "";
                richTextBox.SelectionAlignment = HorizontalAlignment.Center;
                richTextBox.SelectionFont      = new Font("Microsoft Sans Serif", 14f, FontStyle.Bold);
                richTextBox.AppendText("Результат анализа:\r\n");
                richTextBox.SelectionAlignment = HorizontalAlignment.Left;

                var logic = new ModelDiagnosticTest();
                try
                {
                    logic.MakeDiagnosticTest(new DiagnosticTestBindingModel
                    {
                        TestNumber            = textBoxNumber.Text,
                        FileName              = _dialog.FileName,
                        TypeFile              = Converter.ToTypeFile(_typeFile),
                        DatasInFile           = _list,
                        SeriesDiscriptionId   = _seriesId.Value,
                        CountPointsForMemmory = Convert.ToInt32(textBoxCountPointsForMemmory.Text),
                        MessagerEvent         = AddMessage,
                        MessageCountPoint     = AddValue,
                        MakeGranuleUX         = checkBoxGranuleUX.Checked,
                        MakeGranuleFT         = checkBoxGranuleFT.Checked,
                        MakeGranuleEntropy    = checkBoxGranuleEntropy.Checked,
                        MakeGranuleFuzzy      = checkBoxGranuleFuzzy.Checked
                    });
                    if (checkBoxSaveLog.Checked)
                    {
                        _writer.WriteLine("Сделано");
                    }
                    else
                    {
                        MessageBox.Show("Сделано", "Анализ временных рядов",
                                        MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }
                catch (Exception ex)
                {
                    if (checkBoxSaveLog.Checked)
                    {
                        _writer.WriteLine("Ошибка при обработке: " + ex.Message);
                    }
                    else
                    {
                        MessageBox.Show("Ошибка при обработке: " + ex.Message, "Анализ временных рядов", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
                finally
                {
                    if (checkBoxSaveLog.Checked)
                    {
                        _writer.Close();
                    }
                }
            }
        }