Exemplo n.º 1
0
 /// <summary>
 /// Copy constructor
 /// </summary>
 /// <param name="item"></param>
 public ActionReplyMessageItem(ActionReplyMessageItem item)
 {
     Exception    = item.Exception;
     Severity     = item.Severity;
     MessageText  = item.MessageText;
     ReferenceKey = item.ReferenceKey;
 }
Exemplo n.º 2
0
        /// <summary>
        /// Convenience method to add formatted parameter values to reply.  Default severity: information
        /// </summary>
        /// <param name="severity">Describes how important this parameter note is to be considered</param>
        /// <param name="paramName">Name of property or parameter</param>
        /// <param name="paramValue">Current value of parameter</param>
        public void AddParam(ActionStatus severity, string paramName, object paramValue)
        {
            ActionReplyMessageItem item = new ActionReplyMessageItem(paramName, severity, "Param: {0}: {1}", paramName, paramValue);

            item.Severity = severity;
            Messages.Add(item);
        }
Exemplo n.º 3
0
        public void LogWrite()
        {
            if (_log == null)
            {
                _log = Log.NewLog(this.GetType());
            }
            LogMessage logMessage = new LogMessage();

            logMessage.Severity = mapper(this.Messages.MaximumSeverity);
            ActionReplyMessageItem replyMessage = this.Messages.HighestMessage;

            if (replyMessage != null)
            {
                logMessage.MessageText = replyMessage.MessageText + " (" + replyMessage.Severity.ToString() + ") ";
                if (this.Messages.Count > 1)
                {
                    logMessage.MessageText += " 1 of " + this.Messages.Count.ToString();
                }
            }

            var sortedMessageList = Messages.OrderBy((item) => ((int)item.Severity) * -1); //sort most severe first
            int msgCount          = 1;

            foreach (var msg in sortedMessageList)
            {
                string prefix = "Msg" + msgCount.ToString("00");
                logMessage.ExtendedProperties.Add(prefix + "[Severity]", msg.Severity.ToString());
                if (string.IsNullOrWhiteSpace(msg.ReferenceKey) == false)
                {
                    logMessage.ExtendedProperties.Add(prefix + "[Reference]", msg.ReferenceKey.ToString());
                }
                logMessage.ExtendedProperties.Add(prefix + "[Text]", msg.MessageText.ToString());
                if (msg.Exception != null)
                {
                    logMessage.ExtendedProperties.Add(prefix + "[Exception]", msg.Exception.Expand());
                }
                msgCount++;
            }

            //EXTENSION serialize DataItems and Value object and add them to extendend properties

            _log.Write(logMessage);
        }
 /// <summary>
 /// Copy constructor
 /// </summary>
 /// <param name="item"></param>
 public ActionReplyMessageItem(ActionReplyMessageItem item)
 {
     Exception = item.Exception;
     Severity = item.Severity;
     MessageText = item.MessageText;
     ReferenceKey = item.ReferenceKey;
 }
Exemplo n.º 5
0
		/// <summary>
		/// Convenience method to add formatted parameter values to reply.  Default severity: information
		/// </summary>
		/// <param name="severity">Describes how important this parameter note is to be considered</param>
		/// <param name="paramName">Name of property or parameter</param>
		/// <param name="paramValue">Current value of parameter</param>
		public void AddParam(ActionStatus severity, string paramName, object paramValue)
		{
			ActionReplyMessageItem item = new ActionReplyMessageItem(paramName, severity, "Param: {0}: {1}", paramName, paramValue);
			item.Severity = severity;
			Messages.Add(item);
		}