Exemplo n.º 1
0
 public static string GetEnvironmentType()
 {
     if (EnvironmentSettings.EnvType == null)
     {
         string typeUsingNewLogic = EnvironmentSettings.GetEnvironmentTypeUsingNewLogic();
         if (typeUsingNewLogic != null)
         {
             EnvironmentSettings.EnvType = typeUsingNewLogic == null ? "" : typeUsingNewLogic;
             EnvironmentSettings.Environments?environmentFromString = EnvironmentSettings.GetEnvironmentFromString(typeUsingNewLogic);
             if (environmentFromString.HasValue)
             {
                 EnvironmentSettings.EnvironmetType = environmentFromString.Value;
             }
         }
     }
     return(EnvironmentSettings.EnvType);
 }
Exemplo n.º 2
0
 private static void LoadEnvironmentServersSettings()
 {
     System.Configuration.Configuration configuration = ConfigurationManager.OpenMappedExeConfiguration(new ExeConfigurationFileMap()
     {
         ExeConfigFilename = EnvironmentSettings.GetConfigFilePath()
     }, ConfigurationUserLevel.None);
     if (configuration != null)
     {
         AppSettingsSection appSettings = configuration.AppSettings;
         if (appSettings != null)
         {
             EnvironmentSettings.EnvServers = appSettings.Settings.OfType <KeyValueConfigurationElement>().ToDictionary <KeyValueConfigurationElement, string, string>((Func <KeyValueConfigurationElement, string>)(s => s.Key), (Func <KeyValueConfigurationElement, string>)(s => s.Value));
         }
     }
     if (EnvironmentSettings.EnvServers != null)
     {
         return;
     }
     EnvironmentSettings.EnvServers = new Dictionary <string, string>();
 }
Exemplo n.º 3
0
        public static string GetEnvironmentTypeUsingNewLogic()
        {
            string str = EnvironmentSettings.GetEnvironmentFromDeployment();

            if (str == null)
            {
                str = EnvironmentSettings.GetEnvironmentFromStartupDirectory();
                if (str == null)
                {
                    str = ConfigurationManager.AppSettings["Environment"];
                    if (str == null)
                    {
                        RegistryKey registryKey = Registry.LocalMachine.OpenSubKey("Software\\AQR");
                        if (registryKey != null)
                        {
                            str = (string)registryKey.GetValue("Environment");
                        }
                    }
                }
            }
            return(str);
        }
Exemplo n.º 4
0
 public static string GetWebServer()
 {
     EnvironmentSettings.GetEnvironmentType();
     return(EnvironmentSettings.GetWebServerForEnvironment(EnvironmentSettings.EnvironmetType));
 }
Exemplo n.º 5
0
 public static string GetEnvironmentConnectionString(string connectionStringName)
 {
     return(ConfigurationManager.ConnectionStrings[EnvironmentSettings.GetEnvironmentConnectionStringName(connectionStringName)].ConnectionString);
 }
Exemplo n.º 6
0
 public static string GetEnvironmentConnectionStringName(string connectionStringName)
 {
     return(connectionStringName + EnvironmentSettings.GetEnvironmentType());
 }
Exemplo n.º 7
0
 public static string GetWebServiceRedirectionServer()
 {
     return(EnvironmentSettings.AppSettings("WebServerHost"));
 }
Exemplo n.º 8
0
 public static string AppSettings(string name)
 {
     return(ConfigurationManager.AppSettings[name + EnvironmentSettings.GetEnvironmentTypeEx()]);
 }
Exemplo n.º 9
0
        public static string GetDefaultConfigForEnvironment(EnvironmentSettings.Environments env)
        {
            string key    = ((int)env).ToString() + "DefaultConfig";
            string orNull = EnvironmentSettings.EnvServers.GetOrNull <string, string>(key);

            if (orNull != null)
            {
                return(orNull);
            }
            throw new Exception(string.Format("No '{0}' defined in {1}", (object)key, (object)EnvironmentSettings.GetConfigFilePath()));
        }
