Exemple #1
0
 public AnalysisTools()
 {
     HasDefaultAnalysisTool = false;
     DefaultAnalysisTool    = null;
     PetAnalysisToolList    = new List <AnalysisTool>();
     LoadAnalysisToolsFromRegistry();
 }
Exemple #2
0
        public static void LaunchAnalysisTool(AnalysisTool analysisTool, string vizConfigPath, Dataset mergedDataset, string dataDirectoryPath)
        {
            Console.WriteLine(vizConfigPath);

            string logPath          = System.IO.Path.Combine(System.IO.Path.GetTempPath(), string.Format("{0}_{1:yyyyMMdd_HHmmss}.log", analysisTool.InternalName, DateTime.Now));
            var    exePath          = ExpandAnalysisToolString(analysisTool.ExecutableFilePath, vizConfigPath, dataDirectoryPath);
            var    arguments        = ExpandAnalysisToolString(analysisTool.ProcessArguments, vizConfigPath, dataDirectoryPath);
            var    workingDirectory = ExpandAnalysisToolString(analysisTool.WorkingDirectory, vizConfigPath, dataDirectoryPath);

            ProcessStartInfo psi = new ProcessStartInfo()
            {
                FileName         = "cmd.exe",
                Arguments        = string.Format("/S /C \"\"{0}\" {1} > \"{2}\" 2>&1\"", exePath, arguments, logPath),
                CreateNoWindow   = true,
                WindowStyle      = ProcessWindowStyle.Hidden,
                WorkingDirectory = workingDirectory,
                // RedirectStandardError = true,
                // RedirectStandardOutput = true,
                UseShellExecute = true //UseShellExecute must be true to prevent subprocess from inheriting listening sockets from PETBrowser.exe--  which causes problems at next launch if PETBrowser terminates
            };

            if (analysisTool.ShowConsoleWindow)
            {
                psi.Arguments      = string.Format("/S /C \"\"{0}\" {1}", exePath, arguments, logPath);
                psi.CreateNoWindow = false;
                psi.WindowStyle    = ProcessWindowStyle.Normal;
            }

            Console.WriteLine(psi.Arguments);
            var p = new Process();

            p.StartInfo           = psi;
            p.EnableRaisingEvents = true;
            AddRunningSession(vizConfigPath, mergedDataset, dataDirectoryPath);
            p.Start();

            p.Exited += (sender, args) => { RemoveRunningSession(vizConfigPath, mergedDataset, dataDirectoryPath); };
        }
Exemple #3
0
        private void LoadAnalysisToolsFromRegistry()
        {
            using (var petToolsKey = Registry.LocalMachine.OpenSubKey(PetAnalysisToolsKeyName))
            {
                if (petToolsKey != null) //Returns null if key doesn't exist
                {
                    foreach (var toolKeyName in petToolsKey.GetSubKeyNames())
                    {
                        using (var toolKey = petToolsKey.OpenSubKey(toolKeyName))
                        {
                            if (toolKey != null)
                            {
                                try
                                {
                                    var tool = new AnalysisTool(toolKey);
                                    PetAnalysisToolList.Add(tool);

                                    if (tool.InternalName == "OpenMetaVisualizer")
                                    {
                                        HasDefaultAnalysisTool = true;
                                        DefaultAnalysisTool    = tool;
                                    }
                                }
                                catch (InvalidAnalysisToolException e)
                                {
                                    Trace.TraceWarning(e.Message);
                                }
                            }
                        }
                    }
                }
                else
                {
                    //TODO: Create this key (with defaults) if it doesn't already exist?
                }
            }

            using (var petToolsKey = Registry.CurrentUser.OpenSubKey(PetAnalysisToolsKeyName))
            {
                if (petToolsKey != null) //Returns null if key doesn't exist
                {
                    foreach (var toolKeyName in petToolsKey.GetSubKeyNames())
                    {
                        using (var toolKey = petToolsKey.OpenSubKey(toolKeyName))
                        {
                            if (toolKey != null)
                            {
                                try
                                {
                                    var tool = new AnalysisTool(toolKey);
                                    PetAnalysisToolList.Add(tool);

                                    if (tool.InternalName == "OpenMetaVisualizer")
                                    {
                                        HasDefaultAnalysisTool = true;
                                        DefaultAnalysisTool    = tool;
                                    }
                                }
                                catch (InvalidAnalysisToolException e)
                                {
                                    Trace.TraceWarning(e.Message);
                                }
                            }
                        }
                    }
                }
                else
                {
                    //TODO: Create this key (with defaults) if it doesn't already exist?
                }
            }

            if (DefaultAnalysisTool == null && PetAnalysisToolList.Count > 0)
            {
                DefaultAnalysisTool    = PetAnalysisToolList[0];
                HasDefaultAnalysisTool = true;
            }
            else if (DefaultAnalysisTool == null && PetAnalysisToolList.Count == 0)
            {
                HasDefaultAnalysisTool = false;
                //Dummy analysis tool entry for button label
                DefaultAnalysisTool = new AnalysisTool();
            }
        }