Ver código fonte

Create UI Core Client Core

Zixuan 1 mês atrás
pai
commit
30ff98a29c

+ 10 - 4
Analizer/ProximaAnalizer/Helpers/DBDataHelper.cs

@@ -203,11 +203,17 @@ internal class DBDataHelper(SqlSugarCustom sqlSugarCustom)
             return false;
         if (sqlSugarCustom.Client is null)
             return false;
+        try
+        {
+            alarm = sqlSugarCustom.Client
+                .Queryable<EventData>()
+                .AS($"event_data")
+                .Where(t => t.Occur_Time >= this.StartTime && t.Occur_Time <= this.EndTime && (t.Level == "Alarm" || t.Level == "Warning")).ToList();
+        }
+        catch
+        {
 
-        alarm = sqlSugarCustom.Client
-            .Queryable<EventData>()
-            .AS($"event_data")
-            .Where(t => t.Occur_Time >= this.StartTime && t.Occur_Time <= this.EndTime && (t.Level == "Alarm" || t.Level == "Warning")).ToList();
+        }
 
         return alarm is not null;
     }

+ 4 - 0
Data/GeneralData/Class1.cs

@@ -21,8 +21,12 @@ public enum KeplerSubModel
 
 public enum ProximaSubModel
 {
+    [Description("NTP")]
     Proxima_NTP,
+    [Description("SiBN")]
     Proxima_SiBN,
+    [Description("NTP_HRP")]
     Proxima_NTP_HRP,
+    [Description("ELK")]
     Proxima_ELK
 }

+ 21 - 1
EEMSCenterUI/ViewModels/MainWindowViewModel.cs

@@ -1,4 +1,6 @@
 
+using ServiceBase;
+
 namespace EEMSCenterUI.ViewModels;
 
 internal partial class MainWindowViewModel : ObservableObject, IEEMSBaseServerProvider
@@ -12,15 +14,24 @@ internal partial class MainWindowViewModel : ObservableObject, IEEMSBaseServerPr
         };
     }
 
+    private IClientProvider? _clientProvider;
+
     [ObservableProperty]
     private ServiceEndpoint _Server;
 
+    [ObservableProperty]
+    private string? _GUID;
 
     [RelayCommand]
     private void StartService()
     {
         EEMSBaseServer baseServer = new();
-        baseServer.Initialize(this);
+        if (!baseServer.Initialize(this, out _clientProvider) || _clientProvider is null)
+        {
+            MessageBox.Show("Service Start Failed");
+            return;
+        }
+
         Task.Factory.StartNew(async () =>
         {
             if (!await baseServer.StartServiceAsync(this.Server.IP!, this.Server.Port))
@@ -28,6 +39,15 @@ internal partial class MainWindowViewModel : ObservableObject, IEEMSBaseServerPr
         }, TaskCreationOptions.LongRunning);
     }
 
