Пример #1
0
        private void ExecuteSTB(string scenarioName)
        {
            string[] args = new string[8];

            args[0] = "-dispatcher";
            args[1] = Environment.MachineName;
            args[2] = "-database";
            args[3] = _currentDatabase;
            args[4] = "-scenario";
            args[5] = scenarioName;
            args[6] = "-owner";
            args[7] = UserManager.CurrentUser;

            WriteLine("Starting session...");
            using (CommandLineExec commandLine = new CommandLineExec(args))
            {
                try
                {
                    _ticket = commandLine.Ticket;
                    commandLine.HandleSessionClientEvents = false;
                    commandLine.StatusChanged            += CommandLine_StatusChanged;
                    FrameworkServicesInitializer.InitializeExecution();
                    commandLine.StartSession();
                }
                catch (Exception ex)
                {
                    UpdateStatus($"Error: {ex.Message}");
                    WriteLine(ex.ToString());
                }
            }
        }
Пример #2
0
        static void Main(string[] args)
        {
            NameValueCollection _args = new NameValueCollection();

            GlobalSettings.IsDistributedSystem = false;

            if (args != null && args.Length > 0)
            {
                CommandLineMessage();
                Console.ReadLine();
            }
            else
            {
                if (ConfigurationManager.GetSection("UnattendedExecutionConfig") != null)
                {
                    _args.Add(ConfigurationManager.GetSection("UnattendedExecutionConfig") as NameValueCollection);
                }

                if (CommandLineExec.GetAppConfigCount(_args) > 0)
                {
                    SetDispatcherArg(ref _args);
                    using (CommandLineExec commandLine = new CommandLineExec(_args))
                    {
                        try
                        {
                            commandLine.StatusChanged += CommandLine_StatusChanged;
                            FrameworkServicesInitializer.InitializeExecution();
                            commandLine.StartSession();
                        }
                        catch (Exception ex)
                        {
                            TraceFactory.Logger.Debug(ex.ToString());
                            Console.WriteLine(ex.ToString());
                        }
                    }
                }
                else
                {
                    Application.EnableVisualStyles();
                    Application.SetCompatibleTextRenderingDefault(false);

                    TraceFactory.Logger.Debug("Starting STB User Console UI.");

                    using (Form mainForm = new MainForm())
                    {
                        Environment.CurrentDirectory = AppDomain.CurrentDomain.BaseDirectory;
                        ApplicationExceptionHandler.Attach(mainForm);
                        Application.Run(mainForm);
                    }
                }
            }
        }