Compare commits
2 Commits
numpy_impo
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| 1b99564fa9 | |||
| 8df5731d08 |
@ -40,22 +40,22 @@ namespace dopt.DeltaBarth.Tests
|
|||||||
{
|
{
|
||||||
private const string absPath = @"A:\Arbeitsaufgaben\Delta-Barth\cs-wrapper\dopt.DeltaBarth";
|
private const string absPath = @"A:\Arbeitsaufgaben\Delta-Barth\cs-wrapper\dopt.DeltaBarth";
|
||||||
public TPlugin() : base(absPath) { }
|
public TPlugin() : base(absPath) { }
|
||||||
//public new DataObjects.Credentials GetCredentials()
|
public new DataObjects.Credentials GetCredentials()
|
||||||
//{
|
{
|
||||||
// return base.GetCredentials();
|
return base.GetCredentials();
|
||||||
//}
|
}
|
||||||
//public new string GetBaseApiUrl()
|
public new string GetBaseApiUrl()
|
||||||
//{
|
{
|
||||||
// return base.GetBaseApiUrl();
|
return base.GetBaseApiUrl();
|
||||||
//}
|
}
|
||||||
//public new string GetDataPath()
|
public new string GetDataPath()
|
||||||
//{
|
{
|
||||||
// return base.GetDataPath();
|
return base.GetDataPath();
|
||||||
//}
|
}
|
||||||
//public new void Setup(string datenPfad, string basisApiUrl)
|
public new void Setup(string datenPfad, string basisApiUrl)
|
||||||
//{
|
{
|
||||||
// base.Setup(datenPfad, basisApiUrl);
|
base.Setup(datenPfad, basisApiUrl);
|
||||||
//}
|
}
|
||||||
}
|
}
|
||||||
[TestClass]
|
[TestClass]
|
||||||
public sealed class PluginTest
|
public sealed class PluginTest
|
||||||
@ -78,201 +78,194 @@ namespace dopt.DeltaBarth.Tests
|
|||||||
test.Dispose();
|
test.Dispose();
|
||||||
}
|
}
|
||||||
[TestMethod]
|
[TestMethod]
|
||||||
public void DebugCall_Test()
|
public void Set_and_Obtain_Credentials_Test()
|
||||||
{
|
{
|
||||||
var test = new TPlugin();
|
var test = new TPlugin();
|
||||||
test.DebugCall();
|
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<int> comp_id = new List<int> { 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<int> comp_id = new List<int> { 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<int> comp_id = new List<int> { 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();
|
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<int> comp_id = new List<int> { 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<int> comp_id = new List<int> { 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<int> comp_id = new List<int> { 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();
|
|
||||||
//}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -88,10 +88,6 @@ namespace dopt.DeltaBarth
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
protected dynamic pyModPipeline;
|
protected dynamic pyModPipeline;
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Debug-Modul für Python-Umgebung
|
|
||||||
/// </summary>
|
|
||||||
protected dynamic pyDebug;
|
|
||||||
/// <summary>
|
|
||||||
/// Konstruktor der Plugin-Klasse.
|
/// Konstruktor der Plugin-Klasse.
|
||||||
/// Kann mit beliebigem Pfad zu einer Python-Runtime initialisiert werden.
|
/// Kann mit beliebigem Pfad zu einer Python-Runtime initialisiert werden.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -104,159 +100,141 @@ namespace dopt.DeltaBarth
|
|||||||
{
|
{
|
||||||
pyModManagement = Py.Import("delta_barth.management");
|
pyModManagement = Py.Import("delta_barth.management");
|
||||||
pyModPipeline = Py.Import("delta_barth.pipelines");
|
pyModPipeline = Py.Import("delta_barth.pipelines");
|
||||||
pyDebug = Py.Import("delta_barth._debug");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gibt Runtime-relevante Pfade in der Konsole aus
|
/// Initialisiert das Plugin mit allen relevanten Paramtern für die weitere Nutzung.
|
||||||
|
/// Diese Methode sollte nur einmal je Instanz genutzt werden.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string DebugCall()
|
/// <param name="datenPfad">Pfad zu einem Ordner, in dem Programmdaten ohne Bedenken dauerhaft abgelegt werden können.</param>
|
||||||
|
/// <param name="basisApiUrl">Basis-URL zum Zugriff auf die API. Dies muss eine vollständige URL sein inkl. der Route "/api".</param>
|
||||||
|
/// <param name="nutzername">Nutzername für die Datenbankanmeldung.</param>
|
||||||
|
/// <param name="passwort">Passwort für die Datenbankanmeldung.</param>
|
||||||
|
/// <param name="datenbank">Name der Datenbank, bei der die Anmeldung erfolgen soll.</param>
|
||||||
|
/// <param name="mandant">Mandant für die Datenbankanmeldung.</param>
|
||||||
|
public void Startup(string datenPfad, string basisApiUrl, string nutzername, string passwort, string datenbank, string mandant)
|
||||||
{
|
{
|
||||||
string infos;
|
AssertNotDisposed();
|
||||||
|
Setup(datenPfad, basisApiUrl);
|
||||||
|
SetzeNutzerdaten(nutzername, passwort, datenbank, mandant);
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Diese Methode erlaubt es, die relevanten Nutzerdaten zur Laufzeit des Plugins zu ändern.
|
||||||
|
/// Dies beinhaltet: Nutzername, Passwort, Datenbankname, Mandant
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="nutzername">Nutzername für die Datenbankanmeldung.</param>
|
||||||
|
/// <param name="passwort">Passwort für die Datenbankanmeldung.</param>
|
||||||
|
/// <param name="datenbank">Name der Datenbank, bei der die Anmeldung erfolgen soll.</param>
|
||||||
|
/// <param name="mandant">Mandant für die Datenbankanmeldung.</param>
|
||||||
|
public void SetzeNutzerdaten(string nutzername, string passwort, string datenbank, string mandant)
|
||||||
|
{
|
||||||
|
AssertNotDisposed();
|
||||||
|
using (Py.GIL()) {
|
||||||
|
pyModManagement.set_credentials(nutzername, passwort, datenbank, mandant);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Ausführung der Umsatzprognose-Pipeline mit Dummy-Daten.
|
||||||
|
/// Es werden keine API-Abrufe durchgeführt und somit auch keine Live-Daten genutzt.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="firmaId">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</param>
|
||||||
|
/// <param name="analyseBeginn">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.</param>
|
||||||
|
/// <returns cref="DataObjects.UmsatzPrognoseAusgabe">Umsatzprognose inkl. Status-Objekt zur Nachvollziehbarkeit etwaig aufgetretener Fehler.</returns>
|
||||||
|
/// <exception cref="PythonParsingException"></exception>
|
||||||
|
public DataObjects.UmsatzPrognoseAusgabe UmsatzprognoseDummy(int? firmaId, DateTime? analyseBeginn)
|
||||||
|
{
|
||||||
|
AssertNotDisposed();
|
||||||
|
string pyJson;
|
||||||
using (Py.GIL())
|
using (Py.GIL())
|
||||||
{
|
{
|
||||||
|
pyJson = pyModPipeline.pipeline_sales_forecast_dummy(firmaId, analyseBeginn);
|
||||||
infos = pyDebug.print_infos();
|
|
||||||
}
|
}
|
||||||
Console.WriteLine(infos);
|
var parsed = JsonSerializer.Deserialize<DataObjects.UmsatzPrognoseAusgabe>(pyJson) ?? throw new PythonParsingException("Could not correctly parse object from Python");
|
||||||
Console.WriteLine($"PyEngine - PYHOME: {PythonEngine.PythonHome}");
|
return parsed;
|
||||||
Console.WriteLine($"PyEngine - PYPATH: {PythonEngine.PythonPath}");
|
|
||||||
|
|
||||||
return infos;
|
|
||||||
}
|
}
|
||||||
///// <summary>
|
/// <summary>
|
||||||
///// Initialisiert das Plugin mit allen relevanten Paramtern für die weitere Nutzung.
|
/// Ausführung der Umsatzprognose-Pipeline mit Live-Daten.
|
||||||
///// Diese Methode sollte nur einmal je Instanz genutzt werden.
|
/// Es werden API-Abrufe durchgeführt und somit auch Live-Daten genutzt.
|
||||||
///// </summary>
|
/// Hierfür muss sichergestellt sein, dass der API-Server erreichbar und abrufbereit ist.
|
||||||
///// <param name="datenPfad">Pfad zu einem Ordner, in dem Programmdaten ohne Bedenken dauerhaft abgelegt werden können.</param>
|
/// </summary>
|
||||||
///// <param name="basisApiUrl">Basis-URL zum Zugriff auf die API. Dies muss eine vollständige URL sein inkl. der Route "/api".</param>
|
/// <param name="firmaIds">optional: Liste von Firmen-IDs, für die die Pipeline ausgeführt werden soll.
|
||||||
///// <param name="nutzername">Nutzername für die Datenbankanmeldung.</param>
|
/// Wird der Parameter nicht zur Verfügung gestellt, werden alle Firmen bzw. Kunden abgerufen</param>
|
||||||
///// <param name="passwort">Passwort für die Datenbankanmeldung.</param>
|
/// <param name="analyseBeginn">optional: Start-Datum, ab dem die Daten für die Erstellung des Prognosemodells genutzt werden.
|
||||||
///// <param name="datenbank">Name der Datenbank, bei der die Anmeldung erfolgen soll.</param>
|
/// Daten, die weiter in der Vergangenheit liegen, werden nicht berücksichtigt.
|
||||||
///// <param name="mandant">Mandant für die Datenbankanmeldung.</param>
|
/// Wird der Parameter nicht zur Verfügung gestellt, wird die gesamte Historie genutzt.</param>
|
||||||
//public void Startup(string datenPfad, string basisApiUrl, string nutzername, string passwort, string datenbank, string mandant)
|
/// <returns cref="DataObjects.UmsatzPrognoseAusgabe">Umsatzprognose inkl. Status-Objekt zur Nachvollziehbarkeit etwaig aufgetretener Fehler.</returns>
|
||||||
//{
|
/// <exception cref="PythonParsingException"></exception>
|
||||||
// AssertNotDisposed();
|
public DataObjects.UmsatzPrognoseAusgabe Umsatzprognose(List<int>? firmaIds, DateTime? analyseBeginn)
|
||||||
// Setup(datenPfad, basisApiUrl);
|
{
|
||||||
// SetzeNutzerdaten(nutzername, passwort, datenbank, mandant);
|
AssertNotDisposed();
|
||||||
//}
|
string pyJson;
|
||||||
///// <summary>
|
using (Py.GIL())
|
||||||
///// Diese Methode erlaubt es, die relevanten Nutzerdaten zur Laufzeit des Plugins zu ändern.
|
{
|
||||||
///// Dies beinhaltet: Nutzername, Passwort, Datenbankname, Mandant
|
pyJson = pyModPipeline.pipeline_sales_forecast(firmaIds, analyseBeginn);
|
||||||
///// </summary>
|
}
|
||||||
///// <param name="nutzername">Nutzername für die Datenbankanmeldung.</param>
|
var parsed = JsonSerializer.Deserialize<DataObjects.UmsatzPrognoseAusgabe>(pyJson) ?? throw new PythonParsingException("Could not correctly parse object from Python");
|
||||||
///// <param name="passwort">Passwort für die Datenbankanmeldung.</param>
|
return parsed;
|
||||||
///// <param name="datenbank">Name der Datenbank, bei der die Anmeldung erfolgen soll.</param>
|
}
|
||||||
///// <param name="mandant">Mandant für die Datenbankanmeldung.</param>
|
/// <summary>
|
||||||
//public void SetzeNutzerdaten(string nutzername, string passwort, string datenbank, string mandant)
|
/// Setup der Python-internen Umgebung
|
||||||
//{
|
/// </summary>
|
||||||
// AssertNotDisposed();
|
/// <param name="datenPfad">Pfad zu einem Ordner, in dem Programmdaten ohne Bedenken dauerhaft abgelegt werden können.</param>
|
||||||
// using (Py.GIL()) {
|
/// <param name="basisApiUrl">Basis-URL zum Zugriff auf die API. Dies muss eine vollständige URL sein inkl. der Route "/api".</param>
|
||||||
// pyModManagement.set_credentials(nutzername, passwort, datenbank, mandant);
|
protected void Setup(string datenPfad, string basisApiUrl)
|
||||||
// }
|
{
|
||||||
//}
|
AssertNotDisposed();
|
||||||
///// <summary>
|
using (Py.GIL())
|
||||||
///// Ausführung der Umsatzprognose-Pipeline mit Dummy-Daten.
|
{
|
||||||
///// Es werden keine API-Abrufe durchgeführt und somit auch keine Live-Daten genutzt.
|
pyModManagement.setup(datenPfad, basisApiUrl);
|
||||||
///// </summary>
|
}
|
||||||
///// <param name="firmaId">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</param>
|
/// <summary>
|
||||||
///// <param name="analyseBeginn">optional: Start-Datum, ab dem die Daten für die Erstellung des Prognosemodells genutzt werden.
|
/// Hole die konfigurierte API-Basis-URL aus der Python-Umgebung
|
||||||
///// Daten, die weiter in der Vergangenheit liegen, werden nicht berücksichtigt.
|
/// </summary>
|
||||||
///// Wird der Parameter nicht zur Verfügung gestellt, wird die gesamte Historie genutzt.</param>
|
/// <returns>konfigurierte Basis-URL</returns>
|
||||||
///// <returns cref="DataObjects.UmsatzPrognoseAusgabe">Umsatzprognose inkl. Status-Objekt zur Nachvollziehbarkeit etwaig aufgetretener Fehler.</returns>
|
protected string GetBaseApiUrl()
|
||||||
///// <exception cref="PythonParsingException"></exception>
|
{
|
||||||
//public DataObjects.UmsatzPrognoseAusgabe UmsatzprognoseDummy(int? firmaId, DateTime? analyseBeginn)
|
AssertNotDisposed();
|
||||||
//{
|
string pyJson;
|
||||||
// AssertNotDisposed();
|
using (Py.GIL())
|
||||||
// string pyJson;
|
{
|
||||||
// using (Py.GIL())
|
pyJson = (string)pyModManagement.get_base_url();
|
||||||
// {
|
}
|
||||||
// pyJson = pyModPipeline.pipeline_sales_forecast_dummy(firmaId, analyseBeginn);
|
return pyJson;
|
||||||
// }
|
}
|
||||||
// var parsed = JsonSerializer.Deserialize<DataObjects.UmsatzPrognoseAusgabe>(pyJson) ?? throw new PythonParsingException("Could not correctly parse object from Python");
|
/// <summary>
|
||||||
// return parsed;
|
/// Hole den konfigurierten Datenpfad zur Dateiverwaltung aus der Python-Umgebung
|
||||||
//}
|
/// </summary>
|
||||||
///// <summary>
|
/// <returns>konfigurierten Datenpfad</returns>
|
||||||
///// Ausführung der Umsatzprognose-Pipeline mit Live-Daten.
|
protected string GetDataPath()
|
||||||
///// 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.
|
AssertNotDisposed();
|
||||||
///// </summary>
|
string pyJson;
|
||||||
///// <param name="firmaIds">optional: Liste von Firmen-IDs, für die die Pipeline ausgeführt werden soll.
|
using (Py.GIL())
|
||||||
///// Wird der Parameter nicht zur Verfügung gestellt, werden alle Firmen bzw. Kunden abgerufen</param>
|
{
|
||||||
///// <param name="analyseBeginn">optional: Start-Datum, ab dem die Daten für die Erstellung des Prognosemodells genutzt werden.
|
pyJson = (string)pyModManagement.get_data_path();
|
||||||
///// Daten, die weiter in der Vergangenheit liegen, werden nicht berücksichtigt.
|
}
|
||||||
///// Wird der Parameter nicht zur Verfügung gestellt, wird die gesamte Historie genutzt.</param>
|
return pyJson;
|
||||||
///// <returns cref="DataObjects.UmsatzPrognoseAusgabe">Umsatzprognose inkl. Status-Objekt zur Nachvollziehbarkeit etwaig aufgetretener Fehler.</returns>
|
}
|
||||||
///// <exception cref="PythonParsingException"></exception>
|
/// <summary>
|
||||||
//public DataObjects.UmsatzPrognoseAusgabe Umsatzprognose(List<int>? firmaIds, DateTime? analyseBeginn)
|
/// Hole die konfigurierten Nutzerdaten zur API-Interaktion aus der Python-Umgebung
|
||||||
//{
|
/// </summary>
|
||||||
// AssertNotDisposed();
|
/// <returns cref="DataObjects.Credentials">konfigurierte Nutzerdaten</returns>
|
||||||
// string pyJson;
|
/// <exception cref="PythonParsingException"></exception>
|
||||||
// using (Py.GIL())
|
protected DataObjects.Credentials GetCredentials()
|
||||||
// {
|
{
|
||||||
// pyJson = pyModPipeline.pipeline_sales_forecast(firmaIds, analyseBeginn);
|
AssertNotDisposed();
|
||||||
// }
|
string pyJson;
|
||||||
// var parsed = JsonSerializer.Deserialize<DataObjects.UmsatzPrognoseAusgabe>(pyJson) ?? throw new PythonParsingException("Could not correctly parse object from Python");
|
using (Py.GIL())
|
||||||
// return parsed;
|
{
|
||||||
//}
|
pyJson = (string)pyModManagement.get_credentials();
|
||||||
///// <summary>
|
}
|
||||||
///// Setup der Python-internen Umgebung
|
|
||||||
///// </summary>
|
|
||||||
///// <param name="datenPfad">Pfad zu einem Ordner, in dem Programmdaten ohne Bedenken dauerhaft abgelegt werden können.</param>
|
|
||||||
///// <param name="basisApiUrl">Basis-URL zum Zugriff auf die API. Dies muss eine vollständige URL sein inkl. der Route "/api".</param>
|
|
||||||
//protected void Setup(string datenPfad, string basisApiUrl)
|
|
||||||
//{
|
|
||||||
// AssertNotDisposed();
|
|
||||||
// using (Py.GIL())
|
|
||||||
// {
|
|
||||||
// pyModManagement.setup(datenPfad, basisApiUrl);
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
///// <summary>
|
|
||||||
///// Hole die konfigurierte API-Basis-URL aus der Python-Umgebung
|
|
||||||
///// </summary>
|
|
||||||
///// <returns>konfigurierte Basis-URL</returns>
|
|
||||||
//protected string GetBaseApiUrl()
|
|
||||||
//{
|
|
||||||
// AssertNotDisposed();
|
|
||||||
// string pyJson;
|
|
||||||
// using (Py.GIL())
|
|
||||||
// {
|
|
||||||
// pyJson = (string)pyModManagement.get_base_url();
|
|
||||||
// }
|
|
||||||
// return pyJson;
|
|
||||||
//}
|
|
||||||
///// <summary>
|
|
||||||
///// Hole den konfigurierten Datenpfad zur Dateiverwaltung aus der Python-Umgebung
|
|
||||||
///// </summary>
|
|
||||||
///// <returns>konfigurierten Datenpfad</returns>
|
|
||||||
//protected string GetDataPath()
|
|
||||||
//{
|
|
||||||
// AssertNotDisposed();
|
|
||||||
// string pyJson;
|
|
||||||
// using (Py.GIL())
|
|
||||||
// {
|
|
||||||
// pyJson = (string)pyModManagement.get_data_path();
|
|
||||||
// }
|
|
||||||
// return pyJson;
|
|
||||||
//}
|
|
||||||
///// <summary>
|
|
||||||
///// Hole die konfigurierten Nutzerdaten zur API-Interaktion aus der Python-Umgebung
|
|
||||||
///// </summary>
|
|
||||||
///// <returns cref="DataObjects.Credentials">konfigurierte Nutzerdaten</returns>
|
|
||||||
///// <exception cref="PythonParsingException"></exception>
|
|
||||||
//protected DataObjects.Credentials GetCredentials()
|
|
||||||
//{
|
|
||||||
// AssertNotDisposed();
|
|
||||||
// string pyJson;
|
|
||||||
// using (Py.GIL())
|
|
||||||
// {
|
|
||||||
// pyJson = (string)pyModManagement.get_credentials();
|
|
||||||
// }
|
|
||||||
|
|
||||||
// DataObjects.Credentials? parsed = JsonSerializer.Deserialize<DataObjects.Credentials>(pyJson);
|
DataObjects.Credentials? parsed = JsonSerializer.Deserialize<DataObjects.Credentials>(pyJson);
|
||||||
// return parsed ?? throw new PythonParsingException("Could not correctly parse object from Python");
|
return parsed ?? throw new PythonParsingException("Could not correctly parse object from Python");
|
||||||
//}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -6,12 +6,12 @@
|
|||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
<PlatformTarget>x64</PlatformTarget>
|
<PlatformTarget>x64</PlatformTarget>
|
||||||
<Platforms>x64</Platforms>
|
<Platforms>x64</Platforms>
|
||||||
<Version>0.4.1-alpha1</Version>
|
<Version>0.4.1</Version>
|
||||||
<GenerateDocumentationFile>True</GenerateDocumentationFile>
|
<GenerateDocumentationFile>True</GenerateDocumentationFile>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="dopt.SharpPython" Version="0.4.2" />
|
<PackageReference Include="dopt.SharpPython" Version="0.4.4" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user