diff --git a/Class/TcpServer.cs b/Class/TcpServer.cs index 8ac6e54..690eeee 100644 --- a/Class/TcpServer.cs +++ b/Class/TcpServer.cs @@ -78,7 +78,10 @@ namespace SunlightAggregationTerminal.Class } catch (Exception ex) { - await Application.Current!.Windows[0].Page!.DisplayAlertAsync("错误", ex.Message.ToString(), "是"); + MainThread.BeginInvokeOnMainThread(() => + { + Application.Current!.Windows[0].Page!.DisplayAlertAsync("错误", ex.Message.ToString(), "是"); + }); } finally { @@ -171,7 +174,12 @@ namespace SunlightAggregationTerminal.Class } } - catch (Exception ex) { Application.Current!.Windows[0].Page!.DisplayAlertAsync("", ex.Message.ToString(), "是"); } + catch (Exception ex) { + MainThread.BeginInvokeOnMainThread(() => + { + Application.Current!.Windows[0].Page!.DisplayAlertAsync("", ex.Message.ToString(), "是"); + }); + } return EasyTask.CompletedTask; }; @@ -180,6 +188,7 @@ namespace SunlightAggregationTerminal.Class try { await tcpClient.SetupAsync(new TouchSocketConfig() + .SetSingleStreamDataHandlingAdapter(() => new PeriodPackageAdapter())//以超时周期和包 .SetRemoteIPHost(ip) .ConfigurePlugins(a => { @@ -188,11 +197,15 @@ namespace SunlightAggregationTerminal.Class options.PollingInterval = TimeSpan.FromSeconds(5); }); })); + await tcpClient.ConnectAsync();//调用连接,当连接不成功时,会抛出异常。 } catch (Exception ex) { - await Application.Current!.Windows[0].Page!.DisplayAlertAsync("网络错误", ex.Message.ToString(), "是"); + MainThread.BeginInvokeOnMainThread(() => + { + Application.Current!.Windows[0].Page!.DisplayAlertAsync("网络错误", ex.Message.ToString(), "是"); + }); } } } diff --git a/InfoPage.xaml.cs b/InfoPage.xaml.cs index 1ca518a..e17686c 100644 --- a/InfoPage.xaml.cs +++ b/InfoPage.xaml.cs @@ -11,8 +11,6 @@ public partial class InfoPage : ContentPage { public static ObservableCollection InfoItems { get; set; } = new(); private DateTime _lastRefreshTime = DateTime.MinValue; - public static string? _Name, _State, _MachineName, _Machine, _Information, _Model, - _Type, _ModelA, _ModelB, _ModelC, _ModelD, _ModelE, _ModelF; public InfoPage() { @@ -27,8 +25,8 @@ public partial class InfoPage : ContentPage }); //注册当前页面的下滑刷新 myRefreshView_.Refreshing += (sender, e) => { - // 5秒防抖判断:如果距离上次刷新不足5秒,直接取消本次操作 - if ((DateTime.Now - _lastRefreshTime).TotalSeconds < 5) + // 防抖判断:如果距离上次刷新不足5秒,直接取消本次操作 + if ((DateTime.Now - _lastRefreshTime).TotalSeconds < 1) { myRefreshView_.IsRefreshing = false; return; diff --git a/QueryDetail.xaml b/QueryDetail.xaml index d2fef09..4c2f6a0 100644 --- a/QueryDetail.xaml +++ b/QueryDetail.xaml @@ -8,34 +8,34 @@ diff --git a/QueryDetail.xaml.cs b/QueryDetail.xaml.cs index 89bbfd0..73cbb1e 100644 --- a/QueryDetail.xaml.cs +++ b/QueryDetail.xaml.cs @@ -8,11 +8,17 @@ public partial class QueryDetail : ContentPage public static ObservableCollection QueryDetailDyelotDetailsItems { get; set; } = new(); public static ObservableCollection QueryDetailDyelotDetailsItemst { get; set; } = new(); public QueryDetail(DyelotItem item) - { - - + { InitializeComponent(); + _Dyelot.Text = item.Dyelot; + _ReDye.Text = item.ReDye?.ToString()??""; + _Machine.Text = item.Machine; + _CreationTime.Text = item.CreationTime; + _FabricName.Text = item.FabricName; + _CustomerName.Text = item.CustomerName; + _ColorName.Text = item.ColorName; + QueryDetailDyelotDetailsItems.Add(new DyelotDetailsItem { Dyelot = "2134566", diff --git a/QueryPage.xaml b/QueryPage.xaml index fcac371..d6af685 100644 --- a/QueryPage.xaml +++ b/QueryPage.xaml @@ -4,8 +4,9 @@ x:Class="SunlightAggregationTerminal.QueryPage" Title=""> - - + + - +