예제 #1
0
 private static void readOutput(WorkSettings settings, string value)
 {
     if (value.Length > 0)
     {
         settings.FileNameForReport = value;
     }
 }
예제 #2
0
 private static void readInclude(WorkSettings settings, string value)
 {
     if (value.Length > 0)
     {
         settings.includeItems.Add(value);
     }
 }
예제 #3
0
 private static void readSettingsFile(WorkSettings settings, string value)
 {
     if (!File.Exists(value))
     {
         throw new SettingsException("Cannot find settings file (" + value + ")");
     }
     settings.settingsFile = value;
 }
예제 #4
0
 private static void readTargetWorkDir(WorkSettings settings, string value)
 {
     if (!Directory.Exists(value))
     {
         throw new SettingsException("Cannot find target working dir (" + value + ")");
     }
     settings.TargetWorkingDir = Path.GetFullPath(value);
 }
예제 #5
0
 private static void readTarget(WorkSettings settings, string value)
 {
     if (!File.Exists(value))
     {
         throw new SettingsException("Cannot find target (" + value + ")");
     }
     settings.TargetPath = Path.GetFullPath(value);
 }
예제 #6
0
 private static void readLogLevel(WorkSettings settings, string value)
 {
     try
     {
         settings.logLevel = int.Parse(value, CultureInfo.InvariantCulture);
     }
     catch (Exception ex)
     {
         throw new SettingsException("Wrong value for --log (" + ex.Message + ")");
     }
 }
예제 #7
0
        private void btnLoad_Click(object sender, EventArgs e)
        {
            dlgOpen.Filter = "Settings files (*.xml)|*.xml";
            if (dlgOpen.ShowDialog(this) != DialogResult.OK)
            {
                return;
            }

            var settings = new WorkSettings
            {
                SettingsFile = dlgOpen.FileName
            };

            try
            {
                settings.ReadSettingsFile();
            }
            catch (Exception ex)
            {
                ShowInformation("Cannot load settings (" + ex.Message + ")");
                return;
            }

            tbPath.Text = settings.TargetPath;
            tbWorkingDir.Text = settings.TargetWorkingDir;
            tbArgs.Text = settings.TargetArgs;

            SetLoggingEnabled(chkLoggingDumpMethod, settings.LogLevel, Logging.DumpMethod);
            SetLoggingEnabled(chkLoggingDumpInstrumentation, settings.LogLevel, Logging.DumpInstrumentation);
            SetLoggingEnabled(chkLoggingInstrumentMessages, settings.LogLevel, Logging.MethodInstrumentation);
            SetLoggingEnabled(chkLoggingMethodInner, settings.LogLevel, Logging.MethodInner);
            SetLoggingEnabled(chkLoggingSkipByRule, settings.LogLevel, Logging.SkipByRules);
            SetLoggingEnabled(chkLoggingSkipByState, settings.LogLevel, Logging.SkipByState);

            ckbFlattenDomains.Checked = settings.DisableFlattenDomains;
            tbRules.Text = string.Empty;

            foreach (var s in settings.IncludeItems)
            {
                if (tbRules.Text.Length > 0) tbRules.Text = tbRules.Text + "\r\n";
                tbRules.Text = tbRules.Text + "+" + s;
            }
            foreach (var s in settings.ExcludeItems)
            {
                if (tbRules.Text.Length > 0) tbRules.Text = tbRules.Text + "\r\n";
                tbRules.Text = tbRules.Text + "-" + s;
            }

        }
예제 #8
0
 private static void readTargetWorkDir(WorkSettings settings, string value)
 {
     if (!Directory.Exists(value))
         throw new SettingsException("Cannot find target working dir (" + value + ")");
     settings.TargetWorkingDir = Path.GetFullPath(value);
 }
예제 #9
0
 private static void readHelp(WorkSettings settings)
 {
     settings.printLongHelp = true;
 }
예제 #10
0
 private static void readVersion(WorkSettings settings)
 {
     settings.printVersion = true;
 }
예제 #11
0
 private static void register(WorkSettings settings)
 {
     settings.Register = true;
 }
예제 #12
0
 private static void readGenerateSettingsFile(WorkSettings settings, string value)
 {
     settings.generateSettingsFileName = value;
 }
예제 #13
0
 private static void readDisableDomainFlatten(WorkSettings settings)
 {
     settings.DisableFlattenDomains = true;
 }
예제 #14
0
 private static void readInclude(WorkSettings settings, string value)
 {
     if (value.Length > 0) settings.includeItems.Add(value);
 }
예제 #15
0
 private static void readSettingsFile(WorkSettings settings, string value)
 {
     if (!File.Exists(value))
         throw new SettingsException("Cannot find settings file (" + value + ")");
     settings.settingsFile = value;
 }
예제 #16
0
 private static void readDisableDomainFlatten(WorkSettings settings)
 {
     settings.DisableFlattenDomains = true;
 }
예제 #17
0
 private static void readTargetArgs(WorkSettings settings, string value)
 {
     settings.TargetArgs = value;
 }
예제 #18
0
 private static void readOutput(WorkSettings settings, string value)
 {
     if (value.Length > 0) settings.FileNameForReport = value;
 }
