Merge branch 'master' of http://www.scserverddns.top:13000/sc/SunlightAggregationTerminal
This commit is contained in:
commit
7e8b05dfdf
8 files changed
+146
-33
No files matched your search
+13
-2
@@ -1,7 +1,10 @@
|
||||
using System;
|
||||
using Microsoft.VisualBasic;
|
||||
using SunlightAggregationTerminal.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Net;
|
||||
using System.Net.Sockets;
|
||||
using System.Reflection.PortableExecutable;
|
||||
using System.Text;
|
||||
using System.Text.Json;
|
||||
using TouchSocket.Core;
|
||||
@@ -38,6 +41,7 @@ namespace SunlightAggregationTerminal.Class
|
||||
public static string ServerPassword = "";
|
||||
public static string ServerTerminal = "";
|
||||
|
||||
|
||||
public static TouchSocket.Sockets.TcpClient tcpClient = new TouchSocket.Sockets.TcpClient();
|
||||
|
||||
public static void Configuration(string ip, string Name, string Password, string Terminal)
|
||||
@@ -77,7 +81,7 @@ namespace SunlightAggregationTerminal.Class
|
||||
{
|
||||
tcpClient.Connecting = (client, e) => { return EasyTask.CompletedTask; };//即将连接到服务器,此时已经创建socket,但是还未建立tcp
|
||||
tcpClient.Connected = (client, e) => {
|
||||
TcpServer.TcpTransmit("Log");
|
||||
TcpServer.TcpTransmit("\"{\"Command\":\"Log\"}\"");
|
||||
return EasyTask.CompletedTask; };//成功连接到服务器
|
||||
tcpClient.Closing = (client, e) => { return EasyTask.CompletedTask; };//即将从服务器断开连接。此处仅主动断开才有效。
|
||||
tcpClient.Closed = (client, e) => { return EasyTask.CompletedTask; };//从服务器断开连接,当连接不成功时不会触发。
|
||||
@@ -102,6 +106,8 @@ namespace SunlightAggregationTerminal.Class
|
||||
{
|
||||
App.GlobalData.UserId = val.ToString() ?? "";
|
||||
App.GlobalData.LogNo = true;
|
||||
|
||||
TcpServer.TcpTransmit("{\"Command\":\"Info\"}");
|
||||
}
|
||||
|
||||
if (data.TryGetValue("UserData", out var value_UserData))
|
||||
@@ -113,7 +119,12 @@ namespace SunlightAggregationTerminal.Class
|
||||
|
||||
}
|
||||
|
||||
if (data.TryGetValue("Info", out val) && val != null)//机台信息接受
|
||||
{
|
||||
DataModel.Info_data = JsonSerializer.Deserialize<List<Dictionary<string, object>>>(val.ToString()!)!;
|
||||
|
||||
InfoPage.OnInfoPage();
|
||||
}
|
||||
if (data.TryGetValue("Query", out val) && val != null)//查询接受
|
||||
{
|
||||
QueryPage.Query_data(val.ToString()!);
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Text;
|
||||
|
||||
namespace SunlightAggregationTerminal.Converters
|
||||
{
|
||||
public class StringToBoolConverter : IValueConverter
|
||||
{
|
||||
public object Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
|
||||
{
|
||||
if (value !=null)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public object ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture)
|
||||
{
|
||||
// 单向绑定通常不需要实现,除非你需要双向绑定
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
+19
-4
@@ -7,6 +7,7 @@
|
||||
<ContentPage.Resources>
|
||||
<ResourceDictionary>
|
||||
<converters:StringToImageConverter x:Key="StringToImageConverter" />
|
||||
<converters:StringToBoolConverter x:Key="StringToBoolConverter" />
|
||||
</ResourceDictionary>
|
||||
</ContentPage.Resources>
|
||||
<ScrollView>
|
||||
@@ -57,14 +58,28 @@
|
||||
</HorizontalStackLayout>
|
||||
</Grid>
|
||||
<BoxView HeightRequest="3" Color="#CCCCCC" />
|
||||
<HorizontalStackLayout>
|
||||
<!-- 设备信息 -->
|
||||
<Label Text="{Binding Information}" FontAttributes="Bold"
|
||||
<!-- 设备信息 -->
|
||||
<Label Text="{Binding ModelA}" FontAttributes="Bold" FontSize="22" TextColor="Black"
|
||||
IsVisible="{Binding Path=ModelA, Converter={StaticResource StringToBoolConverter}}"/>
|
||||
<Label Text="{Binding ModelB}" FontAttributes="Bold" FontSize="22" TextColor="Black"
|
||||
IsVisible="{Binding Path=ModelB, Converter={StaticResource StringToBoolConverter}}"/>
|
||||
<Label Text="{Binding ModelC}" FontAttributes="Bold" FontSize="22" TextColor="Black"
|
||||
IsVisible="{Binding Path=ModelC, Converter={StaticResource StringToBoolConverter}}"/>
|
||||
<Label Text="{Binding ModelD}" FontAttributes="Bold" FontSize="22" TextColor="Black"
|
||||
IsVisible="{Binding Path=ModelD, Converter={StaticResource StringToBoolConverter}}"/>
|
||||
<Label Text="{Binding ModelE}" FontAttributes="Bold" FontSize="22" TextColor="Black"
|
||||
IsVisible="{Binding Path=ModelE, Converter={StaticResource StringToBoolConverter}}"/>
|
||||
<Label Text="{Binding ModelF}" FontAttributes="Bold" FontSize="22" TextColor="Black"
|
||||
IsVisible="{Binding Path=ModelF, Converter={StaticResource StringToBoolConverter}}"/>
|
||||
<Label Text="{Binding Information}" FontAttributes="Bold"
|
||||
FontSize="22" TextColor="Black"/>
|
||||
</HorizontalStackLayout>
|
||||
</VerticalStackLayout>
|
||||
</Grid>
|
||||
</Grid>
|
||||
<!-- 点击事件 -->
|
||||
<Border.GestureRecognizers>
|
||||
<TapGestureRecognizer Tapped="TapGestureRecognizer_Tapped"/>
|
||||
</Border.GestureRecognizers>
|
||||
</Border>
|
||||
</DataTemplate>
|
||||
</CollectionView.ItemTemplate>
|
||||
|
||||
+63
-12
@@ -1,26 +1,77 @@
|
||||
using Microsoft.Maui.Controls;
|
||||
using SunlightAggregationTerminal.Class;
|
||||
using SunlightAggregationTerminal.Models;
|
||||
using System.Collections.ObjectModel;
|
||||
|
||||
namespace SunlightAggregationTerminal;
|
||||
|
||||
public partial class InfoPage : ContentPage
|
||||
{
|
||||
public ObservableCollection<InfoItem> InfoItems { get; set; } = new();
|
||||
{
|
||||
public static ObservableCollection<InfoItem> InfoItems { get; set; } = new();
|
||||
public static string? _Name, _State, _MachineName, _Machine, _Information, _Model,
|
||||
_Type, _ModelA, _ModelB, _ModelC, _ModelD, _ModelE, _ModelF;
|
||||
|
||||
public InfoPage()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
|
||||
InfoItems.Add(new InfoItem { Name="202",Model= "302", State="tz",Machine="123456",Information="etggsgt\n234423\ngsgsg\nstset" });
|
||||
InfoItems.Add(new InfoItem { Name = "pdw", Model = "252-2T", State = "tz", Machine = "123456", Information = "etggsgt\n234423\ngsgsg\nstset" });
|
||||
InfoItems.Add(new InfoItem { Name = "pdw", Model = "242W", State = "tz", Machine = "123456", Information = "etggsgt\n234423\ngsgsg\nstset" });
|
||||
|
||||
|
||||
CardCollectionView.ItemsSource = InfoItems;
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void CardCollectionView_RemainingItemsThresholdReached(object sender, EventArgs e)
|
||||
public static void OnInfoPage()//打开时加载信息
|
||||
{
|
||||
MainThread.BeginInvokeOnMainThread(() =>
|
||||
{
|
||||
InfoItems.Clear();
|
||||
foreach (Dictionary<string, object> List in DataModel.Info_data)
|
||||
{
|
||||
if (List.TryGetValue("Name", out var val) && val != null) _Name = val.ToString()!;
|
||||
if (List.TryGetValue("State", out val) && val != null) _State = val.ToString()!;
|
||||
if (List.TryGetValue("MachineName", out val) && val != null) _MachineName = val.ToString()!;
|
||||
if (List.TryGetValue("Machine", out val) && val != null) _Machine = val.ToString()!;
|
||||
if (List.TryGetValue("Information", out val) && val != null) _Information = val.ToString()!;
|
||||
if (List.TryGetValue("Type", out val) && val != null) _Type = val.ToString()!;
|
||||
if (List.TryGetValue("Model", out val) && val != null) _Model = val.ToString()!;
|
||||
if (List.TryGetValue("ModelA", out val) && val != null) _ModelA = val.ToString()!;
|
||||
if (List.TryGetValue("ModelB", out val) && val != null) _ModelB = val.ToString()!;
|
||||
if (List.TryGetValue("ModelC", out val) && val != null) _ModelC = val.ToString()!;
|
||||
if (List.TryGetValue("ModelD", out val) && val != null) _ModelD = val.ToString()!;
|
||||
if (List.TryGetValue("ModelE", out val) && val != null) _ModelE = val.ToString()!;
|
||||
if (List.TryGetValue("ModelF", out val) && val != null) _ModelF = val.ToString()!;
|
||||
|
||||
InfoItems.Add(new InfoItem
|
||||
{
|
||||
Name = _Name,
|
||||
State = _State,
|
||||
MachineName = _MachineName,
|
||||
Machine = _Machine,
|
||||
Information = _Information,
|
||||
Type = _Type,
|
||||
Model = _Model,
|
||||
ModelA = _ModelA,
|
||||
ModelB = _ModelB,
|
||||
ModelC = _ModelC,
|
||||
ModelD = _ModelD,
|
||||
ModelE = _ModelE,
|
||||
ModelF = _ModelF
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
private void TapGestureRecognizer_Tapped(object sender, TappedEventArgs e)
|
||||
{
|
||||
// 将 sender 强制转换为 BindingContext 定义在 BindableObject
|
||||
if (sender is Microsoft.Maui.Controls.BindableObject bindable)
|
||||
{
|
||||
var context = bindable.BindingContext;
|
||||
|
||||
if (context is InfoItem item)
|
||||
{
|
||||
DisplayAlert("提示", $"你点击了工单: {item.MachineName}", "确定");
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -36,5 +36,7 @@ namespace SunlightAggregationTerminal.Models
|
||||
[ObservableProperty]
|
||||
public partial bool MessageNotificationMode { get; set; }
|
||||
|
||||
|
||||
public static List<Dictionary<string, object>> Info_data = new List<Dictionary<string, object>>();
|
||||
}
|
||||
}
|
||||
+15
-10
@@ -1,8 +1,10 @@
|
||||
using System;
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Text;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace SunlightAggregationTerminal.Models
|
||||
{
|
||||
@@ -23,20 +25,23 @@ namespace SunlightAggregationTerminal.Models
|
||||
public DateTime Time { get; set; }
|
||||
public MsgType Type { get; set; }
|
||||
}
|
||||
public class InfoItem
|
||||
public partial class InfoItem : ObservableObject
|
||||
{
|
||||
public string? Name { get; set; }
|
||||
[ObservableProperty]
|
||||
public string _name;
|
||||
// public string? Name { get; set; }
|
||||
public string? State { get; set; }
|
||||
public string? MachineName { get; set; }
|
||||
public string? Machine { get; set; }
|
||||
public string? Information { get; set; }
|
||||
public string? Model { get; set; }
|
||||
public string? Type { get; set; }
|
||||
public string? A { get; set; }
|
||||
public string? B { get; set; }
|
||||
public string? C { get; set; }
|
||||
public string? D { get; set; }
|
||||
public string? E { get; set; }
|
||||
public string? F { get; set; }
|
||||
public string? ModelA { get; set; }
|
||||
public string? ModelB { get; set; }
|
||||
public string? ModelC { get; set; }
|
||||
public string? ModelD { get; set; }
|
||||
public string? ModelE { get; set; }
|
||||
public string? ModelF { get; set; }
|
||||
}
|
||||
|
||||
public class DyelotItem
|
||||
|
||||
@@ -3,7 +3,6 @@ using SunlightAggregationTerminal.Class;
|
||||
using SunlightAggregationTerminal.Models;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Text.Json;
|
||||
using static SunlightAggregationTerminal.QueryPage;
|
||||
|
||||
namespace SunlightAggregationTerminal;
|
||||
|
||||
|
||||
@@ -65,6 +65,15 @@
|
||||
<MauiAsset Include="Resources\Raw\**" LogicalName="%(RecursiveDir)%(Filename)%(Extension)" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<AndroidResource Remove="Services\**" />
|
||||
<Compile Remove="Services\**" />
|
||||
<EmbeddedResource Remove="Services\**" />
|
||||
<MauiCss Remove="Services\**" />
|
||||
<MauiXaml Remove="Services\**" />
|
||||
<None Remove="Services\**" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Remove="Images\adduserfilled.svg" />
|
||||
<None Remove="Images\infofeed.svg" />
|
||||
@@ -124,8 +133,4 @@
|
||||
</MauiXaml>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="Services\" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
Reference in new issue
Block a user