Compare commits

...

4 Commits

Author SHA1 Message Date
Developer 02
4939396f71 Konfigurierte .csproj-Dateien für die Paketierung von WindreamHub.Client und WindreamHub.Abstractions als NuGet-Pakete. 2024-06-28 03:15:48 +02:00
Developer 02
ce3a9f90db Initialer Commit: Projekteinrichtung und erste Implementierung
- Erstellte Lösungsstruktur und Projektdateien
- Hinzugefügte grundlegende Abstraktionen und Client-Services
- Implementierte anfängliche Antwortverarbeitungsklassen
- Einrichtung von Dependency Injection und Konfigurationsoptionen
2024-06-28 02:42:38 +02:00
Developer 02
5cd343216a Gitignore aktualisieren 2024-06-28 02:42:23 +02:00
Developer 02
7c0f8b56e8 Neue Lösung und Klassenbibliotheksprojekt erstellt und das Projekt zur Lösung hinzugefügt. 2024-06-27 13:51:30 +02:00
13 changed files with 235 additions and 0 deletions

2
.gitignore vendored
View File

@ -412,3 +412,5 @@ FodyWeavers.xsd
# Built Visual Studio Code Extensions
*.vsix
/src/WindreamHub.ConsoleApp/WindreamHub.ConsoleApp.csproj
/src/WindreamHub.ConsoleApp

44
WindreamHub.sln Normal file
View File

@ -0,0 +1,44 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.0.31903.59
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{7BFFBEF2-6639-41F6-B6C2-D231FF719F57}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WindreamHub.Abstractions", "src\WindreamHub.Abstractions\WindreamHub.Abstractions.csproj", "{4C12B988-FEB8-4141-8CD2-1EA4AC3E9270}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WindreamHub.Client", "src\WindreamHub.Client\WindreamHub.Client.csproj", "{D499FEC3-FDDD-45F0-BEA2-025B533BCD21}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WindreamHub.ConsoleApp", "src\WindreamHub.ConsoleApp\WindreamHub.ConsoleApp.csproj", "{6EABACDA-161C-4F1F-97DD-349EDC6B0ECE}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{4C12B988-FEB8-4141-8CD2-1EA4AC3E9270}.Debug|Any CPU.ActiveCfg = Release|Any CPU
{4C12B988-FEB8-4141-8CD2-1EA4AC3E9270}.Debug|Any CPU.Build.0 = Release|Any CPU
{4C12B988-FEB8-4141-8CD2-1EA4AC3E9270}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4C12B988-FEB8-4141-8CD2-1EA4AC3E9270}.Release|Any CPU.Build.0 = Release|Any CPU
{D499FEC3-FDDD-45F0-BEA2-025B533BCD21}.Debug|Any CPU.ActiveCfg = Release|Any CPU
{D499FEC3-FDDD-45F0-BEA2-025B533BCD21}.Debug|Any CPU.Build.0 = Release|Any CPU
{D499FEC3-FDDD-45F0-BEA2-025B533BCD21}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D499FEC3-FDDD-45F0-BEA2-025B533BCD21}.Release|Any CPU.Build.0 = Release|Any CPU
{6EABACDA-161C-4F1F-97DD-349EDC6B0ECE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{6EABACDA-161C-4F1F-97DD-349EDC6B0ECE}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6EABACDA-161C-4F1F-97DD-349EDC6B0ECE}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6EABACDA-161C-4F1F-97DD-349EDC6B0ECE}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{4C12B988-FEB8-4141-8CD2-1EA4AC3E9270} = {7BFFBEF2-6639-41F6-B6C2-D231FF719F57}
{D499FEC3-FDDD-45F0-BEA2-025B533BCD21} = {7BFFBEF2-6639-41F6-B6C2-D231FF719F57}
{6EABACDA-161C-4F1F-97DD-349EDC6B0ECE} = {7BFFBEF2-6639-41F6-B6C2-D231FF719F57}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {C2C9327F-0E3C-40B5-B878-DA59F03CF150}
EndGlobalSection
EndGlobal

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.5 KiB

View File

@ -0,0 +1,14 @@
namespace WindreamHub.Abstractions.Client
{
public record BaseEndpoint(string Route);
public record SystemDetails(string Route) : BaseEndpoint(Route)
{
public required Func<Task<SimplifiedResponse<dynamic, dynamic>>> GetAsync { get; init; }
}
public record Subscriptions(string Route) : BaseEndpoint(Route)
{
public required Func<Task<SimplifiedResponse<dynamic, dynamic>>> GetEventsAsync { get; init; }
}
}

View File

@ -0,0 +1,12 @@
using DigitalData.Core.Abstractions.Client;
using System.ComponentModel.Design;
namespace WindreamHub.Abstractions.Client
{
public interface IWindreamClientService : IBaseHttpClientService
{
public Subscriptions Subscriptions { get; }
public SystemDetails SystemDetails { get; }
}
}

View File

@ -0,0 +1,6 @@
using System.Net;
namespace WindreamHub.Abstractions.Client
{
public record SimplifiedResponse<TData, TError>(bool Ok, HttpStatusCode Status, TData Data, TError Error);
}

View File

