Compare commits
1 Commits
Refactored
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| 9dd6ee8481 |
@@ -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),ex.Message);
|
||||
Console.WriteLine("ERROR: Wrong Path {0}. Please provide folder like '843.818 - 847.187 SAGA HD 28 2023_12_18'", Path.GetDirectoryName(v.AbsoluteFilePath));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
29
Program.cs
29
Program.cs
@@ -1,10 +1,12 @@
|
||||
using MergeCMInpro.Business;
|
||||
using MergeCMInpro.Data;
|
||||
using NLog;
|
||||
using System;
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using MergeCMInpro.Business;
|
||||
using MergeCMInpro.Data;
|
||||
using NLog;
|
||||
using Sentry;
|
||||
using static System.Net.WebRequestMethods;
|
||||
|
||||
|
||||
namespace MergeCMInpro
|
||||
{
|
||||
@@ -22,14 +24,15 @@ namespace MergeCMInpro
|
||||
Console.ForegroundColor = ConsoleColor.White;
|
||||
|
||||
//productive
|
||||
csvPath = Path.Combine(Directory.GetFiles(Environment.CurrentDirectory, "*.csv").FirstOrDefault());
|
||||
//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());
|
||||
csvPath = Path.Combine(Directory.GetFiles(@"E:\TestData\MergeCMInpro", "*.csv").FirstOrDefault());
|
||||
|
||||
|
||||
string pathOutputFileCM = Path.Combine(Directory.GetParent(csvPath).FullName, "outputCM.csv");
|
||||
string pathOutputFileInpro = Path.Combine(Directory.GetParent(csvPath).FullName, "outputInpro.csv");
|
||||
@@ -52,19 +55,19 @@ namespace MergeCMInpro
|
||||
return;
|
||||
}
|
||||
|
||||
var config = File.ReadLines(@".\config.txt").ToArray();
|
||||
var config = System.IO.File.ReadLines(@".\config.txt").ToArray();
|
||||
DataOperations.conString = config[0];
|
||||
DataOperations.kanalAktePath = config[2];
|
||||
DataOperations.csvPath = csvPath;
|
||||
|
||||
if (!File.Exists(DataOperations.kanalAktePath))
|
||||
if (!System.IO.File.Exists(DataOperations.kanalAktePath))
|
||||
throw new FileNotFoundException("Kanalaktendatei nicht gefunden.");
|
||||
|
||||
//Testing
|
||||
//string archivNetPath = Path.Combine(@"C:\TEMP\ArchivPath");
|
||||
string archivNetPath = Path.Combine(@"E:\TestData\ArchivPath");
|
||||
|
||||
//productive
|
||||
string archivNetPath = Path.Combine(config[1]);
|
||||
//string archivNetPath = Path.Combine(config[1]);
|
||||
|
||||
Console.WriteLine("Working, please wait... or get yourself a tea.");
|
||||
|
||||
@@ -141,6 +144,7 @@ namespace MergeCMInpro
|
||||
Console.ReadLine();
|
||||
}
|
||||
}
|
||||
|
||||
static string CallSentry()
|
||||
{
|
||||
try
|
||||
@@ -150,7 +154,7 @@ namespace MergeCMInpro
|
||||
// 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 = "";
|
||||
options.Dsn = "https://73fd45bffc79360f9de9b7a7a622d96f@sentry.katyes.dynv6.net/3";
|
||||
|
||||
// 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.
|
||||
@@ -171,7 +175,6 @@ namespace MergeCMInpro
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private static bool CheckFolderStructure(string csvName)
|
||||
{
|
||||
string fileName = Path.GetFileNameWithoutExtension(csvName);
|
||||
@@ -193,7 +196,7 @@ namespace MergeCMInpro
|
||||
{
|
||||
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 ((System.IO.File.Exists(Path.Combine(Directory.GetParent(csvPath).FullName, "outputInpro.csv")) && fi.Length!=0) || System.IO.File.Exists(Path.Combine(Directory.GetParent(csvPath).FullName, "outputCM.csv")))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
# MergeCMInpro
|
||||
|
||||
Zusammenführen von Informationen/Dateien aus dem Content Manager und Inpro
|
||||
Ergänzt Informationen aus der Inpro-DB zu den gegebenen Informationen des Scandienstleisters und schreibt Import-Datei für CM und Inpro
|
||||
278
Vorgang.cs
278
Vorgang.cs
@@ -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<int, string> 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<string, string> 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<string, string> 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<string, string>(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
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user