增加 升级功能的 日志监控

This commit is contained in:
2026-03-17 15:58:22 +08:00
parent ddd4f5a6b4
commit a93c11fbfe
8 changed files with 108 additions and 2 deletions

Binary file not shown.

View File

@@ -497,6 +497,22 @@ namespace Common
arry[1] = (byte)(data & 0xFF);
return arry;
}
// 方法B自定义字符数组判断
public static bool ContainsSpecialChars(string input)
{
// 定义特殊字符数组
char[] specialChars = {
'!', '@', '#', '$', '%', '^', '&', '*', '(', ')',
'+', '=', '[', ']', '{', '}', '|', '\\', ':', ';',
'"', '\'', '<', '>', ',', '.', '?', '/', '`', '~'
};
// 判断是否包含空白字符(空格、制表符、换行符等)
bool hasWhiteSpace = input.Any(char.IsWhiteSpace);
return input.Any(c => specialChars.Contains(c))&&hasWhiteSpace;
}
/// <summary>
/// 把int32类型的数据转存到2个字节的byte数组中小端
/// </summary>

View File

@@ -13,4 +13,24 @@ namespace CommonEntity
public string device_id { get; set; }
public string room_id { 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; }
}
}

View File

@@ -10,6 +10,7 @@ using Common;
using Dao;
using Domain;
using RCUHost.Protocols;
using CommonEntity;
namespace RCUHost.Implement
{
@@ -30,6 +31,7 @@ namespace RCUHost.Implement
public override void Process(ReceiverContext context)
{
int startIndex = StructConverter.SizeOf(context.SystemHeader);
var endpoint = context.RemoteEndPoint.ToString();
UpdateHostPacketReply? reply = DecodeUpdateHostPacketReply(context.Data, startIndex);
if (reply.HasValue)
{
@@ -67,6 +69,25 @@ namespace RCUHost.Implement
break;
}
var host = updateHostWorker.Host;
ShengJi_Log s1 = new ShengJi_Log();
s1.hotel_id = host.SysHotel.Code;
s1.room_id = host.RoomNumber;
s1.device_id = host.HostNumber;
s1.is_send = 0;
s1.udp_raw = context.Data;
s1.remote_endpoint = endpoint;
s1.md5 = "";
s1.partition = 0;
s1.file_type = 0;
s1.file_path = "";
s1.upgrade_state = reply.Value.Status;
s1.app_version = reply.Value.Version;
CSRedisCacheHelper.Publish("redis-up", Newtonsoft.Json.JsonConvert.SerializeObject(s1));
BarData bbb = new BarData();
bbb.HostID = updateHostWorker.Host.ID;
bbb.Upgrade_status = Upgrade_Status;
@@ -97,6 +118,24 @@ namespace RCUHost.Implement
Upgrade_Status = "升级失败";
break;
}
ShengJi_Log s1 = new ShengJi_Log();
s1.hotel_id = host.SysHotel.Code;
s1.room_id = host.RoomNumber;
s1.device_id = host.HostNumber;
s1.is_send = 0;
s1.udp_raw = context.Data;
s1.remote_endpoint = endpoint;
s1.md5 = "";
s1.partition = 0;
s1.file_type = 0;
s1.file_path = "";
s1.upgrade_state = reply.Value.Status;
s1.app_version = reply.Value.Version;
CSRedisCacheHelper.Publish("redis-up", Newtonsoft.Json.JsonConvert.SerializeObject(s1));
BarData bbb = new BarData();
bbb.HostID = host.ID;
bbb.Upgrade_status = Upgrade_Status;

View File

@@ -10,6 +10,7 @@ using Common;
using Dao;
using Domain;
using RCUHost.Protocols;
using CommonEntity;
namespace RCUHost.Implement
{
@@ -221,6 +222,28 @@ namespace RCUHost.Implement
byte[] data = CreateUpdateRequestPacket(updateFileMd5, blockNum, fileType, fileName);
logger.Error("升级HostNumber为" + host.HostNumber);
logger.Error("升级指令为:" + Tools.ByteToString(data));
ShengJi_Log s1 = new ShengJi_Log();
s1.hotel_id = host.SysHotel.Code;
s1.room_id = host.RoomNumber;
s1.device_id = host.HostNumber;
s1.is_send = 1;
s1.udp_raw = data;
string ipAndPort = CSRedisCacheHelper.Get<string>(host.HostNumber, host.MAC);
if (!string.IsNullOrEmpty(ipAndPort))
{
s1.remote_endpoint = ipAndPort;
}
s1.md5 = updateFileMd5;
s1.partition = blockNum;
s1.file_type = fileType;
s1.file_path = fileName;
s1.upgrade_state = 0;
s1.app_version = host.Version;
CSRedisCacheHelper.Publish("redis-up", Newtonsoft.Json.JsonConvert.SerializeObject(s1));
Send(data, host.HostNumber, host.MAC);// host.IP, host.Port);
}
/// <summary>

View File

@@ -1086,6 +1086,11 @@ namespace WebSite.Controllers
public ActionResult Save(string jsonData)
{
RoomType entity = Newtonsoft.Json.JsonConvert.DeserializeObject<RoomType>(jsonData);
if (Tools.ContainsSpecialChars(entity.Name) || Tools.ContainsSpecialChars(entity.HostName))
{
return Json(new { IsSuccess = false, Message = "房型名称不得包含特殊符号、空格,命名字数不得超过 N 个文字"});
}
RoomType existRoomType = RoomTypeManager.GetByCode(entity.Code, CurrentHotelID);
if (existRoomType != null)
{

View File

@@ -104,6 +104,9 @@ function delProgramFile() {
}
//保存房型
function save() {
var a1= $("#txtHostName").val();
var a2 = $("#txtName").val();
console.log(a1+"#########"+a2);
var form = $('#dialog').find('form');
if (form.form('enableValidation').form('validate')) {
var entry = form.serializeJson();

View File

@@ -32,13 +32,13 @@
<tr>
<th><label for="txtName"><%: Html.Language("RoomHeight")%></label></th>
<td>
<input id="txtName" name="Name" class="easyui-validatebox textbox text" data-options="required:true,validType:'blwtext'" value="<%: Model.RoomHeight %>" />
<input id="txtNameHeight" name="RoomHeight" class="easyui-validatebox textbox text" data-options="required:true,validType:'blwtext'" value="<%: Model.RoomHeight %>" />
</td>
</tr>
<tr>
<th><label for="txtName"><%: Html.Language("RoomHotLossRatio")%></label></th>
<td>
<input id="txtName" name="Name" class="easyui-validatebox textbox text" data-options="required:true,validType:'blwtext'" value="<%: Model.RoomHotLossRatio %>" />
<input id="txtNameRoomHotLossRatio" name="RoomHotLossRatio" class="easyui-validatebox textbox text" data-options="required:true,validType:'blwtext'" value="<%: Model.RoomHotLossRatio %>" />
</td>
</tr>
<%--<tr>