コード例 #1
0
        /// <summary>
        /// Sets global settings for which database
        /// </summary>
        /// <returns></returns>
        public static bool ConnectToDatabase()
        {
            if (STFDispatcherManager.Dispatcher == null || STFDispatcherManager.DisconnectFromDispatcher(true))
            {
                var systems = GetAvailableSystems();

                if (systems.Count == 1)
                {
                    StfSystem system = systems.First();
                    InitializeDataConnection(system.Name, system.Address);
                    return(true);
                }
                else
                {
                    string lastUsedSystem = UserAppDataRegistry.GetValue("STFSystem") as string;
                    using (InputDialog inputDialog = new InputDialog("Select an Environment to connect to:", "Connect to Environment", lastUsedSystem))
                    {
                        inputDialog.StartPosition = FormStartPosition.CenterScreen;
                        inputDialog.InitializeComboBox(systems.Select(x => x.Name).ToList());

                        if (inputDialog.ShowDialog() == DialogResult.OK)
                        {
                            var selectedSystem = systems.First(x => x.Name.Equals(inputDialog.Value));
                            InitializeDataConnection(selectedSystem.Name, selectedSystem.Address);
                            return(true);
                        }
                    }
                }
            }

            return(false);
        }
コード例 #2
0
        private static void LoadGlobalSettings(string database)
        {
            // Load or reload settings from the selected database
            GlobalSettings.Clear();
            GlobalSettings.Load(database);
            SystemDatabase = database;

            STFDispatcherManager.DisconnectFromDispatcher(false);
        }