Пример #1
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;
        }
Пример #2
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;
            }
        }
Пример #3
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();
                }
            }
        }