Schnittstelle um logging erweitert

This commit is contained in:
2023-06-27 12:41:47 +02:00
parent b22b9855fa
commit 8b5d706db4
10 changed files with 43 additions and 19 deletions

View File

@@ -28,6 +28,7 @@ namespace SewerStammGen.DAL.Services.PostgresqlData
{ {
IAuftraggeberDataService auftraggeberDataService = new AuftraggeberDataService(connString); IAuftraggeberDataService auftraggeberDataService = new AuftraggeberDataService(connString);
var s = await auftraggeberDataService.GetAll(); var s = await auftraggeberDataService.GetAll();
// TODO : Auftraggeber verwaltung
entity.Auftraggeber = s.ToList().Last(); entity.Auftraggeber = s.ToList().Last();
} }

View File

@@ -1,4 +1,5 @@
using SewerStammGen.Shared.Domain; using SewerStammGen.Shared.Contracts;
using SewerStammGen.Shared.Domain;
using SewerStammGen.Shared.Enum; using SewerStammGen.Shared.Enum;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
@@ -10,6 +11,6 @@ namespace Shared.Contracts
{ {
public interface IExport public interface IExport
{ {
Task<bool> Export(string projektname,EKodierungssystem kodierungssystem,List<Kanal> haltungen, List<Schacht> schaechte); Task<bool> Export(string projektname,EKodierungssystem kodierungssystem,List<Kanal> haltungen, List<Schacht> schaechte, IWWLog log);
} }
} }

View File

@@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SewerStammGen.Shared.Contracts
{
public interface IWWLog
{
void Log(string message);
}
}

View File

