コード例 #1
0
        static void Main(string[] args)
        {
            String path = Path.Combine(Environment.CurrentDirectory, "testtxt.txt");

            if (File.Exists(path))
            {
                FileInfo file = new FileInfo(path);
                //文件内容
                using (var contents = new StreamReader(file.FullName, Encoding.UTF8))
                {
                    Random rnd = new Random();
                    while (!contents.EndOfStream)
                    {
                        int            level  = rnd.Next(0, 4);
                        SealedLogModel detail = new SealedLogModel()
                        {
                            Level       = (SealedLogLevel)level,
                            ProjectName = "testtxt",
                            Sign        = "测试",
                            Time        = DateTime.Now.AddMinutes(level),
                            Value       = contents.ReadLine()
                        };
                        LucenceHelper.StorageData(detail);
                    }
                }
            }
            Console.WriteLine("Hello World!");

            while (true)
            {
                String query = Console.ReadLine();
                LucenceHelper.SearchData("testtxt", query);
            }
        }
コード例 #2
0
 public JsonResult Logger(String project, String dateTime, String search)
 {
     if (String.IsNullOrWhiteSpace(search))
     {
         search = "Warn Info Error Trace";
     }
     if (!DateTime.TryParse(dateTime, out DateTime dt))
     {
         return(new JsonResult("错误"));
     }
     return(new JsonResult(LucenceHelper.SearchData(project, search, dt)));
 }