Compare commits

...

5 Commits

Author SHA1 Message Date
Developer 02
8eabf99616 chore: für NuGet-Paket konfiguriert 2024-07-31 09:55:00 +02:00
Developer 02
8c1ae0e373 refactor: CreateFetchAsyncAction in CreateFetchAction umbenannt 2024-07-30 11:46:58 +02:00
Developer 02
ccf76a72c1 refactor: Fehler-Action-Parameter in der FetchAsync-Methode optional machen 2024-07-30 11:31:42 +02:00
Developer 02
bcf0db1d5a refactor: Methoden von 'Subscribe' auf 'Fetch' umbenannt 2024-07-30 11:22:51 +02:00
Developer 02
82ce7996d1 feat: Erweiterung der ModelExtensions um zusätzliche Subscribe-Methoden
- Hinzugefügt: `SubscribeAsync` Methode für asynchrone Verarbeitung mit Abbruch-Token.
- Hinzugefügt: Überlastung von `Subscribe` Methode für sofortige Ausführung und wiederholte Ausführung mit Delay.
- Hinzugefügt: Methoden zur Erstellung von `Subscribe`-Aktionen mit Unterstützung für Abbruch-Token.
2024-07-30 11:12:31 +02:00
6 changed files with 122 additions and 7 deletions

View File

@@ -27,8 +27,8 @@ Global
{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
{67E6A3A1-F863-417E-9619-DC9B6A710512}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{67E6A3A1-F863-417E-9619-DC9B6A710512}.Debug|Any CPU.Build.0 = Debug|Any CPU
{67E6A3A1-F863-417E-9619-DC9B6A710512}.Debug|Any CPU.ActiveCfg = Release|Any CPU
{67E6A3A1-F863-417E-9619-DC9B6A710512}.Debug|Any CPU.Build.0 = Release|Any CPU
{67E6A3A1-F863-417E-9619-DC9B6A710512}.Release|Any CPU.ActiveCfg = Release|Any CPU
{67E6A3A1-F863-417E-9619-DC9B6A710512}.Release|Any CPU.Build.0 = Release|Any CPU
{DE6A7FB2-87D6-471E-8019-DF6E196FA471}.Debug|Any CPU.ActiveCfg = Debug|Any CPU

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.5 KiB

View File

@@ -1,8 +1,8 @@
using DigitalData.Core.Legacy.Client;
using System;
using System.Net.Http;
using System.Threading;
using System.Threading.Tasks;
using static System.Net.Mime.MediaTypeNames;
namespace WindreamHub.Legacy.Client.Models
{
@@ -16,13 +16,78 @@ namespace WindreamHub.Legacy.Client.Models
return new SimplifiedResponse<TData, TError>(ok: message.IsSuccessStatusCode, status: message.StatusCode, data: data, error: err);
}
public static async Task Subscribe<TData, TError>(this Task<SimplifiedResponse<TData, TError>> responseAsync, Action<TData> next, Action<TError> error)
public static async Task FetchAsync<TData, TError>(this Task<SimplifiedResponse<TData, TError>> responseAsync, Action<TData> next, Action<TError> error = null, CancellationToken cancellationToken = default)
{
if (cancellationToken.IsCancellationRequested)
return;
var res = await responseAsync;
if (res.Ok)
next(res.Data);
else
error(res.Error);
error?.Invoke(res.Error);
}
public static void Fetch<TData, TError>(this Task<SimplifiedResponse<TData, TError>> responseAsync, Action<TData> next, Action<TError> error = null, CancellationToken cancellationToken = default)
{
Task.Run(async () =>
{
if (cancellationToken.IsCancellationRequested)
return;
var res = await responseAsync;
if (res.Ok)
next(res.Data);
else
error?.Invoke(res.Error);
});
}
public static void Fetch<TData, TError>(this Task<SimplifiedResponse<TData, TError>> responseAsync, int millisecondsDelay, Action<TData> next, Action<TError> error = null, CancellationToken cancellationToken = default)
{
Task.Run(async () =>
{
while (!cancellationToken.IsCancellationRequested)
{
var res = await responseAsync;
if (res.Ok)
next(res.Data);
else
error?.Invoke(res.Error);
await Task.Delay(millisecondsDelay, cancellationToken);
}
});
}
public static Func<Task> CreateFetchAsync<TData, TError>(this Task<SimplifiedResponse<TData, TError>> responseAsync, Action<TData> next, Action<TError> error = null, CancellationToken cancellationToken = default)
{
return async () =>
{
if (cancellationToken.IsCancellationRequested)
return;
var res = await responseAsync;
if (res.Ok)
next(res.Data);
else
error?.Invoke(res.Error);
};
}
public static Action CreateFetch<TData, TError>(this Task<SimplifiedResponse<TData, TError>> responseAsync, Action<TData> next, Action<TError> error = null, CancellationToken cancellationToken = default)
{
return () => Task.Run(async () =>
{
if (cancellationToken.IsCancellationRequested)
return;
var res = await responseAsync;
if (res.Ok)
next(res.Data);
else
error?.Invoke(res.Error);
});
}
}
}

