static void RunForm(string logFilename) { StatoscopeForm ssForm = new StatoscopeForm(logFilename); WCF.CreateServiceHost(ssForm); Application.Run(ssForm); }
static void Main(string[] args) { Application.CurrentCulture = new CultureInfo("en-US"); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); bool success = false; InstallProtocolHandler(); try { if (args.Length == 1 && !args[0].StartsWith("/")) { if (WCF.CheckForExistingToolProcess(args[0])) { Environment.Exit(0); } success = true; RunForm(args[0]); } else if (args.Length > 0) { string logfilename = string.Empty; string uploadSettings = string.Empty; string platform = string.Empty; string buildid = string.Empty; string metricManifest = string.Empty; string buildInfo = string.Empty; bool uploadSummary = true; string[] groups = null; for (int idx = 0; idx < args.Length; idx++) { if (args[idx].StartsWith("/dumplog")) { logfilename = args[idx + 1]; } if (args[idx].StartsWith("/statgroups")) { groups = args[idx + 1].Split(','); } if (args[idx].StartsWith("/autoupload")) { uploadSettings = args[idx + 1]; } if (args[idx].StartsWith("/metrics")) { metricManifest = args[idx + 1]; } if (args[idx].StartsWith("/nosummary")) { uploadSummary = false; } if (args[idx].StartsWith("/buildinfo")) { buildInfo = args[idx + 1]; } } if (logfilename != string.Empty) { success = WriteXMLForLog(logfilename, groups); } if (uploadSettings != string.Empty && success) { if (buildInfo != string.Empty) { StreamReader stream = new StreamReader(buildInfo); while (!stream.EndOfStream) { string line = stream.ReadLine(); if (line.StartsWith("BuildName=")) { buildid = line.Substring(line.IndexOf('=') + 1); string[] tokens = buildid.Split('(')[0].Split('_'); platform = tokens[tokens.Length - 2]; } } stream.Close(); buildid += " - Auto-testing Statistics - "; platform += " - Auto-testing Statistics - "; } success = UploadConfluenceData(uploadSettings, logfilename, groups, platform, buildid, metricManifest, uploadSummary); } } else { //If launching graphical front end, assume success here. success = true; RunForm(""); } } catch (System.Exception ex) { // Use this as a last ditch attempt to catch failures without the crash dialog being displayed Console.WriteLine("Unhandled exception thrown! {0}: {1}", ex.Message, ex.StackTrace); } Environment.Exit(success ? 0 : 1); }