private void LaunchBatchSingle(Batch batch) { foreach (KeyValuePair<string, Tuple<string, string, string>> element in batch.Get_BatchElements()) { /* Define paths (input, logs) */ DirectoryInfo targetPath = new DirectoryInfo(element.Key); FileInfo[] inputFiles = targetPath.GetFiles(); _InputFiles.Clear(); foreach (FileInfo file in inputFiles) { _InputFiles.Add(file.FullName); _LogsPath = file.Directory.FullName; } /* Create a new config */ Config config = new Config(element.Value.Item1, element.Value.Item2); /* Create launcher and associated UC. */ _LaunchersList.Add(new Launcher(config, PreProcessButton.Checked, ProcessButton.Checked, ControlsButton.Checked, HCButton.Checked, new List<String>(_InputFiles), _LogsPath, _UpdateProgressBarDel, _UpdateRichTextBoxDel, _AddLogsGridViewDel, _DisplayConfigProcessTimeDel)); _ProgressBarsList.Add(new ProgressBar(config.Get_Name(), _ProgressBarsList.Count, _AbortThreadDel)); _Navigator.ProgressGroupBox.Panel.Controls.Add(_ProgressBarsList[_ProgressBarsList.Count - 1]); _LogsList.Add(new Log(config.Get_Name(), config.Get_TargetsNumber(), PreProcessButton.Checked, ProcessButton.Checked, ControlsButton.Checked)); _Navigator.LogsNavigator.Pages.Insert(0, _LogsList[_LogsList.Count - 1].Get_NavigatorTab()); _Navigator.LogsNavigator.SelectedIndex = 0; _LogsList[_LogsList.Count - 1].Get_NavigatorTab().ButtonSpecs[0].Click += new EventHandler(_Navigator.CloseLogsNavigatorTab); _PoolThreads.Add(new Thread(() => _LaunchersList[_LaunchersList.Count - 1].Run(_LaunchersList.Count - 1))); _PoolThreads[_PoolThreads.Count - 1].IsBackground = true; _PoolThreads[_PoolThreads.Count - 1].Start(); } }
private void LaunchBatchMulti(Batch batch) { foreach (KeyValuePair<Tuple<string,string>, List<Tuple<string, string>>> element in batch.Get_BatchElementsMulti()) { int configCounter = 1; // Define paths (input, logs) DirectoryInfo targetPath = new DirectoryInfo(element.Key.Item1); FileInfo[] inputFiles = targetPath.GetFiles(); _InputFiles.Clear(); foreach (FileInfo file in inputFiles) _InputFiles.Add(file.FullName); // Create Config/Instanciate launcher for each config of each batch element foreach (Tuple<string, string> config in element.Value) { // Copy all inputs in a separated directory if (!Directory.Exists(targetPath + "\\" + configCounter.ToString())) Directory.CreateDirectory(targetPath + "\\" + configCounter.ToString()); foreach (String input in _InputFiles) File.Copy(input, targetPath + "\\" + configCounter.ToString() + "\\" + Path.GetFileName(input), true); // Redefine paths DirectoryInfo specificTargetPath = new DirectoryInfo(targetPath + "\\" + configCounter.ToString()); FileInfo[] specificInputFiles = specificTargetPath.GetFiles(); List<string> specificInputs = new List<string>(); string specificLogPath = specificTargetPath.FullName; foreach (FileInfo file in specificInputFiles) specificInputs.Add(file.FullName); // Create a new config Config specificConfig = new Config(config.Item1, config.Item2); // Create launcher and associated UC. _LaunchersList.Add(new Launcher(specificConfig, PreProcessButton.Checked, ProcessButton.Checked, ControlsButton.Checked, HCButton.Checked, new List<String>(specificInputs), specificLogPath, _UpdateProgressBarDel, _UpdateRichTextBoxDel, _AddLogsGridViewDel, _DisplayConfigProcessTimeDel)); _ProgressBarsList.Add(new ProgressBar(specificConfig.Get_Name(), _ProgressBarsList.Count, _AbortThreadDel)); _Navigator.ProgressGroupBox.Panel.Controls.Add(_ProgressBarsList[_ProgressBarsList.Count - 1]); _LogsList.Add(new Log(specificConfig.Get_Name(), specificConfig.Get_TargetsNumber(), PreProcessButton.Checked, ProcessButton.Checked, ControlsButton.Checked)); _Navigator.LogsNavigator.Pages.Insert(0, _LogsList[_LogsList.Count - 1].Get_NavigatorTab()); _Navigator.LogsNavigator.SelectedIndex = 0; _LogsList[_LogsList.Count - 1].Get_NavigatorTab().ButtonSpecs[0].Click += new EventHandler(_Navigator.CloseLogsNavigatorTab); _PoolThreads.Add(new Thread(() => _LaunchersList[_LaunchersList.Count - 1].Run(_LaunchersList.Count - 1))); _PoolThreads[_PoolThreads.Count - 1].IsBackground = true; _PoolThreads[_PoolThreads.Count - 1].Start(); configCounter++; } } }