View File

@@ -31,12 +31,15 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="DigitalData.Core.Client.Legacy">
<HintPath>..\..\..\WebCoreModules\DigitalData.Core.Legacy.Client\bin\Debug\DigitalData.Core.Client.Legacy.dll</HintPath>
<Reference Include="DigitalData.Core.Client.Legacy, Version=1.0.1.1, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\..\packages\DigitalData.Core.Client.Legacy.1.0.1.2\lib\net462\DigitalData.Core.Client.Legacy.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Bcl.AsyncInterfaces, Version=8.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\..\packages\Microsoft.Bcl.AsyncInterfaces.8.0.0\lib\net462\Microsoft.Bcl.AsyncInterfaces.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Extensions.DependencyInjection, Version=8.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
<HintPath>..\..\packages\Microsoft.Extensions.DependencyInjection.8.0.0\lib\net462\Microsoft.Extensions.DependencyInjection.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Extensions.DependencyInjection.Abstractions, Version=8.0.0.1, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
<HintPath>..\..\packages\Microsoft.Extensions.DependencyInjection.Abstractions.8.0.1\lib\net462\Microsoft.Extensions.DependencyInjection.Abstractions.dll</HintPath>
</Reference>
@@ -46,6 +49,9 @@
<Reference Include="Microsoft.Extensions.Primitives, Version=8.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
<HintPath>..\..\packages\Microsoft.Extensions.Primitives.8.0.0\lib\net462\Microsoft.Extensions.Primitives.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\..\packages\Newtonsoft.Json.13.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Buffers, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\..\packages\System.Buffers.4.5.1\lib\net461\System.Buffers.dll</HintPath>
@@ -93,5 +99,10 @@
<None Include="app.config" />
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<Content Include="Assets\icon.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

View File

@@ -0,0 +1,35 @@
<?xml version="1.0" encoding="utf-8"?>
<package>
<metadata>
<id>WindreamHub.Legacy.Client</id>
<version>1.0.0</version>
<title>WindreamHub.Legacy.Client</title>
<authors>Digital Data GmbH</authors>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<license type="expression">MIT</license>
<icon>Assets\icon.png</icon>
<projectUrl>http://git.dd:3000/tekh/WindreamHub.git</projectUrl>
<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. This version is specifically designed to be compatible with .NET Framework.</description>
<copyright>Copyright 2024</copyright>
<tags>digital data core http windream legacy</tags>
<dependencies>
<dependency id="DigitalData.Core.Client.Legacy" version="1.0.1.2" />
<dependency id="Microsoft.Bcl.AsyncInterfaces" version="8.0.0" />
<dependency id="Microsoft.Extensions.DependencyInjection" version="8.0.0" />
<dependency id="Microsoft.Extensions.DependencyInjection.Abstractions" version="8.0.1" />
<dependency id="Microsoft.Extensions.Options" version="8.0.2" />
<dependency id="Microsoft.Extensions.Primitives" version="8.0.0" />
<dependency id="Newtonsoft.Json" version="13.0.1" />
<dependency id="System.Buffers" version="4.5.1" />
<dependency id="System.Memory" version="4.5.5" />
<dependency id="System.Numerics.Vectors" version="4.5.0" />
<dependency id="System.Runtime.CompilerServices.Unsafe" version="6.0.0" />
<dependency id="System.Threading.Tasks.Extensions" version="4.5.4" />
<dependency id="System.ValueTuple" version="4.5.0" />
</dependencies>
</metadata>
<files>
<file src="bin\Release\WindreamHub.Legacy.Client.dll" target="lib\net462\WindreamHub.Legacy.Client.dll" />
<file src="Assets\icon.png" target="Assets\" />
</files>
</package>

View File

@@ -1,9 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="DigitalData.Core.Client.Legacy" version="1.0.1.2" targetFramework="net462" />
<package id="Microsoft.Bcl.AsyncInterfaces" version="8.0.0" targetFramework="net462" />
<package id="Microsoft.Extensions.DependencyInjection" version="8.0.0" targetFramework="net462" />
<package id="Microsoft.Extensions.DependencyInjection.Abstractions" version="8.0.1" targetFramework="net462" />
<package id="Microsoft.Extensions.Options" version="8.0.2" targetFramework="net462" />
<package id="Microsoft.Extensions.Primitives" version="8.0.0" targetFramework="net462" />
<package id="Newtonsoft.Json" version="13.0.1" targetFramework="net462" />
<package id="NuGet.CommandLine" version="6.10.1" targetFramework="net462" developmentDependency="true" />
<package id="System.Buffers" version="4.5.1" targetFramework="net462" />
<package id="System.Memory" version="4.5.5" targetFramework="net462" />
<package id="System.Numerics.Vectors" version="4.5.0" targetFramework="net462" />