private void newRunButton_Click(object sender, EventArgs e) { RunInfo runInfo = new RunInfo(); runInfo.RunName = "new run"; runInfo.RunDuration = 1; runInfo.RunDataTag = ""; runInfo.RunLogDirectoryPath = ""; runInfo.ExternalSetupArguments = ""; runInfo.ExternalSetupCommand = ""; runInfo.ExternalSetupDelay = 1; runInfo.ExternalSetupWorkingDirectory = ""; runInfo.ExternalTeardownArguments = ""; runInfo.ExternalTeardownCommand = ""; runInfo.ExternalTeardownDelay = 1; runInfo.ExternalTeardownWorkingDirectory = ""; runInfo.UpdateListViewItem(); BatchRunForm brf = new BatchRunForm(runInfo); brf.ShowDialog(); if (brf.DialogResult == DialogResult.OK) { runListView.Items.Add(runInfo); } }
public MainWindow() { InitializeComponent(); m_loadedRuns = null; m_ddd = null; m_currentRun = null; m_currentRunFinishTime = 0; m_externalCommandProcess = null; m_dddProcess = null; }
private void loadBatchButton_Click(object sender, EventArgs e) { // load stuff, if successful, change the state m_loadedRuns = RunInfo.LoadBatchFile(batchFilePathTextBox.Text); if (m_loadedRuns != null) { m_state = BatchRunnerState.Loaded; } UpdateView(); }
private void BatchEditorForm_Load(object sender, EventArgs e) { if (BatchFilePath != String.Empty) { List <RunInfo> runs = RunInfo.LoadBatchFile(BatchFilePath); runListView.Items.Clear(); foreach (RunInfo ri in runs) { ri.UpdateListViewItem(); runListView.Items.Add(ri); } } }
private void deleteButton_Click(object sender, EventArgs e) { RunInfo selected = null; foreach (RunInfo ri in runListView.SelectedItems) { selected = ri; break; } if (selected != null) { runListView.Items.Remove(selected); } }
private void runListView_DoubleClick(object sender, EventArgs e) { RunInfo selected = null; foreach (RunInfo ri in runListView.SelectedItems) { selected = ri; break; } if (selected != null) { BatchRunForm brf = new BatchRunForm(selected); brf.ShowDialog(); } }
public BatchRunForm(RunInfo r) { runInfo = r; InitializeComponent(); runNameTextBox.Text = r.RunName; scenarioNameTextBox.Text = r.RunScenarioPath; durationNumericUpDown.Value = r.RunDuration; runLogDirectoryPathTextBox.Text = r.RunLogDirectoryPath; runDataTagTextBox.Text = r.RunDataTag; externalSetupCommandTextBox.Text = r.ExternalSetupCommand; externalSetupArgumentsTextBox.Text = r.ExternalSetupArguments; externalSetupWorkingDirectoryTextBox.Text = r.ExternalSetupWorkingDirectory; externalSetupDelayNumericUpDown.Value = r.ExternalSetupDelay; externalTeardownCommandTextBox.Text = r.ExternalTeardownCommand; externalTeardownArgumentsTextBox.Text = r.ExternalTeardownArguments; externalTeardownWorkingDirectoryTextBox.Text = r.ExternalTeardownWorkingDirectory; externalTeardownDelayNumericUpDown.Value = r.ExternalTeardownDelay; }
void FinishCurrentRun() { m_ddd.SendStopScenarioRequest(); Thread.Sleep(2000); if (m_externalCommandProcess != null) { if (!m_externalCommandProcess.HasExited) { m_externalCommandProcess.Kill(); } m_externalCommandProcess = null; if (m_currentRun.ExternalTeardownCommand != String.Empty) { System.Diagnostics.ProcessStartInfo procInfo = new System.Diagnostics.ProcessStartInfo(); procInfo.FileName = m_currentRun.ExternalTeardownCommand; procInfo.WorkingDirectory = m_currentRun.ExternalTeardownWorkingDirectory; procInfo.Arguments = m_currentRun.ExternalTeardownArguments; procInfo.CreateNoWindow = true; System.Diagnostics.Process proc = System.Diagnostics.Process.Start(procInfo); Thread.Sleep(m_currentRun.ExternalTeardownDelay * 1000); if (!proc.HasExited) { proc.Kill(); } } } //TODO external command stop stuff statusRichTextBox.AppendText(String.Format("Finished run\n")); m_currentRun = null; if (Properties.Settings.Default.StopDDDServerBetweenRuns) { StopDDD(); } else { if (m_ddd != null) { m_ddd.ResetForNewSession(); } } StartNextRun(); }
public static List <RunInfo> LoadBatchFile(String path) { List <RunInfo> batch = new List <RunInfo>(); FileInfo fileInfo = new FileInfo(path); if (!fileInfo.Exists) { MessageBox.Show("The file specified doesn't exist!", "Error Loading Batch File"); return(null); } XPathNavigator nav; XPathDocument docNav; XPathNodeIterator nodeIter; docNav = new XPathDocument(path); nav = docNav.CreateNavigator(); nodeIter = nav.Select("BatchRunner/RunInfo"); while (nodeIter.MoveNext()) { RunInfo run = new RunInfo(); run.RunName = nodeIter.Current.SelectSingleNode("RunName").Value; run.RunScenarioPath = nodeIter.Current.SelectSingleNode("RunScenarioPath").Value; run.RunLogDirectoryPath = nodeIter.Current.SelectSingleNode("RunLogDirectoryPath").Value; run.RunDataTag = nodeIter.Current.SelectSingleNode("RunDataTag").Value; run.RunDuration = nodeIter.Current.SelectSingleNode("RunDuration").ValueAsInt; run.ExternalSetupCommand = nodeIter.Current.SelectSingleNode("ExternalSetupCommand").Value; run.ExternalSetupArguments = nodeIter.Current.SelectSingleNode("ExternalSetupArguments").Value; run.ExternalSetupWorkingDirectory = nodeIter.Current.SelectSingleNode("ExternalSetupWorkingDirectory").Value; run.ExternalSetupDelay = nodeIter.Current.SelectSingleNode("ExternalSetupDelay").ValueAsInt; run.ExternalTeardownCommand = nodeIter.Current.SelectSingleNode("ExternalTeardownCommand").Value; run.ExternalTeardownArguments = nodeIter.Current.SelectSingleNode("ExternalTeardownArguments").Value; run.ExternalTeardownWorkingDirectory = nodeIter.Current.SelectSingleNode("ExternalTeardownWorkingDirectory").Value; run.ExternalTeardownDelay = nodeIter.Current.SelectSingleNode("ExternalTeardownDelay").ValueAsInt; batch.Add(run); } return(batch); }
private void moveDownButton_Click(object sender, EventArgs e) { RunInfo selected = null; foreach (RunInfo ri in runListView.SelectedItems) { selected = ri; break; } if (selected != null) { int i = runListView.Items.IndexOf(selected); if (i < runListView.Items.Count - 1) { runListView.Items.RemoveAt(i); runListView.Items.Insert(i + 1, selected); } selected.Selected = true; runListView.Refresh(); runListView.Focus(); } }
private void saveButton_Click(object sender, EventArgs e) { SaveFileDialog sfd = new SaveFileDialog(); sfd.Title = "Save Batch As"; sfd.FileName = BatchFilePath; sfd.Filter = "XML (*.xml)|*.xml"; DialogResult r = sfd.ShowDialog(); if (r != DialogResult.Cancel) { BatchFilePath = sfd.FileName; List <RunInfo> runs = new List <RunInfo>(); foreach (RunInfo ri in runListView.Items) { runs.Add(ri); } RunInfo.SaveBatchFile(runs, BatchFilePath); DialogResult = DialogResult.OK; } }
void StartNextRun() { if (m_loadedRuns == null || m_loadedRuns.Count == 0) { statusRichTextBox.AppendText("Nothing to do...\n"); m_state = BatchRunnerState.Uninitialized; return; } if (m_ddd == null) { StartDDD(); } m_currentRun = m_loadedRuns[0]; m_loadedRuns.Remove(m_currentRun); m_currentRunFinishTime = m_currentRun.RunDuration * 1000; //m_ddd.ResetForNewSession(); String dataTag = dataTagTextBox.Text; if (m_currentRun.RunDataTag != String.Empty) { dataTag = m_currentRun.RunDataTag; } String logPath = logPathTextBox.Text; if (m_currentRun.RunLogDirectoryPath != String.Empty) { logPath = m_currentRun.RunLogDirectoryPath; } statusRichTextBox.AppendText("Starting new run:\n"); statusRichTextBox.AppendText(String.Format(" {0}: {1}\n", "RunName", m_currentRun.RunName)); statusRichTextBox.AppendText(String.Format(" {0}: {1}\n", "RunScenarioPath", m_currentRun.RunScenarioPath)); statusRichTextBox.AppendText(String.Format(" {0}: {1}\n", "RunLogDirectoryPath", logPath)); statusRichTextBox.AppendText(String.Format(" {0}: {1}\n", "RunDataTag", dataTag)); statusRichTextBox.AppendText(String.Format(" {0}: {1}\n", "RunDuration", m_currentRun.RunDuration)); statusRichTextBox.AppendText(String.Format(" {0}: {1}\n", "ExternalCommandSetup", m_currentRun.ExternalSetupCommand)); statusRichTextBox.AppendText(String.Format(" {0}: {1}\n", "ExternalCommandSetupDelay", m_currentRun.ExternalSetupDelay)); statusRichTextBox.AppendText(String.Format(" {0}: {1}\n", "ExternalCommandTeardown", m_currentRun.ExternalTeardownCommand)); statusRichTextBox.AppendText(String.Format(" {0}: {1}\n", "ExternalCommandTeardownDelay", m_currentRun.ExternalTeardownDelay)); statusRichTextBox.Select(statusRichTextBox.Text.Length - 1, 0); statusRichTextBox.ScrollToCaret(); //m_ddd.SendStopScenarioRequest(); //Thread.Sleep(2000); m_ddd.SendLoadScenarioRequest(m_currentRun.RunScenarioPath, dataTag, logPath); Thread.Sleep(2000); if (m_currentRun.ExternalSetupCommand != String.Empty) { //TODO external command start stuff System.Diagnostics.ProcessStartInfo procInfo = new System.Diagnostics.ProcessStartInfo(); procInfo.FileName = m_currentRun.ExternalSetupCommand; procInfo.WorkingDirectory = m_currentRun.ExternalSetupWorkingDirectory; procInfo.Arguments = m_currentRun.ExternalSetupArguments + String.Format(" 1>>{0}\\{1}.log 2>&1", logPath, dataTag); procInfo.CreateNoWindow = true; m_externalCommandProcess = System.Diagnostics.Process.Start(procInfo); Thread.Sleep(m_currentRun.ExternalSetupDelay * 1000); } if (Properties.Settings.Default.RunNextAutomatically) { m_ddd.SendResumeScenarioRequest(); } else { m_state = BatchRunnerState.WaitingToResume; } UpdateView(); }
public static List<RunInfo> LoadBatchFile(String path) { List<RunInfo> batch = new List<RunInfo>(); FileInfo fileInfo = new FileInfo(path); if (!fileInfo.Exists) { MessageBox.Show("The file specified doesn't exist!", "Error Loading Batch File"); return null; } XPathNavigator nav; XPathDocument docNav; XPathNodeIterator nodeIter; docNav = new XPathDocument(path); nav = docNav.CreateNavigator(); nodeIter = nav.Select("BatchRunner/RunInfo"); while (nodeIter.MoveNext()) { RunInfo run = new RunInfo(); run.RunName = nodeIter.Current.SelectSingleNode("RunName").Value; run.RunScenarioPath = nodeIter.Current.SelectSingleNode("RunScenarioPath").Value; run.RunLogDirectoryPath = nodeIter.Current.SelectSingleNode("RunLogDirectoryPath").Value; run.RunDataTag = nodeIter.Current.SelectSingleNode("RunDataTag").Value; run.RunDuration = nodeIter.Current.SelectSingleNode("RunDuration").ValueAsInt; run.ExternalSetupCommand = nodeIter.Current.SelectSingleNode("ExternalSetupCommand").Value; run.ExternalSetupArguments = nodeIter.Current.SelectSingleNode("ExternalSetupArguments").Value; run.ExternalSetupWorkingDirectory = nodeIter.Current.SelectSingleNode("ExternalSetupWorkingDirectory").Value; run.ExternalSetupDelay = nodeIter.Current.SelectSingleNode("ExternalSetupDelay").ValueAsInt; run.ExternalTeardownCommand = nodeIter.Current.SelectSingleNode("ExternalTeardownCommand").Value; run.ExternalTeardownArguments = nodeIter.Current.SelectSingleNode("ExternalTeardownArguments").Value; run.ExternalTeardownWorkingDirectory = nodeIter.Current.SelectSingleNode("ExternalTeardownWorkingDirectory").Value; run.ExternalTeardownDelay = nodeIter.Current.SelectSingleNode("ExternalTeardownDelay").ValueAsInt; batch.Add(run); } return batch; }