46 lines
1.3 KiB
C#
46 lines
1.3 KiB
C#
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;
|
|
}
|
|
}
|
|
}
|