Exemplo n.º 1
0
        static CommonUtils()
        {
            CommandExecutionEvents     = (CommandExecutionEventEnum[])Enum.GetValues(typeof(CommandExecutionEventEnum));
            CoreCommandExecutionEvents = new CommandExecutionEventEnum[]
            {
                CommandExecutionEventEnum.Success, CommandExecutionEventEnum.Failed, CommandExecutionEventEnum.Timeout, CommandExecutionEventEnum.ShortCircuited,
                CommandExecutionEventEnum.Rejected, CommandExecutionEventEnum.BadRequest
            };
            ValuableCommandExecutionEvents = new CommandExecutionEventEnum[]
            {
                CommandExecutionEventEnum.Success, CommandExecutionEventEnum.Failed, CommandExecutionEventEnum.Timeout, CommandExecutionEventEnum.ShortCircuited
            };
            CoreFailedCommandExecutionEvents = new CommandExecutionEventEnum[]
            {
                CommandExecutionEventEnum.Failed, CommandExecutionEventEnum.Timeout, CommandExecutionEventEnum.ShortCircuited,
                CommandExecutionEventEnum.Rejected, CommandExecutionEventEnum.BadRequest
            };

            AppId = ConfigurationManager.AppSettings["AppId"];
            if (string.IsNullOrWhiteSpace(AppId))
            {
                AppId = null;
            }
            else
            {
                AppId = AppId.Trim();
            }

            Log = ComponentFactory.CreateLog(typeof(CommonUtils));

            try
            {
                HostIP = Dns.GetHostAddresses(Dns.GetHostName())
                         .Where(c => c.AddressFamily == AddressFamily.InterNetwork)
                         .Select(c => c.ToString()).FirstOrDefault();
            }
            catch (Exception ex)
            {
                Log.Log(LogLevelEnum.Fatal, "Failed to get host IP.", ex);
            }
        }
Exemplo n.º 2
0
 static CommonUtils()
 {
     CommandExecutionEvents = (CommandExecutionEventEnum[])System.Enum.GetValues(typeof(CommandExecutionEventEnum));
     CommandExecutionEventEnum[] enumArray = new CommandExecutionEventEnum[6];
     enumArray[1] = CommandExecutionEventEnum.Failed;
     enumArray[2] = CommandExecutionEventEnum.Timeout;
     enumArray[3] = CommandExecutionEventEnum.ShortCircuited;
     enumArray[4] = CommandExecutionEventEnum.Rejected;
     enumArray[5] = CommandExecutionEventEnum.BadRequest;
     CoreCommandExecutionEvents = enumArray;
     CommandExecutionEventEnum[] enumArray2 = new CommandExecutionEventEnum[4];
     enumArray2[1] = CommandExecutionEventEnum.Failed;
     enumArray2[2] = CommandExecutionEventEnum.Timeout;
     enumArray2[3] = CommandExecutionEventEnum.ShortCircuited;
     ValuableCommandExecutionEvents   = enumArray2;
     CoreFailedCommandExecutionEvents = new CommandExecutionEventEnum[] { CommandExecutionEventEnum.Failed, CommandExecutionEventEnum.Timeout, CommandExecutionEventEnum.ShortCircuited, CommandExecutionEventEnum.Rejected, CommandExecutionEventEnum.BadRequest };
     AppId = ConfigurationManager.AppSettings["AppId"];
     if (string.IsNullOrWhiteSpace(AppId))
     {
         AppId = null;
     }
     else
     {
         AppId = AppId.Trim();
     }
     Log = ComponentFactory.CreateLog(typeof(CommonUtils));
     try
     {
         HostIP = (from c in Dns.GetHostAddresses(Dns.GetHostName())
                   where c.AddressFamily == AddressFamily.InterNetwork
                   select c.ToString()).FirstOrDefault <string>();
     }
     catch (Exception exception)
     {
         Log.Log(LogLevelEnum.Fatal, "Failed to get host IP.", exception);
     }
 }