initial commit

This commit is contained in:
2025-03-19 18:24:04 +01:00
commit 052a031dbf
9 changed files with 800 additions and 0 deletions

View File

@@ -0,0 +1,50 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Collections.Immutable;
namespace dopt.DeltaBarth.JsonStructs
{
public readonly struct ApiServerError
{
public int status_code { get; init; }
public string message { get; init; }
public string? code { get; init; }
public string? hints { get; init; }
public string? type { get; init; }
public string? title { get; init; }
public string? traceId { get; init; }
}
public readonly struct Status
{
public int code { get; init; }
public string description { get; init; }
public string message { get; init; }
public ApiServerError? apiServerError { get; init; }
}
public readonly struct Credentials
{
public string user_name { get; init; }
public string password { get; init; }
public string database { get; init; }
public string mandant { get; init; }
}
public readonly struct UmsatzPrognoseEinzelergebnis
{
public int jahr { get; init; }
public int monat { get; init; }
public float vorhersage { get; init; }
}
public readonly struct UmsatzPrognoseErgebnisse
{
public ImmutableArray<UmsatzPrognoseEinzelergebnis> daten { get; init; }
}
public readonly struct UmsatzPrognoseAusgabe
{
public UmsatzPrognoseErgebnisse response { get; init; }
public Status status { get; init; }
}
}

45
dopt.DeltaBarth/Plugin.cs Normal file
View File

@@ -0,0 +1,45 @@
using System.ComponentModel.DataAnnotations.Schema;
using dopt;
using Python.Runtime;
using System.Text.Json;
namespace dopt.DeltaBarth
{
public class Plugin : SharpPython.BasePlugin
{
protected dynamic pyModManagement;
protected dynamic pyModPipeline;
public Plugin() : base()
{
base.Initialise();
using (Py.GIL())
{
pyModManagement = Py.Import("delta_barth.management");
pyModPipeline = Py.Import("delta_barth.pipelines");
}
}
public void Shutdown()
{
base.Finalise();
}
public void SetCredentials(string username, string password, string database, string mandant)
{
using (Py.GIL()) {
pyModManagement.set_credentials(username, password, database, mandant);
}
}
public JsonStructs.Credentials GetCredentials()
{
string pyJson;
using (Py.GIL())
{
pyJson = (string)pyModManagement.get_credentials();
}
JsonStructs.Credentials credentials = JsonSerializer.Deserialize<JsonStructs.Credentials>(pyJson);
return credentials;
}
}
}

View File

@@ -0,0 +1,18 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<PlatformTarget>x64</PlatformTarget>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="dopt.SharpPython" Version="0.1.2" />
<Content Include="..\python\**\*">
<Link>python\%(RecursiveDir)/%(FileName)%(Extension)</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
</Project>