Ejemplo n.º 1
0
 /// <summary>
 /// Initializes object instance
 /// </summary>
 /// <param name="LogMessage">log client object</param>
 public LogMessage(CLogMessage LogMessage)
 {
     if (LogMessage == null)
     {
         throw new ArgumentNullException("LogMessage");
     }
     _LogMessage = LogMessage;
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Inserts log message to dataset
        /// </summary>
        /// <param name="logMessage">log message</param>
        private void Insert2DataSet(CLogMessage Message)
        {
            if (null == Message)
            {
                return;
            }

            DataRow row = _dataSet.Tables[0].NewRow();

            row.ItemArray = new object[] { Message.Severity, Message.AddedDate, Message.Message, new LogMessage(Message) };
            _dataSet.Tables[0].Rows.Add(row);
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Parameterless ctor
 /// </summary>
 public LogMessage()
 {
     _LogMessage = new CLogMessageClass();
 }
Ejemplo n.º 4
0
 /// <summary>
 /// Initializes object instance
 /// </summary>
 /// <param name="LogMessage">log client object</param>
 public LogMessage(CLogMessage LogMessage)
 {
     if (LogMessage == null)
         throw new ArgumentNullException("LogMessage");
     _LogMessage = LogMessage;
 }
Ejemplo n.º 5
0
 /// <summary>
 /// Parameterless ctor
 /// </summary>
 public LogMessage()
 {
     _LogMessage = new CLogMessageClass();
 }
Ejemplo n.º 6
0
        /// <summary>
        /// Perform parsing
        /// </summary>
        public void Parse()
        {
            FileInfo logFileInfo = new FileInfo(_fileName);

            logFileInfo.Attributes = FileAttributes.Normal;

            /// constructing grammar object
            MemoryStream stream  = new MemoryStream(NetLogViewer.res.Resource1.AidLibLogs);
            Grammar      grammar = new Grammar(new BinaryReader(stream));

            /// creating parser
            _parser = new Parser(new StreamReader(logFileInfo.OpenRead()), grammar);
            CLogMessage logMessage = new CLogMessage();
            string      token = "", valueToken = "";

            if (null != _progressBar)
            {
                _progressBar.Minimum = 0;
                _progressBar.Maximum = (int)logFileInfo.Length;
            }
            for (int i = 0;; ++i)
            {
                if (null != _progressBar && i % 100 == 0)
                {
                    _progressBar.Value = _parser.CharPosition;
                    Application.DoEvents();
                }
                ParseMessage parseMsg = _parser.Parse();
                switch (parseMsg)
                {
                case ParseMessage.Reduction:
                    if ("<message>" == _parser.ReductionRule.Name)
                    {
                        logMessage.Severity = 0;     //_MESSAGE
                        Insert2DataSet(logMessage);
                        logMessage = new CLogMessage();
                    }
                    else if ("<warning>" == _parser.ReductionRule.Name)
                    {
                        logMessage.Severity = 1;     //_WARNING
                        Insert2DataSet(logMessage);
                        logMessage = new CLogMessage();
                    }
                    else if ("<error>" == _parser.ReductionRule.Name)
                    {
                        logMessage.Severity = 2;     //_ERROR
                        Insert2DataSet(logMessage);
                        logMessage = new CLogMessage();
                    }
                    else if ("<exception>" == _parser.ReductionRule.Name)
                    {
                        logMessage.Severity = 3;     //_EXCEPTION
                        Insert2DataSet(logMessage);
                        logMessage = new CLogMessage();
                    }
                    else if ("<timeValue>" == _parser.ReductionRule.Name)
                    {
                        DateTimeFormatInfo dateTimeFormatInfo = Thread.CurrentThread.CurrentCulture.DateTimeFormat.Clone() as DateTimeFormatInfo;
                        //System.Windows.Forms.MessageBox.Show(dateTimeFormatInfo.MonthDayPattern);
                        dateTimeFormatInfo.MonthDayPattern = "dd.MM";
                        logMessage.AddedDate = DateTime.Parse(valueToken, dateTimeFormatInfo);
                    }
                    else if ("<processValue>" == _parser.ReductionRule.Name)
                    {
                        logMessage.PID = valueToken;
                    }
                    else if ("<threadValue>" == _parser.ReductionRule.Name)
                    {
                        logMessage.TID = valueToken;
                    }
                    else if ("<sourceFileValue>" == _parser.ReductionRule.Name)
                    {
                        logMessage.FileName = valueToken;
                    }
                    else if ("<lineNumberValue>" == _parser.ReductionRule.Name)
                    {
                        logMessage.FileLine = short.Parse(valueToken);
                    }
                    else if ("<compileDateValue>" == _parser.ReductionRule.Name)
                    {
                        logMessage.CompileDate = valueToken;
                    }
                    else if ("<callStackValue>" == _parser.ReductionRule.Name)
                    {
                        logMessage.CallStack = valueToken;
                    }
                    else if ("<messageValue>" == _parser.ReductionRule.Name)
                    {
                        logMessage.Message = valueToken;
                    }
                    else if ("<systemErrorValue>" == _parser.ReductionRule.Name)
                    {
                        logMessage.SysError = valueToken;
                    }
                    break;

                case ParseMessage.Accept:
                    if (null != _progressBar)
                    {
                        _progressBar.Value = _parser.CharPosition;
                    }
                    return;

                case ParseMessage.InternalError:
                case ParseMessage.LexicalError:
                case ParseMessage.NotLoadedError:
                case ParseMessage.SyntaxError:
                    throw new Exception(String.Format("{0} occured while parsing file", parseMsg.ToString()));

                case ParseMessage.TokenRead:
                    valueToken = token;
                    token      = CleanupLogString(_parser.TokenString);
                    break;
                }
            }
        }