From 3af9c4fc6d44d8ed857f8d96fc9d7aff51d2de5b Mon Sep 17 00:00:00 2001 From: foefl Date: Wed, 11 Jun 2025 11:40:12 +0200 Subject: [PATCH] add debug method to look for relevant paths, related to delta-barth/delta-barth-py#33 --- dopt.DeltaBarth.Tests/PluginTest.cs | 409 +++++++++++++------------ dopt.DeltaBarth/Plugin.cs | 274 +++++++++-------- dopt.DeltaBarth/dopt.DeltaBarth.csproj | 2 +- 3 files changed, 357 insertions(+), 328 deletions(-) diff --git a/dopt.DeltaBarth.Tests/PluginTest.cs b/dopt.DeltaBarth.Tests/PluginTest.cs index 7d0acaa..f6bb26c 100644 --- a/dopt.DeltaBarth.Tests/PluginTest.cs +++ b/dopt.DeltaBarth.Tests/PluginTest.cs @@ -40,22 +40,22 @@ namespace dopt.DeltaBarth.Tests { private const string absPath = @"A:\Arbeitsaufgaben\Delta-Barth\cs-wrapper\dopt.DeltaBarth"; public TPlugin() : base(absPath) { } - public new DataObjects.Credentials GetCredentials() - { - return base.GetCredentials(); - } - public new string GetBaseApiUrl() - { - return base.GetBaseApiUrl(); - } - public new string GetDataPath() - { - return base.GetDataPath(); - } - public new void Setup(string datenPfad, string basisApiUrl) - { - base.Setup(datenPfad, basisApiUrl); - } + //public new DataObjects.Credentials GetCredentials() + //{ + // return base.GetCredentials(); + //} + //public new string GetBaseApiUrl() + //{ + // return base.GetBaseApiUrl(); + //} + //public new string GetDataPath() + //{ + // return base.GetDataPath(); + //} + //public new void Setup(string datenPfad, string basisApiUrl) + //{ + // base.Setup(datenPfad, basisApiUrl); + //} } [TestClass] public sealed class PluginTest @@ -78,194 +78,201 @@ namespace dopt.DeltaBarth.Tests test.Dispose(); } [TestMethod] - public void Set_and_Obtain_Credentials_Test() + public void DebugCall_Test() { var test = new TPlugin(); - string user = "user", password = "password", database = "DB1", mandant = "mandant1"; - test.SetzeNutzerdaten(user, password, database, mandant); - var creds = test.GetCredentials(); - PrettyPrint(creds); - Assert.AreEqual(user, creds.username); - Assert.AreEqual(password, creds.password); - Assert.AreEqual(database, creds.database); - Assert.AreEqual(mandant, creds.mandant); - test.Dispose(); - } - [TestMethod] - public void SetupSession_Test() - { - var test = new TPlugin(); - string apiUrlSet = "http://10.2.22.21:8080/api/"; - test.Setup(baseDataPath, apiUrlSet); - // data path - var dataPathGet = test.GetDataPath(); - Console.WriteLine($"Result for data path from Python session was: {dataPathGet}"); - bool pathElementsContained = dataPathGet.Contains("test_data_path"); - Assert.IsTrue(pathElementsContained); - // API URL - var apiUrlGet = test.GetBaseApiUrl(); - Console.WriteLine($"Result for API URL from Python session was: {apiUrlGet}"); - Assert.AreEqual(apiUrlSet, apiUrlGet); - test.Dispose(); - } - [TestMethod] - public void Startup_Test() - { - var test = new TPlugin(); - string apiUrlSet = "http://10.2.22.21:8080/api/", user = "user", password = "password", database = "DB1", mandant = "mandant1"; - test.Startup(baseDataPath, apiUrlSet, user, password, database, mandant); - var apiUrlGet = test.GetBaseApiUrl(); - var creds = test.GetCredentials(); - Console.WriteLine($"Result from Python session was: API-URL={apiUrlGet}, creds={creds}"); - PrettyPrint(creds); - Assert.AreEqual(apiUrlSet, apiUrlGet); - Assert.AreEqual(user, creds.username); - Assert.AreEqual(password, creds.password); - Assert.AreEqual(database, creds.database); - Assert.AreEqual(mandant, creds.mandant); - test.Dispose(); - } - [TestMethod] - public void UmsatzprognoseDummy_WithoutParams_Test() - { - var test = new TPlugin(); - string apiUrlSet = "http://10.2.22.21:8080/api/", user = "user", password = "password", database = "DB1", mandant = "mandant1"; - test.Startup(baseDataPath, apiUrlSet, user, password, database, mandant); - var res = test.UmsatzprognoseDummy(null, null); - PrettyPrint(res); - Assert.AreEqual((int)StatusCodes.Erfolg, res.status.code); - test.Dispose(); - } - [TestMethod] - public void UmsatzprognoseDummy_WithCompanyIdWithoutDate_Test() - { - var test = new TPlugin(); - string apiUrlSet = "http://10.2.22.21:8080/api/", user = "user", password = "password", database = "DB1", mandant = "mandant1"; - test.Startup(baseDataPath, apiUrlSet, user, password, database, mandant); - var comp_id = 1000; - var res = test.UmsatzprognoseDummy(comp_id, null); - PrettyPrint(res); - Assert.AreEqual((int)StatusCodes.Erfolg, res.status.code); - test.Dispose(); - } - [TestMethod] - public void UmsatzprognoseDummy_WithoutCompanyIdWithDate_Test() - { - var test = new TPlugin(); - string apiUrlSet = "http://10.2.22.21:8080/api/", user = "user", password = "password", database = "DB1", mandant = "mandant1"; - test.Startup(baseDataPath, apiUrlSet, user, password, database, mandant); - var date = new DateTime(2023, 1, 1, 12, 45, 30); - var res = test.UmsatzprognoseDummy(null, date); - PrettyPrint(res); - Assert.AreEqual((int)StatusCodes.Erfolg, res.status.code); - test.Dispose(); - } - [TestMethod] - public void Umsatzprognose_NoConnectionNeeded_Test() - { - var test = new TPlugin(); - string apiUrlSet = config.apiUrl, user = config.username, password = config.password, database = config.database, mandant = config.mandant; - test.Startup(baseDataPath, apiUrlSet, user, password, database, mandant); - var date = new DateTime(2030, 1, 1, 12, 45, 30); - var res = test.Umsatzprognose(null, date); - PrettyPrint(res); - test.Dispose(); - } - [TestMethod] - [TestCategory("ActiveAPI")] - public void Umsatzprognose_WithCompanyIdWithDate_Test() - { - var test = new TPlugin(); - string apiUrlSet = config.apiUrl, user = config.username, password = config.password, database = config.database, mandant = config.mandant; - test.Startup(baseDataPath, apiUrlSet, user, password, database, mandant); - var date = new DateTime(2023, 8, 15, 12, 45, 30); - List comp_id = new List { 1027, 5661, 1024 }; - var res = test.Umsatzprognose(comp_id, date); - PrettyPrint(res); - Assert.AreEqual(4, res.status.code); - Assert.AreEqual((int)StatusCodes.DatensatzZuWenigeMonatsdatenpunkte, res.status.code); - test.Dispose(); - } - [TestMethod] - [TestCategory("ActiveAPI")] - public void Umsatzprognose_WithCompanyIdWithoutDate_Test() - { - var test = new TPlugin(); - string apiUrlSet = config.apiUrl, user = config.username, password = config.password, database = config.database, mandant = config.mandant; - test.Startup(baseDataPath, apiUrlSet, user, password, database, mandant); - List comp_id = new List { 5661 }; - var res = test.Umsatzprognose(comp_id, null); - PrettyPrint(res); - Assert.AreEqual(4, res.status.code); - Assert.AreEqual((int)StatusCodes.DatensatzZuWenigeMonatsdatenpunkte, res.status.code); - test.Dispose(); - } - [TestMethod] - public void Umsatzprognose_WithCompanyIdWithoutDate_Test_FailConnection() - { - var test = new TPlugin(); - string apiUrlSet = config.apiUrl, user = config.username, password = config.password, database = config.database, mandant = config.mandant; - test.Startup(baseDataPath, apiUrlSet, user, password, database, mandant); - List comp_id = new List { 5661 }; - var res = test.Umsatzprognose(comp_id, null); - PrettyPrint(res); - Assert.AreEqual(1, res.status.code); - Assert.AreEqual((int)StatusCodes.VerbindungTimeout, res.status.code); - test.Dispose(); - } - [TestMethod] - [TestCategory("ActiveAPI")] - public void Umsatzprognose_WithoutCompanyIdWithInvalidDate_Test() - { - var test = new TPlugin(); - string apiUrlSet = config.apiUrl, user = config.username, password = config.password, database = config.database, mandant = config.mandant; - test.Startup(baseDataPath, apiUrlSet, user, password, database, mandant); - var date = new DateTime(2030, 1, 1, 12, 45, 30); - var res = test.Umsatzprognose(null, date); - PrettyPrint(res); - Assert.AreEqual(3, res.status.code); - Assert.AreEqual((int)StatusCodes.DatensatzZuWenigeDatenpunkte, res.status.code); - test.Dispose(); - } - [TestMethod] - public void Umsatzprognose_WithoutCompanyIdWithInvalidDate_Test_FailConnection() - { - var test = new TPlugin(); - string apiUrlSet = config.apiUrl, user = config.username, password = config.password, database = config.database, mandant = config.mandant; - test.Startup(baseDataPath, apiUrlSet, user, password, database, mandant); - var date = new DateTime(2030, 1, 1, 12, 45, 30); - var res = test.Umsatzprognose(null, date); - PrettyPrint(res); - Assert.AreEqual(1, res.status.code); - Assert.AreEqual((int)StatusCodes.VerbindungTimeout, res.status.code); - test.Dispose(); - } - [TestMethod] - [TestCategory("ActiveAPI")] - public void Umsatzprognose_WithoutCompanyIdWithValidDate_Test() - { - var test = new TPlugin(); - string apiUrlSet = config.apiUrl, user = config.username, password = config.password, database = config.database, mandant = config.mandant; - test.Startup(baseDataPath, apiUrlSet, user, password, database, mandant); - var date = new DateTime(2021, 1, 1, 12, 45, 30); - var res = test.Umsatzprognose(null, date); - PrettyPrint(res); - Assert.AreEqual(0, res.status.code); - Assert.AreEqual((int)StatusCodes.Erfolg, res.status.code); - test.Dispose(); - } - [TestMethod] - public void Umsatzprognose_WithoutCompanyIdWithValidDate_Test_FailConnection() - { - var test = new TPlugin(); - string apiUrlSet = config.apiUrl, user = config.username, password = config.password, database = config.database, mandant = config.mandant; - test.Startup(baseDataPath, apiUrlSet, user, password, database, mandant); - var date = new DateTime(2015, 1, 1, 12, 45, 30); - var res = test.Umsatzprognose(null, date); - PrettyPrint(res); - Assert.AreEqual(1, res.status.code); - Assert.AreEqual((int)StatusCodes.VerbindungTimeout, res.status.code); + test.DebugCall(); test.Dispose(); } + //[TestMethod] + //public void Set_and_Obtain_Credentials_Test() + //{ + // var test = new TPlugin(); + // string user = "user", password = "password", database = "DB1", mandant = "mandant1"; + // test.SetzeNutzerdaten(user, password, database, mandant); + // var creds = test.GetCredentials(); + // PrettyPrint(creds); + // Assert.AreEqual(user, creds.username); + // Assert.AreEqual(password, creds.password); + // Assert.AreEqual(database, creds.database); + // Assert.AreEqual(mandant, creds.mandant); + // test.Dispose(); + //} + //[TestMethod] + //public void SetupSession_Test() + //{ + // var test = new TPlugin(); + // string apiUrlSet = "http://10.2.22.21:8080/api/"; + // test.Setup(baseDataPath, apiUrlSet); + // // data path + // var dataPathGet = test.GetDataPath(); + // Console.WriteLine($"Result for data path from Python session was: {dataPathGet}"); + // bool pathElementsContained = dataPathGet.Contains("test_data_path"); + // Assert.IsTrue(pathElementsContained); + // // API URL + // var apiUrlGet = test.GetBaseApiUrl(); + // Console.WriteLine($"Result for API URL from Python session was: {apiUrlGet}"); + // Assert.AreEqual(apiUrlSet, apiUrlGet); + // test.Dispose(); + //} + //[TestMethod] + //public void Startup_Test() + //{ + // var test = new TPlugin(); + // string apiUrlSet = "http://10.2.22.21:8080/api/", user = "user", password = "password", database = "DB1", mandant = "mandant1"; + // test.Startup(baseDataPath, apiUrlSet, user, password, database, mandant); + // var apiUrlGet = test.GetBaseApiUrl(); + // var creds = test.GetCredentials(); + // Console.WriteLine($"Result from Python session was: API-URL={apiUrlGet}, creds={creds}"); + // PrettyPrint(creds); + // Assert.AreEqual(apiUrlSet, apiUrlGet); + // Assert.AreEqual(user, creds.username); + // Assert.AreEqual(password, creds.password); + // Assert.AreEqual(database, creds.database); + // Assert.AreEqual(mandant, creds.mandant); + // test.Dispose(); + //} + //[TestMethod] + //public void UmsatzprognoseDummy_WithoutParams_Test() + //{ + // var test = new TPlugin(); + // string apiUrlSet = "http://10.2.22.21:8080/api/", user = "user", password = "password", database = "DB1", mandant = "mandant1"; + // test.Startup(baseDataPath, apiUrlSet, user, password, database, mandant); + // var res = test.UmsatzprognoseDummy(null, null); + // PrettyPrint(res); + // Assert.AreEqual((int)StatusCodes.Erfolg, res.status.code); + // test.Dispose(); + //} + //[TestMethod] + //public void UmsatzprognoseDummy_WithCompanyIdWithoutDate_Test() + //{ + // var test = new TPlugin(); + // string apiUrlSet = "http://10.2.22.21:8080/api/", user = "user", password = "password", database = "DB1", mandant = "mandant1"; + // test.Startup(baseDataPath, apiUrlSet, user, password, database, mandant); + // var comp_id = 1000; + // var res = test.UmsatzprognoseDummy(comp_id, null); + // PrettyPrint(res); + // Assert.AreEqual((int)StatusCodes.Erfolg, res.status.code); + // test.Dispose(); + //} + //[TestMethod] + //public void UmsatzprognoseDummy_WithoutCompanyIdWithDate_Test() + //{ + // var test = new TPlugin(); + // string apiUrlSet = "http://10.2.22.21:8080/api/", user = "user", password = "password", database = "DB1", mandant = "mandant1"; + // test.Startup(baseDataPath, apiUrlSet, user, password, database, mandant); + // var date = new DateTime(2023, 1, 1, 12, 45, 30); + // var res = test.UmsatzprognoseDummy(null, date); + // PrettyPrint(res); + // Assert.AreEqual((int)StatusCodes.Erfolg, res.status.code); + // test.Dispose(); + //} + //[TestMethod] + //public void Umsatzprognose_NoConnectionNeeded_Test() + //{ + // var test = new TPlugin(); + // string apiUrlSet = config.apiUrl, user = config.username, password = config.password, database = config.database, mandant = config.mandant; + // test.Startup(baseDataPath, apiUrlSet, user, password, database, mandant); + // var date = new DateTime(2030, 1, 1, 12, 45, 30); + // var res = test.Umsatzprognose(null, date); + // PrettyPrint(res); + // test.Dispose(); + //} + //[TestMethod] + //[TestCategory("ActiveAPI")] + //public void Umsatzprognose_WithCompanyIdWithDate_Test() + //{ + // var test = new TPlugin(); + // string apiUrlSet = config.apiUrl, user = config.username, password = config.password, database = config.database, mandant = config.mandant; + // test.Startup(baseDataPath, apiUrlSet, user, password, database, mandant); + // var date = new DateTime(2023, 8, 15, 12, 45, 30); + // List comp_id = new List { 1027, 5661, 1024 }; + // var res = test.Umsatzprognose(comp_id, date); + // PrettyPrint(res); + // Assert.AreEqual(4, res.status.code); + // Assert.AreEqual((int)StatusCodes.DatensatzZuWenigeMonatsdatenpunkte, res.status.code); + // test.Dispose(); + //} + //[TestMethod] + //[TestCategory("ActiveAPI")] + //public void Umsatzprognose_WithCompanyIdWithoutDate_Test() + //{ + // var test = new TPlugin(); + // string apiUrlSet = config.apiUrl, user = config.username, password = config.password, database = config.database, mandant = config.mandant; + // test.Startup(baseDataPath, apiUrlSet, user, password, database, mandant); + // List comp_id = new List { 5661 }; + // var res = test.Umsatzprognose(comp_id, null); + // PrettyPrint(res); + // Assert.AreEqual(4, res.status.code); + // Assert.AreEqual((int)StatusCodes.DatensatzZuWenigeMonatsdatenpunkte, res.status.code); + // test.Dispose(); + //} + //[TestMethod] + //public void Umsatzprognose_WithCompanyIdWithoutDate_Test_FailConnection() + //{ + // var test = new TPlugin(); + // string apiUrlSet = config.apiUrl, user = config.username, password = config.password, database = config.database, mandant = config.mandant; + // test.Startup(baseDataPath, apiUrlSet, user, password, database, mandant); + // List comp_id = new List { 5661 }; + // var res = test.Umsatzprognose(comp_id, null); + // PrettyPrint(res); + // Assert.AreEqual(1, res.status.code); + // Assert.AreEqual((int)StatusCodes.VerbindungTimeout, res.status.code); + // test.Dispose(); + //} + //[TestMethod] + //[TestCategory("ActiveAPI")] + //public void Umsatzprognose_WithoutCompanyIdWithInvalidDate_Test() + //{ + // var test = new TPlugin(); + // string apiUrlSet = config.apiUrl, user = config.username, password = config.password, database = config.database, mandant = config.mandant; + // test.Startup(baseDataPath, apiUrlSet, user, password, database, mandant); + // var date = new DateTime(2030, 1, 1, 12, 45, 30); + // var res = test.Umsatzprognose(null, date); + // PrettyPrint(res); + // Assert.AreEqual(3, res.status.code); + // Assert.AreEqual((int)StatusCodes.DatensatzZuWenigeDatenpunkte, res.status.code); + // test.Dispose(); + //} + //[TestMethod] + //public void Umsatzprognose_WithoutCompanyIdWithInvalidDate_Test_FailConnection() + //{ + // var test = new TPlugin(); + // string apiUrlSet = config.apiUrl, user = config.username, password = config.password, database = config.database, mandant = config.mandant; + // test.Startup(baseDataPath, apiUrlSet, user, password, database, mandant); + // var date = new DateTime(2030, 1, 1, 12, 45, 30); + // var res = test.Umsatzprognose(null, date); + // PrettyPrint(res); + // Assert.AreEqual(1, res.status.code); + // Assert.AreEqual((int)StatusCodes.VerbindungTimeout, res.status.code); + // test.Dispose(); + //} + //[TestMethod] + //[TestCategory("ActiveAPI")] + //public void Umsatzprognose_WithoutCompanyIdWithValidDate_Test() + //{ + // var test = new TPlugin(); + // string apiUrlSet = config.apiUrl, user = config.username, password = config.password, database = config.database, mandant = config.mandant; + // test.Startup(baseDataPath, apiUrlSet, user, password, database, mandant); + // var date = new DateTime(2021, 1, 1, 12, 45, 30); + // var res = test.Umsatzprognose(null, date); + // PrettyPrint(res); + // Assert.AreEqual(0, res.status.code); + // Assert.AreEqual((int)StatusCodes.Erfolg, res.status.code); + // test.Dispose(); + //} + //[TestMethod] + //public void Umsatzprognose_WithoutCompanyIdWithValidDate_Test_FailConnection() + //{ + // var test = new TPlugin(); + // string apiUrlSet = config.apiUrl, user = config.username, password = config.password, database = config.database, mandant = config.mandant; + // test.Startup(baseDataPath, apiUrlSet, user, password, database, mandant); + // var date = new DateTime(2015, 1, 1, 12, 45, 30); + // var res = test.Umsatzprognose(null, date); + // PrettyPrint(res); + // Assert.AreEqual(1, res.status.code); + // Assert.AreEqual((int)StatusCodes.VerbindungTimeout, res.status.code); + // test.Dispose(); + //} } } diff --git a/dopt.DeltaBarth/Plugin.cs b/dopt.DeltaBarth/Plugin.cs index 5d7ea1e..52f95c0 100644 --- a/dopt.DeltaBarth/Plugin.cs +++ b/dopt.DeltaBarth/Plugin.cs @@ -88,6 +88,10 @@ namespace dopt.DeltaBarth /// protected dynamic pyModPipeline; /// + /// Debug-Modul für Python-Umgebung + /// + protected dynamic pyDebug; + /// /// Konstruktor der Plugin-Klasse. /// Kann mit beliebigem Pfad zu einer Python-Runtime initialisiert werden. /// @@ -100,141 +104,159 @@ namespace dopt.DeltaBarth { pyModManagement = Py.Import("delta_barth.management"); pyModPipeline = Py.Import("delta_barth.pipelines"); + pyDebug = Py.Import("delta_barth._debug"); } } /// - /// Initialisiert das Plugin mit allen relevanten Paramtern für die weitere Nutzung. - /// Diese Methode sollte nur einmal je Instanz genutzt werden. + /// Gibt Runtime-relevante Pfade in der Konsole aus /// - /// Pfad zu einem Ordner, in dem Programmdaten ohne Bedenken dauerhaft abgelegt werden können. - /// Basis-URL zum Zugriff auf die API. Dies muss eine vollständige URL sein inkl. der Route "/api". - /// Nutzername für die Datenbankanmeldung. - /// Passwort für die Datenbankanmeldung. - /// Name der Datenbank, bei der die Anmeldung erfolgen soll. - /// Mandant für die Datenbankanmeldung. - public void Startup(string datenPfad, string basisApiUrl, string nutzername, string passwort, string datenbank, string mandant) + public string DebugCall() { - AssertNotDisposed(); - Setup(datenPfad, basisApiUrl); - SetzeNutzerdaten(nutzername, passwort, datenbank, mandant); - } - /// - /// Diese Methode erlaubt es, die relevanten Nutzerdaten zur Laufzeit des Plugins zu ändern. - /// Dies beinhaltet: Nutzername, Passwort, Datenbankname, Mandant - /// - /// Nutzername für die Datenbankanmeldung. - /// Passwort für die Datenbankanmeldung. - /// Name der Datenbank, bei der die Anmeldung erfolgen soll. - /// Mandant für die Datenbankanmeldung. - public void SetzeNutzerdaten(string nutzername, string passwort, string datenbank, string mandant) - { - AssertNotDisposed(); - using (Py.GIL()) { - pyModManagement.set_credentials(nutzername, passwort, datenbank, mandant); - } - } - /// - /// Ausführung der Umsatzprognose-Pipeline mit Dummy-Daten. - /// Es werden keine API-Abrufe durchgeführt und somit auch keine Live-Daten genutzt. - /// - /// optional: Firmen-ID, für die die Pipeline ausgeführt werden soll. - /// Wird der Parameter nicht zur Verfügung gestellt, werden alle Firmen bzw. Kunden abgerufen - /// optional: Start-Datum, ab dem die Daten für die Erstellung des Prognosemodells genutzt werden. - /// Daten, die weiter in der Vergangenheit liegen, werden nicht berücksichtigt. - /// Wird der Parameter nicht zur Verfügung gestellt, wird die gesamte Historie genutzt. - /// Umsatzprognose inkl. Status-Objekt zur Nachvollziehbarkeit etwaig aufgetretener Fehler. - /// - public DataObjects.UmsatzPrognoseAusgabe UmsatzprognoseDummy(int? firmaId, DateTime? analyseBeginn) - { - AssertNotDisposed(); - string pyJson; + string infos; using (Py.GIL()) { - pyJson = pyModPipeline.pipeline_sales_forecast_dummy(firmaId, analyseBeginn); - } - var parsed = JsonSerializer.Deserialize(pyJson) ?? throw new PythonParsingException("Could not correctly parse object from Python"); - return parsed; - } - /// - /// Ausführung der Umsatzprognose-Pipeline mit Live-Daten. - /// Es werden API-Abrufe durchgeführt und somit auch Live-Daten genutzt. - /// Hierfür muss sichergestellt sein, dass der API-Server erreichbar und abrufbereit ist. - /// - /// optional: Liste von Firmen-IDs, für die die Pipeline ausgeführt werden soll. - /// Wird der Parameter nicht zur Verfügung gestellt, werden alle Firmen bzw. Kunden abgerufen - /// optional: Start-Datum, ab dem die Daten für die Erstellung des Prognosemodells genutzt werden. - /// Daten, die weiter in der Vergangenheit liegen, werden nicht berücksichtigt. - /// Wird der Parameter nicht zur Verfügung gestellt, wird die gesamte Historie genutzt. - /// Umsatzprognose inkl. Status-Objekt zur Nachvollziehbarkeit etwaig aufgetretener Fehler. - /// - public DataObjects.UmsatzPrognoseAusgabe Umsatzprognose(List? firmaIds, DateTime? analyseBeginn) - { - AssertNotDisposed(); - string pyJson; - using (Py.GIL()) - { - pyJson = pyModPipeline.pipeline_sales_forecast(firmaIds, analyseBeginn); - } - var parsed = JsonSerializer.Deserialize(pyJson) ?? throw new PythonParsingException("Could not correctly parse object from Python"); - return parsed; - } - /// - /// Setup der Python-internen Umgebung - /// - /// Pfad zu einem Ordner, in dem Programmdaten ohne Bedenken dauerhaft abgelegt werden können. - /// Basis-URL zum Zugriff auf die API. Dies muss eine vollständige URL sein inkl. der Route "/api". - protected void Setup(string datenPfad, string basisApiUrl) - { - AssertNotDisposed(); - using (Py.GIL()) - { - pyModManagement.setup(datenPfad, basisApiUrl); - } - } - /// - /// Hole die konfigurierte API-Basis-URL aus der Python-Umgebung - /// - /// konfigurierte Basis-URL - protected string GetBaseApiUrl() - { - AssertNotDisposed(); - string pyJson; - using (Py.GIL()) - { - pyJson = (string)pyModManagement.get_base_url(); - } - return pyJson; - } - /// - /// Hole den konfigurierten Datenpfad zur Dateiverwaltung aus der Python-Umgebung - /// - /// konfigurierten Datenpfad - protected string GetDataPath() - { - AssertNotDisposed(); - string pyJson; - using (Py.GIL()) - { - pyJson = (string)pyModManagement.get_data_path(); - } - return pyJson; - } - /// - /// Hole die konfigurierten Nutzerdaten zur API-Interaktion aus der Python-Umgebung - /// - /// konfigurierte Nutzerdaten - /// - protected DataObjects.Credentials GetCredentials() - { - AssertNotDisposed(); - string pyJson; - using (Py.GIL()) - { - pyJson = (string)pyModManagement.get_credentials(); + + infos = pyDebug.print_infos(); } + Console.WriteLine(infos); + Console.WriteLine($"PyEngine - PYHOME: {PythonEngine.PythonHome}"); + Console.WriteLine($"PyEngine - PYPATH: {PythonEngine.PythonPath}"); - DataObjects.Credentials? parsed = JsonSerializer.Deserialize(pyJson); - return parsed ?? throw new PythonParsingException("Could not correctly parse object from Python"); + return infos; } + ///// + ///// Initialisiert das Plugin mit allen relevanten Paramtern für die weitere Nutzung. + ///// Diese Methode sollte nur einmal je Instanz genutzt werden. + ///// + ///// Pfad zu einem Ordner, in dem Programmdaten ohne Bedenken dauerhaft abgelegt werden können. + ///// Basis-URL zum Zugriff auf die API. Dies muss eine vollständige URL sein inkl. der Route "/api". + ///// Nutzername für die Datenbankanmeldung. + ///// Passwort für die Datenbankanmeldung. + ///// Name der Datenbank, bei der die Anmeldung erfolgen soll. + ///// Mandant für die Datenbankanmeldung. + //public void Startup(string datenPfad, string basisApiUrl, string nutzername, string passwort, string datenbank, string mandant) + //{ + // AssertNotDisposed(); + // Setup(datenPfad, basisApiUrl); + // SetzeNutzerdaten(nutzername, passwort, datenbank, mandant); + //} + ///// + ///// Diese Methode erlaubt es, die relevanten Nutzerdaten zur Laufzeit des Plugins zu ändern. + ///// Dies beinhaltet: Nutzername, Passwort, Datenbankname, Mandant + ///// + ///// Nutzername für die Datenbankanmeldung. + ///// Passwort für die Datenbankanmeldung. + ///// Name der Datenbank, bei der die Anmeldung erfolgen soll. + ///// Mandant für die Datenbankanmeldung. + //public void SetzeNutzerdaten(string nutzername, string passwort, string datenbank, string mandant) + //{ + // AssertNotDisposed(); + // using (Py.GIL()) { + // pyModManagement.set_credentials(nutzername, passwort, datenbank, mandant); + // } + //} + ///// + ///// Ausführung der Umsatzprognose-Pipeline mit Dummy-Daten. + ///// Es werden keine API-Abrufe durchgeführt und somit auch keine Live-Daten genutzt. + ///// + ///// optional: Firmen-ID, für die die Pipeline ausgeführt werden soll. + ///// Wird der Parameter nicht zur Verfügung gestellt, werden alle Firmen bzw. Kunden abgerufen + ///// optional: Start-Datum, ab dem die Daten für die Erstellung des Prognosemodells genutzt werden. + ///// Daten, die weiter in der Vergangenheit liegen, werden nicht berücksichtigt. + ///// Wird der Parameter nicht zur Verfügung gestellt, wird die gesamte Historie genutzt. + ///// Umsatzprognose inkl. Status-Objekt zur Nachvollziehbarkeit etwaig aufgetretener Fehler. + ///// + //public DataObjects.UmsatzPrognoseAusgabe UmsatzprognoseDummy(int? firmaId, DateTime? analyseBeginn) + //{ + // AssertNotDisposed(); + // string pyJson; + // using (Py.GIL()) + // { + // pyJson = pyModPipeline.pipeline_sales_forecast_dummy(firmaId, analyseBeginn); + // } + // var parsed = JsonSerializer.Deserialize(pyJson) ?? throw new PythonParsingException("Could not correctly parse object from Python"); + // return parsed; + //} + ///// + ///// Ausführung der Umsatzprognose-Pipeline mit Live-Daten. + ///// Es werden API-Abrufe durchgeführt und somit auch Live-Daten genutzt. + ///// Hierfür muss sichergestellt sein, dass der API-Server erreichbar und abrufbereit ist. + ///// + ///// optional: Liste von Firmen-IDs, für die die Pipeline ausgeführt werden soll. + ///// Wird der Parameter nicht zur Verfügung gestellt, werden alle Firmen bzw. Kunden abgerufen + ///// optional: Start-Datum, ab dem die Daten für die Erstellung des Prognosemodells genutzt werden. + ///// Daten, die weiter in der Vergangenheit liegen, werden nicht berücksichtigt. + ///// Wird der Parameter nicht zur Verfügung gestellt, wird die gesamte Historie genutzt. + ///// Umsatzprognose inkl. Status-Objekt zur Nachvollziehbarkeit etwaig aufgetretener Fehler. + ///// + //public DataObjects.UmsatzPrognoseAusgabe Umsatzprognose(List? firmaIds, DateTime? analyseBeginn) + //{ + // AssertNotDisposed(); + // string pyJson; + // using (Py.GIL()) + // { + // pyJson = pyModPipeline.pipeline_sales_forecast(firmaIds, analyseBeginn); + // } + // var parsed = JsonSerializer.Deserialize(pyJson) ?? throw new PythonParsingException("Could not correctly parse object from Python"); + // return parsed; + //} + ///// + ///// Setup der Python-internen Umgebung + ///// + ///// Pfad zu einem Ordner, in dem Programmdaten ohne Bedenken dauerhaft abgelegt werden können. + ///// Basis-URL zum Zugriff auf die API. Dies muss eine vollständige URL sein inkl. der Route "/api". + //protected void Setup(string datenPfad, string basisApiUrl) + //{ + // AssertNotDisposed(); + // using (Py.GIL()) + // { + // pyModManagement.setup(datenPfad, basisApiUrl); + // } + //} + ///// + ///// Hole die konfigurierte API-Basis-URL aus der Python-Umgebung + ///// + ///// konfigurierte Basis-URL + //protected string GetBaseApiUrl() + //{ + // AssertNotDisposed(); + // string pyJson; + // using (Py.GIL()) + // { + // pyJson = (string)pyModManagement.get_base_url(); + // } + // return pyJson; + //} + ///// + ///// Hole den konfigurierten Datenpfad zur Dateiverwaltung aus der Python-Umgebung + ///// + ///// konfigurierten Datenpfad + //protected string GetDataPath() + //{ + // AssertNotDisposed(); + // string pyJson; + // using (Py.GIL()) + // { + // pyJson = (string)pyModManagement.get_data_path(); + // } + // return pyJson; + //} + ///// + ///// Hole die konfigurierten Nutzerdaten zur API-Interaktion aus der Python-Umgebung + ///// + ///// konfigurierte Nutzerdaten + ///// + //protected DataObjects.Credentials GetCredentials() + //{ + // AssertNotDisposed(); + // string pyJson; + // using (Py.GIL()) + // { + // pyJson = (string)pyModManagement.get_credentials(); + // } + + // DataObjects.Credentials? parsed = JsonSerializer.Deserialize(pyJson); + // return parsed ?? throw new PythonParsingException("Could not correctly parse object from Python"); + //} } } diff --git a/dopt.DeltaBarth/dopt.DeltaBarth.csproj b/dopt.DeltaBarth/dopt.DeltaBarth.csproj index 26208a2..5ff4f2d 100644 --- a/dopt.DeltaBarth/dopt.DeltaBarth.csproj +++ b/dopt.DeltaBarth/dopt.DeltaBarth.csproj @@ -6,7 +6,7 @@ enable x64 x64 - 0.4.0 + 0.4.1-alpha1 True