diff --git a/Class/HttpServer.cs b/Class/HttpServer.cs index 62e9888..9ff3777 100644 --- a/Class/HttpServer.cs +++ b/Class/HttpServer.cs @@ -40,52 +40,62 @@ namespace SunlightAggregationTerminal.Class else { await HttpClient(DataReceived.ServerIP); - - HttpTransmit("{\"Command\":\"Log\"}"); } } public static async Task HttpClient(string url) { - var config = new TouchSocketConfig(); - #region Http设置远程服务器地址 - config.SetRemoteIPHost("http://" + url); - #endregion - - #region Http客户端获取断线通知 - config.ConfigurePlugins(a => + try { - //处理连接断开 - a.AddTcpClosedPlugin(async (c, e) => - { - //MainThread.BeginInvokeOnMainThread(() => - // { - // Application.Current!.Windows[0].Page!.DisplayAlertAsync("", "客户端断开连接", "是"); - // }); - // await e.InvokeNext(); - }); - //自动重连 - a.UseReconnection(options => + var config = new TouchSocketConfig(); + #region Http设置远程服务器地址 + config.SetRemoteIPHost("http://" + url); + #endregion + + #region Http客户端获取断线通知 + config.ConfigurePlugins(a => { - options.PollingInterval = TimeSpan.FromSeconds(3); + //处理连接断开 + a.AddTcpClosedPlugin(async (c, e) => + { + //MainThread.BeginInvokeOnMainThread(() => + // { + // Application.Current!.Windows[0].Page!.DisplayAlertAsync("", "客户端断开连接", "是"); + // }); + // await e.InvokeNext(); + }); + //自动重连 + a.UseReconnection(options => + { + options.PollingInterval = TimeSpan.FromSeconds(3); + }); + //处理连接 + a.AddTcpConnectedPlugin(async (c, e) => + { + await e.InvokeNext(); + }); }); - //处理连接 - a.AddTcpConnectedPlugin(async (c, e) => + #endregion + + if (httpclient.Online)//是否重置客户端 { - await e.InvokeNext(); - }); - }); - #endregion + await httpclient.CloseAsync(); + } - if (httpclient.Online)//是否重置客户端 + //配置config + await httpclient.SetupAsync(config); + //连接 + await httpclient.ConnectAsync(); + + HttpTransmit("{\"Command\":\"Log\"}"); + } + catch (Exception ex) { - await httpclient.CloseAsync(); + MainThread.BeginInvokeOnMainThread(() => + { + Application.Current!.Windows[0].Page!.DisplayAlertAsync("网络错误", ex.Message.ToString(), "是"); + }); } - - //配置config - await httpclient.SetupAsync(config); - //连接 - await httpclient.ConnectAsync(); } /***发送信息处理***/ @@ -142,7 +152,7 @@ namespace SunlightAggregationTerminal.Class } finally { - Start(); + //Start(); } } diff --git a/InfoChemicalStatistics.xaml b/InfoChemicalStatistics.xaml index 38a367d..3b405f1 100644 --- a/InfoChemicalStatistics.xaml +++ b/InfoChemicalStatistics.xaml @@ -28,10 +28,12 @@ FontSize="22" TextColor="Black"/> - diff --git a/InfoChemicalStatistics.xaml.cs b/InfoChemicalStatistics.xaml.cs index f880c9b..1089f15 100644 --- a/InfoChemicalStatistics.xaml.cs +++ b/InfoChemicalStatistics.xaml.cs @@ -59,7 +59,7 @@ public partial class InfoChemicalStatistics : ContentPage { foreach (var item in data) { - item.TotalDispenseGrams = item.TotalDispenseGrams / 1000; + item.TotalDispenseGrams = MathF.Round((float)item.TotalDispenseGrams! / 1000, 5); ChemicalTotals.Add(item); } diff --git a/InfoDetail.xaml b/InfoDetail.xaml index 7c11524..51d9207 100644 --- a/InfoDetail.xaml +++ b/InfoDetail.xaml @@ -136,7 +136,7 @@ diff --git a/InfoDetail.xaml.cs b/InfoDetail.xaml.cs index 789858f..4230815 100644 --- a/InfoDetail.xaml.cs +++ b/InfoDetail.xaml.cs @@ -496,7 +496,13 @@ public class InfoMachineItem } dyelotDetailsItem.DispenseStartTime = item.GetValue("DispenseStartTime").ToString()!.Replace("T", " "); dyelotDetailsItem.DispenseEndTime = item.GetValue("DispenseEndTime").ToString()!.Replace("T", " "); - dyelotDetailsItem.UsageTime = item.GetValue("CallTime").ToString()!.Replace("T", " "); + if (item!.TryGetValue("CallTime", out var _CallTime) && _CallTime != null) + { + if (DateTime.TryParse(_CallTime.ToString(), out DateTime dtc)) + { + dyelotDetailsItem.CallTime = dtc.ToString("yyyy-MM-dd HH:mm:ss"); + } + } InfoDyelotHistoryItems.Add(dyelotDetailsItem); } if (InfoDyelotHistoryItems.Count == 0) InfoDyelotHistoryItems.Add(new DyelotDetailsItem()); @@ -569,7 +575,13 @@ public class InfoMachineItem } dyelotDetailsItem.DispenseStartTime = item.GetValue("DispenseStartTime").ToString()!.Replace("T", " "); dyelotDetailsItem.DispenseEndTime = item.GetValue("DispenseEndTime").ToString()!.Replace("T", " "); - dyelotDetailsItem.UsageTime = item.GetValue("CallTime").ToString()!.Replace("T", " "); + if (item!.TryGetValue("CallTime", out var _CallTime) && _CallTime != null) + { + if (DateTime.TryParse(_CallTime.ToString(), out DateTime dtc)) + { + dyelotDetailsItem.CallTime = dtc.ToString("yyyy-MM-dd HH:mm:ss"); + } + } InfoDyelotHistoryItems.Add(dyelotDetailsItem); } if (InfoDyelotHistoryItems.Count == 0) InfoDyelotHistoryItems.Add(new DyelotDetailsItem()); diff --git a/Models/DataSource.cs b/Models/DataSource.cs index 6da2c93..2d12a97 100644 --- a/Models/DataSource.cs +++ b/Models/DataSource.cs @@ -78,7 +78,8 @@ namespace SunlightAggregationTerminal.Models public string? DispenseTime { get; set; } public string? CallTime { get; set; } public string? UsageTime { get; set; } - public string? Tank { get; set; } + public string? Tank { get; set; } + public object? PowderTargetTank { get; set; } public double? DispenseGrams { get; set; } public string DispenseGramsDisplay => DispenseGrams?.ToString("F2") ?? ""; public int? DispenseResult { get; set; } diff --git a/QueryDetail.xaml b/QueryDetail.xaml index 633b238..e74255d 100644 --- a/QueryDetail.xaml +++ b/QueryDetail.xaml @@ -60,8 +60,6 @@ FontSize="22" TextColor="Black"/> + +