diff --git a/Class/TcpServer.cs b/Class/TcpServer.cs index 7096b47..182c58f 100644 --- a/Class/TcpServer.cs +++ b/Class/TcpServer.cs @@ -69,11 +69,11 @@ namespace SunlightAggregationTerminal.Class #region Tcp客户端使用Received异步委托接收数据 tcpClient.Received = (client, e) => { - //从服务器收到信息。但是一般byteBlock和requestInfo会根据适配器呈现不同的值。 - var mes = e.Memory.Span.ToString(Encoding.UTF8); + //从服务器收到信息。但是一般byteBlock和requestInfo会根据适配器呈现不同的值。 + var mes = e.Memory.Span.ToString(Encoding.UTF8); try - { + { var data = JsonSerializer.Deserialize>(mes); if (data != null) @@ -95,7 +95,11 @@ namespace SunlightAggregationTerminal.Class } - if (data.TryGetValue("Notification", out val) && val != null)//信息接受 + if (data.TryGetValue("Query", out val) && val != null)//查询接受 + { + QueryPage.Query_data(val.ToString()!); + } + if (data.TryGetValue("Notification", out val) && val != null)//信息通知接受 { var dataNotification = JsonSerializer.Deserialize>(val.ToString()!); @@ -126,20 +130,21 @@ namespace SunlightAggregationTerminal.Class _Title + "','" + _Content + "','" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff") + "','" + _Type + "');"); } } - + } catch (Exception) { } - + return EasyTask.CompletedTask; }; #endregion try { - await tcpClient.SetupAsync(new TouchSocketConfig() - .SetRemoteIPHost(ip)); + await tcpClient.SetupAsync(new TouchSocketConfig() + .SetRemoteIPHost(ip)); await tcpClient.ConnectAsync();//调用连接,当连接不成功时,会抛出异常。 - } catch (Exception) + } + catch (Exception) { await Application.Current!.Windows[0].Page!.DisplayAlertAsync("错误", "不合法的访问地址", "是"); } diff --git a/Models/AppModels.cs b/Models/AppModels.cs index c8b12cc..a4c496c 100644 --- a/Models/AppModels.cs +++ b/Models/AppModels.cs @@ -76,7 +76,7 @@ namespace SunlightAggregationTerminal.Models //发生登录请求 - // 创建一个 5 秒的延时任务 + // 创建一个 15 秒的延时任务 Task delayTask = Task.Delay(15000); // 创建一个监测任务,不断检查变量 Task monitorTask = Task.Run(async () => diff --git a/Models/DataSource.cs b/Models/DataSource.cs index ec7f3b1..41705c5 100644 --- a/Models/DataSource.cs +++ b/Models/DataSource.cs @@ -23,6 +23,15 @@ namespace SunlightAggregationTerminal.Models public DateTime Time { get; set; } public MsgType Type { get; set; } } + public class DyelotItem + { + public string? Dyelot { get; set; } + public string? Machine { get; set; } + public string? CreationTime { get; set; } + public string? FabricName { get; set; } + public string? ColorName { get; set; } + public string? CustomerName { get; set; } + } public static class DataService { diff --git a/NotificationView/MessagePage.xaml.cs b/NotificationView/MessagePage.xaml.cs index 888dc8b..e45c76e 100644 --- a/NotificationView/MessagePage.xaml.cs +++ b/NotificationView/MessagePage.xaml.cs @@ -17,14 +17,13 @@ public partial class MessagePage : ContentPage private void LoadData() { - // 假设这是你获取数据的地方 var allData = DataService._NotificationData; if (allData != null) { // 清空旧数据 MessageItems.Clear(); - // 按时间倒序,并只取最新的 N 条(例如 50 条) + // 按时间倒序,并只取最新的 50 条 var itemsToShow = allData.OrderByDescending(x => x.Time).Take(50).Where(x => x.Type == MsgType.Message); // 将数据添加到集合中,UI 会自动更新 diff --git a/QueryPage.xaml b/QueryPage.xaml index 38a4016..38af455 100644 --- a/QueryPage.xaml +++ b/QueryPage.xaml @@ -3,8 +3,10 @@ xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" x:Class="SunlightAggregationTerminal.QueryPage" Title=""> - - + + + - - - - - - - + + + + + + + + + + +