@@ -32,6 +32,7 @@ namespace StammGenerator.Commands
public override async Task ExecuteAsync(object? parameter) public override async Task ExecuteAsync(object? parameter)
{ {
if (_projektListViewModel.SelectedProjekt == null) return; if (_projektListViewModel.SelectedProjekt == null) return;
IWWLog wwLog = null ;
Projekt _selectedProjekt = _projektListViewModel.SelectedProjekt; Projekt _selectedProjekt = _projektListViewModel.SelectedProjekt;
try try
{ {
@@ -39,7 +40,7 @@ namespace StammGenerator.Commands
IEnumerable<Kanal> haltungen = await _haltungDataService.GetAllByProjekt(_selectedProjekt); IEnumerable<Kanal> haltungen = await _haltungDataService.GetAllByProjekt(_selectedProjekt);
IEnumerable<Schacht> schaechte = await _schachtDataService.GetAllByProjekt(_selectedProjekt); IEnumerable<Schacht> schaechte = await _schachtDataService.GetAllByProjekt(_selectedProjekt);
await export.Export(_selectedProjekt.Id.ToString(), _selectedProjekt.Kodierungssystem, haltungen.ToList(), schaechte.ToList()); await export.Export(_selectedProjekt.Id.ToString(), _selectedProjekt.Kodierungssystem, haltungen.ToList(), schaechte.ToList(), wwLog);
} }
catch(NotImplementedException) catch(NotImplementedException)
{ {

View File

@@ -1,4 +1,5 @@
using SewerStammGen.Shared.Domain; using SewerStammGen.Shared.Contracts;
using SewerStammGen.Shared.Domain;
using SewerStammGen.Shared.Enum; using SewerStammGen.Shared.Enum;
using Shared.Contracts; using Shared.Contracts;
using System; using System;
@@ -11,10 +12,10 @@ namespace WWTech_KanalSchnittstelle.Exporter.Kandis
{ {
public class KANDIS60 : IExport public class KANDIS60 : IExport
{ {
public async Task<bool> Export(string projektname,EKodierungssystem kodierungssystem, List<Kanal> haltungen, List<Schacht> schaechte) public async Task<bool> Export(string projektname,EKodierungssystem kodierungssystem, List<Kanal> haltungen, List<Schacht> schaechte, IWWLog log)
{ {
KANDIS_HALTUNG60 haltung = new KANDIS_HALTUNG60(projektname, haltungen); KANDIS_HALTUNG60 haltung = new KANDIS_HALTUNG60(projektname, haltungen,log);
KANDIS_SCHACHT60 schacht = new KANDIS_SCHACHT60(projektname, schaechte); KANDIS_SCHACHT60 schacht = new KANDIS_SCHACHT60(projektname, schaechte,log);
return true; return true;
} }
} }

View File

@@ -1,4 +1,5 @@
using SewerStammGen.Shared.Enum; using SewerStammGen.Shared.Contracts;
using SewerStammGen.Shared.Enum;
using System; using System;
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
@@ -32,11 +33,13 @@ namespace WWTech_KanalSchnittstelle.Exporter.Kandis
private StreamWriter sw; private StreamWriter sw;
char[] zeile; char[] zeile;
protected IWWLog Logger;
protected string Zeile => new string(zeile); protected string Zeile => new string(zeile);
public KANDIS_Exporter(string filename, EExportType exportType, kType kType) public KANDIS_Exporter(string filename, EExportType exportType, kType kType, IWWLog Logger)
{ {
this.Logger = Logger;
string version = string.Empty; string version = string.Empty;
switch (kType) switch (kType)
{ {
@@ -104,9 +107,11 @@ namespace WWTech_KanalSchnittstelle.Exporter.Kandis
uint length = (ende+1) - start; uint length = (ende+1) - start;
if(content.Length > length) if(content.Length > length)
{ {
content = content.Substring(0, (int)length); string newcontent = content.Substring(0,(int)length);
//Debugger.Break(); Logger.Log(string.Format("Inhalt {0} des Feldes war zu lang. Feld wird auf {1} stellen gekürzt." +
//throw new Exception("Inhalt des Feldes ist zu lang"); "Neue Inhalt lautet: {2}",content,length,newcontent));
content = newcontent;
} }
int counter = 0; int counter = 0;

View File

@@ -1,4 +1,5 @@
using SewerStammGen.Shared.Domain; using SewerStammGen.Shared.Contracts;
using SewerStammGen.Shared.Domain;
using SewerStammGen.Shared.Enum; using SewerStammGen.Shared.Enum;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
@@ -10,7 +11,7 @@ namespace WWTech_KanalSchnittstelle.Exporter.Kandis
{ {
internal class KANDIS_HALTUNG60 : KANDIS_Exporter internal class KANDIS_HALTUNG60 : KANDIS_Exporter
{ {
public KANDIS_HALTUNG60(string filename, List<Kanal> kanaele) : base(filename+".hal", EExportType.KANDIS6, kType.HALTUNG) public KANDIS_HALTUNG60(string filename, List<Kanal> kanaele, IWWLog log) : base(filename+".hal", EExportType.KANDIS6, kType.HALTUNG,log)
{ {
foreach(Kanal haltung in kanaele) foreach(Kanal haltung in kanaele)
{ {

View File

@@ -1,11 +1,12 @@
using SewerStammGen.Shared.Domain; using SewerStammGen.Shared.Contracts;
using SewerStammGen.Shared.Domain;
using SewerStammGen.Shared.Enum; using SewerStammGen.Shared.Enum;
namespace WWTech_KanalSchnittstelle.Exporter.Kandis namespace WWTech_KanalSchnittstelle.Exporter.Kandis
{ {
internal class KANDIS_SCHACHT60 : KANDIS_Exporter internal class KANDIS_SCHACHT60 : KANDIS_Exporter
{ {
public KANDIS_SCHACHT60(string filename,List<Schacht> schaechte) : base(filename+".sch", EExportType.KANDIS6, kType.SCHACHT) public KANDIS_SCHACHT60(string filename,List<Schacht> schaechte, IWWLog log) : base(filename+".sch", EExportType.KANDIS6, kType.SCHACHT,log)
{ {
foreach(Schacht schacht in schaechte) foreach(Schacht schacht in schaechte)

View File

@@ -17,7 +17,7 @@ namespace WWTech_KanalSchnittstelle.Exporter.XML
private XmlDocument _file; private XmlDocument _file;
private List<Schacht> _schaechte; private List<Schacht> _schaechte;
private List<Kanal> _haltungen; private List<Kanal> _haltungen;
public async Task<bool> Export(string projektname, EKodierungssystem kodierungssystem, List<Kanal> haltungen, List<Schacht> schaechte) public async Task<bool> Export(string projektname, EKodierungssystem kodierungssystem, List<Kanal> haltungen, List<Schacht> schaechte, IWWLog logger)
{ {
_schaechte = schaechte; _schaechte = schaechte;
_haltungen = haltungen; _haltungen = haltungen;
@@ -27,7 +27,7 @@ namespace WWTech_KanalSchnittstelle.Exporter.XML
XmlElement xmlElement = CreateElementFor("Identifikation", _file); XmlElement xmlElement = CreateElementFor("Identifikation", _file);
xmlElement.SetAttribute("xmlns", "http://www.ofd-hannover.la/Identifikation"); xmlElement.SetAttribute("xmlns", "http://www.ofd-hannover.la/Identifikation");
XmlElement xmlElement2 = CreateElementFor("Version", xmlElement); XmlElement xmlElement2 = CreateElementFor("Version", xmlElement);
xmlElement2.InnerText = "2006-2"; xmlElement2.InnerText = "2006-2"; // XML Version
DoAdmindata(xmlElement); DoAdmindata(xmlElement);
DoCollectives(xmlElement); DoCollectives(xmlElement);

View File

@@ -29,7 +29,7 @@ namespace WWTech_KanalSchnittstelle.Importer
{ {
decimal result = 0m; decimal result = 0m;
input = string.Format("{0:0.000}", input).Replace('.', ','); input = string.Format("{0:0.000}", input).Replace('.', ',');
if(decimal.TryParse(input, out result)) if(!decimal.TryParse(input, out result))
{ {
throw new Exception("Konnte koordinate nicht parsen"); throw new Exception("Konnte koordinate nicht parsen");
} }