Пример #1
0
 private void CompileToolStripMenuItem_Click(object sender, EventArgs e)
 {
     ReportText.Clear();
     ErrorText.Clear();
     try
     {
         File.WriteAllText(ConfigurationManager.AppSettings.Get("ErrorsFile"), string.Empty);
         if (string.IsNullOrEmpty(currFile))
         {
             MessageBox.Show("Збережіть файл перед тим як компілювати");
             return;
         }
         if (!ifSave)
         {
             Save();
         }
         tabControl.SelectedIndex = tabControl.TabPages.IndexOfKey("ReportTab");
         // Отримання і формування мен ввхідних та вихідних файлів
         var inFileName  = currFile;
         var outFileName = currWay + "\\" + currName + ".mc";
         ReportText.AppendText("Компілювання проекту почалось...\r\n");
         ReportText.AppendText("Вхідний файл проекту " + currName + ".as.\r\n");
         ReportText.AppendText("Пошук помилок...\r\n");
         bool isError = false;
         try
         {
             sol = new ASol();
             sol.Run(inFileName, outFileName);
         }
         catch (MessageException ex)
         {
             isError = true;
             File.WriteAllText(ConfigurationManager.AppSettings.Get("ErrorsFile"), ex.Message);
         }
         ErrorText.AppendText(File.ReadAllText(ConfigurationManager.AppSettings.Get("ErrorsFile")));
         if (!isError)
         {
             ReportText.AppendText("Помилок не знайдено.\r\n");
             ReportText.AppendText("Компілювання завершено.\r\n");
             ReportText.AppendText("Тепер можете запустити проект.\r\n");
             RunToolStripMenuItem.Enabled = true;
         }
         else
         {
             tabControl.SelectedIndex = tabControl.TabPages.IndexOfKey("ErrorTab");
             ReportText.AppendText("Упс.. знайшлись помилки.\r\n");
         }
     }
     catch (Exception ex)
     {
         Logger.Log.Error(ex.Message + " " + ex.StackTrace);
         tabControl.SelectedIndex = tabControl.TabPages.IndexOfKey("ErrorTab");
         ErrorText.AppendText("Упс.. щось сталось, гляньте Error.log");
         MessageBox.Show("Ой...щось пішло не так, гляньте Error.log", "НЛО", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Пример #2
0
 private static bool Project(ISol sol, List <string> argv)
 {
     try
     {
         sol.Run(argv);
         LoggingHelper.LogEntry(SystemCategories.GeneralUIDebug, sol.Result());
         return(true);
     }
     catch (MessageException me)
     {
         LoggingHelper.LogEntry(SystemCategories.GeneralUIError, me.Message);
     }
     catch (Exception ex)
     {
         LoggingHelper.LogEntry(SystemCategories.GeneralUIError, ex.Message + ex.StackTrace);
     }
     return(false);
 }
Пример #3
0
 private void RunToolStripMenuItem_Click(object sender, EventArgs e)
 {
     ReportText.Clear();
     ErrorText.Clear();
     OutputText.Clear();
     try
     {
         File.WriteAllText(ConfigurationManager.AppSettings.Get("ErrorsFile"), string.Empty);
         if (string.IsNullOrEmpty(currFile))
         {
             MessageBox.Show("Збережіть файл перед тим як компілювати");
             return;
         }
         if (!ifSave)
         {
             Save();
         }
         tabControl.SelectedIndex = tabControl.TabPages.IndexOfKey("ReportTab");
         // Отримання і формування мен ввхідних та вихідних файлів
         var inFileName = Path.ChangeExtension(currFile, ".mc");
         if (!File.Exists(inFileName))
         {
             ReportText.AppendText($"Файл за шляхом: {inFileName} не знайдено!\r\n");
             ReportText.AppendText($"Скомпілюйте проект ще раз!\r\n");
         }
         else
         {
             var outFileName = currWay + "\\" + currName + ".mc_report";
             ReportText.AppendText("Запуск проекту почався...\r\n");
             ReportText.AppendText("Вхідний файл " + currName + ".mc.\r\n");
             ReportText.AppendText("Пошук помилок...\r\n");
             bool isError = false;
             try
             {
                 sol = new SSol();
                 sol.Run(inFileName, outFileName);
             }
             catch (MessageException ex)
             {
                 isError = true;
                 File.WriteAllText(ConfigurationManager.AppSettings.Get("ErrorsFile"), ex.Message);
             }
             ErrorText.AppendText(File.ReadAllText(ConfigurationManager.AppSettings.Get("ErrorsFile")));
             if (!isError)
             {
                 tabControl.SelectedIndex = tabControl.TabPages.IndexOfKey("OutputTab");
                 OutputText.AppendText(File.ReadAllText(outFileName));
                 ReportText.AppendText("Помилок не знайдено.\r\n");
                 ReportText.AppendText("Кінець.");
             }
             else
             {
                 tabControl.SelectedIndex = tabControl.TabPages.IndexOfKey("ErrorTab");
                 ReportText.AppendText("Упс.. знайшлись помилки.\r\n");
             }
         }
     }
     catch (Exception ex)
     {
         Logger.Log.Error(ex.Message + " " + ex.StackTrace);
         MessageBox.Show("Ой...щось пішло не так, глянь Error.log", "НЛО", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }