private void button2_Click(object sender, EventArgs e)
        {
            if (folderBrowserDialog1.ShowDialog() == DialogResult.OK)
            {
                string fullPath = folderBrowserDialog1.SelectedPath;

                List <string> allFiles = new List <string>();
                fillAllFiles(allFiles, fullPath);

                //richTextBox1
                Dictionary <string, string> ips = new Dictionary <string, string>();

                foreach (string f in allFiles)
                {
                    string line = string.Empty;
                    using (System.IO.StreamReader sr = new System.IO.StreamReader(f)) {
                        while ((line = sr.ReadLine()) != null)
                        {
                            string ip = LogFileHelper.getClientIP(line);
                            if (!ips.ContainsKey(ip))
                            {
                                ips.Add(ip, f);
                            }
                        }
                    }
                }
                richTextBox1.Clear();
                foreach (string ip in ips.Keys)
                {
                    richTextBox1.AppendText(ip + " " + ips[ip]);
                    richTextBox1.AppendText("\n");
                }
            }
        }
Exemple #2
0
        private void loadDataToGrid(List <TreeNode> nodes)
        {
            this.Cursor = Cursors.WaitCursor;
            try {
                LogDataLoadInfo loadInfo     = new LogDataLoadInfo();
                List <string>   logFileNames = new List <string>();
                foreach (TreeNode node in nodes)
                {
                    if (node == null || node.Parent == null || node.Tag == null)
                    {
                        continue;
                    }

                    string fullFileName = _Current_LogFile_Path + @"\" + node.Tag.ToString() + ".txt";
                    logFileNames.Add(fullFileName);
                }
                if (logFileNames.Count == 0)
                {
                    this.Cursor = Cursors.Default;
                    return;
                }

                LogFileHelper.LoadDataToCtl(gridControl1, logFileNames.ToArray(), loadInfo);

                labExecuteTime.Text = "1)本次服务器记录时间从:" + loadInfo.BeginDate.ToString() + " 到:" + loadInfo.EndDate.ToString();
                labLoadInfo.Text    = "2)发现错误的消息有:" + loadInfo.ErrCount + " 个,超过1秒执行的方法有:" + loadInfo.OverTimeCount.ToString() + "个。";
            }
            catch (Exception ex) {
                MessageBox.Show("加载日记有误,请检查是否有该目录的访问权限?" + ex.Message);
            }
            this.Cursor = Cursors.Default;
        }
        private void butQAMiddleLayer_Click(object sender, EventArgs e)
        {
            if (folderBrowserDialog1.ShowDialog() == DialogResult.OK)
            {
                string fullPath = folderBrowserDialog1.SelectedPath;

                List <string> allFiles = new List <string>();
                fillAllFiles(allFiles, fullPath);

                //richTextBox1
                Dictionary <string, UserDateInfo> datas = new Dictionary <string, UserDateInfo>();

                foreach (string f in allFiles)
                {
                    string line = string.Empty;
                    using (System.IO.StreamReader sr = new System.IO.StreamReader(f)) {
                        DateTime lastTime = DateTime.MinValue;
                        while ((line = sr.ReadLine()) != null)
                        {
                            if (string.IsNullOrEmpty(line))
                            {
                                continue;
                            }
                            DateTime dt = LogFileHelper.getDatetime(line);
                            string   ip = LogFileHelper.getClientIP(line);

                            string key = ip + " " + dt.ToString("yyyy-MM-dd HH:mm:ss");
                            if (!datas.ContainsKey(key))
                            {
                                TimeSpan span = dt.Subtract(lastTime);
                                if (span.TotalSeconds <= 1)
                                {
                                    datas.Add(key, new UserDateInfo(ip, dt.ToString("yyyy-MM-dd HH:mm:ss")));
                                }

                                lastTime = dt;
                            }
                        }
                        sr.Close();
                    }
                }
                if (datas.Count > 0)
                {
                    frmViewIpAndDate frm = new frmViewIpAndDate(datas.Values.ToList <UserDateInfo>());
                    frm.ShowDialog();
                }
            }
        }
        private void butQAMiddleError_Click(object sender, EventArgs e)
        {
            if (folderBrowserDialog1.ShowDialog() == DialogResult.OK)
            {
                string fullPath = folderBrowserDialog1.SelectedPath;

                List <string> allFiles = new List <string>();
                fillAllFiles(allFiles, fullPath);

                //richTextBox1
                Dictionary <string, string> datas = new Dictionary <string, string>();

                foreach (string f in allFiles)
                {
                    string line = string.Empty;
                    using (System.IO.StreamReader sr = new System.IO.StreamReader(f)) {
                        while ((line = sr.ReadLine()) != null)
                        {
                            if (string.IsNullOrEmpty(line))
                            {
                                continue;
                            }
                            string type = LogFileHelper.getMessageType(line, new LogDataLoadInfo());
                            if (type != "代码执行轨迹")
                            {
                                if (!datas.ContainsKey(line))
                                {
                                    datas.Add(line, f);
                                }
                            }
                        }
                    }
                }
                richTextBox1.Clear();
                foreach (string ip in datas.Keys)
                {
                    richTextBox1.AppendText(ip + " " + datas[ip]);
                    richTextBox1.AppendText("\n");
                }
            }
        }