예제 #19
0
 private static void register(WorkSettings settings)
 {
     settings.Register = true;
 }
예제 #20
0
 private static void readTargetArgs(WorkSettings settings, string value)
 {
     settings.TargetArgs = value;
 }
예제 #21
0
 private static void readGenerateSettingsFile(WorkSettings settings, string value)
 {
     settings.generateSettingsFileName = value;
 }
예제 #22
0
 private static void readLogLevel(WorkSettings settings, string value)
 {
     try
     {
         settings.logLevel = int.Parse(value, CultureInfo.InvariantCulture);
     }
     catch (Exception ex)
     {
         throw new SettingsException("Wrong value for --log (" + ex.Message + ")");
     }
 }
예제 #23
0
 private static void readErrorsToStdOut(WorkSettings settings)
 {
     settings.ErrorsToStdout = true;
 }
예제 #24
0
 private static void readTarget(WorkSettings settings, string value)
 {
     if (!File.Exists(value))
         throw new SettingsException("Cannot find target (" + value + ")");
     settings.TargetPath = Path.GetFullPath(value);
 }
예제 #25
0
 private static void readHelp(WorkSettings settings)
 {
     settings.printLongHelp = true;
 }
예제 #26
0
 private static void readErrorsToStdOut(WorkSettings settings)
 {
     settings.ErrorsToStdout = true;
 }
예제 #27
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            var settings = new WorkSettings
            {
                TargetPath = TargetPath,
                TargetArgs = TargetArgs,
                TargetWorkingDir = TargetWorkingDir,
                FileNameForReport = FileNameForReport,
                LogLevel = ((int)LogLevel),
                DisableFlattenDomains = ckbFlattenDomains.Checked
            };

            settings.IncludeRules(IncludeItems);
            settings.ExcludeRules(ExcludeItems);

            dlgSave.Filter = "Settings files (*.xml)|*.xml";
            if (dlgSave.ShowDialog(this) != DialogResult.OK)
            {
                return;
            }

            try
            {
                settings.GenerateSettingsFileName = dlgSave.FileName;
                settings.GenerateSettingsFile();
                ShowInformation("Settings were saved!");
            }
            catch (Exception ex)
            {
                ShowInformation("Cannot save settings (" + ex.Message + ")");
            }
        }
예제 #28
0
 private static void readVersion(WorkSettings settings)
 {
     settings.printVersion = true;
 }
예제 #29
0
        static int Main(string[] args)
        {
            try
            {
                var settings = new WorkSettings();
                if (!settings.InitializeFromCommandLine(args))
                {
                    return -1;
                }

                if (settings.ErrorsToStdout)
                {
                    Console.SetError(Console.Out);
                }

                using (Registration.Create(settings.Register ? System.Reflection.Assembly.GetExecutingAssembly().Location : null))
                {
                    //Console.ReadLine();

                    var connector = new Connector();
                    connector.StatusMessageReceived += connector_StatusMessageReceived;
                    connector.LogEntryReceived += connector_LogEntryReceived;

                    connector.UseFileLogging(true);
                    connector.UsePipeLogging(true);
                    connector.SetLogging((Logging)settings.LogLevel);

                    foreach (var item in settings.IncludeItems)
                    {
                        try
                        {
                            connector.IncludeItem(item);
                        }
                        catch (ArgumentException)
                        {
                            Console.Error.WriteLine("Item '" + item + "' have wrong format");
                        }
                    }

                    foreach (var item in settings.ExcludeItems)
                    {
                        try
                        {
                            connector.ExcludeItem(item);
                        }
                        catch (ArgumentException)
                        {
                            Console.Error.WriteLine("Item '" + item + "' have wrong format");
                        }
                    }

                    var options = new SessionRunOptions
                    {
                        TargetPath = settings.TargetPath,
                        TargetDirectory = settings.TargetWorkingDir,
                        TargetArguments = settings.TargetArgs,
                        RedirectOutput = true,
                        DelayClose = false,
                        FlattenDomains = !settings.DisableFlattenDomains
                    };

                    connector.Options = options;
                    connector.StartTarget();

                    try
                    {
                        var writer = settings.OutputToFile
                            ? new XmlTextWriter(File.CreateText(settings.FileNameForReport))
                            : new XmlTextWriter(Console.Out);
                        using (writer)
                        {
                            writer.Formatting = Formatting.Indented;
                            writer.Indentation = 1;
                            writer.IndentChar = ' ';
                            ReportSerializer.Save(writer, connector.Report);
                        }
                    }
                    catch (Exception ex)
                    {
                        Console.Error.WriteLine("Can't save report (" + ex.Message + ")");
                    }

#if DEBUG
                    WriteListOfSkippedItems(connector.Report);
#endif

                    if (connector.TargetExitCode.HasValue)
                        return connector.TargetExitCode.Value;
                } // end using
            }
            catch (SettingsException ex)
            {
                Console.Error.WriteLine(ex.Message);
                return -1;
            }
            catch (Exception ex)
            {
                Console.Error.WriteLine(ex.Message);
                Console.Error.WriteLine(ex.StackTrace);
                return -1;
            }

            return 0;
        }