diff --git a/DakotaSender/App.config b/DakotaSender/App.config index 9d9b5098f..7abd3f046 100644 --- a/DakotaSender/App.config +++ b/DakotaSender/App.config @@ -4,6 +4,8 @@ + + @@ -12,12 +14,12 @@ - - - - - - + + + + + + diff --git a/DakotaSender/Config.cs b/DakotaSender/Config.cs index d3db362a3..244d9b635 100644 --- a/DakotaSender/Config.cs +++ b/DakotaSender/Config.cs @@ -10,6 +10,12 @@ namespace DakotaSender { internal static class Config { + public static string TenantsAllowTxtPath { get; } + = ConfigurationManager.AppSettings.Get("TenantsAllowTxtPath") ?? @"C:\GkvAbrechnung\Sender\tenants_allow.txt"; + + public static string TenantsTestTxtPath { get; } + = ConfigurationManager.AppSettings.Get("TenantsTestTxtPath") ?? @"C:\GkvAbrechnung\Sender\tenants_test.txt"; + public static DirectoryInfo ResultFolder { get; } = new DirectoryInfo(ConfigurationManager.AppSettings.Get("GkvAbrechnungResultFolderPath") ?? @"C:\GkvAbrechnung\Results\"); diff --git a/DakotaSender/DakotaSender.csproj b/DakotaSender/DakotaSender.csproj index 67c1688ef..8c7471ffc 100644 --- a/DakotaSender/DakotaSender.csproj +++ b/DakotaSender/DakotaSender.csproj @@ -45,6 +45,7 @@ + @@ -61,5 +62,9 @@ Shared + + + + \ No newline at end of file diff --git a/DakotaSender/DakotaSenderUtils.cs b/DakotaSender/DakotaSenderUtils.cs new file mode 100644 index 000000000..17183b64c --- /dev/null +++ b/DakotaSender/DakotaSenderUtils.cs @@ -0,0 +1,25 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace DakotaSender +{ + internal static class DakotaSenderUtils + { + public static bool IsTenantAllowed(string tenant) + { + var list = FileController.GetTenantsAllowedList(); + + return list.Contains(tenant); + } + + public static bool IsTenantTest(string tenant) + { + var list = FileController.GetTenantsTestList(); + + return list.Contains(tenant); + } + } +} diff --git a/DakotaSender/DakotaSystemFile.cs b/DakotaSender/DakotaSystemFile.cs index b24cea9ef..389d87709 100644 --- a/DakotaSender/DakotaSystemFile.cs +++ b/DakotaSender/DakotaSystemFile.cs @@ -9,6 +9,8 @@ namespace DakotaSender { internal class DakotaSystemFile { + public bool TestCase { get; set; } + public string Tenant { get; set; } public long ProtokollOid { get; set; } public long ApplicationUserOid { get; set; } diff --git a/DakotaSender/FileController.cs b/DakotaSender/FileController.cs index 319d5cab2..38bb8aa7d 100644 --- a/DakotaSender/FileController.cs +++ b/DakotaSender/FileController.cs @@ -56,7 +56,7 @@ namespace DakotaSender } internal static void CopyFile(string source, string destination) { - Program.Print($"Kopiere \"{source}\" nach \"{destination}\". "); + Program.Print($"- Kopiere \"{source}\" nach \"{destination}\". "); File.Copy(source, destination); @@ -77,7 +77,7 @@ namespace DakotaSender } internal static void DeleteFile(string file) { - Program.Print($"Lösche {file}. "); + Program.Print($"- Lösche {file}. "); File.Delete(file); @@ -99,5 +99,18 @@ namespace DakotaSender Program.PrintLine("Ok."); } + + internal static IEnumerable GetTenantsAllowedList() + { + var path = Config.TenantsAllowTxtPath; + + return File.ReadAllLines(path); + } + internal static IEnumerable GetTenantsTestList() + { + var path = Config.TenantsTestTxtPath; + + return File.ReadAllLines(path); + } } } diff --git a/DakotaSender/Program.cs b/DakotaSender/Program.cs index 3219c10c7..38a8914c4 100644 --- a/DakotaSender/Program.cs +++ b/DakotaSender/Program.cs @@ -195,16 +195,18 @@ namespace DakotaSender var datenannahmestelle = split[3]; var transfername = split[4]; - // Muss nachher nur entfernt werden, um andere zu testen - // Ggf Tool einbauen? - if (tenant != TEST_TENANT && tenant != TEST_TENANT_2) + var test = DakotaSenderUtils.IsTenantTest(tenant); + var allow = DakotaSenderUtils.IsTenantAllowed(tenant); + + if(!test && !allow) { - PrintLine($"{auft.FullName} wird ignoriert. Tenant {tenant} nicht gültig."); + PrintLine($"{auft.FullName} wird ignoriert. Tenant \'{tenant}\' ungültig."); return null; } var file = new DakotaSystemFile() { + TestCase = test, SourceAuftragsdatei = auft, SourceNutzdatendatei = nutz, Tenant = tenant, @@ -318,8 +320,14 @@ namespace DakotaSender PrintFileInfo(file); + if (file.TestCase) + { + success = true; + return "- TestCase. "; + } + if (!Config.IsDatenannahmestelleValid(file.Datenannahmestelle)) - return $"Datenannahmestelle {file.Datenannahmestelle} unbekannt."; + return $"- Datenannahmestelle {file.Datenannahmestelle} unbekannt."; FileController.CopyFileToDestination(file); @@ -339,7 +347,10 @@ namespace DakotaSender throw new Exception(); } - return message; + if (success) + return "Ok."; + else + return message; } static void Add2Results(DakotaSystemFile file, GkvTransferResultType type, string nachricht = null, string title = null) { diff --git a/DakotaSender/tenants_allows.txt b/DakotaSender/tenants_allows.txt new file mode 100644 index 000000000..5f282702b --- /dev/null +++ b/DakotaSender/tenants_allows.txt @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/DakotaSender/tenants_test.txt b/DakotaSender/tenants_test.txt new file mode 100644 index 000000000..5f282702b --- /dev/null +++ b/DakotaSender/tenants_test.txt @@ -0,0 +1 @@ + \ No newline at end of file