private void controlwatch() { threadcontrolI = 0; while (threadcontrolI != threads) { Thread.Sleep(500); Progressbar(currentline, totalline); } Progressbar(totalline, totalline); SortableBindingList <Line> exportlist = new SortableBindingList <Line>(); Dictionary <String, int>[] exportcache = new Dictionary <String, int> [6]; UpdateStatus("Pass Processing..."); foreach (SortableBindingList <Line> templ in ListofLinelist) { foreach (Line l in templ) { exportlist.Add(l); } } //List<Dictionary<String, int>[]> foreach (Dictionary <String, int>[] tempcache in ListofCache) { if (tempcache[0] == null && tempcache[5] == null) { continue; } int i = 0; foreach (Dictionary <String, int> tempdic in tempcache) { if (exportcache[i] == null) { exportcache[i] = new Dictionary <string, int>(); } foreach (String key in tempdic.Keys) { if (exportcache[i].ContainsKey(key)) { exportcache[i][key] += tempdic[key]; } else { exportcache[i].Add(key, tempdic[key]); } } i++; } } t2 = DateTime.Now; UpdateStatus(exportlist.Count + "Entries\t" + (t2 - t1).TotalSeconds + "s"); form1instance.setGridDataView(exportlist, exportcache); //UpdateStatus(String.Format("Complete: {0} Entries", linelist.Count)); }
private void parse(int totalline, StreamReader sr, int threadid) { Console.WriteLine("Thread {0} started!", Thread.CurrentThread.ManagedThreadId); String line = ""; SortableBindingList <Line> linelist = new SortableBindingList <Line>(); Dictionary <String, int>[] cache = new Dictionary <string, int> [6]; while ((line = readStreamLine(sr)) != null) { Match regexMatch = Regex.Match(line, logEntryPattern); if (regexMatch.Groups.Count < 10) { return; } //Progressbar //if ((currentLine % progressbarPara) == 0) //{ // Progressbar(currentLine, tillLine, Thread.CurrentThread.ToString()); //} //using keys from listbox1 if (useKeys) { bool foundsomething = false; bool exit = false; foreach (String key in keys) { if (line.Contains(key)) { //|| or mode //At least one key must be found foundsomething = true; if (keymode == 0) { break; } } else { //&& and mode //Every key must be found if (keymode == 1) { exit = true; break; } } } //go back if ((!foundsomething) || exit) { continue; } } //Extracting Data from Regex Match DateTime d = DateTime.MinValue; try{ d = DateTime.ParseExact(regexMatch.Groups[INDEXdate].Value, (datePattern + " K"), System.Globalization.CultureInfo.InvariantCulture); } catch (System.FormatException e) { } String hostname = getItem(regexMatch, INDEXip); String request = getItem(regexMatch, INDEXrequest); String trafficstr = getItem(regexMatch, INDEXtraffic); //Log Syntax traffic 0 = '-' if (trafficstr == "-") { trafficstr = "0"; } int traffic = int.Parse(trafficstr); String agent = getItem(regexMatch, INDEXagent); //Filter if (agent.Length > 3) { if (agent.Substring(0, 3) == "\" \"") { agent = agent.Substring(3, agent.Length - 3); } if (agent[0] == '<') { agent = ""; } } Match mBrowser = Regex.Match(agent, browserPattern); String browser = ""; if (mBrowser.Success && mBrowser.Groups[0].Value[0] != '<') { browser = mBrowser.Groups[0].Value; } Line l = new Line(hostname, d, request, short.Parse(getItem(regexMatch, INDEXhttpcode)), traffic, browser);//,agent); linelist.Add(l); dicchecker(cache, 0, hostname); dicchecker(cache, 1, d.ToString()); dicchecker(cache, 2, request); dicchecker(cache, 3, l.httpcode.ToString()); dicchecker(cache, 4, traffic.ToString()); dicchecker(cache, 5, browser); //dicchecker(cache, 6 , agent); } //Progressbar(tillLine, tillLine, Thread.CurrentThread.ToString()); //form1instance.setGridDataView(linelist,cache); //UpdateStatus(String.Format("Complete: {0} Entries", linelist.Count)); registerlinelist(linelist, threadid); registercachelist(cache); if (threads - threadcontrolI == 1) { t2 = DateTime.Now; } threadcontrolI++; Console.WriteLine("Thread {0} stopped!", threadid); }