Files
BeWoPlaner/DakotaSender/Config.cs

88 lines
3.2 KiB
C#

using System;
using System.Collections.Generic;
using System.Configuration;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DakotaSender
{
internal static class Config
{
public static DirectoryInfo ResultFolder { get; }
= new DirectoryInfo(ConfigurationManager.AppSettings.Get("GkvAbrechnungResultFolderPath") ?? @"C:\GkvAbrechnung\Results\");
public static DirectoryInfo QueueFolder { get; }
= new DirectoryInfo(ConfigurationManager.AppSettings.Get("GkvAbrechnungQueueFolderPath") ?? @"C:\GkvAbrechnung\Data\Queue\");
public static DirectoryInfo CopyFolder { get; }
= new DirectoryInfo(ConfigurationManager.AppSettings.Get("GkvAbrechnungCopyFolderPath") ?? @"C:\GkvAbrechnung\Data\Copy\");
public static DirectoryInfo FailedFolder { get; }
= new DirectoryInfo(ConfigurationManager.AppSettings.Get("GkvAbrechnungFailedFolderPath") ?? @"C:\GkvAbrechnung\Data\Failed\");
public static DirectoryInfo SuccessFolder { get; }
= new DirectoryInfo(ConfigurationManager.AppSettings.Get("GkvAbrechnungSuccessFolderPath") ?? @"C:\GkvAbrechnung\Data\Success\");
public static bool CopySave { get; }
= bool.Parse(ConfigurationManager.AppSettings.Get("GkvAbrechnungCopySave") ?? bool.TrueString);
public static bool FailedSave { get; }
= bool.Parse(ConfigurationManager.AppSettings.Get("GkvAbrechnungFailedSave") ?? bool.TrueString);
public static bool SuccessSave { get; }
= bool.Parse(ConfigurationManager.AppSettings.Get("GkvAbrechnungSuccessSave") ?? bool.TrueString);
public static FileInfo DakotaExe { get; }
= new FileInfo(ConfigurationManager.AppSettings.Get("DakotaExePath") ?? @"C:\Program Files (x86)\ITSG\dakotale\dakota30.exe");
public static DirectoryInfo DakotaFolder { get; }
= new DirectoryInfo(ConfigurationManager.AppSettings.Get("DakotaFolder") ?? @"C:\dakotale\");
public static int ProcessWaitForExitMs { get; }
= int.Parse(ConfigurationManager.AppSettings.Get("ProcessWaitForExitMs") ?? "10000");
public static string LogPath { get; }
= ConfigurationManager.AppSettings.Get("LogPath") ?? @"C:\GkvAbrechnung\Sender\log.txt";
public static string GkvSecretKey { get; set; } = ConfigurationManager.AppSettings.Get("GkvSecretKey");
public static bool IsDatenannahmestelleValid(string datenannahmestelle)
{
try
{
_ = LoadDatenannahmestelleFolder(datenannahmestelle);
}
catch (Exception)
{
return false;
}
return true;
}
public static DirectoryInfo LoadDatenannahmestelleFolder(string datenannahmestelle)
{
var folder = new DirectoryInfo(Path.Combine(Config.DakotaFolder.FullName, "TP5Daten", datenannahmestelle));
if (!folder.Exists)
folder = new DirectoryInfo(Path.Combine(Config.DakotaFolder.FullName, "TP5Daten", datenannahmestelle.Substring(0, datenannahmestelle.Length - 1)));
if (!folder.Exists)
throw new Exception($"Datenannahmestelle {datenannahmestelle} konnte nicht gefunden werden.");
return folder;
}
public static DirectoryInfo GetResultTenantFolder(string tenant)
{
var dirinfo = new DirectoryInfo(Path.Combine(Config.ResultFolder.FullName, tenant));
if (!dirinfo.Exists)
dirinfo.Create();
return dirinfo;
}
}
}