Example #1
0
 static EnvironmentUtility()
 {
     try
     {
         EnvironmentUtility.EnvToZoneIdMapping         = new Dictionary <string, string>();
         EnvironmentUtility.EnvToZoneIdMapping["test"] = "NTGXH";
         EnvironmentUtility.EnvToZoneIdMapping["uat"]  = "NTGXH";
         EnvironmentUtility.EnvToZoneIdMapping["prod"] = "SHAJQ";
         EnvironmentUtility.EnvType    = EnvironmentUtility.ReadEnvFromFoundation();
         EnvironmentUtility.SubEnvType = EnvironmentUtility.ReadSubEnvFromFoundation();
         EnvironmentUtility.CurrentEnv = EnvironmentUtility.GetEnvType(EnvironmentUtility.SubEnvType ?? EnvironmentUtility.EnvType) ?? EnvironmentUtility.ReadEnvTypeFromReleaseInfo() ?? EnvironmentUtility.ReadEnvTypeFromCLoggingSetting() ?? "test";
         EnvironmentUtility.IsTestEnv  = EnvironmentUtility.CurrentEnv == "test";
         EnvironmentUtility.IsUatEnv   = EnvironmentUtility.CurrentEnv == "uat";
         EnvironmentUtility.IsProdEnv  = EnvironmentUtility.CurrentEnv == "prod";
         if (EnvironmentUtility.IsUatEnv || EnvironmentUtility.IsProdEnv)
         {
             EnvironmentUtility.SubEnvType = EnvironmentUtility.EnvType;
         }
         EnvironmentUtility.RegionId = "SHA";
         if (!string.IsNullOrWhiteSpace(EnvironmentUtility.ZoneId))
         {
             return;
         }
         EnvironmentUtility.ZoneId = EnvironmentUtility.EnvToZoneIdMapping[EnvironmentUtility.CurrentEnv];
         string message = string.Format("Missing {0} property in {1} file, using default value: {2}", (object)"idc", (object)"C:\\opt\\settings\\server.properties", (object)EnvironmentUtility.ZoneId);
         EnvironmentUtility.log.Warn(message);
     }
     catch (Exception ex)
     {
         EnvironmentUtility.log.Error("Error occurred while initializing EnvUtils.", ex);
     }
 }
Example #2
0
 private static string ReadEnvTypeFromReleaseInfo()
 {
     try
     {
         if (File.Exists(EnvironmentUtility.ReleaseInfoPathName))
         {
             XmlDocument xmlDocument = new XmlDocument();
             xmlDocument.Load(EnvironmentUtility.ReleaseInfoPathName);
             XmlNode xmlNode = xmlDocument.SelectSingleNode("ReleaseInfo/Target/EnvType");
             if (xmlNode == null || xmlNode.InnerText == null)
             {
                 return((string)null);
             }
             return(EnvironmentUtility.GetEnvType(xmlNode.InnerText));
         }
     }
     catch (Exception ex)
     {
         EnvironmentUtility.log.Warn("Failed to read environment from 'ReleaseInfo' file!", ex, new Dictionary <string, string>()
         {
             {
                 "ErrorCode",
                 "FXD300029"
             }
         });
     }
     return((string)null);
 }