Esempio n. 1
0
        public static ExperimentResult run(string fileName)
        {
            string currentDir = Directory.GetCurrentDirectory();

            string           mainFileName      = System.IO.Path.GetFileNameWithoutExtension(fileName);
            string           logFileName       = String.Format("{0}\\results\\{1}.log", currentDir, mainFileName);
            string           resultPicFileName = String.Format("{0}\\results\\{1}.png", currentDir, mainFileName);
            ProcessStartInfo processInfo       = new ProcessStartInfo("tester.exe", String.Format("{0} {1} {2}", fileName, logFileName, resultPicFileName));

            processInfo.CreateNoWindow         = true;
            processInfo.UseShellExecute        = false;
            processInfo.RedirectStandardOutput = true;

            Process process = Process.Start(processInfo);

            process.WaitForExit();

            int exitCode = process.ExitCode;

            try
            {
                if (exitCode == 0)
                {
                    ExperimentResult result = new ExperimentResult();
                    result.textFileName    = logFileName;
                    result.pictureFileName = resultPicFileName;
                    return(result);
                }
                else
                {
                    throw new Exception("no result");
                }
            }
            catch (Exception e)
            {
                throw e;
            }
            finally
            {
                process.Close();
            }
        }
Esempio n. 2
0
        private void ListBoxFileNames_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (e.AddedItems.Count == 0)
            {
                return;
            }
            int    index    = this.listBoxFileNames.Items.IndexOf(e.AddedItems[0]);
            string filename = this.fileNames[index];

            try
            {
                ExperimentResult result = RunSubProcess.run(filename);
                this.textBlock.Text = System.IO.File.ReadAllText(result.textFileName);
                BitmapImage src = new BitmapImage(new Uri(result.pictureFileName, UriKind.RelativeOrAbsolute));


                this.image.Source = src;
            }
            catch (Exception exception)
            {
                this.textBlock.Text = exception.Message;
            }
        }