wanshenmean
8 天以前 fd18eaba5e1c086a588509371f91310e7aafff9c
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
using System.Text.RegularExpressions;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using WIDESEAWCS_Core;
using WIDESEAWCS_Core.BaseController;
using WIDESEAWCS_ITaskInfoService;
using WIDESEAWCS_Model.Models;
 
namespace WIDESEAWCS_WCSServer.Controllers.Task
{
    [Route("api/Task_Hty")]
    [ApiController]
    public class Task_HtyController : ApiBaseController<ITask_HtyService, Dt_Task_Hty>
    {
        private readonly IHttpContextAccessor _httpContextAccessor;
        public Task_HtyController(ITask_HtyService service, IHttpContextAccessor httpContextAccessor) : base(service)
        {
            _httpContextAccessor = httpContextAccessor;
        }
 
        [HttpGet, Route("Test")]
        public WebResponseContent Test()
        {
            var pattern = @"\u0002\[([^\]]+)\] \[([^\]]+)\](?: \[([^\]]+)\])?(?: ([^\u0003]*?))?(?:\n\[异常\]([\s\S]*?))?\u0003";
 
            Regex.Match("\u0002[2025-09-17 16:40:11.180] [ERROR] CommonStackerCraneJob Start{\"LogKey\":null}\u0003", pattern);
 
            var temp = Regex.Matches("\u0002[2025-09-17 16:40:11.180] [ERROR] CommonStackerCraneJob Start{\"LogKey\":null}\u0003", pattern);
            List<Match> matches = temp.ToList();
 
            for (int i = 0; i < matches.Count; i++)
            {
                Match match = matches[i];
                if (match.Success)
                {
                    var timestamp = match.Groups[1].Value;
                    var logLevel = match.Groups[2].Value;
                    var keyword = match.Groups[3].Value;      // 可能为空
                    var message = match.Groups[4].Value;      // 可能为空
                    var exception = match.Groups[5].Value;    // 可能为空
                }
            }
 
            return WebResponseContent.Instance.OK();
        }
    }
}