예제 #1
0
        public LogRowElements ParseElements(string entry)
        {
            LogRowElements elements = new LogRowElements();

            Regex rgx   = new Regex(MatchPattern, RegexOptions.IgnoreCase);
            var   parts = rgx.Matches(entry);

            elements.PartsCount     = parts.Count;
            elements.IP             = parts[0].ToString();
            elements.Identity       = parts[1].ToString();
            elements.UserId         = parts[2].ToString();
            elements.Timestamp      = parts[3].ToString();
            elements.Offset         = parts[4].ToString();
            elements.RequestMessage = parts[5].ToString();
            elements.StatusCode     = parts[6].ToString();
            elements.Size           = parts[7].ToString();
            elements.Referer        = parts[8].ToString();
            elements.URL            = parts[9].ToString();
            elements.UserAgent      = parts[10].ToString();
            elements.Forwarded      = parts[11].ToString();

            if (parts.Count != 12)
            {
                elements.Error = true;
            }

            return(elements);
        }
예제 #2
0
        public override IEnumerable <IRow> Extract(IUnstructuredReader input, IUpdatableRow output)
        {
            string line;

            //Read the input line by line
            foreach (Stream current in input.Split(_row_delim))
            {
                using (StreamReader streamReader = new StreamReader(current, this._encoding))
                {
                    line = streamReader.ReadToEnd().Trim();

                    LogRowParser   splitter = new LogRowParser();
                    LogRowElements parts    = new LogRowElements();

                    parts = splitter.ParseElements(line);

                    output.Set <string>(0, parts.IP);
                    output.Set <string>(1, parts.Identity);
                    output.Set <string>(2, parts.UserId);
                    output.Set <string>(3, parts.Timestamp);
                    output.Set <string>(4, parts.Offset);
                    output.Set <string>(5, parts.RequestMessage);
                    output.Set <string>(6, parts.StatusCode);
                    output.Set <string>(7, parts.Size);
                    output.Set <string>(8, parts.Referer);
                    output.Set <string>(9, parts.URL);
                    output.Set <string>(10, parts.UserAgent);
                    output.Set <string>(11, parts.Forwarded);

                    yield return(output.AsReadOnly());
                }
            }
        }