This commit is contained in:
Administrator committed 2026-06-06 00:29:45 +08:00
commit e0c949bde9
4 files changed
+92 -46

No files matched your search

+38 -21
View File
@@ -2,6 +2,7 @@
using SunlightAggregationTerminal.Models;
using System;
using System.Collections.Generic;
using System.Data;
using System.Net;
using System.Net.Sockets;
using System.Text;
@@ -116,33 +117,49 @@ namespace SunlightAggregationTerminal.Class
}
if (data.TryGetValue("Notification", out val) && val != null)//信息通知接受
{
var dataNotification = JsonSerializer.Deserialize<Dictionary<string, object>>(val.ToString()!);
var dataNotification = JsonSerializer.Deserialize<List<Dictionary<string, object>>>(val.ToString()!);
string _Title = "", _Content = "";
int _Type = 0;
int _Type = 0 ,_id = 0;
if (dataNotification!.TryGetValue("Title", out var value_Notification_Title))
foreach (var dataNotificationrow in dataNotification!)
{
_Title = value_Notification_Title.ToString() ?? "";
}
if (dataNotification!.TryGetValue("Content", out var value_Notification_Content))
{
_Content = value_Notification_Content.ToString() ?? "";
}
if (dataNotification!.TryGetValue("Type", out var value_Notification_Type))
{
string temp = value_Notification_Type?.ToString() ?? "";
// 转换
_Type = temp switch
//解析信息
if (dataNotificationrow!.TryGetValue("id", out var value_Notification_id))
{
"System" => 2,
"Message" => 1,
_ => 0
};
_id = (int)value_Notification_id;
}
if (dataNotificationrow!.TryGetValue("Title", out var value_Notification_Title))
{
_Title = value_Notification_Title.ToString() ?? "";
}
if (dataNotificationrow!.TryGetValue("Content", out var value_Notification_Content))
{
_Content = value_Notification_Content.ToString() ?? "";
}
if (dataNotificationrow!.TryGetValue("Type", out var value_Notification_Type))
{
string temp = value_Notification_Type?.ToString() ?? "";
// 转换
_Type = temp switch
{
"System" => 2,
"Message" => 1,
_ => 0
};
}
//记录信息到数据库
DataSet? Notificationdata = AppModels.Select("select * from Notification where Id = " + _id);
if (Notificationdata != null)
{
if (Notificationdata.Tables[0].Rows.Count == 0)
{
AppModels.INSERT("INSERT INTO Notification (Title,Content,Time,Type,Id)VALUES('" +
_Title + "','" + _Content + "','" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff") +
"','" + _Type + "'," + _id + ");");
}
}
}
Models.AppModels.INSERT("INSERT INTO Notification (Title,Content,Time,Type)VALUES('" +
_Title + "','" + _Content + "','" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff") + "','" + _Type + "');");
}
}