public static void RunAll() { if (m_IsCurrentlySomeTaskRunning) { MessageBox.Show("В данный момент выполняется задача №" + m_CurrentTask.GetTaskID + Environment.NewLine + "Запуск задач отменён."); return; } if (m_Tasks == null || m_Tasks.Count == 0) { System.Windows.MessageBox.Show("Отсутствуют задачи!", "Ошибка!", System.Windows.MessageBoxButton.OK, System.Windows.MessageBoxImage.Error); return; } //m_Tasks[0].StartProcess(); m_RunMode = RunMode.All; m_CurrentTask = m_Tasks[0]; m_CurrentTask.SubscribeOutputDataAndErrorReceivedHandler(m_DataReceivedHandler); m_MainWindow.StatusBarNumOfTasksToComplete = m_Tasks.Count; m_MainWindow.StatusBarCurrentTaskId = m_TaskCounter; m_TaskCounter++; m_IsCurrentlySomeTaskRunning = true; m_MainWindow.SetBordersForProgressBar(m_Tasks.Count); m_MainWindow.ProgressBarValue = 0; Execution(m_CurrentTask); }
public static void GetExitedTask(MyTask task, int exitCode) { m_CurrentTask = task; if (exitCode == 0) { m_CurrentTask.SetStateOfTask(MyTask.TaskState.Completed); m_CurrentTask.UnubscribeOutputDataAndErrorReceivedHandler(m_DataReceivedHandler); m_MainWindow.SendMessageToTextBox("Задача № " + task.GetTaskID.ToString() + " выполнена!"); } else { m_CurrentTask.SetStateOfTask(MyTask.TaskState.Error); m_CurrentTask.UnubscribeOutputDataAndErrorReceivedHandler(m_DataReceivedHandler); m_MainWindow.SendMessageToTextBox("Задача № " + task.GetTaskID.ToString() + " завершилась с ошибкой!"); } if (m_RunMode == RunMode.All) { if (m_TaskCounter < m_Tasks.Count) { m_CurrentTask = m_Tasks[m_Tasks.IndexOf(m_CurrentTask) + 1]; m_CurrentTask.SubscribeOutputDataAndErrorReceivedHandler(m_DataReceivedHandler); m_MainWindow.ProgressBarValue = m_TaskCounter; m_MainWindow.StatusBarCurrentTaskId = m_TaskCounter; m_TaskCounter++; m_IsCurrentlySomeTaskRunning = true; Execution(m_CurrentTask); } else { m_TaskCounter = 0; m_IsCurrentlySomeTaskRunning = false; m_MainWindow.SendMessageToTextBox(Environment.NewLine + "Все задачи выполнены!" + Environment.NewLine + "Время завершения: " + DateTime.Now.ToString()); m_MainWindow.StatusBarMessage = "Все задачи завершены"; m_MainWindow.ProgressBarValue = m_Tasks.Count; m_MainWindow.StatusBarCurrentTaskId = m_Tasks.Count; } } else if (m_RunMode == RunMode.Selected) { m_IsCurrentlySomeTaskRunning = false; m_MainWindow.SendMessageToTextBox(Environment.NewLine + "Выбранная задача выполнена!" + Environment.NewLine + "Время завершения: " + DateTime.Now.ToString()); m_MainWindow.StatusBarMessage = "Все задачи завершены"; m_MainWindow.ProgressBarValue = 1.0d; m_MainWindow.StatusBarCurrentTaskId = 1; } }
public static void RunAll() { if (m_IsCurrentlySomeTaskRunning) { MessageBox.Show("В данный момент выполняется задача №" + m_CurrentTask.GetTaskID + Environment.NewLine + "Запуск задач отменён."); return; } if (m_Tasks == null || m_Tasks.Count == 0) { System.Windows.MessageBox.Show("Отсутствуют задачи!", "Ошибка!", System.Windows.MessageBoxButton.OK, System.Windows.MessageBoxImage.Error); return; } //m_Tasks[0].StartProcess(); m_RunMode = RunMode.All; m_CurrentTask = m_Tasks[0]; m_CurrentTask.SubscribeOutputDataAndErrorReceivedHandler(m_DataReceivedHandler); m_MainWindow.StatusBarNumOfTasksToComplete = m_Tasks.Count; m_MainWindow.StatusBarCurrentTaskId = m_TaskCounter; m_TaskCounter++; m_IsCurrentlySomeTaskRunning = true; m_MainWindow.SetBordersForProgressBar(m_Tasks.Count); m_MainWindow.ProgressBarValue = 0; Execution(m_CurrentTask); }
public static void GetExitedTask(MyTask task, int exitCode) { m_CurrentTask = task; if (exitCode == 0) { m_CurrentTask.SetStateOfTask(MyTask.TaskState.Completed); m_CurrentTask.UnubscribeOutputDataAndErrorReceivedHandler(m_DataReceivedHandler); m_MainWindow.SendMessageToTextBox("Задача № " + task.GetTaskID.ToString() + " выполнена!"); } else { m_CurrentTask.SetStateOfTask(MyTask.TaskState.Error); m_CurrentTask.UnubscribeOutputDataAndErrorReceivedHandler(m_DataReceivedHandler); m_MainWindow.SendMessageToTextBox("Задача № " + task.GetTaskID.ToString() + " завершилась с ошибкой!"); } if (m_RunMode == RunMode.All) { if (m_TaskCounter < m_Tasks.Count) { m_CurrentTask = m_Tasks[m_Tasks.IndexOf(m_CurrentTask) + 1]; m_CurrentTask.SubscribeOutputDataAndErrorReceivedHandler(m_DataReceivedHandler); m_MainWindow.ProgressBarValue = m_TaskCounter; m_MainWindow.StatusBarCurrentTaskId = m_TaskCounter; m_TaskCounter++; m_IsCurrentlySomeTaskRunning = true; Execution(m_CurrentTask); } else { m_TaskCounter = 0; m_IsCurrentlySomeTaskRunning = false; m_MainWindow.SendMessageToTextBox(Environment.NewLine + "Все задачи выполнены!" + Environment.NewLine + "Время завершения: " + DateTime.Now.ToString()); m_MainWindow.StatusBarMessage = "Все задачи завершены"; m_MainWindow.ProgressBarValue = m_Tasks.Count; m_MainWindow.StatusBarCurrentTaskId = m_Tasks.Count; } } else if (m_RunMode == RunMode.Selected) { m_IsCurrentlySomeTaskRunning = false; m_MainWindow.SendMessageToTextBox(Environment.NewLine + "Выбранная задача выполнена!" + Environment.NewLine + "Время завершения: " + DateTime.Now.ToString()); m_MainWindow.StatusBarMessage = "Все задачи завершены"; m_MainWindow.ProgressBarValue = 1.0d; m_MainWindow.StatusBarCurrentTaskId = 1; } }