@ -0,0 +1,32 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<PackageId>WindreamHub.Abstractions</PackageId>
<Version>1.0.0</Version>
<Authors>Digital Data GmbH</Authors>
<Company>Digital Data GmbH</Company>
<Product>WindreamHub.Abstractions</Product>
<Description>This package contains interfaces for the WindreamHub solution. It provides abstractions for making HTTP requests and includes interfaces for proxy server interactions, promoting modularity and ease of integration within the Windream ecosystem.</Description>
<Copyright>Copyright 2024</Copyright>
<PackageProjectUrl></PackageProjectUrl>
<PackageIcon>Assets\icon.png</PackageIcon>
<RepositoryUrl>http://git.dd:3000/tekh/WindreamHub.git</RepositoryUrl>
<PackageTags>digital data core abstractions http proxy windream</PackageTags>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="DigitalData.Core.Abstractions" Version="1.0.1.1" />
</ItemGroup>
<ItemGroup>
<None Update="Assets\icon.png">
<Pack>True</Pack>
<PackagePath>\</PackagePath>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
</Project>

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.5 KiB

View File

@ -0,0 +1,24 @@
using DigitalData.Core.Client;
using Microsoft.Extensions.DependencyInjection;
using WindreamHub.Abstractions.Client;
namespace WindreamHub.Client
{
public static class DIExtensions
{
public static IServiceCollection AddWindreamClientService(this IServiceCollection services, string uri, bool useAbstract = true)
{
services.AddHttpClientService<WindreamClientOptions>(opt =>
{
opt.Uri = uri;
});
if (useAbstract)
services.AddSingleton<IWindreamClientService, WindreamClientService>();
else
services.AddSingleton<WindreamClientService>();
return services;
}
}
}

View File

@ -0,0 +1,24 @@
using DigitalData.Core.Client;
using WindreamHub.Abstractions.Client;
namespace WindreamHub.Client
{
public static class ResponseExtensions
{
public static async Task<SimplifiedResponse<dynamic, dynamic>> SimplifyDynamic(this HttpResponseMessage message)
{
dynamic data = message.IsSuccessStatusCode ? await message.Json() : new { };
dynamic err = message.IsSuccessStatusCode ? await message.Json() : new { };
return new (Ok: message.IsSuccessStatusCode,Status: message.StatusCode, Data: data, Error: err);
}
public static async Task<SimplifiedResponse<IEnumerable<dynamic>, dynamic>> SimplifyDynamicList(this HttpResponseMessage message)
{
dynamic data = message.IsSuccessStatusCode ? await message.JsonList() : new { };
dynamic err = message.IsSuccessStatusCode ? await message.Json() : new { };
return new(Ok: message.IsSuccessStatusCode, Status: message.StatusCode, Data: data, Error: err);
}
}
}

View File

@ -0,0 +1,8 @@
using DigitalData.Core.Client;
namespace WindreamHub.Client
{
public class WindreamClientOptions : HttpClientOptions
{
}
}

View File

@ -0,0 +1,33 @@
using DigitalData.Core.Abstractions.Client;
using DigitalData.Core.Client;
using Microsoft.Extensions.Options;
using System.Net;
using WindreamHub.Abstractions.Client;
namespace WindreamHub.Client
{
public class WindreamClientService :
HttpClientService<WindreamClientOptions>,
IWindreamClientService,
IHttpClientService<WindreamClientOptions>
{
public WindreamClientService(HttpClient client, CookieContainer cookieContainer, IOptions<WindreamClientOptions> clientOptions) : base(client, cookieContainer, clientOptions)
{
Subscriptions = new(Route: "subscriptions")
{
GetEventsAsync = async () => await FetchAsync($"/{Subscriptions!.Route}/GetSubscriptionEvents")
.ThenAsync(res => res.SimplifyDynamic())
};
SystemDetails = new(Route: "systemDetails")
{
GetAsync = async () => await FetchAsync($"/{SystemDetails!.Route}/GetSystemDetails")
.ThenAsync(res => res.SimplifyDynamic())
};
}
public Subscriptions Subscriptions { get; }
public SystemDetails SystemDetails { get; }
}
}

View File

@ -0,0 +1,36 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<PackageId>WindreamHub.Client</PackageId>
<Version>1.0.0</Version>
<Authors>Digital Data GmbH</Authors>
<Company>Digital Data GmbH</Company>
<Product>Digital Data GmbH</Product>
<Description>This package provides the client library for the Windream. It includes functionality for making HTTP requests to the Windream Webservice API, facilitating integration and communication with Windream document management systems.</Description>
<Copyright>Copyright 2024</Copyright>
<PackageIcon>Assets\icon.png</PackageIcon>
<RepositoryUrl>http://git.dd:3000/tekh/WindreamHub.git</RepositoryUrl>
<PackageTags>digital data core http windream</PackageTags>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="DigitalData.Core.Abstractions" Version="1.0.1.1" />
<PackageReference Include="DigitalData.Core.Client" Version="1.0.1.1" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\WindreamHub.Abstractions\WindreamHub.Abstractions.csproj" />
</ItemGroup>
<ItemGroup>
<None Update="Assets\icon.png">
<PackagePath>\</PackagePath>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<Pack>True</Pack>
</None>
</ItemGroup>
</Project>