Scannt Dakota Files ein
This commit is contained in:
@@ -6,7 +6,8 @@
|
|||||||
<appSettings>
|
<appSettings>
|
||||||
<add key="GkvAbrechnungResultFolderPath" value="C:\GkvAbrechnung\Results\" />
|
<add key="GkvAbrechnungResultFolderPath" value="C:\GkvAbrechnung\Results\" />
|
||||||
<add key="GkvAbrechnungQueueFolderPath" value="C:\GkvAbrechnung\Queue\" />
|
<add key="GkvAbrechnungQueueFolderPath" value="C:\GkvAbrechnung\Queue\" />
|
||||||
<add key="DakotaPath" value="C:\Program Files (x86)\ITSG\dakotale\dakota30.exe" />
|
<add key="DakotaExePath" value="C:\Program Files (x86)\ITSG\dakotale\dakota30.exe" />
|
||||||
|
<add key="DakotaFolder" value="C:\dakotale\" />
|
||||||
<add key="ProcessWaitForExitMs" value="10000" />
|
<add key="ProcessWaitForExitMs" value="10000" />
|
||||||
<add key="LogPath" value="C:\GkvAbrechnung\Sender\log.txt" />
|
<add key="LogPath" value="C:\GkvAbrechnung\Sender\log.txt" />
|
||||||
</appSettings>
|
</appSettings>
|
||||||
|
|||||||
@@ -44,6 +44,7 @@
|
|||||||
<Reference Include="System.Xml" />
|
<Reference Include="System.Xml" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<Compile Include="DakotaSystemFile.cs" />
|
||||||
<Compile Include="Program.cs" />
|
<Compile Include="Program.cs" />
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|||||||
20
DakotaSender/DakotaSystemFile.cs
Normal file
20
DakotaSender/DakotaSystemFile.cs
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace DakotaSender
|
||||||
|
{
|
||||||
|
internal class DakotaSystemFile
|
||||||
|
{
|
||||||
|
public string Tenant { get; set; }
|
||||||
|
public long ProtokollOid { get; set; }
|
||||||
|
public string Datenannahmestelle { get; set; }
|
||||||
|
public string Transfernummer { get; set; }
|
||||||
|
|
||||||
|
public FileInfo Auftragsdatei { get; set; }
|
||||||
|
public FileInfo Nutzdatendatei { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -12,7 +12,10 @@ namespace DakotaSender
|
|||||||
{
|
{
|
||||||
class Program
|
class Program
|
||||||
{
|
{
|
||||||
|
static readonly string TEST_TENANT = "7375324044";
|
||||||
|
|
||||||
static int[] AcceptStatusCodes = new int[] { 0};
|
static int[] AcceptStatusCodes = new int[] { 0};
|
||||||
|
static int[] AcceptSendCodes = new int[] { 0 };
|
||||||
|
|
||||||
static void Main(string[] args)
|
static void Main(string[] args)
|
||||||
{
|
{
|
||||||
@@ -63,14 +66,121 @@ namespace DakotaSender
|
|||||||
{
|
{
|
||||||
Console.WriteLine("Ok");
|
Console.WriteLine("Ok");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
throw new Exception($"Statuscode {code} wird nicht akzeptiert");
|
throw new Exception($"Statuscode {code} wird nicht akzeptiert");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
static void ProcessFiles()
|
static void ProcessFiles()
|
||||||
{
|
{
|
||||||
|
Console.WriteLine("Scanne Dakota Dateien");
|
||||||
|
|
||||||
|
var toCheck = ScanQueueFolder();
|
||||||
|
|
||||||
|
if(toCheck is null)
|
||||||
|
{
|
||||||
|
Console.WriteLine("Keine Dakota Dateien gefunden.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var testCheck = toCheck.TryGetValue(TEST_TENANT, out var files);
|
||||||
|
|
||||||
|
if (!testCheck)
|
||||||
|
{
|
||||||
|
Console.WriteLine($"Keine Dakota Dateien für {TEST_TENANT} gefunden.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (var file in files)
|
||||||
|
{
|
||||||
|
CopyFile(file);
|
||||||
|
|
||||||
|
Console.WriteLine("Sende via Dakota.");
|
||||||
|
|
||||||
|
var code = ExecuteDakota("-e");
|
||||||
|
|
||||||
|
if (AcceptSendCodes.Contains(code))
|
||||||
|
{
|
||||||
|
Console.WriteLine("Ok");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw new Exception($"Statuscode {code} wird nicht akzeptiert");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static Dictionary<string, List<DakotaSystemFile>> ScanQueueFolder()
|
||||||
|
{
|
||||||
|
var queue = GetQueueFolder();
|
||||||
|
|
||||||
|
var files = queue.GetFiles("*.auf", SearchOption.TopDirectoryOnly);
|
||||||
|
|
||||||
|
var toCheck = new Dictionary<string, List<DakotaSystemFile>>();
|
||||||
|
foreach (var auft in files)
|
||||||
|
{
|
||||||
|
var nutz_fullname = auft.FullName.Substring(0, auft.FullName.Length - 4);
|
||||||
|
var nutz = new FileInfo(nutz_fullname);
|
||||||
|
|
||||||
|
if (!nutz.Exists)
|
||||||
|
{
|
||||||
|
Console.WriteLine($"{auft.FullName} wird ignoriert. {nutz.FullName} nicht vorhanden");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
Console.WriteLine($"{auft.FullName} gefunden.");
|
||||||
|
|
||||||
|
var split = nutz.Name.Split('_');
|
||||||
|
var tenant = split[0];
|
||||||
|
|
||||||
|
if(tenant != TEST_TENANT && tenant != "demo")
|
||||||
|
{
|
||||||
|
Console.WriteLine($"{auft.FullName} wird ignoriert. Tenant {tenant} nicht gültig.");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
tenant = TEST_TENANT;
|
||||||
|
}
|
||||||
|
|
||||||
|
var file = new DakotaSystemFile()
|
||||||
|
{
|
||||||
|
Auftragsdatei = auft,
|
||||||
|
Nutzdatendatei = nutz,
|
||||||
|
Tenant = tenant,
|
||||||
|
ProtokollOid = long.Parse(split[1]),
|
||||||
|
Datenannahmestelle = split[2],
|
||||||
|
Transfernummer = split[3]
|
||||||
|
};
|
||||||
|
|
||||||
|
if (!toCheck.ContainsKey(tenant))
|
||||||
|
toCheck.Add(tenant, new List<DakotaSystemFile>());
|
||||||
|
|
||||||
|
toCheck[tenant].Add(file);
|
||||||
|
}
|
||||||
|
|
||||||
|
return toCheck.Any() ? toCheck : null;
|
||||||
|
}
|
||||||
|
static void CopyFile(DakotaSystemFile file)
|
||||||
|
{
|
||||||
|
var transfernummer = file.Transfernummer;
|
||||||
|
var dest_folder = GetDakotaFolderDatenannahmestelle(file.Datenannahmestelle).FullName;
|
||||||
|
var sour_auftrags = file.Auftragsdatei.FullName;
|
||||||
|
var dest_auftrags = Path.Combine(dest_folder, transfernummer + ".auf");
|
||||||
|
var sour_nutz = file.Nutzdatendatei.FullName;
|
||||||
|
var dest_nutz = Path.Combine(dest_folder, transfernummer);
|
||||||
|
|
||||||
|
Console.Write($"Kopiere \"{sour_auftrags}\" nach \"{dest_auftrags}\". ");
|
||||||
|
|
||||||
|
File.Copy(sour_auftrags, dest_auftrags);
|
||||||
|
|
||||||
|
Console.WriteLine("Ok.");
|
||||||
|
|
||||||
|
Console.Write($"Kopiere \"{sour_nutz}\" nach \"{dest_nutz}\". ");
|
||||||
|
|
||||||
|
File.Copy(sour_nutz, dest_nutz);
|
||||||
|
|
||||||
|
Console.WriteLine("Ok.");
|
||||||
}
|
}
|
||||||
|
|
||||||
static int ExecuteDakota(string arg)
|
static int ExecuteDakota(string arg)
|
||||||
@@ -97,12 +207,27 @@ namespace DakotaSender
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static DirectoryInfo GetDakotaFolderDatenannahmestelle(string datenannahmestelle)
|
||||||
|
{
|
||||||
|
var folder = new DirectoryInfo(Path.Combine(GetDakotaFolder().FullName, "TP5Daten", datenannahmestelle));
|
||||||
|
|
||||||
|
if(!folder.Exists)
|
||||||
|
folder = new DirectoryInfo(Path.Combine(GetDakotaFolder().FullName, "TP5Daten", datenannahmestelle.Substring(0, datenannahmestelle.Length - 1)));
|
||||||
|
|
||||||
|
if (!folder.Exists)
|
||||||
|
throw new Exception($"Datenannahmestelle {datenannahmestelle} konnte nicht gefunden werden.");
|
||||||
|
|
||||||
|
return folder;
|
||||||
|
}
|
||||||
|
|
||||||
static string GetLogPath()
|
static string GetLogPath()
|
||||||
=> ConfigurationManager.AppSettings.Get("LogPath") ?? @"C:\GkvAbrechnung\Sender\log.txt";
|
=> ConfigurationManager.AppSettings.Get("LogPath") ?? @"C:\GkvAbrechnung\Sender\log.txt";
|
||||||
static int GetProcessWaitForExitMs()
|
static int GetProcessWaitForExitMs()
|
||||||
=> int.Parse(ConfigurationManager.AppSettings.Get("ProcessWaitForExitMs") ?? "10000");
|
=> int.Parse(ConfigurationManager.AppSettings.Get("ProcessWaitForExitMs") ?? "10000");
|
||||||
static FileInfo GetDakotaExe()
|
static FileInfo GetDakotaExe()
|
||||||
=> new FileInfo(ConfigurationManager.AppSettings.Get("DakotaPath") ?? @"C:\Program Files (x86)\ITSG\dakotale\dakota30.exe");
|
=> new FileInfo(ConfigurationManager.AppSettings.Get("DakotaExePath") ?? @"C:\Program Files (x86)\ITSG\dakotale\dakota30.exe");
|
||||||
|
static DirectoryInfo GetDakotaFolder()
|
||||||
|
=> new DirectoryInfo(ConfigurationManager.AppSettings.Get("DakotaFolder") ?? @"C:\dakotale\");
|
||||||
static DirectoryInfo GetQueueFolder()
|
static DirectoryInfo GetQueueFolder()
|
||||||
=> new DirectoryInfo(ConfigurationManager.AppSettings.Get("GkvAbrechnungQueueFolderPath") ?? @"C:\GkvAbrechnung\Queue\");
|
=> new DirectoryInfo(ConfigurationManager.AppSettings.Get("GkvAbrechnungQueueFolderPath") ?? @"C:\GkvAbrechnung\Queue\");
|
||||||
static DirectoryInfo GetResultFolder()
|
static DirectoryInfo GetResultFolder()
|
||||||
|
|||||||
Reference in New Issue
Block a user