增加很多功能

增加几个日志监控功能
This commit is contained in:
2026-03-19 11:55:00 +08:00
parent f4d67cb673
commit 0aa223d891
7 changed files with 105 additions and 20 deletions

View File

@@ -11,6 +11,7 @@ namespace BLWLogProduce.Models
{
public static CSRedisClient? redis4;
public static CSRedisClient? redis6;
public static CSRedisClient? redis7;
public static Logger logger = LogManager.GetCurrentClassLogger();
private const string ip = "127.0.0.1";
@@ -22,6 +23,7 @@ namespace BLWLogProduce.Models
{
redis4 = new CSRedisClient(redisHostStr + ",password=,defaultDatabase=4");
redis6 = new CSRedisClient(redisHostStr + ",password=,defaultDatabase=6");
redis7 = new CSRedisClient(redisHostStr + ",password=,defaultDatabase=7");
string channel = "__keyevent@6__:expired";
var QQQ = new ValueTuple<string, Action<CSRedisClient.SubscribeMessageEventArgs>>(channel, (msg) =>
{
@@ -38,6 +40,7 @@ namespace BLWLogProduce.Models
string str = Newtonsoft.Json.JsonConvert.SerializeObject(o);
redis6.Publish("redis-on_off_line", str);
//redis7.Del(o.HostNumber);
}
}
catch (Exception ex)

View File

@@ -522,13 +522,13 @@ namespace BLWLogProduce.Services
{
NewVersionLog? poo = System.Text.Json.JsonSerializer.Deserialize<NewVersionLog>(body);
poo.ts_ms = Tools.GetUnixTime_MS();
if (poo.hotel_id.Equals("2144")&&poo.room_id.Equals("1006")||poo.room_id.Equals("1007"))
if (poo.hotel_id.Equals("2144") && poo.room_id.Equals("1006") || poo.room_id.Equals("1007"))
{
logger.Error("漏数据监控:"+poo.room_id+"##"+poo.comm_seq);
logger.Error("漏数据监控:" + poo.room_id + "##" + poo.comm_seq);
}
if (poo.hotel_id.Equals("1085")&&poo.room_id.Equals("8099"))
if (poo.hotel_id.Equals("1085") && poo.room_id.Equals("8099"))
{
logger.Error("漏数据监控:"+poo.room_id+"##"+poo.comm_seq);
logger.Error("漏数据监控:" + poo.room_id + "##" + poo.comm_seq);
}
if (string.IsNullOrEmpty(poo.hotel_id) || string.IsNullOrEmpty(poo.device_id))
@@ -566,8 +566,10 @@ namespace BLWLogProduce.Services
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
Console.WriteLine(ex.StackTrace);
logger.Error("注册日志错误:" + body);
logger.Error(ex.Message);
logger.Error(ex.StackTrace);
}
}));
@@ -581,7 +583,7 @@ namespace BLWLogProduce.Services
{
RegisterInfo? poo = System.Text.Json.JsonSerializer.Deserialize<RegisterInfo>(body);
string TopicKey1 = KafkaKey.blwlog4Nodejs_rcu_register_topic;
string DetailKey1 =poo.device_id;
string DetailKey1 = poo.device_id;
var jsonstr = JsonConvert.SerializeObject(poo);
await p.ProduceAsync(TopicKey1, new Message<string, byte[]> { Key = DetailKey1, Value = Encoding.UTF8.GetBytes(jsonstr) });
@@ -589,11 +591,38 @@ namespace BLWLogProduce.Services
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
Console.WriteLine(ex.StackTrace);
logger.Error("注册日志错误:" + body);
logger.Error(ex.Message);
logger.Error(ex.StackTrace);
}
}));
//注册0xB1
var TSLog_DingYue_ShengJi = ("redis-up", new Action<SubscribeMessageEventArgs>(async (args) =>
{
string body = args.Body;
try
{
ShengJi_Log poo = System.Text.Json.JsonSerializer.Deserialize<ShengJi_Log>(body);
poo.ts_ms= Tools.GetUnixTime_MS();
string TopicKey1 = KafkaKey.blwlog4Nodejs_rcu_upgrade_topic;
string DetailKey1 = poo.hotel_id;
var jsonstr = JsonConvert.SerializeObject(poo);
await p.ProduceAsync(TopicKey1, new Message<string, byte[]> { Key = DetailKey1, Value = Encoding.UTF8.GetBytes(jsonstr) });
}
catch (Exception ex)
{
logger.Error("升级日志错误:" + body);
logger.Error(ex.Message);
logger.Error(ex.StackTrace);
}
}));
var TSLog_DingYue_0X36 = ("redis-0X36-0X0F", new Action<SubscribeMessageEventArgs>(async (args) =>
{
@@ -865,7 +894,7 @@ namespace BLWLogProduce.Services
MAC = usa.MAC,
RoomNumber = usa.RoomNumber,
EndPoint = usa.RemoteEndPoint,
CurrentStatus = usa.CurrentStatus,
CurrentStatus ="restart",
CurrentTime = usa.CurrentTime,
UnixTime = Tools.GetUnixTime_MS(),
LauncherVersion = usa.LauncherVersion,
@@ -1043,6 +1072,7 @@ namespace BLWLogProduce.Services
CSRedisCacheHelper.redis3.Subscribe(DingYue11);
CSRedisCacheHelper.redis3.Subscribe(TSLog_DingYue_XinTiao);
CSRedisCacheHelper.redis3.Subscribe(TSLog_DingYue_ZhuCe);
CSRedisCacheHelper.redis3.Subscribe(TSLog_DingYue_ShengJi);
}
catch (Exception ex)
{

View File

@@ -0,0 +1,16 @@
using Microsoft.Extensions.Caching.Memory;
namespace BLWLogProduce.Services
{
public class MyCache
{
public IConfiguration Configuration { get; set; }
public IMemoryCache _Cache { get; set; }
public MyCache(IConfiguration configuration, IMemoryCache cache)
{
this.Configuration = configuration;
_Cache = cache;
}
}
}

View File

@@ -44,6 +44,7 @@ namespace CommonEntity
/// "上报" 或 "下发"
/// </summary>
public string direction { get; set; }
public string ip { get; set; }
public string cmd_word { get; set; }
public int frame_id { get; set; }
@@ -113,6 +114,7 @@ namespace CommonEntity
public string central_control_name { get; set; }
public string configure_hotel_name { get; set; }
public string configure_room_type_name { get; set; }
public long upgrade_ts_ms { get; set; }
}
public record Kafka_XinTiao
{
@@ -121,6 +123,30 @@ namespace CommonEntity
public string device_id { get; set; }
public string hotel_id { get; set; }
public string room_id { get; set; }
public string ip { get; set; }
}
public struct ShengJi_Log
{
public string hotel_id { get; set; }
public string device_id { get; set; }
public string room_id { get; set; }
public long ts_ms { get; set; }
public int is_send { get; set; }
public byte[] udp_raw { get; set; }
public object extra { get; set; }
public string remote_endpoint { get; set; }
public string md5 { get; set; }
public int partition { get; set; }
public int file_type { get; set; }
public string file_path { get; set; }
public int upgrade_state { get; set; }
public string app_version { get; set; }
}
/// <summary>
/// ts 日志

View File

@@ -43,6 +43,7 @@ namespace CommonEntity
/// 注册
/// </summary>
public static string blwlog4Nodejs_rcu_register_topic= "blwlog4Nodejs-rcu-register-topic";
public static string blwlog4Nodejs_rcu_upgrade_topic= "blwlog4Nodejs-rcu-upgrade-topic";
#endregion

View File

@@ -17,15 +17,18 @@ namespace UseSQLQueryData.Controllers
[ApiController]
public class ValuesController : ControllerBase
{
public static string SqlConnectionString = "server=WIN-061EVIHKD86\\BLW;database=CRICS;uid=sa;pwd=pass@123$%^;TrustServerCertificate=True;";
public static string SqlConnectionString = "server=WIN-O4NK3EJNBT1\\SQLEXPRESS;database=RICS;uid=sa;pwd=WIN-O4NK3EJNBT1;TrustServerCertificate=True;";
//public static string SqlConnectionString = "Data Source=DESKTOP-DUNS5K7;Initial Catalog=RICS;User ID=sa;Password=123456;Trust Server Certificate=True";
//public static Logger logger = LogManager.GetCurrentClassLogger();
public RicsContext db { get; set; }
public IMemoryCache _memorycache { get; set; }
public ValuesController(RicsContext context, IMemoryCache cache)
public IConfiguration _configuration { get; set; }
public ValuesController(RicsContext context, IMemoryCache cache, IConfiguration configuration)
{
this.db = context;
this._memorycache = cache;
_configuration = configuration;
}
public record hotelinfo
{
@@ -69,7 +72,8 @@ namespace UseSQLQueryData.Controllers
//return returnInfo;
try
{
using SqlConnection con = new SqlConnection(SqlConnectionString);
//using SqlConnection con = new SqlConnection(SqlConnectionString);
using SqlConnection con = new SqlConnection(this._configuration.GetConnectionString("DefaultConnection"));
con.Open();
using SqlCommand sqlCommand = con.CreateCommand();
@@ -113,7 +117,8 @@ namespace UseSQLQueryData.Controllers
//return returnInfo;
try
{
using SqlConnection con = new SqlConnection(SqlConnectionString);
//using SqlConnection con = new SqlConnection(SqlConnectionString);
using SqlConnection con = new SqlConnection(this._configuration.GetConnectionString("DefaultConnection"));
con.Open();
using SqlCommand sqlCommand = con.CreateCommand();
@@ -162,7 +167,8 @@ namespace UseSQLQueryData.Controllers
ReturnInfo returnInfo = new ReturnInfo();
try
{
using SqlConnection con = new SqlConnection(SqlConnectionString);
//using SqlConnection con = new SqlConnection(SqlConnectionString);
using SqlConnection con = new SqlConnection(this._configuration.GetConnectionString("DefaultConnection"));
con.Open();
using SqlCommand sqlCommand = con.CreateCommand();
@@ -211,7 +217,8 @@ namespace UseSQLQueryData.Controllers
//var sql = $"SELECT * FROM Products WHERE Id IN ({string.Join(",", parameters)})";
//var qqq = await db.TbRoomTypeModals.Where(A => RoomTypeIDList.Contains<int>(A.RoomTypeId)).ToListAsync();
//var qqq = await db.TbRoomTypeModals.Where(A=>A.RoomTypeId==1).ToListAsync();
using SqlConnection con = new SqlConnection(SqlConnectionString);
//using SqlConnection con = new SqlConnection(SqlConnectionString);
using SqlConnection con = new SqlConnection(this._configuration.GetConnectionString("DefaultConnection"));
con.Open();
using SqlCommand sqlCommand = con.CreateCommand();
@@ -274,7 +281,8 @@ namespace UseSQLQueryData.Controllers
//return returnInfo;
try
{
using SqlConnection con = new SqlConnection(SqlConnectionString);
//using SqlConnection con = new SqlConnection(SqlConnectionString);
using SqlConnection con = new SqlConnection(this._configuration.GetConnectionString("DefaultConnection"));
con.Open();
using SqlCommand sqlCommand = con.CreateCommand();
@@ -340,7 +348,7 @@ namespace UseSQLQueryData.Controllers
string nn3 = nn1 + nn2;
using SqlConnection con = new SqlConnection("server=WIN-061EVIHKD86\\BLW;database=CRICS;uid=sa;pwd=pass@123$%^;TrustServerCertificate=True;");
using SqlConnection con = new SqlConnection(_configuration.GetConnectionString("DefaultConnection"));
con.Open();
SqlTransaction tran = con.BeginTransaction();
using SqlCommand sqlCommand = con.CreateCommand();
@@ -436,7 +444,8 @@ namespace UseSQLQueryData.Controllers
try
{
using SqlConnection con = new SqlConnection(SqlConnectionString);
//using SqlConnection con = new SqlConnection(SqlConnectionString);
using SqlConnection con = new SqlConnection(this._configuration.GetConnectionString("DefaultConnection"));
await con.OpenAsync();
using SqlCommand sqlCommand = con.CreateCommand();

View File

@@ -3,7 +3,7 @@
<Project>
<PropertyGroup>
<_PublishTargetUrl>E:\tian\chongxin\NewGit\Web_BLSKafka_Server_Prod\UseSQLQueryData\bin\Release\net8.0\publish\</_PublishTargetUrl>
<History>True|2026-01-31T06:49:29.1275223Z||;True|2026-01-31T14:13:11.7242950+08:00||;True|2026-01-31T14:10:05.1267470+08:00||;True|2026-01-31T13:37:30.6761345+08:00||;True|2026-01-31T11:30:39.2792110+08:00||;True|2026-01-31T11:28:44.6978619+08:00||;True|2026-01-31T11:27:35.8243470+08:00||;</History>
<History>True|2026-03-19T00:52:57.0894202Z||;True|2026-03-18T20:03:13.8908757+08:00||;True|2026-01-31T14:49:29.1275223+08:00||;True|2026-01-31T14:13:11.7242950+08:00||;True|2026-01-31T14:10:05.1267470+08:00||;True|2026-01-31T13:37:30.6761345+08:00||;True|2026-01-31T11:30:39.2792110+08:00||;True|2026-01-31T11:28:44.6978619+08:00||;True|2026-01-31T11:27:35.8243470+08:00||;</History>
<LastFailureDetails />
</PropertyGroup>
</Project>