Example #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());
                }
            }
        }
        /// <summary>
        /// Sets up this instance using the specified client controller host name.
        /// </summary>
        /// <param name="clientControllerHostName">Name of the client controller host.</param>
        public static OfficeWorkerActivityController Create(string clientControllerHostName, string instanceId)
        {
            // The office worker is a separate process, so it must make a call up to the client controller to obtain
            // the manifest that will be used for the test.
            SystemManifest manifest = null;

            using (var serviceConnection = ClientControllerServiceConnection.Create(clientControllerHostName))
            {
                var data = serviceConnection.Channel.GetManifest(instanceId);
                manifest = SystemManifest.Deserialize(data);
                manifest.PushToGlobalDataStore(instanceId);
                manifest.PushToGlobalSettings();
                _sessionId    = manifest.SessionId;
                _statusLogger = new VirtualResourceInstanceStatusLogger(_sessionId, Environment.UserName, 0, Enum.GetName(typeof(RuntimeState), 6), false, GlobalDataStore.ResourceInstanceId);
            }


            TraceFactory.Logger.Debug("Resource type: {0}".FormatWith(manifest.ResourceType));
            TraceFactory.Logger.Debug("InstanceId: {0}".FormatWith(GlobalDataStore.ResourceInstanceId));
            TraceFactory.Logger.Debug("UserName: {0}".FormatWith(GlobalDataStore.Credential.UserName));

            FrameworkServicesInitializer.InitializeExecution();

            return(ObjectFactory.Create <OfficeWorkerActivityController>(manifest.ResourceType, clientControllerHostName));
        }
Example #3
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            if (STFLoginManager.Login())
            {
                _currentDatabase = STFLoginManager.SystemDatabase;
                //Set whether STF or STB based on the worker type in the database.
                GlobalSettings.IsDistributedSystem = false;
                //string officeWorkerType = VirtualResourceType.OfficeWorker.ToString();
                //using (EnterpriseTestContext dataContext = new EnterpriseTestContext(_currentDatabase))
                //{
                //    GlobalSettings.IsDistributedSystem = dataContext.VirtualResources.Any(r => r.ResourceType == officeWorkerType);
                //}
                LoggedInTextBlock.Text = $"Logged in as: {UserManager.CurrentUserName} to {STFLoginManager.SystemDatabase}";
            }
            else
            {
                Environment.Exit(1);
            }

            _edtAssetSelectionControl?.Initialize(AssetAttributes.None);
            GlobalSettings.Load(_currentDatabase);
            FrameworkServicesInitializer.InitializeConfiguration();


            BuildComboBox.DataContext    = _accessDds.GetBuilds();
            ProductComboBox.DataContext  = _accessDds.GetProducts();
            ScenarioDataGrid.DataContext = _scenarioList;
            GroupComboBox.DataContext    = _groupCollection;
        }
Example #4
0
 public KellyTest()
 {
     //Load Dev settings
     //Prod: 15.86.232.53
     //STBServer: 15.86.232.90
     GlobalSettings.Load("15.86.232.90");
     GlobalSettings.IsDistributedSystem = false;
     FrameworkServicesInitializer.InitializeExecution();
 }
Example #5
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);
                    }
                }
            }
        }
Example #6
0
        static void Main(string[] args)
        {
            Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException);

            if (args != null && args.Length > 0)
            {
                CommandLineMessage();
                Console.ReadLine();
            }
            else
            {
                NameValueCollection appConfig = ConfigurationManager.GetSection("UnattendedExecutionConfig") as NameValueCollection;
                if (CommandLineExec.GetAppConfigCount(appConfig) > 0)
                {
                    using (CommandLineExec commandLine = new CommandLineExec(appConfig))
                    {
                        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);
                    try
                    {
                        using (Form mainForm = new MainForm())
                        {
                            Environment.CurrentDirectory = AppDomain.CurrentDomain.BaseDirectory;
                            ApplicationExceptionHandler.Attach(mainForm);
                            Application.Run(mainForm);
                        }
                    }
                    catch (Exception ex)
                    {
                        TraceFactory.Logger.Error(ex);
                        Application.Exit();
                    }
                }
            }
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="SessionProxyController"/> class.
        /// </summary>
        /// <param name="sessionId">The session unique identifier.</param>
        public SessionProxyController(string sessionId)
        {
            _sessionId = sessionId;

            string extension = "{0}-{1}".FormatWith(sessionId, Guid.NewGuid().ToShortString());

            _endpoint = WcfService.SessionProxy.GetLocalHttpUri(extension);

            // Instatiate the proxy and start the backend service for STF Lite
            if (GlobalSettings.IsDistributedSystem == false)
            {
                FrameworkServicesInitializer.InitializeExecution();
                _sessionProxy = new SessionProxy(sessionId);
                _sessionProxy.StartBackendService();
            }
        }
