so many stuff
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>net5.0</TargetFramework>
|
<TargetFramework>net5.0</TargetFramework>
|
||||||
|
|||||||
@@ -1,10 +1,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Linq;
|
|
||||||
using System.Net.NetworkInformation;
|
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using ConsoleTools;
|
using ConsoleTools;
|
||||||
using WD7UVN_HFT_2023241.Models;
|
using WD7UVN_HFT_2023241.Models;
|
||||||
using WD7UVN_HFT_2023241.Client.Shared;
|
|
||||||
|
|
||||||
namespace WD7UVN_HFT_2023241.Client.TUI
|
namespace WD7UVN_HFT_2023241.Client.TUI
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,8 +1,5 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Linq;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using ConsoleTools;
|
using ConsoleTools;
|
||||||
using WD7UVN_HFT_2023241.Client.Shared;
|
|
||||||
using WD7UVN_HFT_2023241.Models;
|
using WD7UVN_HFT_2023241.Models;
|
||||||
|
|
||||||
namespace WD7UVN_HFT_2023241.Client.TUI
|
namespace WD7UVN_HFT_2023241.Client.TUI
|
||||||
|
|||||||
@@ -2,7 +2,6 @@
|
|||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using ConsoleTools;
|
using ConsoleTools;
|
||||||
using WD7UVN_HFT_2023241.Client.Shared;
|
|
||||||
|
|
||||||
namespace WD7UVN_HFT_2023241.Client.TUI
|
namespace WD7UVN_HFT_2023241.Client.TUI
|
||||||
{
|
{
|
||||||
|
|||||||
264
WD7UVN_HFT_2023241.Client/TUI/RestService.cs
Normal file
264
WD7UVN_HFT_2023241.Client/TUI/RestService.cs
Normal file
@@ -0,0 +1,264 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Net;
|
||||||
|
using System.Net.Http;
|
||||||
|
using System.Net.Security;
|
||||||
|
using WD7UVN_HFT_2023241.Models;
|
||||||
|
|
||||||
|
namespace WD7UVN_HFT_2023241.Client.TUI
|
||||||
|
{
|
||||||
|
public class RestService
|
||||||
|
{
|
||||||
|
private static HttpClient client;
|
||||||
|
|
||||||
|
private static bool Ping(string url)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(delegate { return true; });
|
||||||
|
|
||||||
|
WebClient wc = new WebClient();
|
||||||
|
wc.DownloadData(url);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void Init(string baseurl = "https://localhost:5001", string pingableEndpoint = "/swagger")
|
||||||
|
{
|
||||||
|
int tries = 0;
|
||||||
|
bool isOk = false;
|
||||||
|
do
|
||||||
|
{
|
||||||
|
isOk = Ping(baseurl + pingableEndpoint);
|
||||||
|
tries++;
|
||||||
|
} while (isOk == false && tries < 5);
|
||||||
|
|
||||||
|
if (isOk == false)
|
||||||
|
{
|
||||||
|
throw new EndpointNotAvailableException("Endpoint is not available!");
|
||||||
|
}
|
||||||
|
|
||||||
|
HttpClientHandler handler = new HttpClientHandler();
|
||||||
|
handler.ClientCertificateOptions = ClientCertificateOption.Manual;
|
||||||
|
handler.ServerCertificateCustomValidationCallback =
|
||||||
|
(httpRequestMessage, cert, cetChain, policyErrors) =>
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
};
|
||||||
|
|
||||||
|
client = new HttpClient(handler);
|
||||||
|
client.BaseAddress = new Uri(baseurl);
|
||||||
|
client.DefaultRequestHeaders.Accept.Clear();
|
||||||
|
client.DefaultRequestHeaders.Accept.Add(
|
||||||
|
new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue
|
||||||
|
("application/json"));
|
||||||
|
try
|
||||||
|
{
|
||||||
|
client.GetAsync("").GetAwaiter().GetResult();
|
||||||
|
}
|
||||||
|
catch (HttpRequestException e)
|
||||||
|
{
|
||||||
|
Console.WriteLine(e.Message);
|
||||||
|
throw new ArgumentException("Endpoint is not available!");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static List<T> Get<T>(string endpoint)
|
||||||
|
{
|
||||||
|
List<T> items = new List<T>();
|
||||||
|
HttpResponseMessage response = client.GetAsync(endpoint).GetAwaiter().GetResult();
|
||||||
|
if (response.IsSuccessStatusCode)
|
||||||
|
{
|
||||||
|
items = response.Content.ReadAsAsync<List<T>>().GetAwaiter().GetResult();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var error = response.Content.ReadAsAsync<RestExceptionInfo>().GetAwaiter().GetResult();
|
||||||
|
throw new ArgumentException(error.Msg);
|
||||||
|
}
|
||||||
|
return items;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static T GetSingle<T>(string endpoint)
|
||||||
|
{
|
||||||
|
T item = default(T);
|
||||||
|
HttpResponseMessage response = client.GetAsync(endpoint).GetAwaiter().GetResult();
|
||||||
|
if (response.IsSuccessStatusCode)
|
||||||
|
{
|
||||||
|
item = response.Content.ReadAsAsync<T>().GetAwaiter().GetResult();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var error = response.Content.ReadAsAsync<RestExceptionInfo>().GetAwaiter().GetResult();
|
||||||
|
throw new ArgumentException(error.Msg);
|
||||||
|
}
|
||||||
|
return item;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static T Get<T>(int id, string endpoint)
|
||||||
|
{
|
||||||
|
T item = default(T);
|
||||||
|
HttpResponseMessage response = client.GetAsync(endpoint + id.ToString()).GetAwaiter().GetResult();
|
||||||
|
if (response.IsSuccessStatusCode)
|
||||||
|
{
|
||||||
|
item = response.Content.ReadAsAsync<T>().GetAwaiter().GetResult();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var error = response.Content.ReadAsAsync<RestExceptionInfo>().GetAwaiter().GetResult();
|
||||||
|
throw new ArgumentException(error.Msg);
|
||||||
|
}
|
||||||
|
return item;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void Post<T>(T item, string endpoint)
|
||||||
|
{
|
||||||
|
HttpResponseMessage response =
|
||||||
|
client.PostAsJsonAsync(endpoint, item).GetAwaiter().GetResult();
|
||||||
|
|
||||||
|
if (!response.IsSuccessStatusCode)
|
||||||
|
{
|
||||||
|
var error = response.Content.ReadAsAsync<RestExceptionInfo>().GetAwaiter().GetResult();
|
||||||
|
throw new ArgumentException(error.Msg);
|
||||||
|
}
|
||||||
|
response.EnsureSuccessStatusCode();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void Delete(int id, string endpoint)
|
||||||
|
{
|
||||||
|
HttpResponseMessage response =
|
||||||
|
client.DeleteAsync(endpoint + id.ToString()).GetAwaiter().GetResult();
|
||||||
|
|
||||||
|
if (!response.IsSuccessStatusCode)
|
||||||
|
{
|
||||||
|
var error = response.Content.ReadAsAsync<RestExceptionInfo>().GetAwaiter().GetResult();
|
||||||
|
throw new ArgumentException(error.Msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
response.EnsureSuccessStatusCode();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void Put<T>(T item, string endpoint)
|
||||||
|
{
|
||||||
|
HttpResponseMessage response =
|
||||||
|
client.PutAsJsonAsync(endpoint, item).GetAwaiter().GetResult();
|
||||||
|
|
||||||
|
if (!response.IsSuccessStatusCode)
|
||||||
|
{
|
||||||
|
var error = response.Content.ReadAsAsync<RestExceptionInfo>().GetAwaiter().GetResult();
|
||||||
|
throw new ArgumentException(error.Msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
response.EnsureSuccessStatusCode();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static List<Employee> WhoWorksInMaintainerTeam(int id)
|
||||||
|
{
|
||||||
|
var item = default(List<Employee>);
|
||||||
|
HttpResponseMessage response = client.GetAsync("/api/WhoWorksInMaintainerTeam?id=" + id.ToString()).GetAwaiter().GetResult();
|
||||||
|
if (response.IsSuccessStatusCode)
|
||||||
|
{
|
||||||
|
item = response.Content.ReadAsAsync<List<Employee>>().GetAwaiter().GetResult();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var error = response.Content.ReadAsAsync<RestExceptionInfo>().GetAwaiter().GetResult();
|
||||||
|
throw new ArgumentException(error.Msg);
|
||||||
|
}
|
||||||
|
return item;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static List<Employee> GetSubordinates(int id)
|
||||||
|
{
|
||||||
|
var item = default(List<Employee>);
|
||||||
|
HttpResponseMessage response = client.GetAsync("/api/GetSubordinates?id=" + id.ToString()).GetAwaiter().GetResult();
|
||||||
|
if (response.IsSuccessStatusCode)
|
||||||
|
{
|
||||||
|
item = response.Content.ReadAsAsync<List<Employee>>().GetAwaiter().GetResult();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var error = response.Content.ReadAsAsync<RestExceptionInfo>().GetAwaiter().GetResult();
|
||||||
|
throw new ArgumentException(error.Msg);
|
||||||
|
}
|
||||||
|
return item;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static List<Customer> WhoUsesService(int id)
|
||||||
|
{
|
||||||
|
var item = default(List<Customer>);
|
||||||
|
HttpResponseMessage response = client.GetAsync("/api/WhoUsesService?id=" + id.ToString()).GetAwaiter().GetResult();
|
||||||
|
if (response.IsSuccessStatusCode)
|
||||||
|
{
|
||||||
|
item = response.Content.ReadAsAsync<List<Customer>>().GetAwaiter().GetResult();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var error = response.Content.ReadAsAsync<RestExceptionInfo>().GetAwaiter().GetResult();
|
||||||
|
throw new ArgumentException(error.Msg);
|
||||||
|
}
|
||||||
|
return item;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Employee WhoIsResponsibleForService(int id)
|
||||||
|
{
|
||||||
|
Employee item = default(Employee);
|
||||||
|
HttpResponseMessage response = client.GetAsync("/api/WhoIsResponsibleForService?id=" + id.ToString()).GetAwaiter().GetResult();
|
||||||
|
if (response.IsSuccessStatusCode)
|
||||||
|
{
|
||||||
|
item = response.Content.ReadAsAsync<Employee>().GetAwaiter().GetResult();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var error = response.Content.ReadAsAsync<RestExceptionInfo>().GetAwaiter().GetResult();
|
||||||
|
throw new ArgumentException(error.Msg);
|
||||||
|
}
|
||||||
|
return item;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static List<Employee> WhoMaintainsService(int id)
|
||||||
|
{
|
||||||
|
var item = default(List<Employee>);
|
||||||
|
HttpResponseMessage response = client.GetAsync("/api/WhoMaintainsService?id=" + id.ToString()).GetAwaiter().GetResult();
|
||||||
|
if (response.IsSuccessStatusCode)
|
||||||
|
{
|
||||||
|
item = response.Content.ReadAsAsync<List<Employee>>().GetAwaiter().GetResult();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var error = response.Content.ReadAsAsync<RestExceptionInfo>().GetAwaiter().GetResult();
|
||||||
|
throw new ArgumentException(error.Msg);
|
||||||
|
}
|
||||||
|
return item;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class RestExceptionInfo
|
||||||
|
{
|
||||||
|
public RestExceptionInfo()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
public string Msg { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class EndpointNotAvailableException : Exception
|
||||||
|
{
|
||||||
|
public EndpointNotAvailableException() : base("The client could not reach the API endpoint.")
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public EndpointNotAvailableException(string message) : base(message)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public EndpointNotAvailableException(string message, Exception innerException) : base(message, innerException)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -7,11 +7,11 @@
|
|||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\..\WD7UVN_HFT_2023241.Models\WD7UVN_HFT_2023241.Models.csproj" />
|
<ProjectReference Include="..\..\WD7UVN_HFT_2023241.Models\WD7UVN_HFT_2023241.Models.csproj" />
|
||||||
<ProjectReference Include="..\Shared\WD7UVN_HFT_2023241.Client.Shared.csproj" />
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="ConsoleMenu-simple" Version="2.6.1" />
|
<PackageReference Include="ConsoleMenu-simple" Version="2.6.1" />
|
||||||
|
<PackageReference Include="Microsoft.AspNet.WebApi.Client" Version="5.2.7" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
@@ -21,9 +21,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Shared", "Shared", "{18D51E
|
|||||||
EndProject
|
EndProject
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WD7UVN_HFT_2023241.Client.TUI", "WD7UVN_HFT_2023241.Client\TUI\WD7UVN_HFT_2023241.Client.TUI.csproj", "{F68C5B1A-C3B9-4AFC-BBD3-9DCC02A22EA0}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WD7UVN_HFT_2023241.Client.TUI", "WD7UVN_HFT_2023241.Client\TUI\WD7UVN_HFT_2023241.Client.TUI.csproj", "{F68C5B1A-C3B9-4AFC-BBD3-9DCC02A22EA0}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WD7UVN_HFT_2023241.Client.Shared", "WD7UVN_HFT_2023241.Client\Shared\WD7UVN_HFT_2023241.Client.Shared.csproj", "{77C8BEDB-0D81-4703-8FBC-B4DCD32584BD}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WD7UVN_SzTGUI_2023242.Client.WPF", "WD7UVN_SzTGUI_2023242.Client.WPF\WD7UVN_SzTGUI_2023242.Client.WPF.csproj", "{0A994D03-066F-43E7-872E-4D239FC6F764}"
|
||||||
EndProject
|
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WD7UVN_SzTGUI_2023242.Client.WPF", "WD7UVN_SzTGUI_2023242.Client.WPF\WD7UVN_SzTGUI_2023242.Client.WPF.csproj", "{0A994D03-066F-43E7-872E-4D239FC6F764}"
|
|
||||||
EndProject
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
@@ -55,10 +53,6 @@ Global
|
|||||||
{F68C5B1A-C3B9-4AFC-BBD3-9DCC02A22EA0}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{F68C5B1A-C3B9-4AFC-BBD3-9DCC02A22EA0}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{F68C5B1A-C3B9-4AFC-BBD3-9DCC02A22EA0}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{F68C5B1A-C3B9-4AFC-BBD3-9DCC02A22EA0}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{F68C5B1A-C3B9-4AFC-BBD3-9DCC02A22EA0}.Release|Any CPU.Build.0 = Release|Any CPU
|
{F68C5B1A-C3B9-4AFC-BBD3-9DCC02A22EA0}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
{77C8BEDB-0D81-4703-8FBC-B4DCD32584BD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
|
||||||
{77C8BEDB-0D81-4703-8FBC-B4DCD32584BD}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
|
||||||
{77C8BEDB-0D81-4703-8FBC-B4DCD32584BD}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
|
||||||
{77C8BEDB-0D81-4703-8FBC-B4DCD32584BD}.Release|Any CPU.Build.0 = Release|Any CPU
|
|
||||||
{0A994D03-066F-43E7-872E-4D239FC6F764}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
{0A994D03-066F-43E7-872E-4D239FC6F764}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
{0A994D03-066F-43E7-872E-4D239FC6F764}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{0A994D03-066F-43E7-872E-4D239FC6F764}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{0A994D03-066F-43E7-872E-4D239FC6F764}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{0A994D03-066F-43E7-872E-4D239FC6F764}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
@@ -74,7 +68,6 @@ Global
|
|||||||
{316342CA-7521-4A01-8BDB-5AA76D4DE855} = {E7A96BA5-BFD6-4265-A90F-880015BEFE07}
|
{316342CA-7521-4A01-8BDB-5AA76D4DE855} = {E7A96BA5-BFD6-4265-A90F-880015BEFE07}
|
||||||
{63F3B585-3E8C-41F5-8D6C-FB59932D0819} = {E7A96BA5-BFD6-4265-A90F-880015BEFE07}
|
{63F3B585-3E8C-41F5-8D6C-FB59932D0819} = {E7A96BA5-BFD6-4265-A90F-880015BEFE07}
|
||||||
{F68C5B1A-C3B9-4AFC-BBD3-9DCC02A22EA0} = {8FABCF39-D228-4E36-927D-09B4CCF88935}
|
{F68C5B1A-C3B9-4AFC-BBD3-9DCC02A22EA0} = {8FABCF39-D228-4E36-927D-09B4CCF88935}
|
||||||
{77C8BEDB-0D81-4703-8FBC-B4DCD32584BD} = {8FABCF39-D228-4E36-927D-09B4CCF88935}
|
|
||||||
{0A994D03-066F-43E7-872E-4D239FC6F764} = {8FABCF39-D228-4E36-927D-09B4CCF88935}
|
{0A994D03-066F-43E7-872E-4D239FC6F764} = {8FABCF39-D228-4E36-927D-09B4CCF88935}
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||||
|
|||||||
@@ -5,8 +5,79 @@
|
|||||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
xmlns:local="clr-namespace:WD7UVN_SzTGUI_2023242.Client.WPF"
|
xmlns:local="clr-namespace:WD7UVN_SzTGUI_2023242.Client.WPF"
|
||||||
mc:Ignorable="d"
|
mc:Ignorable="d"
|
||||||
Title="MainWindow" Height="450" Width="800">
|
Title="Company database manager" Height="450" Width="900">
|
||||||
<Grid>
|
<Grid>
|
||||||
|
<Grid.ColumnDefinitions>
|
||||||
|
<ColumnDefinition Width="*" />
|
||||||
|
<ColumnDefinition Width="*" />
|
||||||
|
<ColumnDefinition Width="*" />
|
||||||
|
<ColumnDefinition Width="*" />
|
||||||
|
</Grid.ColumnDefinitions>
|
||||||
|
|
||||||
|
<Grid Grid.Column="0">
|
||||||
|
<Grid.RowDefinitions>
|
||||||
|
<RowDefinition Height="9*" />
|
||||||
|
<RowDefinition Height="1*" />
|
||||||
|
</Grid.RowDefinitions>
|
||||||
|
|
||||||
|
<ListBox Grid.Row="0">
|
||||||
|
<ListBox.ItemTemplate>
|
||||||
|
<DataTemplate>
|
||||||
|
<Button Content="{Binding NAME}" Margin="5px"/>
|
||||||
|
</DataTemplate>
|
||||||
|
</ListBox.ItemTemplate>
|
||||||
|
</ListBox>
|
||||||
|
<Button Grid.Row="1" Margin="5" Content="Expand all" Click="ExpandAllServices"/>
|
||||||
|
</Grid>
|
||||||
|
|
||||||
|
<Grid Grid.Column="1">
|
||||||
|
<Grid.RowDefinitions>
|
||||||
|
<RowDefinition Height="9*" />
|
||||||
|
<RowDefinition Height="1*" />
|
||||||
|
</Grid.RowDefinitions>
|
||||||
|
|
||||||
|
<ListBox Grid.Row="0">
|
||||||
|
<ListBox.ItemTemplate>
|
||||||
|
<DataTemplate>
|
||||||
|
<Button Content="{Binding NAME}" Margin="5px"/>
|
||||||
|
</DataTemplate>
|
||||||
|
</ListBox.ItemTemplate>
|
||||||
|
</ListBox>
|
||||||
|
<Button Grid.Row="1" Margin="5" Content="Expand all" Click="ExpandAllCustomers" />
|
||||||
|
</Grid>
|
||||||
|
|
||||||
|
<Grid Grid.Column="2">
|
||||||
|
<Grid.RowDefinitions>
|
||||||
|
<RowDefinition Height="9*" />
|
||||||
|
<RowDefinition Height="1*" />
|
||||||
|
</Grid.RowDefinitions>
|
||||||
|
|
||||||
|
<ListBox Grid.Row="0">
|
||||||
|
<ListBox.ItemTemplate>
|
||||||
|
<DataTemplate>
|
||||||
|
<Button Content="{Binding NAME}" Margin="5px"/>
|
||||||
|
</DataTemplate>
|
||||||
|
</ListBox.ItemTemplate>
|
||||||
|
</ListBox>
|
||||||
|
<Button Grid.Row="1" Margin="5" Content="Expand all" Click="ExpandAllClients" />
|
||||||
|
</Grid>
|
||||||
|
|
||||||
|
<Grid Grid.Column="3">
|
||||||
|
<Grid.RowDefinitions>
|
||||||
|
<RowDefinition Height="9*" />
|
||||||
|
<RowDefinition Height="1*" />
|
||||||
|
</Grid.RowDefinitions>
|
||||||
|
|
||||||
|
<ListBox Grid.Row="0">
|
||||||
|
<ListBox.ItemTemplate>
|
||||||
|
<DataTemplate>
|
||||||
|
<Button Content="{Binding NAME}" Margin="5px"/>
|
||||||
|
</DataTemplate>
|
||||||
|
</ListBox.ItemTemplate>
|
||||||
|
</ListBox>
|
||||||
|
<Button Grid.Row="1" Margin="5" Content="Expand all" Click="ExpandAllTeams" />
|
||||||
|
</Grid>
|
||||||
|
|
||||||
|
|
||||||
</Grid>
|
</Grid>
|
||||||
</Window>
|
</Window>
|
||||||
|
|||||||
@@ -1,17 +1,4 @@
|
|||||||
using System;
|
using System.Windows;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using System.Windows;
|
|
||||||
using System.Windows.Controls;
|
|
||||||
using System.Windows.Data;
|
|
||||||
using System.Windows.Documents;
|
|
||||||
using System.Windows.Input;
|
|
||||||
using System.Windows.Media;
|
|
||||||
using System.Windows.Media.Imaging;
|
|
||||||
using System.Windows.Navigation;
|
|
||||||
using System.Windows.Shapes;
|
|
||||||
|
|
||||||
namespace WD7UVN_SzTGUI_2023242.Client.WPF
|
namespace WD7UVN_SzTGUI_2023242.Client.WPF
|
||||||
{
|
{
|
||||||
@@ -24,5 +11,25 @@ namespace WD7UVN_SzTGUI_2023242.Client.WPF
|
|||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void ExpandAllServices(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ExpandAllCustomers(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ExpandAllClients(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ExpandAllTeams(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
423
WD7UVN_SzTGUI_2023242.Client.WPF/RestCollection.cs
Normal file
423
WD7UVN_SzTGUI_2023242.Client.WPF/RestCollection.cs
Normal file
@@ -0,0 +1,423 @@
|
|||||||
|
using Microsoft.AspNetCore.SignalR.Client;
|
||||||
|
using System;
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Collections.Specialized;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Net;
|
||||||
|
using System.Net.Http;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Windows;
|
||||||
|
|
||||||
|
namespace WD7UVN_SzTGUI_2023242.Client.WPF
|
||||||
|
{
|
||||||
|
public class RestService
|
||||||
|
{
|
||||||
|
HttpClient client;
|
||||||
|
|
||||||
|
public RestService(string baseurl, string pingableEndpoint = "swagger")
|
||||||
|
{
|
||||||
|
bool isOk = false;
|
||||||
|
do
|
||||||
|
{
|
||||||
|
isOk = Ping(baseurl + pingableEndpoint);
|
||||||
|
} while (isOk == false);
|
||||||
|
Init(baseurl);
|
||||||
|
}
|
||||||
|
|
||||||
|
private bool Ping(string url)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
WebClient wc = new WebClient();
|
||||||
|
wc.DownloadData(url);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Init(string baseurl)
|
||||||
|
{
|
||||||
|
client = new HttpClient();
|
||||||
|
client.BaseAddress = new Uri(baseurl);
|
||||||
|
client.DefaultRequestHeaders.Accept.Clear();
|
||||||
|
client.DefaultRequestHeaders.Accept.Add(
|
||||||
|
new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue
|
||||||
|
("application/json"));
|
||||||
|
try
|
||||||
|
{
|
||||||
|
client.GetAsync("").GetAwaiter().GetResult();
|
||||||
|
}
|
||||||
|
catch (HttpRequestException)
|
||||||
|
{
|
||||||
|
throw new ArgumentException("Endpoint is not available!");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<List<T>> GetAsync<T>(string endpoint)
|
||||||
|
{
|
||||||
|
List<T> items = new List<T>();
|
||||||
|
HttpResponseMessage response = await client.GetAsync(endpoint);
|
||||||
|
if (response.IsSuccessStatusCode)
|
||||||
|
{
|
||||||
|
items = await response.Content.ReadAsAsync<List<T>>();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var error = await response.Content.ReadAsAsync<RestExceptionInfo>();
|
||||||
|
throw new ArgumentException(error.Msg);
|
||||||
|
}
|
||||||
|
return items;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<T> Get<T>(string endpoint)
|
||||||
|
{
|
||||||
|
List<T> items = new List<T>();
|
||||||
|
HttpResponseMessage response = client.GetAsync(endpoint).GetAwaiter().GetResult();
|
||||||
|
if (response.IsSuccessStatusCode)
|
||||||
|
{
|
||||||
|
items = response.Content.ReadAsAsync<List<T>>().GetAwaiter().GetResult();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var error = response.Content.ReadAsAsync<RestExceptionInfo>().GetAwaiter().GetResult();
|
||||||
|
throw new ArgumentException(error.Msg);
|
||||||
|
}
|
||||||
|
return items;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<T> GetSingleAsync<T>(string endpoint)
|
||||||
|
{
|
||||||
|
T item = default(T);
|
||||||
|
HttpResponseMessage response = await client.GetAsync(endpoint);
|
||||||
|
if (response.IsSuccessStatusCode)
|
||||||
|
{
|
||||||
|
item = await response.Content.ReadAsAsync<T>();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var error = await response.Content.ReadAsAsync<RestExceptionInfo>();
|
||||||
|
throw new ArgumentException(error.Msg);
|
||||||
|
}
|
||||||
|
return item;
|
||||||
|
}
|
||||||
|
|
||||||
|
public T GetSingle<T>(string endpoint)
|
||||||
|
{
|
||||||
|
T item = default(T);
|
||||||
|
HttpResponseMessage response = client.GetAsync(endpoint).GetAwaiter().GetResult();
|
||||||
|
if (response.IsSuccessStatusCode)
|
||||||
|
{
|
||||||
|
item = response.Content.ReadAsAsync<T>().GetAwaiter().GetResult();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var error = response.Content.ReadAsAsync<RestExceptionInfo>().GetAwaiter().GetResult();
|
||||||
|
throw new ArgumentException(error.Msg);
|
||||||
|
}
|
||||||
|
return item;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<T> GetAsync<T>(int id, string endpoint)
|
||||||
|
{
|
||||||
|
T item = default(T);
|
||||||
|
HttpResponseMessage response = await client.GetAsync(endpoint + "/" + id.ToString());
|
||||||
|
if (response.IsSuccessStatusCode)
|
||||||
|
{
|
||||||
|
item = await response.Content.ReadAsAsync<T>();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var error = await response.Content.ReadAsAsync<RestExceptionInfo>();
|
||||||
|
throw new ArgumentException(error.Msg);
|
||||||
|
}
|
||||||
|
return item;
|
||||||
|
}
|
||||||
|
|
||||||
|
public T Get<T>(int id, string endpoint)
|
||||||
|
{
|
||||||
|
T item = default(T);
|
||||||
|
HttpResponseMessage response = client.GetAsync(endpoint + "/" + id.ToString()).GetAwaiter().GetResult();
|
||||||
|
if (response.IsSuccessStatusCode)
|
||||||
|
{
|
||||||
|
item = response.Content.ReadAsAsync<T>().GetAwaiter().GetResult();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var error = response.Content.ReadAsAsync<RestExceptionInfo>().GetAwaiter().GetResult();
|
||||||
|
throw new ArgumentException(error.Msg);
|
||||||
|
}
|
||||||
|
return item;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task PostAsync<T>(T item, string endpoint)
|
||||||
|
{
|
||||||
|
HttpResponseMessage response =
|
||||||
|
await client.PostAsJsonAsync(endpoint, item);
|
||||||
|
|
||||||
|
if (!response.IsSuccessStatusCode)
|
||||||
|
{
|
||||||
|
var error = await response.Content.ReadAsAsync<RestExceptionInfo>();
|
||||||
|
throw new ArgumentException(error.Msg);
|
||||||
|
}
|
||||||
|
response.EnsureSuccessStatusCode();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Post<T>(T item, string endpoint)
|
||||||
|
{
|
||||||
|
HttpResponseMessage response =
|
||||||
|
client.PostAsJsonAsync(endpoint, item).GetAwaiter().GetResult();
|
||||||
|
|
||||||
|
if (!response.IsSuccessStatusCode)
|
||||||
|
{
|
||||||
|
var error = response.Content.ReadAsAsync<RestExceptionInfo>().GetAwaiter().GetResult();
|
||||||
|
throw new ArgumentException(error.Msg);
|
||||||
|
}
|
||||||
|
response.EnsureSuccessStatusCode();
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task DeleteAsync(int id, string endpoint)
|
||||||
|
{
|
||||||
|
HttpResponseMessage response =
|
||||||
|
await client.DeleteAsync(endpoint + "/" + id.ToString());
|
||||||
|
|
||||||
|
if (!response.IsSuccessStatusCode)
|
||||||
|
{
|
||||||
|
var error = await response.Content.ReadAsAsync<RestExceptionInfo>();
|
||||||
|
throw new ArgumentException(error.Msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
response.EnsureSuccessStatusCode();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Delete(int id, string endpoint)
|
||||||
|
{
|
||||||
|
HttpResponseMessage response =
|
||||||
|
client.DeleteAsync(endpoint + "/" + id.ToString()).GetAwaiter().GetResult();
|
||||||
|
|
||||||
|
if (!response.IsSuccessStatusCode)
|
||||||
|
{
|
||||||
|
var error = response.Content.ReadAsAsync<RestExceptionInfo>().GetAwaiter().GetResult();
|
||||||
|
throw new ArgumentException(error.Msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
response.EnsureSuccessStatusCode();
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task PutAsync<T>(T item, string endpoint)
|
||||||
|
{
|
||||||
|
HttpResponseMessage response =
|
||||||
|
await client.PutAsJsonAsync(endpoint, item);
|
||||||
|
|
||||||
|
if (!response.IsSuccessStatusCode)
|
||||||
|
{
|
||||||
|
var error = await response.Content.ReadAsAsync<RestExceptionInfo>();
|
||||||
|
throw new ArgumentException(error.Msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
response.EnsureSuccessStatusCode();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Put<T>(T item, string endpoint)
|
||||||
|
{
|
||||||
|
HttpResponseMessage response =
|
||||||
|
client.PutAsJsonAsync(endpoint, item).GetAwaiter().GetResult();
|
||||||
|
|
||||||
|
if (!response.IsSuccessStatusCode)
|
||||||
|
{
|
||||||
|
var error = response.Content.ReadAsAsync<RestExceptionInfo>().GetAwaiter().GetResult();
|
||||||
|
throw new ArgumentException(error.Msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
response.EnsureSuccessStatusCode();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
public class RestExceptionInfo
|
||||||
|
{
|
||||||
|
public RestExceptionInfo()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
public string Msg { get; set; }
|
||||||
|
}
|
||||||
|
class NotifyService
|
||||||
|
{
|
||||||
|
private HubConnection conn;
|
||||||
|
|
||||||
|
public NotifyService(string url)
|
||||||
|
{
|
||||||
|
conn = new HubConnectionBuilder()
|
||||||
|
.WithUrl(url)
|
||||||
|
.Build();
|
||||||
|
|
||||||
|
conn.Closed += async (error) =>
|
||||||
|
{
|
||||||
|
await Task.Delay(new Random().Next(0, 5) * 1000);
|
||||||
|
await conn.StartAsync();
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public void AddHandler<T>(string methodname, Action<T> value)
|
||||||
|
{
|
||||||
|
conn.On<T>(methodname, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async void Init()
|
||||||
|
{
|
||||||
|
await conn.StartAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public class RestCollection<T> : INotifyCollectionChanged, IEnumerable<T>
|
||||||
|
{
|
||||||
|
public event NotifyCollectionChangedEventHandler? CollectionChanged;
|
||||||
|
|
||||||
|
NotifyService notify;
|
||||||
|
RestService rest;
|
||||||
|
List<T> items;
|
||||||
|
bool hasSignalR;
|
||||||
|
Type type = typeof(T);
|
||||||
|
|
||||||
|
public RestCollection(string baseurl, string endpoint, string hub = null)
|
||||||
|
{
|
||||||
|
hasSignalR = hub != null;
|
||||||
|
this.rest = new RestService(baseurl, endpoint);
|
||||||
|
if (hub != null)
|
||||||
|
{
|
||||||
|
this.notify = new NotifyService(baseurl + hub);
|
||||||
|
this.notify.AddHandler<T>(type.Name + "Created", (T item) =>
|
||||||
|
{
|
||||||
|
items.Add(item);
|
||||||
|
CollectionChanged?.Invoke(this, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset));
|
||||||
|
});
|
||||||
|
this.notify.AddHandler<T>(type.Name + "Deleted", (T item) =>
|
||||||
|
{
|
||||||
|
var element = items.FirstOrDefault(t => t.Equals(item));
|
||||||
|
if (element != null)
|
||||||
|
{
|
||||||
|
items.Remove(item);
|
||||||
|
CollectionChanged?.Invoke(this, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Init();
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
this.notify.AddHandler<T>(type.Name + "Updated", (T item) =>
|
||||||
|
{
|
||||||
|
Init();
|
||||||
|
});
|
||||||
|
|
||||||
|
this.notify.Init();
|
||||||
|
}
|
||||||
|
Init();
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task Init()
|
||||||
|
{
|
||||||
|
items = await rest.GetAsync<T>(typeof(T).Name);
|
||||||
|
CollectionChanged?.Invoke(this, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset));
|
||||||
|
}
|
||||||
|
|
||||||
|
public IEnumerator<T> GetEnumerator()
|
||||||
|
{
|
||||||
|
if (items != null)
|
||||||
|
{
|
||||||
|
return items.GetEnumerator();
|
||||||
|
}
|
||||||
|
else return new List<T>().GetEnumerator();
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<T> GetItems()
|
||||||
|
{
|
||||||
|
if (items != null)
|
||||||
|
{
|
||||||
|
return items;
|
||||||
|
}
|
||||||
|
else return new List<T>();
|
||||||
|
}
|
||||||
|
|
||||||
|
IEnumerator IEnumerable.GetEnumerator()
|
||||||
|
{
|
||||||
|
if (items != null)
|
||||||
|
{
|
||||||
|
return items.GetEnumerator();
|
||||||
|
}
|
||||||
|
else return new List<T>().GetEnumerator();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Add(T item)
|
||||||
|
{
|
||||||
|
if (hasSignalR)
|
||||||
|
{
|
||||||
|
this.rest.PostAsync(item, typeof(T).Name);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
this.rest.PostAsync(item, typeof(T).Name).ContinueWith((t) =>
|
||||||
|
{
|
||||||
|
Init().ContinueWith(z =>
|
||||||
|
{
|
||||||
|
Application.Current.Dispatcher.Invoke(() =>
|
||||||
|
{
|
||||||
|
CollectionChanged?.Invoke(this, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset));
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Update(T item)
|
||||||
|
{
|
||||||
|
if (hasSignalR)
|
||||||
|
{
|
||||||
|
this.rest.PutAsync(item, typeof(T).Name);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
this.rest.PutAsync(item, typeof(T).Name).ContinueWith((t) =>
|
||||||
|
{
|
||||||
|
Init().ContinueWith(z =>
|
||||||
|
{
|
||||||
|
Application.Current.Dispatcher.Invoke(() =>
|
||||||
|
{
|
||||||
|
CollectionChanged?.Invoke(this, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset));
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Delete(int id)
|
||||||
|
{
|
||||||
|
if (hasSignalR)
|
||||||
|
{
|
||||||
|
this.rest.DeleteAsync(id, typeof(T).Name);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
this.rest.DeleteAsync(id, typeof(T).Name).ContinueWith((t) =>
|
||||||
|
{
|
||||||
|
Init().ContinueWith(z =>
|
||||||
|
{
|
||||||
|
Application.Current.Dispatcher.Invoke(() =>
|
||||||
|
{
|
||||||
|
CollectionChanged?.Invoke(this, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset));
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,62 @@
|
|||||||
|
using CommunityToolkit.Mvvm.ComponentModel;
|
||||||
|
using CommunityToolkit.Mvvm.Input;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Windows;
|
||||||
|
using System.Windows.Input;
|
||||||
|
using WD7UVN_HFT_2023241.Models;
|
||||||
|
|
||||||
|
namespace WD7UVN_SzTGUI_2023242.Client.WPF
|
||||||
|
{
|
||||||
|
internal class ServiceViewModel : ObservableRecipient
|
||||||
|
{
|
||||||
|
private string errorService;
|
||||||
|
|
||||||
|
public string ErrorService
|
||||||
|
{
|
||||||
|
get { return errorService; }
|
||||||
|
set { SetProperty(ref errorService, value); }
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public RestCollection<Service> Services { get; set; }
|
||||||
|
|
||||||
|
private string newServiceText;
|
||||||
|
|
||||||
|
public string NewServiceText
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return newServiceText;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
newServiceText = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public ICommand SendServiceCommand { get; set; }
|
||||||
|
|
||||||
|
|
||||||
|
public static bool IsInDesignMode
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
var prop = DesignerProperties.IsInDesignModeProperty;
|
||||||
|
return (bool)DependencyPropertyDescriptor.FromProperty(prop, typeof(FrameworkElement)).Metadata.DefaultValue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public ServiceViewModel()
|
||||||
|
{
|
||||||
|
if (!IsInDesignMode)
|
||||||
|
{
|
||||||
|
Services = new RestCollection<Service>("http://localhost:62005/", "Service", "hub");
|
||||||
|
SendServiceCommand = new RelayCommand(() =>
|
||||||
|
{
|
||||||
|
Services.Add(new Service(1, NewServiceText, DateTime.Now, new User(1, "Én")));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -7,4 +7,14 @@
|
|||||||
<UseWPF>true</UseWPF>
|
<UseWPF>true</UseWPF>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="CommunityToolkit.Mvvm" Version="7.1.2" />
|
||||||
|
<PackageReference Include="Microsoft.AspNetCore.SignalR.Client" Version="6.0.2" />
|
||||||
|
<PackageReference Include="Microsoft.AspNet.WebApi.Client" Version="5.2.7" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\WD7UVN_HFT_2023241.Models\WD7UVN_HFT_2023241.Models.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
@@ -7,6 +7,14 @@
|
|||||||
</ApplicationDefinition>
|
</ApplicationDefinition>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<Compile Update="Windows\GetAllServices.xaml.cs">
|
||||||
|
<SubType>Code</SubType>
|
||||||
|
</Compile>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Page Update="Windows\GetAllServices.xaml">
|
||||||
|
<SubType>Designer</SubType>
|
||||||
|
</Page>
|
||||||
<Page Update="MainWindow.xaml">
|
<Page Update="MainWindow.xaml">
|
||||||
<SubType>Designer</SubType>
|
<SubType>Designer</SubType>
|
||||||
</Page>
|
</Page>
|
||||||
|
|||||||
64
WD7UVN_SzTGUI_2023242.Client.WPF/Windows/GetAllServices.xaml
Normal file
64
WD7UVN_SzTGUI_2023242.Client.WPF/Windows/GetAllServices.xaml
Normal file
@@ -0,0 +1,64 @@
|
|||||||
|
<Window x:Class="WD7UVN_SzTGUI_2023242.Client.WPF.GetAllServices"
|
||||||
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
|
xmlns:local="clr-namespace:WD7UVN_SzTGUI_2023242.Client.WPF"
|
||||||
|
mc:Ignorable="d"
|
||||||
|
Title="GetAllServices" Height="550" Width="350">
|
||||||
|
|
||||||
|
<Grid>
|
||||||
|
<ListBox>
|
||||||
|
<ListBox.ItemTemplate>
|
||||||
|
<DataTemplate>
|
||||||
|
<Border BorderBrush="Gray" BorderThickness="1">
|
||||||
|
<Grid>
|
||||||
|
<Grid.ColumnDefinitions>
|
||||||
|
<ColumnDefinition Width="2*" />
|
||||||
|
<ColumnDefinition Width="8*" />
|
||||||
|
</Grid.ColumnDefinitions>
|
||||||
|
<Grid.RowDefinitions>
|
||||||
|
<RowDefinition Height="*" />
|
||||||
|
<RowDefinition Height="*" />
|
||||||
|
<RowDefinition Height="*" />
|
||||||
|
<RowDefinition Height="*" />
|
||||||
|
<RowDefinition Height="*" />
|
||||||
|
<RowDefinition Height="*" />
|
||||||
|
<RowDefinition Height="*" />
|
||||||
|
<RowDefinition Height="*" />
|
||||||
|
</Grid.RowDefinitions>
|
||||||
|
|
||||||
|
<Label Grid.Row="0" Grid.Column="0" Content="ID:" />
|
||||||
|
<Label Grid.Row="0" Grid.Column="1" Content="{Binding ID}" />
|
||||||
|
|
||||||
|
<Label Grid.Row="1" Grid.Column="0" Content="Name:" />
|
||||||
|
<Label Grid.Row="1" Grid.Column="1" Content="{Binding NAME}" />
|
||||||
|
|
||||||
|
<Label Grid.Row="2" Grid.Column="0" Content="Version:" />
|
||||||
|
<Label Grid.Row="2" Grid.Column="1" Content="{Binding VERSION}" />
|
||||||
|
|
||||||
|
<Label Grid.Row="3" Grid.Column="0" Content="Account:" />
|
||||||
|
<Label Grid.Row="3" Grid.Column="1" Content="{Binding ACCOUNT}" />
|
||||||
|
|
||||||
|
<Label Grid.Row="4" Grid.Column="0" Content="Domain:" />
|
||||||
|
<Label Grid.Row="4" Grid.Column="1" Content="{Binding SERVICE_DOMAIN}" />
|
||||||
|
|
||||||
|
<Label Grid.Row="5" Grid.Column="0" Content="IP address:" />
|
||||||
|
<Label Grid.Row="5" Grid.Column="1" Content="{Binding IP}" />
|
||||||
|
|
||||||
|
<Label Grid.Row="6" Grid.Column="0" Content="Port:" />
|
||||||
|
<Label Grid.Row="6" Grid.Column="1" Content="{Binding PORT}" />
|
||||||
|
|
||||||
|
<Label Grid.Row="7" Grid.Column="0" Content="Notes:" />
|
||||||
|
<Label Grid.Row="7" Grid.Column="1" Content="{Binding NOTES}" />
|
||||||
|
|
||||||
|
<Label Grid.Row="8" Grid.Column="0" Content="Maintainer Team ID:" />
|
||||||
|
<Label Grid.Row="8" Grid.Column="1" Content="{Binding MAINTAINER_ID}" />
|
||||||
|
|
||||||
|
</Grid>
|
||||||
|
</Border>
|
||||||
|
</DataTemplate>
|
||||||
|
</ListBox.ItemTemplate>
|
||||||
|
</ListBox>
|
||||||
|
</Grid>
|
||||||
|
</Window>
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Windows;
|
||||||
|
using System.Windows.Controls;
|
||||||
|
using System.Windows.Data;
|
||||||
|
using System.Windows.Documents;
|
||||||
|
using System.Windows.Input;
|
||||||
|
using System.Windows.Media;
|
||||||
|
using System.Windows.Media.Imaging;
|
||||||
|
using System.Windows.Shapes;
|
||||||
|
|
||||||
|
namespace WD7UVN_SzTGUI_2023242.Client.WPF
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Interaction logic for GetAllServices.xaml
|
||||||
|
/// </summary>
|
||||||
|
public partial class GetAllServices : Window
|
||||||
|
{
|
||||||
|
public GetAllServices()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user