Exemplo n.º 10
0
 public static string GetEnvironmentFromStartupDirectory()
 {
     return(EnvironmentSettings.GetEnvironmentFromStartupDirectory(AppDomain.CurrentDomain.BaseDirectory));
 }
Exemplo n.º 11
0
 static EnvironmentSettings()
 {
     EnvironmentSettings.GetEnvironmentType();
     EnvironmentSettings.LoadEnvironmentServersSettings();
 }
Exemplo n.º 12
0
 public static string GetEnvironmentFromDeployment()
 {
     if (ApplicationDeployment.IsNetworkDeployed)
     {
         EnvironmentSettings.ApplicationDeploymentVersion = ApplicationDeployment.CurrentDeployment.CurrentVersion.ToString();
         if (AppDomain.CurrentDomain.SetupInformation != null && AppDomain.CurrentDomain.SetupInformation.ActivationArguments != null)
         {
             if (AppDomain.CurrentDomain.SetupInformation.ActivationArguments.ActivationData != null)
             {
                 if ((uint)AppDomain.CurrentDomain.SetupInformation.ActivationArguments.ActivationData.Length > 0U)
                 {
                     Uri uri = new Uri(AppDomain.CurrentDomain.SetupInformation.ActivationArguments.ActivationData[0]);
                     Debug.WriteLine("ApplicationDeploymentUri " + uri.ToString());
                     EnvironmentSettings.ApplicationDeploymentSource = uri.Host;
                     string lower = uri.Host.ToLower();
                     if (lower == "aqrweb")
                     {
                         return("PROD");
                     }
                     if (lower == "st0sweb12")
                     {
                         return("STAGING");
                     }
                     return(lower == "aqrtest" ? "QA" : "QA");
                 }
             }
             else
             {
                 EnvironmentSettings.ApplicationDeploymentSource = AppDomain.CurrentDomain.SetupInformation.ActivationArguments.ApplicationIdentity.CodeBase;
                 Debug.WriteLine("ApplicationDeploymentSource " + EnvironmentSettings.ApplicationDeploymentSource);
                 if (EnvironmentSettings.ApplicationDeploymentSource.ToLower().IndexOf("dev/application/tradeworkflow/bin/publish") > 0)
                 {
                     return("DEV");
                 }
                 if (EnvironmentSettings.ApplicationDeploymentSource.ToLower().IndexOf("qa/application/tradeworkflow/bin/publish") > 0)
                 {
                     return("QA");
                 }
                 if (EnvironmentSettings.ApplicationDeploymentSource.ToLower().IndexOf("testframework/application/tradeworkflow/bin/publish") > 0)
                 {
                     return("TESTFRAMEWORK");
                 }
                 if (EnvironmentSettings.ApplicationDeploymentSource.ToLower().IndexOf("http://aqrweb") >= 0)
                 {
                     return("PROD");
                 }
                 if (EnvironmentSettings.ApplicationDeploymentSource.ToLower().IndexOf("http://st0sweb12") >= 0)
                 {
                     return("STAGING");
                 }
                 if (EnvironmentSettings.ApplicationDeploymentSource.ToLower().StartsWith("file://"))
                 {
                     EnvironmentSettings.ApplicationDeploymentSource = EnvironmentSettings.ApplicationDeploymentSource.ToLower().Substring("file:".Length).Replace('/', '\\');
                 }
                 Debug.WriteLine("ApplicationDeploymentSource Adjusted " + EnvironmentSettings.ApplicationDeploymentSource);
                 string startupDirectory = EnvironmentSettings.GetEnvironmentFromStartupDirectory(EnvironmentSettings.ApplicationDeploymentSource);
                 if (startupDirectory != null)
                 {
                     return(startupDirectory);
                 }
             }
         }
         return("QA");
     }
     EnvironmentSettings.ApplicationDeploymentSource = Environment.MachineName;
     return((string)null);
 }