Initial Project Commit
This commit is contained in:
85
Business/ExcelReader.cs
Normal file
85
Business/ExcelReader.cs
Normal file
@@ -0,0 +1,85 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
using Excel = Microsoft.Office.Interop.Excel;
|
||||
|
||||
namespace MergeCMInpro.Business
|
||||
{
|
||||
internal class ExcelReader
|
||||
{
|
||||
public static string ReadExcel(string filename, string vorgangId)
|
||||
{
|
||||
Excel.Application excel = null;
|
||||
excel = new Excel.Application();
|
||||
excel.Visible = true;
|
||||
Excel.Workbook wkb = null;
|
||||
|
||||
wkb = Open(excel, filename);
|
||||
Excel.Range searchedRange = excel.get_Range("A1", "XFD1048576");
|
||||
Excel.Range currentFind = searchedRange.Find(vorgangId);
|
||||
Excel.Sheets excelSheets = wkb.Worksheets;
|
||||
Excel.Worksheet excelWorksheet = (Excel.Worksheet)excelSheets.get_Item(1);
|
||||
string res = string.Empty;
|
||||
|
||||
if (currentFind != null)
|
||||
{
|
||||
var cellValue = Convert.ToString((excelWorksheet.Cells[currentFind.Row, currentFind.Column+10] as Excel.Range).Value);
|
||||
DateTime dt = DateTime.Parse(cellValue);
|
||||
res = dt.ToShortDateString();
|
||||
}
|
||||
else
|
||||
{
|
||||
res = "01.01.1900";
|
||||
//TODO: Logger, falls nicht gefunden. Und sonst wird 01.01.1900 als default gesetzt
|
||||
}
|
||||
|
||||
wkb.Close(true);
|
||||
excel.Quit();
|
||||
return res;
|
||||
}
|
||||
|
||||
public static Excel.Workbook Open(Excel.Application excelInstance,
|
||||
string fileName, bool readOnly = false, bool editable = true,
|
||||
bool updateLinks = true)
|
||||
{
|
||||
Excel.Workbook book = excelInstance.Workbooks.Open(
|
||||
fileName, updateLinks, readOnly,
|
||||
Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing,
|
||||
Type.Missing, editable, Type.Missing, Type.Missing, Type.Missing,
|
||||
Type.Missing, Type.Missing);
|
||||
return book;
|
||||
}
|
||||
|
||||
public static void ReleaseComObjects(ref List<object> comObjects)
|
||||
{
|
||||
for (int i = 0; i < comObjects.Count; i++)
|
||||
{
|
||||
object obj = comObjects[i];
|
||||
if (Marshal.IsComObject(obj))
|
||||
{
|
||||
while (obj != null && Marshal.ReleaseComObject(obj) != 0) ;
|
||||
while (obj != null && Marshal.FinalReleaseComObject(obj) != 0) ;
|
||||
}
|
||||
obj = null;
|
||||
}
|
||||
|
||||
GC.Collect();
|
||||
GC.WaitForPendingFinalizers();
|
||||
}
|
||||
|
||||
public static int GetColumnNumber(string column)//A --> 1 B --> 2 CI --> 87
|
||||
{
|
||||
int col = 0;
|
||||
char[] temp = column.ToUpper().ToCharArray();
|
||||
for (int i = temp.Length - 1; i >= 0; i--)
|
||||
{
|
||||
int num = Convert.ToInt32(temp[i]) - 64;
|
||||
col += num * Convert.ToInt32(Math.Pow(26, temp.Length - 1 - i));
|
||||
}
|
||||
return col;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
200
Business/FileOperations.cs
Normal file
200
Business/FileOperations.cs
Normal file
@@ -0,0 +1,200 @@
|
||||
using MergeCMInpro.Data;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace MergeCMInpro.Business
|
||||
{
|
||||
public static class FileOperations
|
||||
{
|
||||
public static string[] ExtractFilePath(string path)
|
||||
{
|
||||
var splittedAbsolutePath = path.Split("\\").SkipLast(2).LastOrDefault();
|
||||
return splittedAbsolutePath.Split(" ");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Kopiert Quelldateien an Zielort
|
||||
/// </summary>
|
||||
/// <param name="sourceFilePath">Quellpfad</param>
|
||||
/// <param name="destFolderName ">Zielordner</param>
|
||||
/// <param name="destFileName">Zielname</param>
|
||||
/// <param name="archivNetPath">Zielpfad</param>
|
||||
public static void CopySourcePdfFileToDestination(string sourceFilePath, string destFolderName, string destFileName, string archivNetPath)
|
||||
{
|
||||
string destPath = Path.Combine(archivNetPath, destFolderName);
|
||||
if (!Directory.Exists(destPath))
|
||||
Directory.CreateDirectory(destPath);
|
||||
File.Copy(sourceFilePath, Path.Combine(destPath, destFileName), true);
|
||||
}
|
||||
|
||||
public static void CopyJPMFilesToDestination(string sourcePath, string archivNetPath)
|
||||
{
|
||||
string pattern = "(\\.)";
|
||||
|
||||
if (Directory.GetDirectories(sourcePath).Length > 0 && Directory.GetFiles(sourcePath, "*.jpm").Length == 0)
|
||||
{
|
||||
foreach (var item in Directory.GetDirectories(sourcePath))
|
||||
{
|
||||
CopyJPMFilesToDestination(item, archivNetPath);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
var temp = sourcePath.Split("\\");
|
||||
string extractedPath = string.Empty;
|
||||
string archivPath = Path.Combine(archivNetPath, "Archiv");
|
||||
foreach (var item in temp)
|
||||
{
|
||||
if (Regex.Match(item, pattern).Success)
|
||||
{
|
||||
extractedPath = string.Concat("Sicherungen jpm ", item.Split(" ").FirstOrDefault(), " bis ", item.Split(" ").ElementAt(2));
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!Directory.Exists(Path.Combine(archivPath, extractedPath)))
|
||||
{
|
||||
Directory.CreateDirectory(Path.Combine(archivPath, extractedPath));
|
||||
}
|
||||
int count = 0;
|
||||
foreach (var t in Directory.GetFiles(sourcePath, "*.jpm"))
|
||||
{
|
||||
FileInfo fi = new FileInfo(t);
|
||||
if (!File.Exists(Path.Combine(archivPath, extractedPath, fi.Name)))
|
||||
{
|
||||
File.Copy(t, Path.Combine(archivPath, extractedPath, fi.Name));
|
||||
count++;
|
||||
Console.Write("\r{0} files copied", count);
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.Write("\rskipped!");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static DateTime GetCreationDate(string file)
|
||||
{
|
||||
FileInfo fi = new FileInfo(file);
|
||||
return fi.LastWriteTime;
|
||||
}
|
||||
|
||||
public static string GetFullFilePath(string file, string csvPath)
|
||||
{
|
||||
string currentDirectory = Directory.GetParent(csvPath).FullName;
|
||||
string res = string.Empty;
|
||||
res = Directory.GetFiles(currentDirectory, file, SearchOption.AllDirectories).FirstOrDefault();
|
||||
if (res == null)
|
||||
return string.Empty;
|
||||
else
|
||||
{
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
||||
//Splittet Informationen der Zeilen in Dienstleister-Datei (Rohdaten)
|
||||
public static void SplitRow(string path, string archivNetPath)
|
||||
{
|
||||
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(";");
|
||||
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]);
|
||||
}
|
||||
}
|
||||
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]);
|
||||
}
|
||||
}
|
||||
|
||||
#region PDF
|
||||
if(jpmFiles)
|
||||
{
|
||||
v.AbsoluteFilePath = GetFullFilePath(arr[8], path); //arr[7]=jpm-Dateien
|
||||
}
|
||||
else
|
||||
{
|
||||
v.AbsoluteFilePath = GetFullFilePath(arr[7], path);
|
||||
}
|
||||
|
||||
if (v.AbsoluteFilePath == string.Empty)
|
||||
{
|
||||
Console.WriteLine("Keine PDF-Dateien gefunden.");
|
||||
return;
|
||||
}
|
||||
v.CreationDate = GetCreationDate(v.AbsoluteFilePath);
|
||||
#endregion
|
||||
|
||||
//Ergänze Basis-Vorgang mit den Daten aus der DB
|
||||
DataOperations.ConnectAndExecute(v, archivNetPath);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static string LowerDocumentType(string value)
|
||||
{
|
||||
switch (value)
|
||||
{
|
||||
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;
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
25
Business/StructureException.cs
Normal file
25
Business/StructureException.cs
Normal file
@@ -0,0 +1,25 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace MergeCMInpro.Business
|
||||
{
|
||||
internal class StructureException : Exception
|
||||
{
|
||||
public StructureException()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public StructureException(string foldername) : base(string.Format("No Folder with name {0} available", foldername))
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public StructureException(string message, Exception inner):base(message, inner)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
142
Business/Vorgang.cs
Normal file
142
Business/Vorgang.cs
Normal file
@@ -0,0 +1,142 @@
|
||||
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 MergeCMInpro.Business
|
||||
{
|
||||
public class Vorgang
|
||||
{
|
||||
#region Fields
|
||||
private string aktenzeichen;
|
||||
#endregion
|
||||
|
||||
#region Properties
|
||||
|
||||
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 DocType { get; set; }
|
||||
|
||||
public string NamePDF { get; set; }
|
||||
|
||||
public static Dictionary<int, string> Strassen { get; set; }
|
||||
|
||||
public string Strasse1 { get; set; }
|
||||
|
||||
public string Teil { get; set; }
|
||||
|
||||
public string Hausnummer1 { get; set; }
|
||||
|
||||
public string Strasse2 { get; set; } = string.Empty;
|
||||
|
||||
public string Hausnummer2 { get; set; } = string.Empty;
|
||||
|
||||
public string AbsoluteFilePath { get; set; }
|
||||
|
||||
public DateTime CreationDate { get; set; }
|
||||
|
||||
public DateTime Enddatum { get; set; }
|
||||
|
||||
#endregion Properties
|
||||
|
||||
#region Constructor
|
||||
|
||||
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;
|
||||
this.Hausnummer1 = hausnummer1;
|
||||
}
|
||||
|
||||
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()
|
||||
{
|
||||
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Methods
|
||||
string ReplaceHiphenWithSlash(string aktenzeichen)
|
||||
{
|
||||
var regex = new Regex(Regex.Escape("-"));
|
||||
string res = regex.Replace(aktenzeichen, "/", 1);
|
||||
return res;
|
||||
}
|
||||
|
||||
protected 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);
|
||||
|
||||
return tmp;
|
||||
}
|
||||
|
||||
public virtual string GenerateVorgang(Vorgang v)
|
||||
{
|
||||
return String.Empty;
|
||||
}
|
||||
|
||||
protected string GenerateLangbezeichnungFromPath(string path)
|
||||
{
|
||||
var temp = path.Split('\\').SkipLast(2).LastOrDefault().Split(' ').Skip(3);
|
||||
string result = string.Concat(temp.ElementAt(0), " ", temp.ElementAt(1), " ", temp.ElementAt(2), " Datensatz ");
|
||||
|
||||
//#region TESTING
|
||||
//string testing = "TEST";
|
||||
//string result = testing;
|
||||
//#endregion
|
||||
|
||||
return result;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
59
Business/VorgangCM.cs
Normal file
59
Business/VorgangCM.cs
Normal file
@@ -0,0 +1,59 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace MergeCMInpro.Business
|
||||
{
|
||||
public class VorgangCM : Vorgang
|
||||
{
|
||||
public string BeschreibungVorgang { get; set; }
|
||||
|
||||
public VorgangCM()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public override string GenerateVorgang(Vorgang v)
|
||||
{
|
||||
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(this.BeschreibungVorgang, ";"));
|
||||
sbCM.Append(string.Concat(v.Strasse1, ";"));
|
||||
sbCM.Append(string.Concat(v.Hausnummer1, ";"));
|
||||
sbCM.Append(string.Concat(v.Strasse2.Trim(), ";"));
|
||||
sbCM.Append(string.Concat(v.Hausnummer2.Trim(), ';'));
|
||||
sbCM.Append(string.Concat(this.Enddatum.ToShortDateString(), ";"));
|
||||
sbCM.Append(string.Concat(v.FameId, ";"));
|
||||
sbCM.Append(string.Concat(v.CreationDate.ToShortDateString(), ";"));
|
||||
//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));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine(ex.Message);
|
||||
}
|
||||
//string langBez = base.GenerateLangbezeichnungFromPath(v.AbsoluteFilePath);
|
||||
sbCM.Append(string.Concat(langBez, ";"));
|
||||
|
||||
sbCM.Append(string.Concat(v.FameId, ".pdf"));
|
||||
|
||||
return sbCM.ToString();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
160
Business/VorgangInpro.cs
Normal file
160
Business/VorgangInpro.cs
Normal file
@@ -0,0 +1,160 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace MergeCMInpro.Business
|
||||
{
|
||||
internal class VorgangInpro : Vorgang
|
||||
{
|
||||
#region Properties
|
||||
public string Abteilung { get; set; }
|
||||
|
||||
public string IdStrasse { get; set; }
|
||||
|
||||
public string Hausnummer1Von { get; set; }
|
||||
|
||||
public string Hausnummer1Bis { get; set; }
|
||||
|
||||
public string HsNrVonZusatz { get; set; }
|
||||
|
||||
public string HsNrBisZusatz { get; set; }
|
||||
|
||||
public DateTime Eingangsdatum { get; set; }
|
||||
|
||||
public string Beschreibung1 { get; set; }
|
||||
|
||||
public string Beschreibung2 { get; set; }
|
||||
|
||||
public string Bezeichnung2 { get; set; }
|
||||
|
||||
public string Checkliste { get; set; }
|
||||
|
||||
public string DocsSZ { get; set; }
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
public VorgangInpro()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public override string GenerateVorgang(Vorgang v)
|
||||
{
|
||||
string documentType = FileOperations.LowerDocumentType(v.DocType.Split(" ").FirstOrDefault());
|
||||
string band = 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()));
|
||||
|
||||
StringBuilder sbInpro = new StringBuilder();
|
||||
sbInpro.Append(string.Concat(v.Id, ";"));//Barcode
|
||||
sbInpro.Append(string.Concat(v.Aktenzeichen, ";"));//Vorgangsnummer
|
||||
sbInpro.Append(string.Concat(string.Empty, ";"));//Abteilung
|
||||
sbInpro.Append(string.Concat(this.IdStrasse, ";"));//Strasse1ID
|
||||
sbInpro.Append(string.Concat(v.Strasse1, ";").Trim());//Strasse1
|
||||
|
||||
|
||||
sbInpro.Append(string.Concat(v.Hausnummer1, ";").Trim());//Hausnummer1
|
||||
sbInpro.Append(string.Concat(this.Hausnummer1Von, ";").Trim());//Hausnummer1Von
|
||||
sbInpro.Append(string.Concat(this.HsNrVonZusatz, ";").Trim());//Hausnummer1VonZusatz
|
||||
sbInpro.Append(string.Concat(this.Hausnummer1Bis, ";").Trim());//Hausnummer1Bis
|
||||
sbInpro.Append(string.Concat(this.HsNrBisZusatz, ";").Trim());//Hausnummer1BisZusatz
|
||||
|
||||
|
||||
sbInpro.Append(string.Concat(this.Strasse2, ";").Trim());//Strasse2
|
||||
sbInpro.Append(string.Concat(this.Hausnummer2, ";").Trim());//Hausnummer2
|
||||
|
||||
sbInpro.Append(string.Concat(band, ";"));//Bezeichnung1 bzw. Band
|
||||
sbInpro.Append(string.Concat(this.Eingangsdatum.ToShortDateString(), ";"));//Eingangsdatum
|
||||
sbInpro.Append(string.Concat("Digitalisierte Akte", ";"));//Beschreibung1
|
||||
sbInpro.Append(string.Concat(string.Empty, ";")); //Beschreibung2
|
||||
sbInpro.Append(string.Concat(string.Empty, ";"));//Bezeichnung2
|
||||
sbInpro.Append(string.Concat(this.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(this.Checkliste, ";").Trim());//Checkliste
|
||||
sbInpro.Append(string.Concat(this.Enddatum.ToShortDateString(), ";"));//Abschlussdatum
|
||||
sbInpro.Append(string.Concat(base.GenerateLangbezeichnungFromPath(v.AbsoluteFilePath), v.Id));
|
||||
return sbInpro.ToString();
|
||||
}
|
||||
|
||||
//string GenerateLangbezeichnungFromPath(string path)
|
||||
//{
|
||||
// var temp = path.Split('\\').SkipLast(2).LastOrDefault().Split(' ').Skip(3);
|
||||
// string result = string.Concat(temp.ElementAt(0), " ", temp.ElementAt(1), " ", temp.ElementAt(2), " Datensatz ");
|
||||
|
||||
// //#region TESTING
|
||||
// //string testing = "TEST";
|
||||
// //string result = testing;
|
||||
// //#endregion
|
||||
|
||||
// return result;
|
||||
//}
|
||||
|
||||
|
||||
public void SplittedHausnummerZusatz(Vorgang v)
|
||||
{
|
||||
string hausnummerZusatzVon = string.Empty;
|
||||
string hausnummerZusatzBis = string.Empty;
|
||||
|
||||
Tuple<string, string> result;
|
||||
|
||||
if (v.Hausnummer1.Contains('-')) //13-15, 13a-15
|
||||
{
|
||||
hausnummerZusatzVon = v.Hausnummer1.Split('-').FirstOrDefault();
|
||||
hausnummerZusatzBis = v.Hausnummer1.Split('-').LastOrDefault();
|
||||
result = ExtractingZusatzFromHausnummer(hausnummerZusatzVon);
|
||||
this.Hausnummer1Von = result.Item1;
|
||||
this.HsNrVonZusatz = result.Item2;
|
||||
result = ExtractingZusatzFromHausnummer(hausnummerZusatzBis);
|
||||
this.Hausnummer1Bis = result.Item1;
|
||||
this.HsNrBisZusatz = result.Item2;
|
||||
|
||||
if (this.HsNrBisZusatz.Length >= 2 || this.HsNrVonZusatz.Length >= 2)
|
||||
{
|
||||
this.HsNrVonZusatz = this.HsNrVonZusatz != string.Empty ? this.HsNrVonZusatz.FirstOrDefault().ToString() : string.Empty;
|
||||
this.HsNrBisZusatz = this.HsNrBisZusatz != string.Empty ? this.HsNrBisZusatz.LastOrDefault().ToString() : string.Empty;
|
||||
}
|
||||
}
|
||||
else if (v.Hausnummer1.Contains("bis"))
|
||||
{
|
||||
//Vorkommen von "bis"
|
||||
int firstBisIndex = v.Hausnummer1.IndexOf("bis");
|
||||
int lastBisIndex = v.Hausnummer1.LastIndexOf("bis") + "bis".Length;
|
||||
this.Hausnummer1Von = v.Hausnummer1.Substring(0, firstBisIndex);
|
||||
result = ExtractingZusatzFromHausnummer(this.Hausnummer1Von);
|
||||
this.Hausnummer1Von = result.Item1;
|
||||
this.HsNrVonZusatz = result.Item2;
|
||||
this.Hausnummer1Bis = v.Hausnummer1.Substring(lastBisIndex, v.Hausnummer1.Length - lastBisIndex);
|
||||
result = ExtractingZusatzFromHausnummer(this.Hausnummer1Bis);
|
||||
this.Hausnummer1Bis = result.Item1;
|
||||
this.HsNrBisZusatz = result.Item2;
|
||||
}
|
||||
else //13
|
||||
{
|
||||
result = ExtractingZusatzFromHausnummer(v.Hausnummer1);
|
||||
this.Hausnummer1Von = result.Item1;
|
||||
this.HsNrVonZusatz = result.Item2;
|
||||
}
|
||||
}
|
||||
|
||||
public static 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());
|
||||
}
|
||||
}
|
||||
}
|
||||
58
Business/VorgangStandort.cs
Normal file
58
Business/VorgangStandort.cs
Normal file
@@ -0,0 +1,58 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace MergeCMInpro.Business
|
||||
{
|
||||
internal class VorgangStandort : Vorgang
|
||||
{
|
||||
public string CID { get; set; }
|
||||
|
||||
public string Sachbearbeiter { get; set; }
|
||||
|
||||
public string Bemerkung { get; set; }
|
||||
|
||||
public string Standort { get; set; }
|
||||
|
||||
public DateTime Entnahmedatum { get; set; }
|
||||
|
||||
public string Entnahmezeit { get; set; }
|
||||
|
||||
|
||||
public VorgangStandort(string csvPath)
|
||||
{
|
||||
this.CID = "0001";
|
||||
this.Sachbearbeiter = string.Empty;
|
||||
this.Bemerkung = "Digitalisierte Akte s. E-Akte-Ordner Altakte";
|
||||
this.Standort = "61/1-1 Archiv";
|
||||
this.Entnahmedatum = GetEntnahmedatum(csvPath);
|
||||
this.Entnahmezeit = "18:00:00";
|
||||
}
|
||||
|
||||
public override string GenerateVorgang(Vorgang v)
|
||||
{
|
||||
|
||||
StringBuilder sbStandort = new StringBuilder();
|
||||
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.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
|
||||
|
||||
return sbStandort.ToString();
|
||||
}
|
||||
|
||||
public DateTime GetEntnahmedatum(string pathFile)
|
||||
{
|
||||
string splitted = pathFile.Split('\\').LastOrDefault().Split('_').LastOrDefault();
|
||||
|
||||
DateTime dt = new DateTime(Convert.ToInt32(splitted.Substring(0,4)),Convert.ToInt32(splitted.Substring(4,2)),Convert.ToInt32(splitted.Substring(6,2)));
|
||||
return dt;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user