Esempio n. 1
0
        override public bool Process(FileItem fileItem)
        {
            Console.WriteLine(fileItem.path);
            bool         ok   = false;
            StreamReader file = null;

            try {
                try {
                    file = new StreamReader(fileItem.path);
                    string line;
                    while ((line = file.ReadLine()) != null)
                    {
                        RowItem ri = new RowItem();
                        ri.type = fileItem.type;
                        ri.line = line;
                        rowQueue.Insert(ri);
                    }
                    ok = true;
                }
                finally {
                    if (file != null)
                    {
                        file.Close();
                    }
                }
            }
            catch {
            }
            if (ok)
            {
                processedQueue.Insert(fileItem);
            }
            return(ok);
        }
 public void Scan(string aDirectory)
 {
     string[] files = Directory.GetFiles(aDirectory);
     for (int i = 0; i < files.Length; i++)
     {
         string file = files[i];
         if (File.Exists(file))
         {
             StreamReader aFile = new StreamReader(file);
             string       line;
             do
             {
                 line = aFile.ReadLine();
                 int a = line.IndexOf(" 200 ");
             }while ((line != null) && (line.IndexOf(" 200 ") == -1));
             if (line != null)
             {
                 FileItem fi = new FileItem();
                 if (line.EndsWith("\""))
                 {
                     fi.type = LogFormat.COMBINED;
                 }
                 else
                 {
                     fi.type = LogFormat.CLF;
                 }
                 fi.path = file;
                 outQueue.Insert(fi);
             }
             aFile.Close();
         }
     }
 }
Esempio n. 3
0
        public static void Main(string[] args)
        {
            Tokenizer tokenizer = new Tokenizer();

            URIItem uri = tokenizer.Tokenize(new Uri("http://www.eiroca.net/path/index.html?a=2#frag"));


            logCollector.Start();
            teda.Start();

            paths.Insert("C:\\temp");

            bool a;
            bool b;

            do
            {
                Thread.Sleep(1000);
                a = logCollector.IsFinished();
                b = teda.IsFinished();
            }while ((!a) | (!b));

            logCollector.Stop();
            teda.Stop();

            Console.WriteLine("Press any key to continue . . . ");
            Console.ReadKey(true);
        }
        private bool ProcessWebLog(Regex fmt, RowItem row)
        {
            HitEventItem ev = null;
            bool         ok = false;
            Match        m  = fmt.Match(row.line);

            if (m.Groups.Count >= 11)
            {
                string[] fld   = new string[m.Groups.Count];
                int      count = 0;
                foreach (Group g in m.Groups)
                {
                    foreach (Capture c in g.Captures)
                    {
                        fld[count] = c.Value;
                        count++;
                    }
                }
                try {
                    ev      = new HitEventItem();
                    ev.type = EventType.HIT;
                    if (ParseLogTimeStamp(fld[4], out ev.when))
                    {
                        ev.remoteHost    = NormalizeField(fld[1]);
                        ev.authUser      = NormalizeField(fld[2]);
                        ev.remoteLogName = NormalizeField(fld[3]);
                        ev.timeZone      = NormalizeField(fld[5]);
                        ev.reqMethod     = NormalizeField(fld[6]);
                        ev.reqProtocol   = NormalizeField(fld[8]);
                        ev.status        = NormalizeIntField(fld[9]);
                        ev.byteSent      = NormalizeIntField(fld[10]);
                        ev.reqURI        = new Uri(server, fld[7]);
                        if (row.type == LogFormat.COMBINED)
                        {
                            string refer = NormalizeField(fld[11]);
                            if (refer != null)
                            {
                                ev.refer = new Uri(refer);
                            }
                            ev.userAgent = NormalizeField(fld[12]);
                        }
                        if (ev.authUser != null)
                        {
                            ev.user = "******" + ev.authUser;
                        }
                        else
                        {
                            if (ev.userAgent != null)
                            {
                                ev.user = "******" + ev.remoteHost + "." + ev.userAgent;
                            }
                            else
                            {
                                ev.user = "******" + ev.remoteHost;
                            }
                        }
                        ev.key = ev.user.GetHashCode();
                        ok     = true;
                    }
                }
                catch (Exception e) {
                    Console.WriteLine("ERR=" + e.Message);
                    ok = false;
                }
            }
            if (ok)
            {
                outQueue.Insert(ev);
            }
            else
            {
                Console.WriteLine("ERR " + row.line);
            }
            return(ok);
        }
 protected void Flush(Session s)
 {
     sessionQueue.Insert(s);
 }