diff --git a/BLWLogProduce/Models/MyPublishRedis.cs b/BLWLogProduce/Models/MyPublishRedis.cs index fbde536..b08dd71 100644 --- a/BLWLogProduce/Models/MyPublishRedis.cs +++ b/BLWLogProduce/Models/MyPublishRedis.cs @@ -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>(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) diff --git a/BLWLogProduce/Services/KafkaProduce.cs b/BLWLogProduce/Services/KafkaProduce.cs index c6581b0..6685d50 100644 --- a/BLWLogProduce/Services/KafkaProduce.cs +++ b/BLWLogProduce/Services/KafkaProduce.cs @@ -522,13 +522,13 @@ namespace BLWLogProduce.Services { NewVersionLog? poo = System.Text.Json.JsonSerializer.Deserialize(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(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 { 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(async (args) => + { + string body = args.Body; + + try + { + ShengJi_Log poo = System.Text.Json.JsonSerializer.Deserialize(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 { 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(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) { diff --git a/BLWLogProduce/Services/MyCache.cs b/BLWLogProduce/Services/MyCache.cs new file mode 100644 index 0000000..515ab3d --- /dev/null +++ b/BLWLogProduce/Services/MyCache.cs @@ -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; + } + } +} diff --git a/CommonEntity/TSLog.cs b/CommonEntity/TSLog.cs index 5d5fb22..a8d7427 100644 --- a/CommonEntity/TSLog.cs +++ b/CommonEntity/TSLog.cs @@ -44,6 +44,7 @@ namespace CommonEntity /// "上报" 或 "下发" /// 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; } } /// /// ts 日志 diff --git a/CommonEntity/UDPPackage.cs b/CommonEntity/UDPPackage.cs index 2b00a4b..acdb61b 100644 --- a/CommonEntity/UDPPackage.cs +++ b/CommonEntity/UDPPackage.cs @@ -43,6 +43,7 @@ namespace CommonEntity /// 注册 /// public static string blwlog4Nodejs_rcu_register_topic= "blwlog4Nodejs-rcu-register-topic"; + public static string blwlog4Nodejs_rcu_upgrade_topic= "blwlog4Nodejs-rcu-upgrade-topic"; #endregion diff --git a/UseSQLQueryData/Controllers/ValuesController.cs b/UseSQLQueryData/Controllers/ValuesController.cs index b63d22e..8c92402 100644 --- a/UseSQLQueryData/Controllers/ValuesController.cs +++ b/UseSQLQueryData/Controllers/ValuesController.cs @@ -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(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(); diff --git a/UseSQLQueryData/Properties/PublishProfiles/FolderProfile1.pubxml.user b/UseSQLQueryData/Properties/PublishProfiles/FolderProfile1.pubxml.user index bcc2431..3571821 100644 --- a/UseSQLQueryData/Properties/PublishProfiles/FolderProfile1.pubxml.user +++ b/UseSQLQueryData/Properties/PublishProfiles/FolderProfile1.pubxml.user @@ -3,7 +3,7 @@ <_PublishTargetUrl>E:\tian\chongxin\NewGit\Web_BLSKafka_Server_Prod\UseSQLQueryData\bin\Release\net8.0\publish\ - 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||; + 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||; \ No newline at end of file