From 1905243a4abc18e8ac3a52a7b9b3603748839a43 Mon Sep 17 00:00:00 2001 From: dev-mkoebis Date: Thu, 23 Apr 2026 14:56:47 +0200 Subject: [PATCH 1/3] =?UTF-8?q?Verfolgung=20f=C3=BCr=20Dateien=20in=20bin?= =?UTF-8?q?=20und=20obj-Ordner=20gestoppt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Business/VorgangCM.cs | 2 +- MergeCMInpro.csproj | 38 +++- MergeCMInpro.sln | 30 ++- Program.cs | 420 +++++++++++++++++------------------------- 4 files changed, 229 insertions(+), 261 deletions(-) diff --git a/Business/VorgangCM.cs b/Business/VorgangCM.cs index d6fd9ab..a8da8f4 100644 --- a/Business/VorgangCM.cs +++ b/Business/VorgangCM.cs @@ -41,7 +41,7 @@ namespace MergeCMInpro.Business } catch (ArgumentOutOfRangeException ex) { - Console.WriteLine("ERROR: Wrong Path {0}. Please provide folder like '843.818 - 847.187 SAGA HD 28 2023_12_18'", Path.GetDirectoryName(v.AbsoluteFilePath)); + Console.WriteLine("ERROR: Wrong Path {0}. Please provide folder like '843.818 - 847.187 SAGA HD 28 2023_12_18'", Path.GetDirectoryName(v.AbsoluteFilePath),ex.Message); } catch (Exception ex) { diff --git a/MergeCMInpro.csproj b/MergeCMInpro.csproj index 6e2b31b..c4fa1b7 100644 --- a/MergeCMInpro.csproj +++ b/MergeCMInpro.csproj @@ -1,20 +1,44 @@ - + Exe netcoreapp3.1 + embedded + AnyCPU;x86 - - - + - - - + + tlbimp + 8 + 1 + 00020813-0000-0000-c000-000000000046 + 0 + false + true + + + + + + Always + + + + + + + + + + + + Always + diff --git a/MergeCMInpro.sln b/MergeCMInpro.sln index d19093e..53fe1e7 100644 --- a/MergeCMInpro.sln +++ b/MergeCMInpro.sln @@ -1,25 +1,41 @@  Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 17 -VisualStudioVersion = 17.1.32319.34 +VisualStudioVersion = 17.0.32126.317 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MergeCMInpro", "MergeCMInpro.csproj", "{F50C40BA-1861-48DD-B5E7-9638439E15E1}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MergeCMInpro", "MergeCMInpro.csproj", "{0798D653-CA13-4E5D-8A9E-4D8A3ADA4D1A}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MergeCMInpro.Test", "..\TestProject1\MergeCMInpro.Test.csproj", "{E67A9AAD-585E-4F23-8A85-665A49285C61}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU + Debug|x86 = Debug|x86 Release|Any CPU = Release|Any CPU + Release|x86 = Release|x86 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {F50C40BA-1861-48DD-B5E7-9638439E15E1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {F50C40BA-1861-48DD-B5E7-9638439E15E1}.Debug|Any CPU.Build.0 = Debug|Any CPU - {F50C40BA-1861-48DD-B5E7-9638439E15E1}.Release|Any CPU.ActiveCfg = Release|Any CPU - {F50C40BA-1861-48DD-B5E7-9638439E15E1}.Release|Any CPU.Build.0 = Release|Any CPU + {0798D653-CA13-4E5D-8A9E-4D8A3ADA4D1A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {0798D653-CA13-4E5D-8A9E-4D8A3ADA4D1A}.Debug|Any CPU.Build.0 = Debug|Any CPU + {0798D653-CA13-4E5D-8A9E-4D8A3ADA4D1A}.Debug|x86.ActiveCfg = Debug|x86 + {0798D653-CA13-4E5D-8A9E-4D8A3ADA4D1A}.Debug|x86.Build.0 = Debug|x86 + {0798D653-CA13-4E5D-8A9E-4D8A3ADA4D1A}.Release|Any CPU.ActiveCfg = Release|Any CPU + {0798D653-CA13-4E5D-8A9E-4D8A3ADA4D1A}.Release|Any CPU.Build.0 = Release|Any CPU + {0798D653-CA13-4E5D-8A9E-4D8A3ADA4D1A}.Release|x86.ActiveCfg = Release|x86 + {0798D653-CA13-4E5D-8A9E-4D8A3ADA4D1A}.Release|x86.Build.0 = Release|x86 + {E67A9AAD-585E-4F23-8A85-665A49285C61}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {E67A9AAD-585E-4F23-8A85-665A49285C61}.Debug|Any CPU.Build.0 = Debug|Any CPU + {E67A9AAD-585E-4F23-8A85-665A49285C61}.Debug|x86.ActiveCfg = Debug|Any CPU + {E67A9AAD-585E-4F23-8A85-665A49285C61}.Debug|x86.Build.0 = Debug|Any CPU + {E67A9AAD-585E-4F23-8A85-665A49285C61}.Release|Any CPU.ActiveCfg = Release|Any CPU + {E67A9AAD-585E-4F23-8A85-665A49285C61}.Release|Any CPU.Build.0 = Release|Any CPU + {E67A9AAD-585E-4F23-8A85-665A49285C61}.Release|x86.ActiveCfg = Release|Any CPU + {E67A9AAD-585E-4F23-8A85-665A49285C61}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {A8D0CA7E-16F2-47DA-92BA-34B69950C507} + SolutionGuid = {512F540C-4375-4C7D-B8F4-9D45AE50AA94} EndGlobalSection EndGlobal diff --git a/Program.cs b/Program.cs index 4de573d..3e08634 100644 --- a/Program.cs +++ b/Program.cs @@ -1,278 +1,206 @@ -using System; +using MergeCMInpro.Business; +using MergeCMInpro.Data; +using NLog; +using System; using System.IO; -using Scan2Compress.Business; using System.Linq; -using System.Data.SqlClient; -using System.Collections.Generic; -using System.Text; -using System.Threading; +using Sentry; namespace MergeCMInpro { - class Program + static class Program { - static List vorgängeCM = new List(); - static List vorgängeInpro = new List(); + private static readonly Logger _logger = NLog.LogManager.GetCurrentClassLogger(); - static string destinationFilePath = @"\\asbgvp02\Archivtransfer\"; - - static string constring = "Data Source=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=dborap01.stadtdo.de)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=bgvp.stadtdo.de)));user id=leser;password=leser;"; - - static string csvPath = Path.Combine(Directory.GetFiles(Environment.CurrentDirectory, "*.csv").FirstOrDefault()); - - //static string csvPath = Path.Combine(Directory.GetFiles(@"S:\Bauvorhaben\0_SAGA\815.922 - 819.917 SAGA HD 21 2021_09_27", "*.csv").FirstOrDefault()); - - static string pathOutputFileCM = Path.Combine(Directory.GetParent(csvPath).FullName, "outputCM.csv"); - static string pathOutputFileInpro = Path.Combine(Directory.GetParent(csvPath).FullName, "outputInpro.csv"); + static string csvPath = String.Empty; static void Main(string[] args) - { - Console.WriteLine("Working, please wait... or get yourself a tea."); - SplitRow(csvPath); - using (StreamWriter sw = new StreamWriter(pathOutputFileCM)) - { - foreach (var item in vorgängeCM) - { - sw.WriteLine(item.ToString()); - } - } - using (StreamWriter sw = new StreamWriter(pathOutputFileInpro)) - { - foreach (var item in vorgängeInpro) - { - sw.WriteLine(item.ToString()); - } - } - Console.WriteLine("{0} created.", pathOutputFileCM); - Console.WriteLine("{0} created.", pathOutputFileInpro); - Console.WriteLine(""); - Console.WriteLine("You may close this window now."); - Console.ReadLine(); - } - - public static void SplitRow(string path) - { - int count = 0; - int countRows = File.ReadAllLines(path).Length; - using (StreamReader sr = new StreamReader(path, System.Text.Encoding.GetEncoding("ISO-8859-1"))) - { - string[] arr = new string[10]; - while (!sr.EndOfStream) - { - count++; - if (count != countRows) - { - Console.Write("\r{0}/{1} ", count, countRows); - } - else - { - Console.WriteLine("\r{0}/{1} ", count, countRows); - } - arr = sr.ReadLine().Split(";"); - Vorgang v = new Vorgang(arr[0], arr[2], string.Concat(arr[5], " Teil ", arr[6]), arr[6], arr[8]); - v.AbsoluteFilePath = GetFullFilePath(arr[8]); //arr[7]=jpm-Dateien - if (v.AbsoluteFilePath == string.Empty) - { - Console.WriteLine("Datei {0} nicht gefunden", path); - return; - } - v.CreationDate = GetCreationDate(v.AbsoluteFilePath); - - ConnectAndExecute(v); - - //Backup JPM-Files - var z = ExtractFilePath(v.AbsoluteFilePath); - var folder = string.Concat("Sicherungen jpm ", z.ElementAt(0), " bis ", z.ElementAt(2)); - CopySourceFileToDestination(GetFullFilePath(arr[7]), Path.Combine(destinationFilePath, "Archiv", folder), arr[7]); - } - } - } - - static string[] ExtractFilePath(string path) - { - var splittedAbsolutePath = path.Split("\\").SkipLast(2).LastOrDefault(); - return splittedAbsolutePath.Split(" "); - } - - - public static DateTime GetCreationDate(string file) - { - FileInfo fi = new FileInfo(file); - return fi.CreationTime; - } - - public static string GetFullFilePath(string file) - { - string currentDirectory = Directory.GetParent(csvPath).FullName; //Directory.GetCurrentDirectory(); - string res = string.Empty; - res = Directory.GetFiles(currentDirectory, file, SearchOption.AllDirectories).FirstOrDefault(); - if (res == null) - return string.Empty; - else - { - //res = Directory.GetParent(res).Parent.Name.Split('\\').LastOrDefault(); - return res; - } - } - - public static string GenerateQuery(string az) - { - string sqlQuery = "SELECT " - + "INPROP.PMGTVVORGANG.VORGANGID, " - + "INPROP.PMGTVVORGANG.VORGANGDEFID, " - + "INPROP.PMVBCHECKLIST.CHECKLISTID, " - + "INPROP.PMVBCHECKLIST.DESCRIPTION, " - + "INPROP.PMGTVVORGANG.STRASSE1ID, " - + "INPROP.PMGTVVORGANG.STRASSE1, " - + "INPROP.PMGTVVORGANG.HAUSNUMMER1, " - + "INPROP.PMGTVVORGANG.HSNRVON, " - + "INPROP.PMGTVVORGANG.HSNRVONZUSATZ, " - + "INPROP.PMGTVVORGANG.HSNRBIS, " - + "INPROP.PMGTVVORGANG.HSNRBISZUSATZ, " - + "INPROP.PMGTVVORGANG.STRASSE2, " - + "INPROP.PMGTVVORGANG.HAUSNUMMER2, " - + "INPROP.PMGTVVORGANG.DATUMEINGANG, " - + "INPROP.PMGTVVORGANG.DATUMABSCHLUSS " - + "FROM INPROP.PMGTVVORGANG " - + "INNER JOIN INPROP.PMVBCHECKLIST ON INPROP.PMGTVVORGANG.CHECKID = INPROP.PMVBCHECKLIST.CHECKLISTID " - + "WHERE INPROP.PMGTVVORGANG.VORGANGID='" + az + "'"; - return sqlQuery; - } - - public static void ConnectAndExecute(Vorgang v) { try { - using (Oracle.ManagedDataAccess.Client.OracleConnection oracle = new Oracle.ManagedDataAccess.Client.OracleConnection()) + CallSentry(); + Console.ForegroundColor = ConsoleColor.White; + + //productive + csvPath = Path.Combine(Directory.GetFiles(Environment.CurrentDirectory, "*.csv").FirstOrDefault()); + + //testing + //csvPath = Path.Combine(Directory.GetFiles(@"\\fsdeg002\DatenStA61_S\Bauvorhaben\0_SAGA\839.867 - 843.817 SAGA HD 27 2023_11_08", "*.csv").FirstOrDefault()); + //csvPath = Path.Combine(Directory.GetFiles(@"C:\Testing\MergeInpro", "*.csv").FirstOrDefault()); + //csvPath = Path.Combine(Directory.GetFiles(@"C:\TEMP\SAGA\839.867 - 843.817 SAGA HD 27 2023_11_08", "*.csv").FirstOrDefault()); + //csvPath = Path.Combine(Directory.GetFiles(@"C:\TEMP\SAGA\843.818 - 847.187 SAGA HD 28 2023_12_18", "*.csv").FirstOrDefault()); + csvPath = Path.Combine(Directory.GetFiles(@"D:\TestData\MergeCMInpro", "*.csv").FirstOrDefault()); + + string pathOutputFileCM = Path.Combine(Directory.GetParent(csvPath).FullName, "outputCM.csv"); + string pathOutputFileInpro = Path.Combine(Directory.GetParent(csvPath).FullName, "outputInpro.csv"); + string pathOutputFileStandort = Path.Combine(Directory.GetParent(csvPath).FullName, "outputStandort.csv"); + + if (CheckFileExist()) { - oracle.ConnectionString = constring; + Console.ForegroundColor = ConsoleColor.Yellow; + Console.WriteLine("WARNING: import files already exist."); + Console.ResetColor(); + return; + } - string sqlQuery = GenerateQuery(v.Aktenzeichen); + + if(!CheckFolderStructure(csvPath)) + { + Console.ForegroundColor = ConsoleColor.Yellow; + Console.WriteLine("WARNING: folder structure wrong. Please note folder with name '{0}' has to contain all pdf files.", Path.GetFileNameWithoutExtension(csvPath)); + Console.ResetColor(); + return; + } - using (Oracle.ManagedDataAccess.Client.OracleCommand com = new Oracle.ManagedDataAccess.Client.OracleCommand(sqlQuery, oracle)) + var config = File.ReadLines(@".\config.txt").ToArray(); + DataOperations.conString = config[0]; + DataOperations.kanalAktePath = config[2]; + DataOperations.csvPath = csvPath; + + if (!File.Exists(DataOperations.kanalAktePath)) + throw new FileNotFoundException("Kanalaktendatei nicht gefunden."); + + //Testing + //string archivNetPath = Path.Combine(@"C:\TEMP\ArchivPath"); + + //productive + string archivNetPath = Path.Combine(config[1]); + + Console.WriteLine("Working, please wait... or get yourself a tea."); + + FileOperations.SplitRow(csvPath, archivNetPath); + + //CM + using (StreamWriter sw = new StreamWriter(pathOutputFileCM)) + { + foreach (var item in DataOperations.vorgängeCM) { - oracle.Open(); - using (Oracle.ManagedDataAccess.Client.OracleDataReader reader = com.ExecuteReader()) - { - while (reader.Read()) - { - v.Checkliste = reader.GetString(2); - v.VorgangsDefinition = reader.GetString(1); - v.BeschreibungVorgang = reader.GetString(3); - v.Eingangsdatum = Convert.ToDateTime(reader.GetValue(13).ToString()); - v.Enddatum = Convert.ToDateTime(reader.GetValue(14).ToString()); - //var date = reader.GetValue(12); - //if (date.ToString() == string.Empty) - // v.Enddatum = DateTime.Now; - //else - // v.Enddatum = Convert.ToDateTime(reader.GetValue(12).ToString()); - var strasseId = reader.GetValue(4); - if (strasseId.ToString() == "") - v.IdStrasse = "null"; - else - v.IdStrasse = strasseId.ToString(); - v.Strasse1 = reader.GetValue(5).ToString().Trim(); - v.Hausnummer1Von = reader.GetValue(6).ToString(); - v.HsNrVonZusatz = reader.GetValue(8).ToString(); - v.Hausnummer1Bis = reader.GetValue(9).ToString(); - v.HsNrBisZusatz = reader.GetValue(10).ToString(); - v.Strasse2 = reader.GetValue(11).ToString(); - v.Hausnummer2 = reader.GetValue(12).ToString(); - } - - //CM - StringBuilder sbCM = new StringBuilder(); - sbCM.Append(string.Concat(v.Id, ";")); - sbCM.Append(string.Concat(v.Aktenzeichen, ";")); - sbCM.Append(string.Concat(v.VorgangsDefinition.Trim(), ';')); - sbCM.Append(string.Concat(v.BeschreibungVorgang, ";")); - sbCM.Append(string.Concat(v.Strasse1, ";")); - sbCM.Append(string.Concat(string.Concat(v.Hausnummer1Von, " ", v.HsNrVonZusatz).Trim(), ';')); - sbCM.Append(string.Concat(v.Strasse2.Trim(), ";")); - sbCM.Append(string.Concat(string.Concat(v.Hausnummer1Bis, " ", v.HsNrBisZusatz).Trim(), ';')); - sbCM.Append(string.Concat(v.Enddatum.ToShortDateString(), ";")); - sbCM.Append(string.Concat(v.FameId, ";")); - sbCM.Append(string.Concat(v.CreationDate.ToShortDateString(), ";")); - - //Langbezeichnung - string documentType = CheckedForDocumentType(v.DocType.Split(" ").FirstOrDefault()); - sbCM.Append(string.Concat(documentType, " ", string.Concat(v.DocType.Split(" ").FirstOrDefault().Substring(0, 1), v.DocType.Split(" ").FirstOrDefault().Substring(1).ToLower()), " ", v.DocType.Split(" ", 2).Skip(1).FirstOrDefault(), ";")); - - sbCM.Append(string.Concat(v.AbsoluteFilePath.Split('\\').SkipLast(2).LastOrDefault(), " ", v.Id, ";")); - - sbCM.Append(string.Concat(v.FameId, ".pdf", ";")); - vorgängeCM.Add(sbCM.ToString()); - - StringBuilder sbInpro = new StringBuilder(); - sbInpro.Append(string.Concat(string.Empty, ";"));//Barcode - sbInpro.Append(string.Concat(v.Aktenzeichen, ";"));//Vorgangsnummer - sbInpro.Append(string.Concat(string.Empty, ";"));//Abteilung - sbInpro.Append(string.Concat(v.IdStrasse, ";"));//Strasse1ID - sbInpro.Append(string.Concat(v.Strasse1, ";").Trim());//Strasse1 - sbInpro.Append(string.Concat(v.Hausnummer1Von, ";").Trim());//Hausnummer1 - sbInpro.Append(string.Concat(v.Hausnummer1Von, ";").Trim());//Hausnummer1Von - sbInpro.Append(string.Concat(v.HsNrVonZusatz, ";").Trim());//Hausnummer1VonZusatz - sbInpro.Append(string.Concat(v.Hausnummer1Bis, ";").Trim());//Hausnummer1Bis - sbInpro.Append(string.Concat(v.HsNrBisZusatz, ";").Trim());//Hausnummer1BisZusatz - sbInpro.Append(string.Concat(v.Strasse2, ";").Trim());//Strasse2 - sbInpro.Append(string.Concat(v.Hausnummer2, ";").Trim());//Hausnummer2 - sbInpro.Append(string.Concat(v.DocType, ";"));//Bezeichnung1 - sbInpro.Append(string.Concat(v.Eingangsdatum.ToShortDateString(), ";"));//Eingangsdatum - sbInpro.Append(string.Concat(string.Empty, ";"));//Beschreibung1 - sbInpro.Append(string.Concat(string.Empty, ";")); //Beschreibung2 - sbInpro.Append(string.Concat(string.Empty, ";"));//Bezeichnung2 - sbInpro.Append(string.Concat(v.DocsSZ, ";"));//Bezeichnung3 - sbInpro.Append(string.Concat(v.FameId, ".pdf", ";"));//Dateiname - sbInpro.Append(string.Concat(v.FameId, ";"));//FameId - sbInpro.Append(string.Concat(v.VorgangsDefinition, ";").Trim());//Vorgangsart - sbInpro.Append(string.Concat(v.Checkliste, ";").Trim());//Checkliste - sbInpro.Append(string.Concat(v.Enddatum.ToShortDateString(), ";"));//Abschlussdatum - sbInpro.Append(string.Concat(string.Concat(documentType, " ", string.Concat(v.DocType.Split(" ").FirstOrDefault().Substring(0, 1), v.DocType.Split(" ").FirstOrDefault().Substring(1).ToLower()), " ", v.DocType.Split(" ", 2).Skip(1).FirstOrDefault(), ";")));//Langbezeichnung - vorgängeInpro.Add(sbInpro.ToString()); - - var tmp = ExtractFilePath(v.AbsoluteFilePath); - var destFolder = string.Concat("pdf", tmp.ElementAt(5), " ", tmp.ElementAt(0), " bis ", tmp.ElementAt(1), " ", tmp.ElementAt(2)); - CopySourceFileToDestination(v.AbsoluteFilePath, destFolder, string.Concat(v.FameId, ".pdf")); - } + sw.WriteLine(item.ToString()); } } + + //Inpro + using (StreamWriter sw = new StreamWriter(pathOutputFileInpro)) + { + foreach (var item in DataOperations.vorgängeInpro) + { + sw.WriteLine(item.ToString()); + } + } + + //Standort + using (StreamWriter sw = new StreamWriter(pathOutputFileStandort)) + { + foreach (var item in DataOperations.vorgängeStandort.Distinct()) + { + sw.WriteLine(item.ToString()); + } + } + + + Console.ForegroundColor = ConsoleColor.Green; + Console.WriteLine("{0} created.", pathOutputFileCM); + + FileInfo fi = new FileInfo(pathOutputFileInpro); + if(fi.Length!=0) + { + Console.WriteLine("{0} created.", pathOutputFileInpro); + Console.WriteLine("{0} created.", pathOutputFileStandort); + } + + Console.ResetColor(); + + //#region Backup JPM-Files + //Console.WriteLine("Start copying jpm-files, please wait..."); + //FileInfo fi = new FileInfo(csvPath); + //FileOperations.CopyJPMFilesToDestination(fi.Directory.FullName, archivNetPath); + //Console.WriteLine(""); + //Console.ForegroundColor = ConsoleColor.Green; + //Console.WriteLine("Done. You may close this window now."); + //#endregion + + Console.ReadLine(); + + } + catch (DirectoryNotFoundException) + { + Console.ForegroundColor = ConsoleColor.Red; + Console.WriteLine("ERROR: source directory not found."); + Console.ReadLine(); + } + catch (FileNotFoundException ex) + { + Console.ForegroundColor = ConsoleColor.Red; + Console.WriteLine("ERROR: " + ex.Message); + Console.ReadLine(); } catch (Exception ex) { - Console.WriteLine("ERROR fetching data for {0}:{1}", v.Aktenzeichen, ex.Message); + Console.ForegroundColor = ConsoleColor.Red; + Console.WriteLine("ERROR: unknown error occured. Maybe no csv-File? Please check!\r\n{0}", ex.InnerException); + Console.ReadLine(); } } - static string CheckedForDocumentType(string value) + static string CallSentry() { - switch (value) + try { - case "SCHRIFTVERKEHR": - value = "01"; - break; - case "ZEICHNUNGEN": - value = "02"; - break; - case "STATIK": - value = "03"; - break; - case "SONSTIGES": - value = "04"; - break; - case "GENEHMIGUNG": - value = "05"; - break; - default: - break; + var res = SentrySdk.Init(options => + { + // A Sentry Data Source Name (DSN) is required. + // See https://docs.sentry.io/product/sentry-basics/dsn-explainer/ + // You can set it in the SENTRY_DSN environment variable, or you can set it in code here. + options.Dsn = ""; + + // When debug is enabled, the Sentry client will emit detailed debugging information to the console. + // This might be helpful, or might interfere with the normal operation of your application. + // We enable it here for demonstration purposes when first trying Sentry. + // You shouldn't do this in your applications unless you're troubleshooting issues with Sentry. + options.Debug = true; + + // This option is recommended. It enables Sentry's "Release Health" feature. + options.AutoSessionTracking = true; + }); + return res.ToString(); + + } + catch (Exception ex) + { + SentrySdk.CaptureMessage("Something went wrong"); + return ex.Message; } - return value; } - static void CopySourceFileToDestination(string sourceFilePath, string destFolderName, string destFileName) + + private static bool CheckFolderStructure(string csvName) { - string destPath = Path.Combine(destinationFilePath, destFolderName); - if (!Directory.Exists(destPath)) - Directory.CreateDirectory(destPath); - File.Copy(sourceFilePath, Path.Combine(destPath, destFileName),true); + string fileName = Path.GetFileNameWithoutExtension(csvName); + bool result = false; + string dir = Path.GetDirectoryName(csvName); + DirectoryInfo di = new DirectoryInfo(dir); + if(di.GetFiles("*.pdf").Length > 0) + { + return result; + } + if (Directory.Exists(Path.Combine(dir, fileName))) + { + result = true; + } + return result; + } + + public static bool CheckFileExist() + { + FileInfo fi = new FileInfo(Path.Combine(Directory.GetParent(csvPath).FullName, "outputInpro.csv")); + + if ((File.Exists(Path.Combine(Directory.GetParent(csvPath).FullName, "outputInpro.csv")) && fi.Length!=0) || File.Exists(Path.Combine(Directory.GetParent(csvPath).FullName, "outputCM.csv"))) + { + return true; + } + else + { + return false; + } } } } From 7e3e99ad20195e6a93f4f8738304dffe1fbd9f57 Mon Sep 17 00:00:00 2001 From: dev-mkoebis Date: Thu, 23 Apr 2026 14:59:28 +0200 Subject: [PATCH 2/3] =?UTF-8?q?Server=20in=20config.txt=20angepasst=20Datu?= =?UTF-8?q?m=20in=20Standortklasse=20angepasst=20header=20eingef=C3=BCgt?= =?UTF-8?q?=20Testing=20hinzugef=C3=BCgt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Business/FileOperations.cs | 33 ++-------- Business/VorgangCM.cs | 22 ++----- Business/VorgangStandort.cs | 3 +- MergeCMInpro.csproj | 5 +- MergeCMInpro.sln | 18 +++--- Program.cs | 122 ++++++++---------------------------- 6 files changed, 49 insertions(+), 154 deletions(-) diff --git a/Business/FileOperations.cs b/Business/FileOperations.cs index f5ce93d..6a921c5 100644 --- a/Business/FileOperations.cs +++ b/Business/FileOperations.cs @@ -101,7 +101,6 @@ namespace MergeCMInpro.Business { int count = 0; int countRows = File.ReadAllLines(path).Length; - using (StreamReader sr = new StreamReader(path, System.Text.Encoding.GetEncoding("ISO-8859-1"))) { string[] arr = new string[10]; @@ -117,44 +116,22 @@ namespace MergeCMInpro.Business Console.WriteLine("\r{0}/{1} ", count, countRows); } arr = sr.ReadLine().Split(";"); - bool jpmFiles = arr[2].Contains(".jpm"); + //Erstelle Basis-Vorgang aus den SAGA-Daten Vorgang v; if(arr[2].Contains("70/")) - { + { //arr[0]=ID z.B. 815922, arr[2]=AZ z.B. 61/5-3-048105, arr[3]=Strasse z.B. Westheck, arr[5]=DocType z.B. SCHRIFTVERKEHR, arr[6]=Teil z.B. 001, arr[8]=PDF z.B. 815922.pdf - if (jpmFiles) - { - v = new Vorgang(arr[0], arr[2], string.Concat(arr[5], " Teil ", arr[6]), arr[6], arr[7], arr[3], arr[4]); - } - else - { - v = new Vorgang(arr[0], arr[2], string.Concat(arr[5], " Teil ", arr[6]), arr[6], arr[7], arr[3], arr[4]); - } + v = new Vorgang(arr[0], arr[2], string.Concat(arr[5], " Teil ", arr[6]), arr[6], arr[8], arr[3],arr[4]); } else { - if (jpmFiles) - { - v = new Vorgang(arr[0], arr[2], string.Concat(arr[5], " Teil ", arr[6]), arr[6], arr[8]); - } - else - { - v = new Vorgang(arr[0], arr[2], string.Concat(arr[5], " Teil ", arr[6]), arr[6], arr[7]); - } + v = new Vorgang(arr[0], arr[2], string.Concat(arr[5], " Teil ", arr[6]), arr[6], arr[8]); } #region PDF - if(jpmFiles) - { - v.AbsoluteFilePath = GetFullFilePath(arr[8], path); //arr[7]=jpm-Dateien - } - else - { - v.AbsoluteFilePath = GetFullFilePath(arr[7], path); - } - + v.AbsoluteFilePath = GetFullFilePath(arr[8], path); //arr[7]=jpm-Dateien if (v.AbsoluteFilePath == string.Empty) { Console.WriteLine("Keine PDF-Dateien gefunden."); diff --git a/Business/VorgangCM.cs b/Business/VorgangCM.cs index a8da8f4..1cec134 100644 --- a/Business/VorgangCM.cs +++ b/Business/VorgangCM.cs @@ -14,7 +14,7 @@ namespace MergeCMInpro.Business { } - + public override string GenerateVorgang(Vorgang v) { StringBuilder sbCM = new StringBuilder(); @@ -32,28 +32,16 @@ namespace MergeCMInpro.Business //Langbezeichnung string documentType = FileOperations.LowerDocumentType(v.DocType.Split(" ").FirstOrDefault()); sbCM.Append(string.Concat(documentType, " ", string.Concat(v.DocType.Split(" ").FirstOrDefault().Substring(0, 1), v.DocType.Split(" ").FirstOrDefault().Substring(1).ToLower()), " ", v.DocType.Split(" ", 2).Skip(1).FirstOrDefault(), ";")); - - string langBez = string.Empty; - try - { - langBez = base.GenerateLangbezeichnungFromPath(v.AbsoluteFilePath); - } - catch (ArgumentOutOfRangeException ex) - { - Console.WriteLine("ERROR: Wrong Path {0}. Please provide folder like '843.818 - 847.187 SAGA HD 28 2023_12_18'", Path.GetDirectoryName(v.AbsoluteFilePath),ex.Message); - } - catch (Exception ex) - { - Console.WriteLine(ex.Message); - } - //string langBez = base.GenerateLangbezeichnungFromPath(v.AbsoluteFilePath); + string langBez = base.GenerateLangbezeichnungFromPath(v.AbsoluteFilePath); sbCM.Append(string.Concat(langBez, ";")); sbCM.Append(string.Concat(v.FameId, ".pdf")); return sbCM.ToString(); - } + } + + } } diff --git a/Business/VorgangStandort.cs b/Business/VorgangStandort.cs index c5a0275..62faf2e 100644 --- a/Business/VorgangStandort.cs +++ b/Business/VorgangStandort.cs @@ -37,11 +37,12 @@ namespace MergeCMInpro.Business sbStandort.Append(string.Concat(this.CID, ";"));//CID sbStandort.Append(string.Concat(v.Aktenzeichen, ";"));//Vorgangsnummer sbStandort.Append(string.Concat(this.Sachbearbeiter, ";"));//Sachbearbeiter + sbStandort.Append(string.Concat(this.Bemerkung, ";"));//Bemerkung sbStandort.Append(string.Concat(this.Standort, ";"));//Standort sbStandort.Append(string.Concat(this.Entnahmedatum.ToShortDateString(), ";"));//Entnahmedatum -> Datum Tabelle sbStandort.Append(string.Concat(this.Entnahmezeit, ";"));//Entnahmezeit sbStandort.Append(string.Concat(this.Entnahmedatum.ToShortDateString(), ";"));//Rückgabedatum=Entnahmedatum - sbStandort.Append(string.Concat(this.Entnahmezeit, ";"));//Rückgabezeit=Entnahmezeit + sbStandort.Append(this.Entnahmezeit);//Rückgabezeit=Entnahmezeit return sbStandort.ToString(); } diff --git a/MergeCMInpro.csproj b/MergeCMInpro.csproj index c4fa1b7..3cd4911 100644 --- a/MergeCMInpro.csproj +++ b/MergeCMInpro.csproj @@ -30,9 +30,8 @@ - - - + + diff --git a/MergeCMInpro.sln b/MergeCMInpro.sln index 53fe1e7..f7ff4dc 100644 --- a/MergeCMInpro.sln +++ b/MergeCMInpro.sln @@ -5,7 +5,7 @@ VisualStudioVersion = 17.0.32126.317 MinimumVisualStudioVersion = 10.0.40219.1 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MergeCMInpro", "MergeCMInpro.csproj", "{0798D653-CA13-4E5D-8A9E-4D8A3ADA4D1A}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MergeCMInpro.Test", "..\TestProject1\MergeCMInpro.Test.csproj", "{E67A9AAD-585E-4F23-8A85-665A49285C61}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MergeCMInpro.Testing", "..\MergeCMInpro.Testing\MergeCMInpro.Testing.csproj", "{F0F62B9F-4802-44AE-BFEC-7E20285ED2BE}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -23,14 +23,14 @@ Global {0798D653-CA13-4E5D-8A9E-4D8A3ADA4D1A}.Release|Any CPU.Build.0 = Release|Any CPU {0798D653-CA13-4E5D-8A9E-4D8A3ADA4D1A}.Release|x86.ActiveCfg = Release|x86 {0798D653-CA13-4E5D-8A9E-4D8A3ADA4D1A}.Release|x86.Build.0 = Release|x86 - {E67A9AAD-585E-4F23-8A85-665A49285C61}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {E67A9AAD-585E-4F23-8A85-665A49285C61}.Debug|Any CPU.Build.0 = Debug|Any CPU - {E67A9AAD-585E-4F23-8A85-665A49285C61}.Debug|x86.ActiveCfg = Debug|Any CPU - {E67A9AAD-585E-4F23-8A85-665A49285C61}.Debug|x86.Build.0 = Debug|Any CPU - {E67A9AAD-585E-4F23-8A85-665A49285C61}.Release|Any CPU.ActiveCfg = Release|Any CPU - {E67A9AAD-585E-4F23-8A85-665A49285C61}.Release|Any CPU.Build.0 = Release|Any CPU - {E67A9AAD-585E-4F23-8A85-665A49285C61}.Release|x86.ActiveCfg = Release|Any CPU - {E67A9AAD-585E-4F23-8A85-665A49285C61}.Release|x86.Build.0 = Release|Any CPU + {F0F62B9F-4802-44AE-BFEC-7E20285ED2BE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {F0F62B9F-4802-44AE-BFEC-7E20285ED2BE}.Debug|Any CPU.Build.0 = Debug|Any CPU + {F0F62B9F-4802-44AE-BFEC-7E20285ED2BE}.Debug|x86.ActiveCfg = Debug|Any CPU + {F0F62B9F-4802-44AE-BFEC-7E20285ED2BE}.Debug|x86.Build.0 = Debug|Any CPU + {F0F62B9F-4802-44AE-BFEC-7E20285ED2BE}.Release|Any CPU.ActiveCfg = Release|Any CPU + {F0F62B9F-4802-44AE-BFEC-7E20285ED2BE}.Release|Any CPU.Build.0 = Release|Any CPU + {F0F62B9F-4802-44AE-BFEC-7E20285ED2BE}.Release|x86.ActiveCfg = Release|Any CPU + {F0F62B9F-4802-44AE-BFEC-7E20285ED2BE}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/Program.cs b/Program.cs index 3e08634..cb58c40 100644 --- a/Program.cs +++ b/Program.cs @@ -4,32 +4,28 @@ using NLog; using System; using System.IO; using System.Linq; -using Sentry; namespace MergeCMInpro { static class Program { - private static readonly Logger _logger = NLog.LogManager.GetCurrentClassLogger(); - + private static readonly Logger _logger = NLog.LogManager.GetCurrentClassLogger(); + static string csvPath = String.Empty; - + static void Main(string[] args) { try { - CallSentry(); Console.ForegroundColor = ConsoleColor.White; - + //productive csvPath = Path.Combine(Directory.GetFiles(Environment.CurrentDirectory, "*.csv").FirstOrDefault()); //testing - //csvPath = Path.Combine(Directory.GetFiles(@"\\fsdeg002\DatenStA61_S\Bauvorhaben\0_SAGA\839.867 - 843.817 SAGA HD 27 2023_11_08", "*.csv").FirstOrDefault()); + //csvPath = Path.Combine(Directory.GetFiles(@"\\fsdeg002\DatenStA61_S\Bauvorhaben\0_SAGA\815.922 - 819.917 SAGA HD 21 2021_09_27_Testing", "*.csv").FirstOrDefault()); //csvPath = Path.Combine(Directory.GetFiles(@"C:\Testing\MergeInpro", "*.csv").FirstOrDefault()); - //csvPath = Path.Combine(Directory.GetFiles(@"C:\TEMP\SAGA\839.867 - 843.817 SAGA HD 27 2023_11_08", "*.csv").FirstOrDefault()); - //csvPath = Path.Combine(Directory.GetFiles(@"C:\TEMP\SAGA\843.818 - 847.187 SAGA HD 28 2023_12_18", "*.csv").FirstOrDefault()); - csvPath = Path.Combine(Directory.GetFiles(@"D:\TestData\MergeCMInpro", "*.csv").FirstOrDefault()); + string pathOutputFileCM = Path.Combine(Directory.GetParent(csvPath).FullName, "outputCM.csv"); string pathOutputFileInpro = Path.Combine(Directory.GetParent(csvPath).FullName, "outputInpro.csv"); @@ -43,15 +39,6 @@ namespace MergeCMInpro return; } - - if(!CheckFolderStructure(csvPath)) - { - Console.ForegroundColor = ConsoleColor.Yellow; - Console.WriteLine("WARNING: folder structure wrong. Please note folder with name '{0}' has to contain all pdf files.", Path.GetFileNameWithoutExtension(csvPath)); - Console.ResetColor(); - return; - } - var config = File.ReadLines(@".\config.txt").ToArray(); DataOperations.conString = config[0]; DataOperations.kanalAktePath = config[2]; @@ -60,12 +47,8 @@ namespace MergeCMInpro if (!File.Exists(DataOperations.kanalAktePath)) throw new FileNotFoundException("Kanalaktendatei nicht gefunden."); - //Testing - //string archivNetPath = Path.Combine(@"C:\TEMP\ArchivPath"); - - //productive string archivNetPath = Path.Combine(config[1]); - + Console.WriteLine("Working, please wait... or get yourself a tea."); FileOperations.SplitRow(csvPath, archivNetPath); @@ -91,33 +74,29 @@ namespace MergeCMInpro //Standort using (StreamWriter sw = new StreamWriter(pathOutputFileStandort)) { - foreach (var item in DataOperations.vorgängeStandort.Distinct()) - { - sw.WriteLine(item.ToString()); + for (int i = 0; i < DataOperations.vorgängeStandort.Count; i++) + { + if (i == 0) + { + sw.WriteLine(String.Concat("CID", "VORGANGID", "Sachbearbeiter", "Bemerkung", "Standort", "ENTNAHMEDATUM", "Entnahmezeit", "RUECKGABEDATUM", "Rückgabezeit")); + } + sw.WriteLine(DataOperations.vorgängeStandort[i]); } - } + } - Console.ForegroundColor = ConsoleColor.Green; Console.WriteLine("{0} created.", pathOutputFileCM); - - FileInfo fi = new FileInfo(pathOutputFileInpro); - if(fi.Length!=0) - { - Console.WriteLine("{0} created.", pathOutputFileInpro); - Console.WriteLine("{0} created.", pathOutputFileStandort); - } - + Console.WriteLine("{0} created.", pathOutputFileInpro); + Console.WriteLine("{0} created.", pathOutputFileStandort); Console.ResetColor(); - //#region Backup JPM-Files - //Console.WriteLine("Start copying jpm-files, please wait..."); - //FileInfo fi = new FileInfo(csvPath); - //FileOperations.CopyJPMFilesToDestination(fi.Directory.FullName, archivNetPath); - //Console.WriteLine(""); - //Console.ForegroundColor = ConsoleColor.Green; - //Console.WriteLine("Done. You may close this window now."); - //#endregion + //Backup JPM-Files + Console.WriteLine("Start copying jpm-files, please wait..."); + FileInfo fi = new FileInfo(csvPath); + FileOperations.CopyJPMFilesToDestination(fi.Directory.FullName, archivNetPath); + Console.WriteLine(""); + Console.ForegroundColor = ConsoleColor.Green; + Console.WriteLine("Done. You may close this window now."); Console.ReadLine(); @@ -131,7 +110,7 @@ namespace MergeCMInpro catch (FileNotFoundException ex) { Console.ForegroundColor = ConsoleColor.Red; - Console.WriteLine("ERROR: " + ex.Message); + Console.WriteLine("ERROR: "+ex.Message); Console.ReadLine(); } catch (Exception ex) @@ -141,59 +120,10 @@ namespace MergeCMInpro Console.ReadLine(); } } - static string CallSentry() - { - try - { - var res = SentrySdk.Init(options => - { - // A Sentry Data Source Name (DSN) is required. - // See https://docs.sentry.io/product/sentry-basics/dsn-explainer/ - // You can set it in the SENTRY_DSN environment variable, or you can set it in code here. - options.Dsn = ""; - - // When debug is enabled, the Sentry client will emit detailed debugging information to the console. - // This might be helpful, or might interfere with the normal operation of your application. - // We enable it here for demonstration purposes when first trying Sentry. - // You shouldn't do this in your applications unless you're troubleshooting issues with Sentry. - options.Debug = true; - - // This option is recommended. It enables Sentry's "Release Health" feature. - options.AutoSessionTracking = true; - }); - return res.ToString(); - - } - catch (Exception ex) - { - SentrySdk.CaptureMessage("Something went wrong"); - return ex.Message; - } - } - - - private static bool CheckFolderStructure(string csvName) - { - string fileName = Path.GetFileNameWithoutExtension(csvName); - bool result = false; - string dir = Path.GetDirectoryName(csvName); - DirectoryInfo di = new DirectoryInfo(dir); - if(di.GetFiles("*.pdf").Length > 0) - { - return result; - } - if (Directory.Exists(Path.Combine(dir, fileName))) - { - result = true; - } - return result; - } public static bool CheckFileExist() { - FileInfo fi = new FileInfo(Path.Combine(Directory.GetParent(csvPath).FullName, "outputInpro.csv")); - - if ((File.Exists(Path.Combine(Directory.GetParent(csvPath).FullName, "outputInpro.csv")) && fi.Length!=0) || File.Exists(Path.Combine(Directory.GetParent(csvPath).FullName, "outputCM.csv"))) + if (File.Exists(Path.Combine(Directory.GetParent(csvPath).FullName, "outputInpro.csv")) || File.Exists(Path.Combine(Directory.GetParent(csvPath).FullName, "outputCM.csv"))) { return true; } From c401dae8754ea2a97db7e2dcd5cdf23ffb90ec82 Mon Sep 17 00:00:00 2001 From: dev-mkoebis Date: Fri, 26 Jun 2026 10:12:37 +0200 Subject: [PATCH 3/3] =?UTF-8?q?Pakete=20aktualisiert=20Deprecaterd=20Vorga?= =?UTF-8?q?ng-Datei=20aus=20Scan2Compress=20gel=C3=B6scht?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Business/Vorgang.cs | 3 +- MergeCMInpro.csproj | 7 +- MergeCMInpro.sln | 10 -- Program.cs | 2 +- Vorgang.cs | 278 -------------------------------------------- 5 files changed, 6 insertions(+), 294 deletions(-) delete mode 100644 Vorgang.cs diff --git a/Business/Vorgang.cs b/Business/Vorgang.cs index e8caa08..8ffcea0 100644 --- a/Business/Vorgang.cs +++ b/Business/Vorgang.cs @@ -108,7 +108,8 @@ namespace MergeCMInpro.Business byte[] tmpHash; tmpDt = ASCIIEncoding.ASCII.GetBytes(dt); - tmpHash = new MD5CryptoServiceProvider().ComputeHash(tmpDt); + tmpHash = MD5.Create().ComputeHash(tmpDt); + //tmpHash = new MD5CryptoServiceProvider().ComputeHash(tmpDt); StringBuilder res = new StringBuilder(tmpHash.Length); for (int i = 0; i < tmpHash.Length; i++) diff --git a/MergeCMInpro.csproj b/MergeCMInpro.csproj index 3cd4911..b6c80ba 100644 --- a/MergeCMInpro.csproj +++ b/MergeCMInpro.csproj @@ -2,7 +2,7 @@ Exe - netcoreapp3.1 + net9.0 embedded AnyCPU;x86 @@ -30,8 +30,8 @@ - - + + @@ -39,5 +39,4 @@ Always - diff --git a/MergeCMInpro.sln b/MergeCMInpro.sln index f7ff4dc..44b95c3 100644 --- a/MergeCMInpro.sln +++ b/MergeCMInpro.sln @@ -5,8 +5,6 @@ VisualStudioVersion = 17.0.32126.317 MinimumVisualStudioVersion = 10.0.40219.1 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MergeCMInpro", "MergeCMInpro.csproj", "{0798D653-CA13-4E5D-8A9E-4D8A3ADA4D1A}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MergeCMInpro.Testing", "..\MergeCMInpro.Testing\MergeCMInpro.Testing.csproj", "{F0F62B9F-4802-44AE-BFEC-7E20285ED2BE}" -EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -23,14 +21,6 @@ Global {0798D653-CA13-4E5D-8A9E-4D8A3ADA4D1A}.Release|Any CPU.Build.0 = Release|Any CPU {0798D653-CA13-4E5D-8A9E-4D8A3ADA4D1A}.Release|x86.ActiveCfg = Release|x86 {0798D653-CA13-4E5D-8A9E-4D8A3ADA4D1A}.Release|x86.Build.0 = Release|x86 - {F0F62B9F-4802-44AE-BFEC-7E20285ED2BE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {F0F62B9F-4802-44AE-BFEC-7E20285ED2BE}.Debug|Any CPU.Build.0 = Debug|Any CPU - {F0F62B9F-4802-44AE-BFEC-7E20285ED2BE}.Debug|x86.ActiveCfg = Debug|Any CPU - {F0F62B9F-4802-44AE-BFEC-7E20285ED2BE}.Debug|x86.Build.0 = Debug|Any CPU - {F0F62B9F-4802-44AE-BFEC-7E20285ED2BE}.Release|Any CPU.ActiveCfg = Release|Any CPU - {F0F62B9F-4802-44AE-BFEC-7E20285ED2BE}.Release|Any CPU.Build.0 = Release|Any CPU - {F0F62B9F-4802-44AE-BFEC-7E20285ED2BE}.Release|x86.ActiveCfg = Release|Any CPU - {F0F62B9F-4802-44AE-BFEC-7E20285ED2BE}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/Program.cs b/Program.cs index cb58c40..487aba5 100644 --- a/Program.cs +++ b/Program.cs @@ -24,7 +24,7 @@ namespace MergeCMInpro //testing //csvPath = Path.Combine(Directory.GetFiles(@"\\fsdeg002\DatenStA61_S\Bauvorhaben\0_SAGA\815.922 - 819.917 SAGA HD 21 2021_09_27_Testing", "*.csv").FirstOrDefault()); - //csvPath = Path.Combine(Directory.GetFiles(@"C:\Testing\MergeInpro", "*.csv").FirstOrDefault()); + //csvPath = Path.Combine(Directory.GetFiles(@"E:\TestData\MergeCMInpro", "*.csv").FirstOrDefault()); string pathOutputFileCM = Path.Combine(Directory.GetParent(csvPath).FullName, "outputCM.csv"); diff --git a/Vorgang.cs b/Vorgang.cs deleted file mode 100644 index 86a261c..0000000 --- a/Vorgang.cs +++ /dev/null @@ -1,278 +0,0 @@ -using NLog; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Security.Cryptography; -using System.Text; -using System.Text.RegularExpressions; -using System.Threading.Tasks; - -namespace Scan2Compress.Business -{ - public sealed class Vorgang - { - #region Fields - private static readonly Logger _logger = NLog.LogManager.GetCurrentClassLogger(); - - private string aktenzeichen; - #endregion - //TODO: fehlende Felder aus den CM und Inpro hinzufügen - #region Properties - public DateTime Enddatum { get; set; } - public DateTime Eingangsdatum { get; set; } - public string BeschreibungVorgang { get; set; } - public string Checkliste { get; set; } - public string VorgangsDefinition { get; set; } - public int Id { get; set; } - - public string Aktenzeichen - { - get - { - return aktenzeichen; - } - set - { - aktenzeichen = value; - if (!aktenzeichen.Contains("/")) - { - aktenzeichen = ReplaceHiphenWithSlash(value); - } - } - } - - public string FameId { get; set; } - - public string DocsSZ { get; set; } - - public string DocType { get; set; } - - public static Dictionary Strassen { get; set; } - - public string IdStrasse { get; set; } - - public string Strasse1 { get; set; } - - public string Hausnummer1Von { get; set; } - - public string Hausnummer1Bis { get; set; } - - public string HsNrVonZusatz { get; set; } - - public string HsNrBisZusatz { get; set; } - - public string Strasse2 { get; set; } = string.Empty; - - public string Hausnummer2 { get; set; } = string.Empty; - - public string Teil { get; set; } - - public string NamePDF { get; set; } - - public string AbsoluteFilePath { get; set; } - - public DateTime CreationDate { get; set; } - - public DateTime ScanDatum { get; set; } = DateTime.Now; //Erstelldatum - - #endregion Properties - - #region Contructor - - public Vorgang(string id, string aktenzeichen, string docType, string teil, string namePDF) - { - this.DocType = docType; - this.Teil = teil; - this.Aktenzeichen = aktenzeichen; - this.NamePDF = namePDF; - this.Id = Convert.ToInt32(id); - this.FameId = GenerateFameId(); - } - - public Vorgang(string id, string aktenzeichen, string docType, string teil, string namePDF, string strasse1, string hausnummer1) - { - this.DocType = docType; - this.Teil = teil; - this.Aktenzeichen = aktenzeichen; - this.NamePDF = namePDF; - this.Id = Convert.ToInt32(id); - this.FameId = GenerateFameId(); - this.Strasse1 = strasse1.Trim(); - this.Hausnummer1Von = hausnummer1; - } - - - public Vorgang() - { - - } - - #endregion - - #region Methods - private int GenerateVorgangId(int oldValue) - { - int newValue = oldValue + 1; - return newValue; - } - - //Erstelle Originalaktenzeichen - private string ReplaceHiphenWithSlash(string aktenzeichen) - { - var regex = new Regex(Regex.Escape("-")); - string res = regex.Replace(aktenzeichen, "/", 1); - return res; - } - - #region Extract Strassen - private void ExtractStrasseHausnummer(string strasse) - { - string[] res = strasse.Split(' '); - StringBuilder sb = new StringBuilder(); - - try - { - //Abtrennen von Hausnummerzusätzen wie z.B. "4A" in "4" und "A" sowie Aufspaltung von Bereichen z.B. "4-8" in "4" und "8" - for (int i = 0; i < res.Length; i++) - { - if (!char.IsDigit(res[i].ElementAt(0)) && char.IsDigit(res[i].ElementAt(1))) - { - DocsSZ = res[i]; - } - else if (char.IsDigit(res[i].ElementAt(0))) - { - SplittedHausnummerZusatz(res[i]); - } - else - { - //z.B. Auf der Mühle, Herbert-Scholtissek-Str, Westholz etc. - sb.Append(res[i]); - sb.Append(" "); - } - } - Strasse1 = sb.ToString().Trim(); - - } - catch (System.ArgumentOutOfRangeException ex) - { - _logger.Error(string.Concat(ex.Message, " Beim Extrahieren der Strasse/Hausnummer ist ein Fehler aufgetreten.")); - throw new ArgumentOutOfRangeException("Beim Extrahieren der Strasse1 ist ein Fehler aufgetreten.\n\nBitte Eingaben überprüfen.", ex); - } - catch (Exception ex) - { - _logger.Error(ex.Message); - throw; - } - } - - private void SplittedStrasse2(string input) - { - string[] strasseHnr = input.Split(' '); - - StringBuilder builder = new StringBuilder(); - Hausnummer2 = strasseHnr.LastOrDefault(); - - strasseHnr = strasseHnr.Take(strasseHnr.Length - 1).ToArray(); - for (int i = 0; i < strasseHnr.Length; i++) - { - if (i == strasseHnr.Length - 1) - builder.Append(strasseHnr[i]); - else - builder.Append(string.Concat(strasseHnr[i], " ")); - } - Strasse2 = builder.ToString(); - } - - private void SplittedHausnummerZusatz(string input) - { - string hausnummerZusatzVon = string.Empty; - string hausnummerZusatzBis = string.Empty; - - Tuple result; - - if (input.Contains('-')) //13-15, 13a-15 - { - hausnummerZusatzVon = input.Split('-').FirstOrDefault(); - hausnummerZusatzBis = input.Split('-').LastOrDefault(); - result = ExtractingZusatzFromHausnummer(hausnummerZusatzVon); - Hausnummer1Von = result.Item1; - HsNrVonZusatz = result.Item2; - result = ExtractingZusatzFromHausnummer(hausnummerZusatzBis); - Hausnummer1Bis = result.Item1; - HsNrBisZusatz = result.Item2; - - if (HsNrBisZusatz.Length >= 2 || HsNrVonZusatz.Length >= 2) - { - HsNrVonZusatz = HsNrVonZusatz != string.Empty ? HsNrVonZusatz.FirstOrDefault().ToString() : string.Empty; - HsNrBisZusatz = HsNrBisZusatz != string.Empty ? HsNrBisZusatz.LastOrDefault().ToString() : string.Empty; - } - } - else //13 - { - result = ExtractingZusatzFromHausnummer(input); - Hausnummer1Von = result.Item1; - HsNrBisZusatz = result.Item2; - } - } - - private Tuple ExtractingZusatzFromHausnummer(string input) - { - StringBuilder sbHausnummer = new StringBuilder(); - StringBuilder sbZusatz = new StringBuilder(); - - for (int i = 0; i < input.Length; i++) - { - if (char.IsDigit(input[i])) - { - sbHausnummer.Append(input[i]); - } - else - { - sbZusatz.Append(input[i]); - } - } - return new Tuple(sbHausnummer.ToString(), sbZusatz.ToString()); - } - #endregion - - - private string GenerateFameId() - { - string dt = DateTime.Now.ToString("ddMMyyhhmmssfff"); - byte[] tmpDt; - byte[] tmpHash; - - tmpDt = ASCIIEncoding.ASCII.GetBytes(dt); - tmpHash = new MD5CryptoServiceProvider().ComputeHash(tmpDt); - - StringBuilder res = new StringBuilder(tmpHash.Length); - for (int i = 0; i < tmpHash.Length; i++) - { - res.Append(tmpHash[i].ToString("X2")); - } - string tmp = res.ToString().ToLower().Substring(res.Length - 12); - _logger.Info("FameId " + tmp + " für " + dt + " und " + Aktenzeichen + " erzeugt."); - return tmp; - } - - public override string ToString() - { - return Id.ToString() + ";" + Aktenzeichen + ";" + Checkliste + ";" + VorgangsDefinition + ";" + BeschreibungVorgang + ";" + Strasse1 + ";" + Hausnummer1Von + ";" + HsNrVonZusatz + ";" + Hausnummer1Bis + ";" + HsNrBisZusatz + ";" + Strasse2.Trim() + ";" + Hausnummer2 + ";" + Eingangsdatum.ToShortDateString() + ";" + FameId + ";" + Enddatum.ToShortDateString() + ";" + DocType + ";" + NamePDF; - } - //CM: - //aktenzeichen - //vorgangdefid VV - //Vorgangsart Kanalakte - //strasse 1 - //strasse 1 hausnummer - //strasse 2 - //strasse 2 hausnummer - //datumabschluss - //fameid - //dokumentdatum - //langebzeichnung/dokumentbezeichnung in inpro - //dokumentname mit Endung - #endregion - } -} \ No newline at end of file