Example #8
0
        static void Main(string[] args)
        {
            var database = args[0];
            _sessionId = args[1];
            var proxyServiceUri = new Uri(args[2]);

            TraceFactory.SetThreadContextProperty("PID", Process.GetCurrentProcess().Id.ToString());
            TraceFactory.SetSessionContext(_sessionId);
            TraceFactory.Logger.Debug(string.Join(", ", args));

            UnhandledExceptionHandler.Attach();

            GlobalSettings.Load(database);
            FrameworkServicesInitializer.InitializeExecution();

            try
            {
                using (var sessionProxy = new SessionProxy(_sessionId))
                {
                    sessionProxy.OnExit += _sessionProxy_OnExit;
                    sessionProxy.StartFrontendService(proxyServiceUri);
                    sessionProxy.StartBackendService();

                    TraceFactory.Logger.Debug("Notify Dispatcher process is up...");
                    Retry.WhileThrowing
                        (
                            () =>
                            {
                                using (var connection = SessionDispatcherConnection.Create("localhost"))
                                {
                                    connection.Channel.NotifyProxyStarted(_sessionId);
                                }
                            },
                            10,
                            TimeSpan.FromSeconds(2),
                            new List<Type>() { typeof(EndpointNotFoundException) }
                        );
                    TraceFactory.Logger.Debug("Notify Dispatcher process is up...Done");

                    _mainThreadBlock.WaitOne();
                }
            }
            catch (Exception ex)
            {
                TraceFactory.Logger.Error(ex);
            }
        }
Example #9
0
        private bool ConnectToEnvironment()
        {
            if (!STFLoginManager.Login())
            {
                return(false); //User canceled the login
            }

            Cursor.Current = Cursors.WaitCursor;

            // Update status labels
            main_StatusLabel.Text        = "Connecting to {0}".FormatWith(STFLoginManager.SystemDatabase);
            userName_StatusLabel.Text    = UserManager.CurrentUserName;
            environment_StatusLabel.Text = "{0} {1} Environment".FormatWith(GlobalSettings.Items[Setting.Organization], GlobalSettings.Items[Setting.Environment]);
            SetLoggingContext();

            // DoEvents so the screen will refresh, and then set the wait cursor
            Application.DoEvents();

            try
            {
                // Initialize framework services
                FrameworkServicesInitializer.InitializeConfiguration();

                // Populate the config tree view
                InitializeConfigurationTreeView();

                // Set up the dashboard
                _dashboardControl.Initialize();

                // Apply user security settings
                ApplySecurity();

                // Refresh the status label and return true to indicate success
                main_StatusLabel.Text = "Connected to {0} ({1})".FormatWith(GlobalSettings.Environment, GlobalSettings.Database);
                return(true);
            }
            catch (EnvironmentConnectionException ex)
            {
                MessageBox.Show(ex.Message, "Connection Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(false);
            }
            finally
            {
                Cursor.Current = Cursors.Default;
            }
        }
Example #10
0
        private void MainForm_Shown(object sender, EventArgs e)
        {
            var database = LoadDatabaseName();

            using (SystemSelectionDialog dialog = new SystemSelectionDialog(database))
            {
                if (dialog.ShowDialog() == DialogResult.OK)
                {
                    if (dialog.Database != database)
                    {
                        SaveDatabaseName(dialog.Database);
                    }

                    GlobalSettings.Load(dialog.Database);
                    FrameworkServicesInitializer.InitializeConfiguration();
                    toolStripStatusLabel.Text = "Connected to STF database: {0}".FormatWith(dialog.Database);
                }
                else
                {
                    Application.Exit();
                }
            }
        }