Example #1
0
        public static string CreateLine(LogReportItemType itemType, int level, DateTime dateTime, string message)
        {
            string PATTERN = "[{0}|{1:00}|{2}] {3}";

            string type = GetTypeDisplayAsString(itemType);
            string date = GetDate(dateTime, LogReportDateDisplayType.Time);

            string msg = message.Replace(Environment.NewLine, ITEM_SEPARATOR);

            string line = string.Format(PATTERN, type, level, date, msg);

            return(line);
        }
Example #2
0
        public static bool TryCreateFromString(string pattern, out LogReportItem item)
        {
            item = null;

            try
            {
                int headerLength = _headerPattern.Length;
                if (pattern.Length < headerLength + 2)
                {
                    return(false);
                }

                string header = pattern.Substring(0, headerLength);

                bool isPattern = pattern[0] == '[' && pattern[4] == '|' &&
                                 pattern[7] == '|' && pattern[16] == ']';

                if (!isPattern)
                {
                    return(false);
                }

                string type     = MtString.GetSubString(pattern, 0, 4, false);
                string strLevel = MtString.GetSubString(pattern, 4, 7, false);
                string date     = MtString.GetSubString(pattern, 7, 16, false);
                string tempMsg  = pattern.Substring(18);
                string msg      = tempMsg.Replace(ITEM_SEPARATOR, Environment.NewLine);


                LogReportItemType typeofReport = GetLogReportType(type);
                int      level = int.Parse(strLevel);
                DateTime dt    = DateTime.Parse(date);

                item = new LogReportItem
                {
                    TypeOfLogItem = typeofReport,
                    Level         = level,
                    Date          = dt,
                    Message       = msg
                };

                return(true);
            }
            catch (Exception exc)
            {
            }

            return(false);
        }
Example #3
0
        public void Log(string message, int level, LogReportItemType type)
        {
            LogReportItem item = new LogReportItem()
            {
                Date          = DateTime.Now,
                Level         = level,
                Message       = message,
                TypeOfLogItem = type
            };

            if (null != Current)
            {
                Current.Items.Add(item);
            }
        }
Example #4
0
        public static Bitmap GetBitmap(LogReportItemType itemType)
        {
            if (itemType == LogReportItemType.Error)
            {
                return(Properties.Resources.IconError16);
            }
            else if (itemType == LogReportItemType.Exception)
            {
                return(Properties.Resources.IconError16);
            }
            else if (itemType == LogReportItemType.Warning)
            {
                return(Properties.Resources.IconWarning16);
            }
            else if (itemType == LogReportItemType.Message)
            {
                return(Properties.Resources.IconInfo16);
            }

            return(null);
        }
Example #5
0
 public static string GetTypeDisplayAsString(LogReportItemType typeOfItem)
 {
     return(_shortcutDict[typeOfItem]);
 }
Example #6
0
 public void Log(string message, int level, LogReportItemType type)
 {
 }
Example #7
0
 public void Log(string message, int level, LogReportItemType type)
 {
     throw new NotImplementedException();
 }