+    [RelayCommand]
+    private void RequestFile()
+    {
+        Guid.TryParse(this.GUID, out Guid guid);
+        this._clientProvider?.RequestFile(guid, FileType.Config);
+    }
+
+
+
     void IEEMSBaseServerProvider.Started()
     {
         Task.Factory.StartNew(() =>

+ 0 - 2
EEMSCenterUI/ViewModels/TaskBarViewModel.cs

@@ -8,8 +8,6 @@ public partial class TaskBarViewModel : ObservableObject
 
     }
 
-
-
     [RelayCommand]
     private void HideShow()
     {

+ 3 - 1
EEMSCenterUI/Views/MainWindow.xaml

@@ -35,7 +35,7 @@
                 <TextBlock Grid.Column="2" VerticalAlignment="Center" HorizontalAlignment="Center">EEMS Server</TextBlock>
 
                 <Button Grid.Column="4" Background="Transparent" BorderThickness="0" Width="40" Click="Hide_Click">
-                    <Image Source="{StaticResource Icon_Lock}" Height="20"/>
+                    <Image Source="{StaticResource Icon_Expander}" Height="20"/>
                 </Button>
                 <Button Grid.Column="6" Background="Transparent" BorderThickness="0" Width="40" Click="Exit_Click">
                     <Image Source="{StaticResource Icon_Exit}" Height="20"/>
@@ -52,6 +52,8 @@
                 <TextBox Text="{Binding Server.IP}"/>
                 <TextBox Text="{Binding Server.Port}"/>
                 <Button Command="{Binding StartServiceCommand}">Start Service</Button>
+                <TextBox Text="{Binding GUID}"/>
+                <Button Command="{Binding RequestFileCommand}">Request File</Button>
             </StackPanel>
 
             <ItemsControl ItemsSource="{Binding Clients}" Grid.Row="2">

+ 8 - 1
EEMSMain.sln

@@ -31,7 +31,7 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GlobalData", "Data_ViewMode
 EndProject
 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Test", "Test\Test.csproj", "{7332403B-C2B6-404E-A196-AD6D3FDF207F}"
 EndProject
-Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Analizer", "Analizer", "{62F6EEA5-0B5B-44BC-88B8-8F875BF95424}"
+Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Analyzer", "Analyzer", "{62F6EEA5-0B5B-44BC-88B8-8F875BF95424}"
 EndProject
 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "KeplerAnalizer", "Analizer\KeplerAnalizer\KeplerAnalizer.csproj", "{2735D064-47D5-4905-87D0-D10619806546}"
 EndProject
@@ -78,6 +78,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ServiceBase", "Server\Servi
 EndProject
 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EEMSClientCore", "Server\EEMSClientCore\EEMSClientCore.csproj", "{0B0BF6F8-6BFC-4294-A9C9-014075A09392}"
 EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EEMSUIClientCore", "Server\EEMSUIClientCore\EEMSUIClientCore.csproj", "{0C79BB69-475D-40CC-AC3A-583AFD8F7527}"
+EndProject
 Global
 	GlobalSection(SolutionConfigurationPlatforms) = preSolution
 		Debug|Any CPU = Debug|Any CPU
@@ -192,6 +194,10 @@ Global
 		{0B0BF6F8-6BFC-4294-A9C9-014075A09392}.Debug|Any CPU.Build.0 = Debug|Any CPU
 		{0B0BF6F8-6BFC-4294-A9C9-014075A09392}.Release|Any CPU.ActiveCfg = Release|Any CPU
 		{0B0BF6F8-6BFC-4294-A9C9-014075A09392}.Release|Any CPU.Build.0 = Release|Any CPU
+		{0C79BB69-475D-40CC-AC3A-583AFD8F7527}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{0C79BB69-475D-40CC-AC3A-583AFD8F7527}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{0C79BB69-475D-40CC-AC3A-583AFD8F7527}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{0C79BB69-475D-40CC-AC3A-583AFD8F7527}.Release|Any CPU.Build.0 = Release|Any CPU
 	EndGlobalSection
 	GlobalSection(SolutionProperties) = preSolution
 		HideSolutionNode = FALSE
@@ -218,6 +224,7 @@ Global
 		{E1F62B2E-BC79-4A21-9458-B5CA3641BD08} = {A6000E18-5F55-4CD7-B3F5-82BB4A4A0E80}
 		{C1F57098-909D-4546-A1CB-660E473446AA} = {A6000E18-5F55-4CD7-B3F5-82BB4A4A0E80}
 		{0B0BF6F8-6BFC-4294-A9C9-014075A09392} = {A6000E18-5F55-4CD7-B3F5-82BB4A4A0E80}
+		{0C79BB69-475D-40CC-AC3A-583AFD8F7527} = {A6000E18-5F55-4CD7-B3F5-82BB4A4A0E80}
 	EndGlobalSection
 	GlobalSection(ExtensibilityGlobals) = postSolution
 		SolutionGuid = {331844F6-59F5-4D02-BFA4-2329C0EAB6EF}

+ 5 - 5
Server/EEMSClientCore/EEMSClientCore.csproj

@@ -1,10 +1,10 @@
 <Project Sdk="Microsoft.NET.Sdk">
 
-  <PropertyGroup>
-    <TargetFramework>net8.0</TargetFramework>
-    <ImplicitUsings>enable</ImplicitUsings>
-    <Nullable>enable</Nullable>
-  </PropertyGroup>
+	<PropertyGroup>
+		<TargetFramework>net8.0</TargetFramework>
+		<ImplicitUsings>enable</ImplicitUsings>
+		<Nullable>enable</Nullable>
+	</PropertyGroup>
 	<ItemGroup>
 		<PackageReference Include="Microsoft.AspNetCore.SignalR.Client" />
 	</ItemGroup>

+ 5 - 3
Server/EEMSService/EEMSBaseServer.cs

@@ -5,8 +5,9 @@ public class EEMSBaseServer : IDisposable
 
     public WebApplication? WebApplication { get; private set; }
 
-    public bool Initialize(IEEMSBaseServerProvider provider, long messageSize = 26144)//26144:256kb
+    public bool Initialize(IEEMSBaseServerProvider provider, out IClientProvider? clientProvider, long messageSize = 26144)//26144:256kb
     {
+        clientProvider = null;
         if (WebApplication is not null)
             return false;
 
@@ -18,11 +19,12 @@ public class EEMSBaseServer : IDisposable
                 options.MaximumReceiveMessageSize = messageSize;
             });
 
+        clientProvider = new ClientCaller();
         builder.Services.AddHostedService<HostLifeTime>();
         builder.Services.AddSingleton<DeviceManager>();
         builder.Services.AddSingleton<ClientManager>();
-        builder.Services.AddSingleton<UISender>();
-        builder.Services.AddSingleton<ClientCaller>();
+        builder.Services.AddSingleton<IUIProvider, UICaller>();
+        builder.Services.AddSingleton<IClientProvider>(clientProvider);
         builder.Services.AddSingleton<IEEMSBaseServerProvider>(provider);
 
         WebApplication = builder.Build();

+ 18 - 19
Server/EEMSService/HubSender/ClientCaller.cs

@@ -1,18 +1,17 @@
 namespace EEMSServerCore.HubSender;
 
-public class ClientCaller(ClientManager clientManager) : IClientProvider
+public class ClientCaller : IClientProvider
 {
-    private Task<bool> SendAsync(string name)
+    private Task<bool> SendAsync(Guid guid, string name)
     {
         if (string.IsNullOrEmpty(name))
             return Task.FromResult(false);
-
-        if (clientManager.UIClient is null)
+        if (ClientManager.DeviceClients.TryGetValue(guid, out ISingleClientProxy? client) || client is null)
             return Task.FromResult(false);
 
         try
         {
-            clientManager.UIClient.SendAsync("test");
+            client.SendAsync(name);
         }
         catch
         {
@@ -21,17 +20,17 @@ public class ClientCaller(ClientManager clientManager) : IClientProvider
         return Task.FromResult(true);
     }
 
-    private Task<bool> SendAsync<T>(string name, T para)
+    private Task<bool> SendAsync<T>(Guid guid, string name, T para)
     {
         if (string.IsNullOrEmpty(name))
             return Task.FromResult(false);
 
-        if (clientManager.UIClient is null)
+        if (ClientManager.DeviceClients.TryGetValue(guid, out ISingleClientProxy? client) || client is null)
             return Task.FromResult(false);
 
         try
         {
-            clientManager.UIClient.SendAsync(name, para);
+            client.SendAsync(name, para);
         }
         catch
         {
@@ -40,17 +39,17 @@ public class ClientCaller(ClientManager clientManager) : IClientProvider
         return Task.FromResult(true);
     }
 
-    private Task<bool> SendAsync<T1, T2>(string name, T1 para1, T2 para2)
+    private Task<bool> SendAsync<T1, T2>(Guid guid, string name, T1 para1, T2 para2)
     {
         if (string.IsNullOrEmpty(name))
             return Task.FromResult(false);
 
-        if (clientManager.UIClient is null)
+        if (!ClientManager.DeviceClients.TryGetValue(guid, out ISingleClientProxy? client) || client is null)
             return Task.FromResult(false);
 
         try
         {
-            clientManager.UIClient.SendAsync(name, para1, para2);
+            client.SendAsync(name, para1, para2);
         }
         catch
         {
@@ -59,17 +58,17 @@ public class ClientCaller(ClientManager clientManager) : IClientProvider
         return Task.FromResult(true);
     }
 
-    private Task<bool> SendAsync<T1, T2, T3>(string name, T1 para1, T2 para2, T3 para3)
+    private Task<bool> SendAsync<T1, T2, T3>(Guid guid, string name, T1 para1, T2 para2, T3 para3)
     {
         if (string.IsNullOrEmpty(name))
             return Task.FromResult(false);
 
-        if (clientManager.UIClient is null)
+        if (ClientManager.DeviceClients.TryGetValue(guid, out ISingleClientProxy? client) || client is null)
             return Task.FromResult(false);
 
         try
         {
-            clientManager.UIClient.SendAsync(name, para1, para2, para3);
+            client.SendAsync(name, para1, para2, para3);
         }
         catch
         {
@@ -78,17 +77,17 @@ public class ClientCaller(ClientManager clientManager) : IClientProvider
         return Task.FromResult(true);
     }
 
-    private Task<bool> SendAsync<T1, T2, T3, T4>(string name, T1 para1, T2 para2, T3 para3, T4 para4)
+    private Task<bool> SendAsync<T1, T2, T3, T4>(Guid guid, string name, T1 para1, T2 para2, T3 para3, T4 para4)
     {
         if (string.IsNullOrEmpty(name))
             return Task.FromResult(false);
 
-        if (clientManager.UIClient is null)
+        if (ClientManager.DeviceClients.TryGetValue(guid, out ISingleClientProxy? client) || client is null)
             return Task.FromResult(false);
 
         try
         {
-            clientManager.UIClient.SendAsync(name, para1, para2, para3, para4);
+            client.SendAsync(name, para1, para2, para3, para4);
         }
         catch
         {
@@ -97,8 +96,8 @@ public class ClientCaller(ClientManager clientManager) : IClientProvider
         return Task.FromResult(true);
     }
 
-    Task IClientProvider.RequestFile(Guid guid, FileType fileType)
+    Task<bool> IClientProvider.RequestFile(Guid guid, FileType fileType)
     {
-        return this.SendAsync("RequestFile", guid, fileType);
+        return this.SendAsync(guid, "RequestFile", guid, fileType);
     }
 }

+ 19 - 13
Server/EEMSService/HubSender/UISender.cs

@@ -1,11 +1,17 @@
 
+
 namespace EEMSServerCore.HubSender;
 
-internal class UISender(ClientManager clientManager) : IClientProvider
+internal class UICaller : IUIProvider
 {
-    public Task RequestFile(Guid guid, FileType fileType)
+    public Task<bool> UpdateDevice(DeviceInfo device)
+    {
+        throw new NotImplementedException();
+    }
+
+    public Task<bool> UpdateDeviceList(IEnumerable<DeviceInfo> device)
     {
-        return this.SendAsync<Guid, FileType>("RequestFile", guid, fileType);
+        throw new NotImplementedException();
     }
 
     private Task<bool> SendAsync(string name)
@@ -13,12 +19,12 @@ internal class UISender(ClientManager clientManager) : IClientProvider
         if (string.IsNullOrEmpty(name))
             return Task.FromResult(false);
 
-        if (clientManager.UIClient is null)
+        if (ClientManager.UIClient is null)
             return Task.FromResult(false);
 
         try
         {
-            clientManager.UIClient.SendAsync("test");
+            ClientManager.UIClient.SendAsync("test");
         }
         catch
         {
@@ -32,12 +38,12 @@ internal class UISender(ClientManager clientManager) : IClientProvider
         if (string.IsNullOrEmpty(name))
             return Task.FromResult(false);
 
-        if (clientManager.UIClient is null)
+        if (ClientManager.UIClient is null)
             return Task.FromResult(false);
 
         try
         {
-            clientManager.UIClient.SendAsync(name, para);
+            ClientManager.UIClient.SendAsync(name, para);
         }
         catch
         {
@@ -51,12 +57,12 @@ internal class UISender(ClientManager clientManager) : IClientProvider
         if (string.IsNullOrEmpty(name))
             return Task.FromResult(false);
 
-        if (clientManager.UIClient is null)
+        if (ClientManager.UIClient is null)
             return Task.FromResult(false);
 
         try
         {
-            clientManager.UIClient.SendAsync(name, para1, para2);
+            ClientManager.UIClient.SendAsync(name, para1, para2);
         }
         catch
         {
@@ -70,12 +76,12 @@ internal class UISender(ClientManager clientManager) : IClientProvider
         if (string.IsNullOrEmpty(name))
             return Task.FromResult(false);
 
-        if (clientManager.UIClient is null)
+        if (ClientManager.UIClient is null)
             return Task.FromResult(false);
 
         try
         {
-            clientManager.UIClient.SendAsync(name, para1, para2, para3);
+            ClientManager.UIClient.SendAsync(name, para1, para2, para3);
         }
         catch
         {
@@ -89,12 +95,12 @@ internal class UISender(ClientManager clientManager) : IClientProvider
         if (string.IsNullOrEmpty(name))
             return Task.FromResult(false);
 
-        if (clientManager.UIClient is null)
+        if (ClientManager.UIClient is null)
             return Task.FromResult(false);
 
         try
         {
-            clientManager.UIClient.SendAsync(name, para1, para2, para3, para4);
+            ClientManager.UIClient.SendAsync(name, para1, para2, para3, para4);
         }
         catch
         {

+ 1 - 1
Server/EEMSService/Hubs/ClientsFileHub.cs

@@ -5,7 +5,7 @@ namespace EEMSServerCore.Hubs;
 internal partial class ClientsMainHub
 {
     private static readonly ConcurrentDictionary<Guid, MemoryStream> _streamBuffer = [];
-
+    public static readonly ConcurrentDictionary<Guid, string> _savePath = [];
     public Task<bool> FilePack(Guid guid, byte[] buffer, int current, int total)
     {
         Console.WriteLine($"FilePack {guid} {current} {total}");

+ 3 - 3
Server/EEMSService/Hubs/ClientsMainHub.cs

@@ -2,7 +2,7 @@
 
 namespace EEMSServerCore.Hubs;
 
-internal partial class ClientsMainHub(DeviceManager deviceManager, ClientManager clientManager, IEEMSBaseServerProvider provider) : Hub, IClientCaller
+internal partial class ClientsMainHub(DeviceManager deviceManager, IEEMSBaseServerProvider provider) : Hub, IClientCaller
 {
     public override Task OnConnectedAsync()
     {
@@ -17,7 +17,7 @@ internal partial class ClientsMainHub(DeviceManager deviceManager, ClientManager
         deviceManager.RemoveDevice(Context.ConnectionId, out DeviceInfo? device);
 
         if (device is not null && device.Guid.HasValue)
-            clientManager.DeviceClients.TryRemove(device.Guid.Value, out _);
+            ClientManager.DeviceClients.TryRemove(device.Guid.Value, out _);
 
         if (Context.Features.Get<IHttpConnectionFeature>() is IHttpConnectionFeature feature)
             provider?.OnDisConnected(feature.RemoteIpAddress!.ToString(), (ushort)feature.RemotePort, ServiceHub.ClinetHub);
@@ -29,7 +29,7 @@ internal partial class ClientsMainHub(DeviceManager deviceManager, ClientManager
     {
         deviceInfo.Guid ??= Guid.NewGuid();
         deviceManager.LoginDevice(Context.ConnectionId, deviceInfo);
-        clientManager.DeviceClients[deviceInfo.Guid.Value] = Clients.Caller;
+        ClientManager.DeviceClients[deviceInfo.Guid.Value] = Clients.Caller;
         return Task.FromResult(deviceInfo.Guid.Value);
     }
 }

+ 2 - 2
Server/EEMSService/Hubs/UIHub.cs

@@ -1,10 +1,10 @@
 namespace EEMSServerCore.Hubs;
 
-internal class UIHub(ClientManager clientManager) : Hub
+internal class UIHub : Hub
 {
     public override Task OnConnectedAsync()
     {
-        clientManager.UIClient = Clients.All;
+        ClientManager.UIClient = Clients.All;
         return base.OnConnectedAsync();
     }
 }

+ 2 - 2
Server/EEMSService/Managers/ClientManager.cs

@@ -2,6 +2,6 @@
 
 public class ClientManager
 {
-    public IClientProxy? UIClient;
-    public readonly ConcurrentDictionary<Guid, ISingleClientProxy> DeviceClients = [];
+    public static IClientProxy? UIClient { get; internal set; }
+    public static readonly ConcurrentDictionary<Guid, ISingleClientProxy> DeviceClients = [];
 }

+ 11 - 0
Server/EEMSUIClientCore/ClientCaller.cs

@@ -0,0 +1,11 @@
+using ServiceBase;
+
+namespace EEMSUIClientCore;
+
+public class ClientCaller : IUICaller
+{
+    Task<bool> IUICaller.RequestDeviceLists()
+    {
+        return HubBase.Send("RegisterDevice");
+    }
+}

+ 17 - 0
Server/EEMSUIClientCore/EEMSUIClientCore.csproj

@@ -0,0 +1,17 @@
+<Project Sdk="Microsoft.NET.Sdk">
+
+	<PropertyGroup>
+		<TargetFramework>net8.0</TargetFramework>
+		<ImplicitUsings>enable</ImplicitUsings>
+		<Nullable>enable</Nullable>
+	</PropertyGroup>
+	<ItemGroup>
+		<PackageReference Include="Microsoft.AspNetCore.SignalR.Client" />
+	</ItemGroup>
+
+	<ItemGroup>
+		<ProjectReference Include="..\..\Data\Device\Device.csproj" />
+		<ProjectReference Include="..\..\Server\ServiceBase\ServiceBase.csproj" />
+		<ProjectReference Include="..\..\Universal\Universal.csproj" />
+	</ItemGroup>
+</Project>

+ 231 - 0
Server/EEMSUIClientCore/HubBase.cs

@@ -0,0 +1,231 @@
+using Device;
+using Microsoft.AspNetCore.SignalR.Client;
+using ServiceBase;
+
+namespace EEMSUIClientCore;
+
+public class HubBase : IDisposable
+{
+    private IUIProvider? _provider;
+    private static HubConnection? _HubConnection;
+
+    public bool Initialize(IUIProvider provider)
+    {
+        if (_HubConnection is not null)
+            return false;
+        if (_provider is not null)
+            return false;
+
+        _provider = provider;
+
+        return true;
+    }
+
+    public bool Open(string ip, int port, string hub, int retry = 40)
+    {
+        if (_provider is null)
+            return false;
+
+        HubConnection temp = new HubConnectionBuilder()
+            .WithUrl($"http://{ip}:{port}/{hub}")
+            .WithAutomaticReconnect()
+            .Build();
+
+        temp.On<IEnumerable<DeviceInfo>>("UpdateDeviceList", _provider.UpdateDeviceList);
+        temp.On<DeviceInfo>("UpdateDevice", _provider.UpdateDevice);
+
+        for (int i = 1; i <= retry; i++)
+        {
+            try
+            {
+                temp.StartAsync().Wait();
+                _HubConnection = temp;
+                break;
+            }
+            catch
+            {
+                if (i == retry)
+                    return false;
+                Thread.Sleep(1000);
+            }
+        }
+        return true;
+    }
+
+    public static bool CheckConnect()
+    {
+        if (_HubConnection is null)
+            return false;
+        if (_HubConnection.State != HubConnectionState.Connected)
+            return false;
+
+        return true;
+    }
+
+    public static async Task<bool> Send(string name)
+    {
+        if (!CheckConnect())
+            return false;
+
+        try
+        {
+            await _HubConnection!.SendAsync(name);
+        }
+        catch
+        {
+            return false;
+        }
+
+        return true;
+    }
+
+    public static async Task<bool> Send<T1>(string name, T1 para1)
+    {
+        if (!CheckConnect())
+            return false;
+
+        try
+        {
+            await _HubConnection!.SendAsync(name, para1);
+        }
+        catch
+        {
+            return false;
+        }
+
+        return true;
+    }
+
+    public static async Task<bool> Send<T1, T2>(string name, T1 para1, T2 para2)
+    {
+        if (!CheckConnect())
+            return false;
+
+        try
+        {
+            await _HubConnection!.SendAsync(name, para1, para2);
+        }
+        catch
+        {
+            return false;
+        }
+
+        return true;
+    }
+
+    public static async Task<bool> Send<T1, T2, T3>(string name, T1 para1, T2 para2, T3 para3)
+    {
+        if (!CheckConnect())
+            return false;
+
+        try
+        {
+            await _HubConnection!.SendAsync(name, para1, para2, para3);
+        }
+        catch
+        {
+            return false;
+        }
+
+        return true;
+    }
+
+    public static async Task<bool> Send<T1, T2, T3, T4>(string name, T1 para1, T2 para2, T3 para3, T4 para4)
+    {
+        if (!CheckConnect())
+            return false;
+
+        try
+        {
+            await _HubConnection!.SendAsync(name, para1, para2, para3, para4);
+        }
+        catch
+        {
+            return false;
+        }
+
+        return true;
+    }
+
+    public static bool Invoke<T_Return>(string name, out T_Return? returnValue)
+    {
+        returnValue = default;
+
+        if (!CheckConnect())
+            return false;
+
+        try
+        {
+            returnValue = _HubConnection!.InvokeAsync<T_Return>(name).Result;
+        }
+        catch
+        {
+            return false;
+        }
+
+        return true;
+    }
+
+    public static bool Invoke<T_Return, T_para1>(string name, T_para1 para1, out T_Return? returnValue)
+    {
+        returnValue = default;
+
+        if (!CheckConnect())
+            return false;
+
+        try
+        {
+            returnValue = _HubConnection!.InvokeAsync<T_Return>(name, para1).Result;
+        }
+        catch
+        {
+            return false;
+        }
+
+        return true;
+    }
+
+    public static bool Invoke<T_Return, T_para1, T_Para2>(string name, T_para1 para1, T_Para2 para2, out T_Return? returnValue)
+    {
+        returnValue = default;
+
+        if (!CheckConnect())
+            return false;
+
+        try
+        {
+            returnValue = _HubConnection!.InvokeAsync<T_Return>(name, para1, para2).Result;
+        }
+        catch
+        {
+            return false;
+        }
+
+        return true;
+    }
+
+    public static bool Invoke<T_Return, T_para1, T_Para2, T_Para3>(string name, T_para1 para1, T_Para2 para2, T_Para3 para3, out T_Return? returnValue)
+    {
+        returnValue = default;
+
+        if (!CheckConnect())
+            return false;
+
+        try
+        {
+            returnValue = _HubConnection!.InvokeAsync<T_Return>(name, para1, para2, para3).Result;
+        }
+        catch
+        {
+            return false;
+        }
+
+        return true;
+    }
+
+    public void Dispose()
+    {
+        _HubConnection?.StopAsync().Wait();
+        _HubConnection = null;
+    }
+}

+ 0 - 42
Server/ServiceBase/Class1.cs

@@ -1,42 +0,0 @@
-using Device;
-
-namespace ServiceBase;
-/// <summary>
-/// EEMS Client -> EEMS Server
-/// </summary>
-public interface IClientCaller
-{
-    Task<Guid> RegisterDevice(DeviceInfo deviceInfo);
-
-    Task<bool> FilePack(Guid guid, byte[] buffer, int current, int total);
-}
-
-/// <summary>
-/// EEMS Server -> EEMS Client
-/// </summary>
-public interface IClientProvider
-{
-    Task RequestFile(Guid guid, FileType fileType);
-}
-
-/// <summary>
-/// EEMS UI -> EEMS Server
-/// </summary>
-public interface IUICaller
-{
-
-}
-
-/// <summary>
-/// EEMS Server -> EEMS UI
-/// </summary>
-public interface IUIProvider
-{
-
-}
-
-public enum FileType : byte
-{
-    Config,
-    Recipe
-}

+ 19 - 0
Server/ServiceBase/ClientInterfaces.cs

@@ -0,0 +1,19 @@
+namespace ServiceBase;
+
+/// <summary>
+/// EEMS Client -> EEMS Server
+/// </summary>
+public interface IClientCaller
+{
+    Task<Guid> RegisterDevice(DeviceInfo deviceInfo);
+
+    Task<bool> FilePack(Guid guid, byte[] buffer, int current, int total);
+}
+
+/// <summary>
+/// EEMS Server -> EEMS Client
+/// </summary>
+public interface IClientProvider
+{
+    Task<bool> RequestFile(Guid guid, FileType fileType);
+}

+ 1 - 0
Server/ServiceBase/Properties/_global.cs

@@ -0,0 +1 @@
+global using Device;

+ 24 - 0
Server/ServiceBase/UIInterfaces.cs

@@ -0,0 +1,24 @@
+namespace ServiceBase;
+
+/// <summary>
+/// EEMS UI -> EEMS Server
+/// </summary>
+public interface IUICaller
+{
+    Task<bool> RequestDeviceLists();
+}
+
+/// <summary>
+/// EEMS Server -> EEMS UI
+/// </summary>
+public interface IUIProvider
+{
+    Task<bool> UpdateDeviceList(IEnumerable<DeviceInfo> device);
+    Task<bool> UpdateDevice(DeviceInfo device);
+}
+
+public enum FileType : byte
+{
+    Config,
+    Recipe
+}

+ 3 - 2
TestSignalRClient/Program.cs

@@ -19,14 +19,15 @@ internal class Program
         {
 
         };
+
         Guid guid = caller.RegisterDevice(deviceInfo).Result;
-  
+        Console.WriteLine(guid);
         Thread.Sleep(-1);
     }
 }
 public class ClientProvider(IClientCaller clientCaller) : IClientProvider
 {
-    Task IClientProvider.RequestFile(Guid guid, FileType fileType)
+    Task<bool> IClientProvider.RequestFile(Guid guid, FileType fileType)
     {
         Console.WriteLine($"RequestFile {guid} {fileType}");
         using MemoryStream stream = new();