Compare commits
4 Commits
01c2872d5a
...
4939396f71
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4939396f71 | ||
|
|
ce3a9f90db | ||
|
|
5cd343216a | ||
|
|
7c0f8b56e8 |
2
.gitignore
vendored
2
.gitignore
vendored
@ -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
44
WindreamHub.sln
Normal 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
|
||||
BIN
src/WindreamHub.Abstractions/Assets/icon.png
Normal file
BIN
src/WindreamHub.Abstractions/Assets/icon.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 4.5 KiB |
14
src/WindreamHub.Abstractions/Client/Endpoint.cs
Normal file
14
src/WindreamHub.Abstractions/Client/Endpoint.cs
Normal 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; }
|
||||
}
|
||||
}
|
||||
@ -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; }
|
||||
}
|
||||
}
|
||||
6
src/WindreamHub.Abstractions/Client/Response.cs
Normal file
6
src/WindreamHub.Abstractions/Client/Response.cs
Normal 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);
|
||||
}
|
||||
32
src/WindreamHub.Abstractions/WindreamHub.Abstractions.csproj
Normal file
32
src/WindreamHub.Abstractions/WindreamHub.Abstractions.csproj
Normal 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>
|
||||
BIN
src/WindreamHub.Client/Assets/icon.png
Normal file
BIN
src/WindreamHub.Client/Assets/icon.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 4.5 KiB |
24
src/WindreamHub.Client/DIExtensions.cs
Normal file
24
src/WindreamHub.Client/DIExtensions.cs
Normal 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
24
src/WindreamHub.Client/ResponseExtensions.cs
Normal file
24
src/WindreamHub.Client/ResponseExtensions.cs
Normal 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
8
src/WindreamHub.Client/WindreamClientOptions.cs
Normal file
8
src/WindreamHub.Client/WindreamClientOptions.cs
Normal file
@ -0,0 +1,8 @@
|
||||
using DigitalData.Core.Client;
|
||||
|
||||
namespace WindreamHub.Client
|
||||
{
|
||||
public class WindreamClientOptions : HttpClientOptions
|
||||
{
|
||||
}
|
||||
}
|
||||
33
src/WindreamHub.Client/WindreamClientService.cs
Normal file
33
src/WindreamHub.Client/WindreamClientService.cs
Normal 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; }
|
||||
}
|
||||
}
|
||||
36
src/WindreamHub.Client/WindreamHub.Client.csproj
Normal file
36
src/WindreamHub.Client/WindreamHub.Client.csproj
Normal 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>
|
||||
Loading…
x
Reference in New Issue
Block a user