using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
namespace LTEMvcApp.Models
{
///
/// 日志管理器 - 从JavaScript logs.js迁移
///
public class LogsManager
{
#region 常量定义
public const int DIR_NONE = 0;
public const int DIR_UL = 1;
public const int DIR_DL = 2;
public const int DIR_FROM = 3;
public const int DIR_TO = 4;
#endregion
#region 静态字段
private static readonly string[] modelList = { "RUE", "UE", "PROBE", "ENB", "N3IWF", "MBMSGW", "MME", "IMS", "LICENSE", "MONITOR" };
private static readonly Dictionary modelConfig = new()
{
{ "RUE", new { icon = "icon-ue2" } },
{ "UE", new { icon = "icon-ue" } },
{ "PROBE", new { } },
{ "ENB", new { icon = "icon-air", modelHint = "enb|gnb|bbu", title = "RAN" } },
{ "N3IWF", new { icon = "icon-air", modelHint = "n3iwf", title = "N3IWF" } },
{ "MME", new { icon = "icon-server", modelHint = "epc|mme|amf", title = "CN" } },
{ "MBMSGW", new { icon = "icon-download", modelHint = "mbms" } },
{ "IMS", new { icon = "icon-dial" } },
{ "MONITOR", new { icon = "icon-monitor" } },
{ "LICENSE", new { icon = "icon-file" } }
};
#endregion
#region 实例字段
private readonly Dictionary _logs = new();
private readonly int _logDefaultLevel = 0; // localStorage.debug >> 0
private readonly string[] _logsMethods = { "error", "warn", "info", "debug", "prof" };
private readonly long _startDate = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();
private readonly Dictionary _stringIDs = new();
private readonly List _stringList = new();
private readonly Dictionary _eventListeners = new();
private int _eventListenerId = 0;
#endregion
#region 属性
public string Mode { get; set; } = "web";
public string FontDef { get; set; } = "13px helvetica, arial, verdana, sans-serif";
public int LastClientId { get; set; } = 0;
public int LogsMax { get; set; } = 100000;
public List LogsRange { get; set; } = new();
public List LogsInfo { get; set; } = new();
public List LogsLayers { get; set; } = new();
public string ExportTimeFormat { get; set; } = "HH:mm:ss.fff";
#endregion
#region 构造函数
public LogsManager()
{
Init();
}
#endregion
#region 初始化方法
public void Init()
{
// 初始化通道定义
var def = new Dictionary();
var ids = new Dictionary();
// 这里可以添加通道定义的初始化逻辑
// 对应JavaScript中的_channelsDef.forEach逻辑
}
#endregion
#region 日志相关方法
public void SetLogger(string name, object instance)
{
var module = new { level = _logDefaultLevel, list = new List