Beispiel #1
0
        /// <summary>
        /// Return logging dto with initial values
        /// </summary>
        /// <returns></returns>
        public static LoggingDTO GetLogDTO(string ProcessName, string ProcessId)
        {
            LoggingDTO logDTO = new LoggingDTO();

            if (string.IsNullOrEmpty(logDTO.BaseTransactionID))
            {
                logDTO.BaseTransactionID = Guid.NewGuid().ToString();
            }

            if (string.IsNullOrEmpty(logDTO.ProcessID))
            {
                logDTO.ProcessID = ProcessId;
            }

            if (string.IsNullOrEmpty(logDTO.ProcessName))
            {
                logDTO.ProcessName = ProcessName;
            }

            logDTO.Server     = System.Net.Dns.GetHostName();
            logDTO.ExecutedOn = System.Environment.MachineName;
            logDTO.UserId     = System.Environment.UserName;
            logDTO.Created    = DateTime.Now.ToString();

            return(logDTO);
        }
Beispiel #2
0
        /// <summary>
        /// Log a message of severity Error
        /// </summary>
        /// <param name="c">Category, mapped to categories in EntLib config file</param>
        /// <param name="m">Message string logged</param>
        /// <param name="p">Parameters</param>
        public static void LogError(Constants.Category c, Exception ex, LoggingDTO log)
        {
            if (Logger.IsLoggingEnabled())
            {
                log.StackTrace       = ex.StackTrace;
                log.ErrorDescription = ex.ToString();

                Dictionary <string, object> dic = new Dictionary <string, object>();
                dic = log.GetType()
                      .GetProperties(BindingFlags.Instance | BindingFlags.Public)
                      .ToDictionary(prop => prop.Name, prop => prop.GetValue(log, null));

                LogEntry entry = CreateLogEntry(ex.Message, c, Constants.Severity.Error);
                PerformLogging(dic, entry);
            }
        }
Beispiel #3
0
        /// <summary>
        /// GetLogDTO
        /// </summary>
        /// <param name="logDTO"></param>
        /// <param name="method"></param>
        /// <param name="InText"></param>
        /// <param name="ResponseText"></param>
        /// <returns></returns>
        public static LoggingDTO GetLogDTO(LoggingDTO logDTO, MethodBase method, string RequestText = null, string ResponseText = null)
        {
            if (logDTO == null)
            {
                logDTO = GetLogDTO("", "");
            }

            logDTO.Method = method;
            var fullName = method.DeclaringType.FullName + "." + method.Name;

            logDTO.Source = fullName;

            if (ResponseText != null)
            {
                logDTO.ResponseText = ResponseText;
            }
            return(logDTO);
        }