Shuxia Ning
2024-08-28 1a8a81785470302fc7fbd6914a9df5d1094dac2a
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
using System.IO;
using System.Text;
 
namespace Verify
{
    internal class LogHelper
    {
        public static List<Tuple<long, DateTime, string, bool>> Parse()
        {
            System.Text.Encoding.RegisterProvider(System.Text.CodePagesEncodingProvider.Instance);
            var log_folder = AppDomain.CurrentDomain.BaseDirectory + "\\调度日志\\Logs\\Debug";
            var files = Directory.GetFiles(log_folder);
            var list = new List<Tuple<long, DateTime, string, bool>>();
            foreach (var filePath in files)
            {
                using (var fs = new FileStream(filePath, FileMode.Open, FileAccess.Read))
                using (var sr = new StreamReader(fs, Encoding.GetEncoding("GBK")))
                {
                    var strLine = string.Empty;
                    while (!string.IsNullOrEmpty(strLine = sr.ReadLine()))
                    {
                        var arr = strLine.Split("|");
                        var ar0 = arr[0];
                        var time_str = ar0.Substring(0, ar0.IndexOf(","));
                        if (!DateTime.TryParse(time_str, out DateTime time))
                            continue;
                        var info = arr[1];
                        var id_str = info.Substring(0, info.IndexOf("-"));
                        if (!long.TryParse(id_str, out long id))
                            continue; 
                        var info_json = info.Substring(info.LastIndexOf(">") + 1); 
                        var title = info.Substring(info.IndexOf("-") + 1, info.IndexOf(">"));
                        if (title.StartsWith("需水请求"))
                        {
                            continue;
                        }
                        var bol = title.StartsWith("实时ZyScada请求(调度后5分钟验证)");
                        if (bol)
                        { }
                        list.Add(new(id, time, info_json, bol));
                    }
                }
            }
 
 
            return list; 
 
        }
 
 
    }
}