Exemple #1
0
        /// <summary>
        /// Sets the specified environment to be the current one in use
        /// </summary>
        /// <param name="environmentName">The environment to be assigned as current</param>
        public void SetCurrentEnvironment(string environmentName)
        {
            SqlEnvironment e = GetEnvironment(environmentName);

            foreach (SqlEnvironment env in EnvironmentList)
            {
                env.IsCurrent = (env == e);
            }
        }
Exemple #2
0
        /// <summary>
        /// Adds a new environment into the system
        /// </summary>
        /// <param name="environment"></param>
        public void Add(SqlEnvironment environment)
        {
            if (!EnvironmentList.Contains(environment))
            {
                string n = environment.EnvironmentName;
                foreach (SqlEnvironment e in EnvironmentList)
                {
                    if (e.EnvironmentName == n)
                    {
                        throw new DataException("Environment " + n + " already exists");
                    }
                }

                EnvironmentList.Add(environment);
                if (environment.IsCurrent)
                {
                    SetCurrentEnvironment(environment.EnvironmentName);
                    SQLDMGlobal.Initialise();
                }
            }
        }
        private static void GetEnvironments()
        {
            if (_EnvironmentsCollected)
            {
                return;
            }

            _EnvironmentsCollected = true;

            foreach (Configuration.SQLDataManagerElement envElement in Configuration.SQLDataManager.GetEnvironments())
            {
                SqlEnvironment    env = new SqlEnvironment(envElement.Name);
                ConnectionManager cm  = ConnectionManager.GetConnectionManager();
                env.IsCurrent          = envElement.IsCurrent;
                env.InitialCatalog     = envElement.InitialCatalogue;
                env.IntegratedSecurity = envElement.IntegratedSecurity;
                env.ConnectionTimeout  = envElement.ConnectionTimeout;
                env.DataSource         = envElement.DataSource;
                env.Schema             = envElement.Schema;
                env.UserID             = envElement.UserID;
                env.Password           = envElement.Password;
                cm.Add(env);
            }
        }