diff --git a/dopt.DeltaBarth.Tests/JsonStructsTest.cs b/dopt.DeltaBarth.Tests/JsonStructsTest.cs index f98c930..8ae8451 100644 --- a/dopt.DeltaBarth.Tests/JsonStructsTest.cs +++ b/dopt.DeltaBarth.Tests/JsonStructsTest.cs @@ -42,7 +42,7 @@ namespace dopt.DeltaBarth.Tests Assert.AreEqual("caused by test", parsed.message); Assert.IsNull(parsed.apiServerError); PrettyPrint(parsed); - plugin.Shutdown(); + plugin.Dispose(); } [TestMethod] public void Parse_ApiError_Test() @@ -62,7 +62,7 @@ namespace dopt.DeltaBarth.Tests Assert.IsNull(parsed.title); Assert.IsNull(parsed.traceId); PrettyPrint(parsed); - plugin.Shutdown(); + plugin.Dispose(); } [TestMethod] public void Parse_Credentials_Test() @@ -79,7 +79,7 @@ namespace dopt.DeltaBarth.Tests Assert.AreEqual("test1", parsed.database); Assert.AreEqual("mandant1", parsed.mandant); PrettyPrint(parsed); - plugin.Shutdown(); + plugin.Dispose(); } [TestMethod] public void Parse_SalesPrognosisResult_Test() @@ -95,7 +95,7 @@ namespace dopt.DeltaBarth.Tests Assert.AreEqual(12, parsed.monat); Assert.AreEqual(3000.3456m, parsed.vorhersage); PrettyPrint(parsed); - plugin.Shutdown(); + plugin.Dispose(); } [TestMethod] public void Parse_SalesPrognosisResults_Test() @@ -118,7 +118,7 @@ namespace dopt.DeltaBarth.Tests Assert.AreEqual(arr[i], parsed.daten[i]); } PrettyPrint(parsed); - plugin.Shutdown(); + plugin.Dispose(); } [TestMethod] public void Parse_SalesPrognosisExport_Test() @@ -147,7 +147,7 @@ namespace dopt.DeltaBarth.Tests Assert.AreEqual(data.daten[i], parsed.response.daten[i]); } PrettyPrint(parsed); - plugin.Shutdown(); + plugin.Dispose(); } } } diff --git a/dopt.DeltaBarth.Tests/PluginTest.cs b/dopt.DeltaBarth.Tests/PluginTest.cs index c361ead..5b9cc18 100644 --- a/dopt.DeltaBarth.Tests/PluginTest.cs +++ b/dopt.DeltaBarth.Tests/PluginTest.cs @@ -33,7 +33,7 @@ namespace dopt.DeltaBarth.Tests v = config["delta-barth-server:api:mandant"]; Assert.IsNotNull(v); mandant = v; - } + } } public class TPlugin : DeltaBarth.Plugin { @@ -62,7 +62,7 @@ namespace dopt.DeltaBarth.Tests public void ConstructInitialiseFinalise_Test() { var test = new TPlugin(); - test.Shutdown(); + test.Dispose(); } [TestMethod] public void Set_and_Obtain_Credentials_Test() @@ -76,7 +76,7 @@ namespace dopt.DeltaBarth.Tests Assert.AreEqual(password, creds.password); Assert.AreEqual(database, creds.database); Assert.AreEqual(mandant, creds.mandant); - test.Shutdown(); + test.Dispose(); } [TestMethod] public void Set_and_Obtain_BaseApiUrl_Test() @@ -87,7 +87,7 @@ namespace dopt.DeltaBarth.Tests var apiUrlGet = test.GetBaseApiUrl(); Console.WriteLine($"Result from Python session was: {apiUrlGet}"); Assert.AreEqual(apiUrlSet, apiUrlGet); - test.Shutdown(); + test.Dispose(); } [TestMethod] public void Startup_Test() @@ -104,7 +104,7 @@ namespace dopt.DeltaBarth.Tests Assert.AreEqual(password, creds.password); Assert.AreEqual(database, creds.database); Assert.AreEqual(mandant, creds.mandant); - test.Shutdown(); + test.Dispose(); } [TestMethod] public void UmsatzprognoseDummy_WithoutParams_Test() @@ -114,7 +114,7 @@ namespace dopt.DeltaBarth.Tests test.Startup(apiUrlSet, user, password, database, mandant); var res = test.UmsatzprognoseDummy(null, null); PrettyPrint(res); - test.Shutdown(); + test.Dispose(); } [TestMethod] public void UmsatzprognoseDummy_WithCompanyIdWithoutDate_Test() @@ -125,7 +125,7 @@ namespace dopt.DeltaBarth.Tests var comp_id = 1000; var res = test.UmsatzprognoseDummy(comp_id, null); PrettyPrint(res); - test.Shutdown(); + test.Dispose(); } [TestMethod] public void UmsatzprognoseDummy_WithoutCompanyIdWithDate_Test() @@ -136,7 +136,7 @@ namespace dopt.DeltaBarth.Tests var date = new DateTime(2023, 1, 1, 12, 45, 30); var res = test.UmsatzprognoseDummy(null, date); PrettyPrint(res); - test.Shutdown(); + test.Dispose(); } [TestMethod] @@ -149,7 +149,7 @@ namespace dopt.DeltaBarth.Tests var comp_id = 1024; var res = test.Umsatzprognose(comp_id, null); PrettyPrint(res); - test.Shutdown(); + test.Dispose(); } [TestMethod] [TestCategory("ActiveAPI")] @@ -161,7 +161,7 @@ namespace dopt.DeltaBarth.Tests var date = new DateTime(2030, 1, 1, 12, 45, 30); var res = test.Umsatzprognose(null, date); PrettyPrint(res); - test.Shutdown(); + test.Dispose(); } [TestMethod] [TestCategory("ActiveAPI")] @@ -173,7 +173,7 @@ namespace dopt.DeltaBarth.Tests var date = new DateTime(2015, 1, 1, 12, 45, 30); var res = test.Umsatzprognose(null, date); PrettyPrint(res); - test.Shutdown(); + test.Dispose(); } } } diff --git a/dopt.DeltaBarth/Plugin.cs b/dopt.DeltaBarth/Plugin.cs index 20fa8f2..ebb9b4d 100644 --- a/dopt.DeltaBarth/Plugin.cs +++ b/dopt.DeltaBarth/Plugin.cs @@ -18,25 +18,25 @@ namespace dopt.DeltaBarth } public void Startup(string basisApiUrl, string nutzername, string passwort, string datenbank, string mandant) { + AssertNotDisposed(); SetzeBasisApiUrl(basisApiUrl); SetzeNutzerdaten(nutzername, passwort, datenbank, mandant); } - public void Shutdown() - { - base.Finalise(); - } public void SetzeBasisApiUrl(string basisApiUrl) { + AssertNotDisposed(); pyModManagement.set_base_url(basisApiUrl); } public void SetzeNutzerdaten(string nutzername, string passwort, string datenbank, string mandant) { + AssertNotDisposed(); using (Py.GIL()) { pyModManagement.set_credentials(nutzername, passwort, datenbank, mandant); } } public JsonStructs.UmsatzPrognoseAusgabe UmsatzprognoseDummy(int? firmaId, DateTime? buchungsDatum) { + AssertNotDisposed(); string pyJson; using (Py.GIL()) { @@ -48,6 +48,7 @@ namespace dopt.DeltaBarth } public JsonStructs.UmsatzPrognoseAusgabe Umsatzprognose(int? firmaId, DateTime? buchungsDatum) { + AssertNotDisposed(); string pyJson; using (Py.GIL()) { @@ -59,6 +60,7 @@ namespace dopt.DeltaBarth } protected string GetBaseApiUrl() { + AssertNotDisposed(); string pyJson; using (Py.GIL()) { @@ -68,6 +70,7 @@ namespace dopt.DeltaBarth } protected JsonStructs.Credentials GetCredentials() { + AssertNotDisposed(); string pyJson; using (Py.GIL()) { diff --git a/dopt.DeltaBarth/dopt.DeltaBarth.csproj b/dopt.DeltaBarth/dopt.DeltaBarth.csproj index ade9666..2eaa8c7 100644 --- a/dopt.DeltaBarth/dopt.DeltaBarth.csproj +++ b/dopt.DeltaBarth/dopt.DeltaBarth.csproj @@ -10,7 +10,7 @@ - + python\%(RecursiveDir)/%(FileName)%(Extension) PreserveNewest