namespace LTEMvcApp.Models
{
///
/// 日志过滤器配置
///
public class LogFilterConfig
{
///
/// 全局UE ID列表
///
public List GlobalUeIds { get; set; } = new();
///
/// 小区ID列表
///
public List CellIds { get; set; } = new();
///
/// IMSI列表
///
public List ImsiList { get; set; } = new();
///
/// IMEI列表
///
public List ImeiList { get; set; } = new();
///
/// 信息类型列表
///
public List InfoTypes { get; set; } = new();
///
/// 层类型列表
///
public List LayerTypes { get; set; } = new();
///
/// 日志级别列表
///
public List LogLevels { get; set; } = new();
///
/// 方向过滤器(false表示过滤掉,true表示保留)
///
public bool[] DirectionFilter { get; set; } = { false, false, false };
///
/// 开始时间戳
///
public long StartTime { get; set; } = 0;
///
/// 结束时间戳
///
public long EndTime { get; set; } = long.MaxValue;
///
/// 时间原点
///
public string TimeOrigin { get; set; } = "00:00:00.000";
///
/// 是否分组UE ID
///
public bool GroupUeId { get; set; } = true;
///
/// 搜索文本
///
public string? SearchText { get; set; }
///
/// 是否使用正则表达式搜索
///
public bool UseRegexSearch { get; set; } = false;
///
/// 是否忽略大小写
///
public bool IgnoreCase { get; set; } = true;
///
/// 是否只显示错误
///
public bool ShowErrorsOnly { get; set; } = false;
///
/// 是否只显示警告
///
public bool ShowWarningsOnly { get; set; } = false;
///
/// 客户端过滤器
///
public Dictionary ClientFilters { get; set; } = new();
///
/// 是否启用过滤器
///
public bool IsEnabled { get; set; } = true;
///
/// 过滤器名称
///
public string? FilterName { get; set; }
///
/// 是否持久化
///
public bool IsPersistent { get; set; } = false;
///
/// 创建时间
///
public DateTime CreatedAt { get; set; } = DateTime.Now;
///
/// 更新时间
///
public DateTime UpdatedAt { get; set; } = DateTime.Now;
///
/// 清除所有过滤器
///
public void ClearAll()
{
GlobalUeIds.Clear();
CellIds.Clear();
ImsiList.Clear();
ImeiList.Clear();
InfoTypes.Clear();
LayerTypes.Clear();
LogLevels.Clear();
DirectionFilter = new bool[] { false, false, false };
StartTime = 0;
EndTime = long.MaxValue;
TimeOrigin = "00:00:00.000";
SearchText = null;
ClientFilters.Clear();
UpdatedAt = DateTime.Now;
}
///
/// 重置为默认值
///
public void ResetToDefault()
{
ClearAll();
GroupUeId = true;
IsEnabled = true;
UseRegexSearch = false;
IgnoreCase = true;
ShowErrorsOnly = false;
ShowWarningsOnly = false;
}
///
/// 复制过滤器配置
///
/// 新的过滤器配置
public LogFilterConfig Clone()
{
return new LogFilterConfig
{
GlobalUeIds = new List(GlobalUeIds),
CellIds = new List(CellIds),
ImsiList = new List(ImsiList),
ImeiList = new List(ImeiList),
InfoTypes = new List(InfoTypes),
LayerTypes = new List(LayerTypes),
LogLevels = new List(LogLevels),
DirectionFilter = (bool[])DirectionFilter.Clone(),
StartTime = StartTime,
EndTime = EndTime,
TimeOrigin = TimeOrigin,
GroupUeId = GroupUeId,
SearchText = SearchText,
UseRegexSearch = UseRegexSearch,
IgnoreCase = IgnoreCase,
ShowErrorsOnly = ShowErrorsOnly,
ShowWarningsOnly = ShowWarningsOnly,
ClientFilters = new Dictionary(ClientFilters),
IsEnabled = IsEnabled,
FilterName = FilterName,
IsPersistent = IsPersistent,
CreatedAt = CreatedAt,
UpdatedAt = DateTime.Now
};
}
///
/// 检查是否为空过滤器
///
/// 是否为空
public bool IsEmpty()
{
return GlobalUeIds.Count == 0 &&
CellIds.Count == 0 &&
ImsiList.Count == 0 &&
ImeiList.Count == 0 &&
InfoTypes.Count == 0 &&
LayerTypes.Count == 0 &&
LogLevels.Count == 0 &&
DirectionFilter.All(x => !x) &&
StartTime == 0 &&
EndTime == long.MaxValue &&
string.IsNullOrEmpty(SearchText) &&
ClientFilters.Count == 0 &&
!ShowErrorsOnly &&
!ShowWarningsOnly;
}
}
///
/// 过滤器选项
///
public class FilterOption
{
///
/// 值
///
public object Value { get; set; } = string.Empty;
///
/// 显示文本
///
public string Text { get; set; } = string.Empty;
///
/// 样式
///
public string Style { get; set; } = string.Empty;
///
/// 是否被选中
///
public bool IsSelected { get; set; } = false;
}
///
/// 过滤器类型
///
public static class FilterTypes
{
public const string GlobalUeId = "global_ue_id";
public const string Cell = "cell";
public const string Imsi = "imsi";
public const string Imei = "imei";
public const string Info = "info";
public const string Layer = "layer";
public const string Level = "level";
public const string Direction = "dir";
public const string Time = "time";
public const string Search = "search";
public const string Client = "client";
///
/// 获取所有过滤器类型
///
/// 过滤器类型列表
public static List GetAllFilterTypes()
{
return new List
{
GlobalUeId, Cell, Imsi, Imei, Info, Layer, Level, Direction, Time, Search, Client
};
}
}
}