12 Commits

Author SHA1 Message Date
e7891c1a05 This fixed #4
Schacht können nun wieder gespeichert werden

Converter um Schachttype erweitert.
2023-08-08 09:56:32 +02:00
c5a2a15865 this fixes #5
Es wird nun ein Fehlermeldung angezeigt bei absturz
2023-08-08 09:46:33 +02:00
f867ef6222 Exports werden in einem Export ordner abgelegt 2023-08-06 19:37:42 +02:00
778b4a9a64 Letzte Projekt wird beigehalten 2023-08-06 19:19:44 +02:00
ba3e10fd2d code cleanup 2023-08-06 16:25:26 +02:00
e54b875f1a Haltungsbezeichnung
beim auswahlen des Obere Schachtes wird automatisch die
Haltungsbezeichnung angepasst
2023-08-06 16:25:15 +02:00
16ac432831 Dongle abfrage hinzugefügt 2023-08-06 16:24:27 +02:00
28ad24751d Typo fehler 2023-07-26 16:05:42 +02:00
c933989d19 XML exporter fertiggestellt
Verschiedene Versionen implementiert
2023-07-26 15:56:57 +02:00
7b8b5a2337 Weitere XML felder. 2023-07-25 10:58:18 +02:00
a0067655b4 Revisionschächte werden nun mit abgelegt. 2023-07-24 19:51:45 +02:00
cea3fc448b Daten um Schachttyp erweitert
Wird aus CSV eingelese
2023-07-24 10:45:22 +02:00
27 changed files with 953 additions and 67 deletions

View File

@@ -1,3 +1,7 @@
-- Table: public.schacht
-- DROP TABLE IF EXISTS public.schacht;
CREATE TABLE IF NOT EXISTS public.schacht
(
schacht_id integer NOT NULL GENERATED BY DEFAULT AS IDENTITY ( INCREMENT 1 START 1 MINVALUE 1 MAXVALUE 2147483647 CACHE 1 ),
@@ -9,6 +13,7 @@ CREATE TABLE IF NOT EXISTS public.schacht
sohlhochwert numeric(18,4),
sohlhoehe numeric(18,4) NOT NULL,
entwaesserung integer NOT NULL,
schachtype integer,
vermesser text COLLATE pg_catalog."default",
aufnahmedatum text COLLATE pg_catalog."default",
ref_projekt_id integer,

View File

@@ -20,8 +20,8 @@ namespace SewerStammGen.DAL.Services.PostgresqlData
{
string command = "INSERT INTO " + tableName + " (" +
"objektbezeichnung,deckelrechtswert,deckelhochwert," +
"sohlrechtswert,sohlhochwert,sohlhoehe,deckelhoehe,entwaesserung,vermesser,aufnahmedatum,ref_projekt_id) VALUES " +
"(@1,@2,@3,@4,@5,@6,@7,@8,@9,@10,@11) RETURNING schacht_id";
"sohlrechtswert,sohlhochwert,sohlhoehe,deckelhoehe,entwaesserung,schachtype,vermesser,aufnahmedatum,ref_projekt_id) VALUES " +
"(@1,@2,@3,@4,@5,@6,@7,@8,@9,@10,@11,@12) RETURNING schacht_id";
using(var cmd = new NpgsqlCommand(command,conn))
{
cmd.Parameters.AddWithValue("1", entity.Objektbezeichnung);
@@ -32,9 +32,10 @@ namespace SewerStammGen.DAL.Services.PostgresqlData
cmd.Parameters.AddWithValue("6", entity.SohlHoehe);
cmd.Parameters.AddWithValue("7", entity.DeckelHoehe);
cmd.Parameters.AddWithValue("8", (int)entity.Entwaesserung);
cmd.Parameters.AddWithValue("9", entity.Vermesser);
cmd.Parameters.AddWithValue("10", entity.AufnahmeDatum);
cmd.Parameters.AddWithValue("11", entity.Projekt.Id);
cmd.Parameters.AddWithValue("9", (int)entity.SchachtType);
cmd.Parameters.AddWithValue("10", entity.Vermesser);
cmd.Parameters.AddWithValue("11", entity.AufnahmeDatum);
cmd.Parameters.AddWithValue("12", entity.Projekt.Id);
using var reader = await cmd.ExecuteReaderAsync();
reader.Read();
entity.Id = reader.GetInt32(0);
@@ -65,9 +66,10 @@ namespace SewerStammGen.DAL.Services.PostgresqlData
SohlHochWert = reader.GetDecimal(6),
SohlHoehe = reader.GetDecimal(7),
Entwaesserung = (EEntwaeserung)reader.GetInt32(8),
Vermesser = reader.GetString(9),
AufnahmeDatum = reader.GetString(10),
Projekt = new Projekt() { Id = reader.GetInt32(11) },
SchachtType = (ESchachtType)reader.GetInt32(9),
Vermesser = reader.GetString(10),
AufnahmeDatum = reader.GetString(11),
Projekt = new Projekt() { Id = reader.GetInt32(12) },
};
}
@@ -97,9 +99,10 @@ namespace SewerStammGen.DAL.Services.PostgresqlData
public async Task<Schacht> Update(Schacht entity)
{
// TODO: Typo in Schachtype beheben. Dies erfordert jedoch ein Datenbank updater Siehe Issue #7
string command = @"UPDATE " + tableName + " SET " +
"objektbezeichnung=@1, deckelrechtswert=@2, deckelhochwert=@3, deckelhoehe=@4, " +
"sohlrechtswert=@5, sohlhochwert=@6, sohlhoehe=@7, entwaesserung=@8, vermesser=@9, aufnahmedatum=@10, ref_projekt_id=@11 WHERE schacht_id=@12";
"sohlrechtswert=@5, sohlhochwert=@6, sohlhoehe=@7, entwaesserung=@8, schachtype=@9, vermesser=@10, aufnahmedatum=@11, ref_projekt_id=@12 WHERE schacht_id=@13";
using(var cmd = new NpgsqlCommand(command,conn))
{
cmd.Parameters.AddWithValue("1", entity.Objektbezeichnung);
@@ -110,10 +113,11 @@ namespace SewerStammGen.DAL.Services.PostgresqlData
cmd.Parameters.AddWithValue("6", entity.SohlHochWert);
cmd.Parameters.AddWithValue("7", entity.SohlHoehe);
cmd.Parameters.AddWithValue("8", (int)entity.Entwaesserung);
cmd.Parameters.AddWithValue("9", entity.Vermesser);
cmd.Parameters.AddWithValue("10", entity.AufnahmeDatum);
cmd.Parameters.AddWithValue("11", entity.Projekt.Id);
cmd.Parameters.AddWithValue("12", entity.Id);
cmd.Parameters.AddWithValue("9", (int)entity.SchachtType);
cmd.Parameters.AddWithValue("10", entity.Vermesser);
cmd.Parameters.AddWithValue("11", entity.AufnahmeDatum);
cmd.Parameters.AddWithValue("12", entity.Projekt.Id);
cmd.Parameters.AddWithValue("13", entity.Id);
await cmd.ExecuteNonQueryAsync();
}

View File

@@ -19,6 +19,7 @@ namespace SewerStammGen.Shared.Domain
public decimal SohlHoehe { get; set; }
public Projekt Projekt { get; set; } = new Projekt();
public EEntwaeserung Entwaesserung { get; set; }
public ESchachtType SchachtType { get; set; }
public string Vermesser { get; set; } = String.Empty;
public string AufnahmeDatum { get; set; } = String.Empty;
}

View File

@@ -0,0 +1,8 @@
namespace SewerStammGen.Shared.Enum
{
public enum ESchachtType
{
Hauptkanal,
Revisionschacht
}
}

View File

@@ -12,4 +12,8 @@
<None Remove="Services\**" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Wibu.CodeMeter.WibuCmNET" Version="7.60.5615.502" />
</ItemGroup>
</Project>

View File

@@ -0,0 +1,203 @@
using CodeMeter;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SewerStammGen.Shared
{
public class DongleNotFoundException : Exception
{
}
public class WWRuntime : IDisposable
{
uint FirmCode;
uint ProductCode;
Api cmApi;
CmCredential cmCred;
CmAccess2 cmAcc;
HCMSysEntry hcmse;
CmBoxInfo cmBoxInfo;
CmBoxEntry2? BoxContent;
uint ExportCount;
public WWRuntime(uint ProductCode)
{
this.ProductCode = ProductCode;
FirmCode = 103086;
cmApi = new Api();
cmCred = new CmCredential();
cmAcc = new CmAccess2();
cmAcc.Credential = cmCred;
cmAcc.Ctrl |= CmAccess.Option.UserLimit;
cmAcc.FirmCode = FirmCode;
cmAcc.ProductCode = ProductCode;
hcmse = cmApi.CmAccess2(CmAccessOption.Local, cmAcc);
if(hcmse == null)
{
ErrorCodes2 code = cmApi.CmGetLastErrorCode2();
throw new DongleNotFoundException();
}
cmBoxInfo = new CmBoxInfo();
CmGetBoxContentsOption boxOptions = new CmGetBoxContentsOption();
boxOptions = CmGetBoxContentsOption.AllEntries;
CmBoxEntry2[] tmpBoxContent;
tmpBoxContent = cmApi.CmGetBoxContents2(hcmse, boxOptions, this.FirmCode, cmBoxInfo);
CmEntryData[] pCmBoxEntry = (CmEntryData[])cmApi.CmGetInfo(hcmse, CmGetInfoOption.EntryData);
for (int i = 0; i < pCmBoxEntry.Length; i++)
{
switch (pCmBoxEntry[i].Ctrl & 0x0ffff)
{
case (uint)CodeMeter.GlobalEntryOption.UserData:
{
ExportCount = BitConverter.ToUInt32(pCmBoxEntry[i].Data);
}
break;
case (uint)CodeMeter.GlobalEntryOption.ProtectedData:
// Transfer to transformed byte
uint length = pCmBoxEntry[i].DataLen;
byte[] datas = new byte[length];
for (uint f = 0; f < length; f++)
{
datas[f] = pCmBoxEntry[i].Data[f];
}
//SyncfusionKey = Encoding.ASCII.GetString(datas);
break;
}
}
foreach (CmBoxEntry2 boxes in tmpBoxContent)
{
if (boxes.ProductCode == this.ProductCode)
{
this.BoxContent = boxes;
}
}
}
public bool IsLicensed(byte neededMask)
{
uint DongleFeature = GetFeatureMap();
byte DongleFeatureB = (byte)DongleFeature;
if ((DongleFeatureB & neededMask) == neededMask)
return true;
return false;
}
private uint GetFeatureMap()
{
if (BoxContent == null) return 0;
return BoxContent.FeatureMap;
}
string GetDongleSerial()
{
CmBoxInfo res = (CmBoxInfo)cmApi.CmGetInfo(hcmse, CmGetInfoOption.BoxInfo);
if (null != res)
{
return res.SerialNumber.ToString();
}
else
{
throw new Exception("Fehler beim aufrufen der Seriennummer");
}
}
int GetExportCount()
{
return 0;
}
public void IncrementExportCounter()
{
ExportCount++;
writeExportCount(ExportCount);
}
public bool CheckDongleVorhanden()
{
return hcmse != null;
}
public void CleanDongle()
{
cmApi.CmRelease(hcmse);
}
private void writeExportCount(uint count)
{
CmCreatePioUserData cmCreatePioUserData = new CmCreatePioUserData();
CmProgramUpdateProductItem pcmUpdateProductItem = new CmProgramUpdateProductItem();
CmCreateItem hcmCreateItem = new CmCreateItem();
object pvPio = new object();
CmInternalEntryInfo[] cmInternalEntryData;
cmInternalEntryData = (CmInternalEntryInfo[])cmApi.CmGetInfo(hcmse, CmGetInfoOption.InternalEntryInfo);
byte[] newCount = BitConverter.GetBytes(count);
newCount.CopyTo(cmCreatePioUserData.Data, 0);
cmCreatePioUserData.DataLen = (ushort)newCount.Length;
pvPio = cmCreatePioUserData;
CmCreatePioProductCode cmPC = new CmCreatePioProductCode();
cmPC.TvbCtrl = (CmCreatePioProductCode.Option)0;
cmPC.ProductCode = ProductCode;
cmPC.FirmItemReference = cmInternalEntryData[0].FirmItemReference;
cmPC.ProductItemReference = cmInternalEntryData[0].ProductItemReference;
string? error;
bool res = cmApi.CmCreateProductItemOption(hcmse, CmCreateProductItemOptionOption.Update | CmCreateProductItemOptionOption.ProductCode, cmPC);
if(!res)
{
error = cmApi.CmGetLastErrorText();
return;
}
res = cmApi.CmCreateProductItemOption(hcmse, CmCreateProductItemOptionOption.UserData | CmCreateProductItemOptionOption.Terminate, pvPio);
if(!res)
{
error = cmApi.CmGetLastErrorText();
return;
}
hcmCreateItem.FirmCode = 103086;
hcmCreateItem.ProductCode = ProductCode;
byte[] sequence = cmApi.CmCreateSequence(hcmse, GlobalProgrammingOption.UpdateProductItem, ref hcmCreateItem, pcmUpdateProductItem);
res = cmApi.CmProgram(hcmse, GlobalProgrammingOption.UpdateProductItem, sequence);
if (!res)
{
error = cmApi.CmGetLastErrorText();
return;
}
}
public void Dispose()
{
CleanDongle();
}
}
}

View File

@@ -9,6 +9,10 @@ using System.Data;
using System.Linq;
using System.Threading.Tasks;
using System.Windows;
using CodeMeter;
using SewerStammGen.Shared;
using System.Threading;
using System.Windows.Threading;
namespace StammGenerator
{
@@ -20,8 +24,28 @@ namespace StammGenerator
private readonly IHost _host;
public App()
{
new Mutex(initiallyOwned: true, "Stammdatengenerator", out bool result);
if(!result)
{
MessageBox.Show("Bitte nur 1 Instanz der Software Starten!","Fehler", MessageBoxButton.OK, MessageBoxImage.Error);
Environment.Exit(0);
}
using (WWRuntime wWRuntime = new WWRuntime(21))
{
if(wWRuntime.CheckDongleVorhanden())
{
wWRuntime.CleanDongle();
_host = CreateHostBuilder().Build();
}
else
{
MessageBox.Show("Kein Dongle gefunden");
Environment.Exit(0);
}
}
}
static IHostBuilder CreateHostBuilder(string[]? args = null)
{
@@ -34,14 +58,35 @@ namespace StammGenerator
protected override void OnStartup(StartupEventArgs e)
{
if (_host == null) return;
Application.Current.DispatcherUnhandledException += Current_DispatcherUnhandledException;
AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
_host.Start();
MainWindow? window = new MainWindow() { DataContext = _host.Services.GetRequiredService<MainWindowViewModel>() };
window.Show();
base.OnStartup(e);
}
private void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
{
try
{
Exception ex = (Exception)e.ExceptionObject;
string text = "Ein Software fehler ist Aufgetreten. Bitte kontaktiere uns mit folgende Information:\n\n";
MessageBox.Show(text + " " + ex.Message + "\n\n" + ex.StackTrace);
}
catch (Exception ex2)
{
MessageBox.Show("Fatal Non-UI error", ex2.Message, MessageBoxButton.OK, MessageBoxImage.Error);
}
}
private void Current_DispatcherUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e)
{
throw new NotImplementedException();
}
}
}

View File

@@ -1,4 +1,5 @@
using SewerStammGen.Shared.Contracts;
using SewerStammGen.Shared;
using SewerStammGen.Shared.Contracts;
using SewerStammGen.Shared.Domain;
using Shared.Contracts;
using StammGenerator.Commands;
@@ -6,6 +7,7 @@ using StammGenerator.ViewModel;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using System.Windows;
@@ -39,13 +41,21 @@ namespace StammGenerator.Commands
IExport export = ExporterFactory.Export(_selectedProjekt.ExportType);
IEnumerable<Kanal> haltungen = await _haltungDataService.GetAllByProjekt(_selectedProjekt);
IEnumerable<Schacht> schaechte = await _schachtDataService.GetAllByProjekt(_selectedProjekt);
if(!Directory.Exists("./export/"))
{
Directory.CreateDirectory("./export/");
}
await export.Export(_selectedProjekt.Id.ToString(), _selectedProjekt.Kodierungssystem, haltungen.ToList(), schaechte.ToList(), wwLog);
await export.Export("./export/"+_selectedProjekt.Id.ToString(), _selectedProjekt.Kodierungssystem, haltungen.ToList(), schaechte.ToList(), wwLog);
}
catch(NotImplementedException)
{
MessageBoxResult result = MessageBox.Show(string.Format("Schnittstelle Export format: {0} ist nicht Implementiert", _selectedProjekt.ExportType), "Fehlende Implementation", MessageBoxButton.OK, MessageBoxImage.Exclamation);
}
catch(DongleNotFoundException)
{
MessageBoxResult result = MessageBox.Show("Dongle nicht vorhanden");
}
}
}
}

View File

@@ -23,6 +23,7 @@ namespace StammGenerator.Converters
if (targetType == typeof(EEntwaeserung)) return (EEntwaeserung)parameter;
if (targetType == typeof(EExportType)) return (EExportType)parameter;
if (targetType == typeof(EKodierungssystem)) return (EKodierungssystem)parameter;
if (targetType == typeof(ESchachtType)) return (ESchachtType)parameter;
throw new NotImplementedException();
}
}

View File

@@ -5,7 +5,7 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:StammGenerator"
mc:Ignorable="d"
WindowState="Maximized"
xmlns:view="clr-namespace:StammGenerator.Views"
xmlns:viewmodel="clr-namespace:StammGenerator.ViewModel"

View File

@@ -10,6 +10,7 @@
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Hosting" Version="7.0.1" />
<PackageReference Include="Microsoft.Extensions.Hosting.Abstractions" Version="7.0.0" />
<PackageReference Include="Wibu.CodeMeter.WibuCmNET" Version="7.60.5615.502" />
</ItemGroup>
<ItemGroup>

View File

@@ -15,7 +15,7 @@ namespace StammGenerator.ViewModel
private readonly IActualState _actualState;
private readonly IHaltungDataService _haltungDataService;
private readonly ISchachtDataService _schachtDataService;
private List<Schacht> avaibleSchaechte;
private List<Schacht> avaibleSchaechte = new List<Schacht>();
private int _selectedObenIndex;
private int _selectedUntenIndex;
private Kanal _model;
@@ -52,6 +52,7 @@ namespace StammGenerator.ViewModel
_selectedObenIndex = value;
_model.StartSchacht = avaibleSchaechte[value];
RecalculateLength();
Haltungsbezeichnung = _model.StartSchacht.Objektbezeichnung;
OnPropertyChanged();
}
}

View File

@@ -43,17 +43,11 @@ namespace StammGenerator.ViewModel
_actualState = actualState;
_actualState.ProjektChanged += ActualState_ProjektChanged;
_actualState.ProjektChanged += ActualState_ProjektChanged;
_actualState.LoadLastProjekt();
Navigator.StateChanged += Navigator_StateChanged;
#if DEBUG
_actualState.SetProjekt(new Projekt() { Id = 5 });
#endif
}
private void ActualState_ProjektChanged(object? sender, EventArgs e)

View File

@@ -138,6 +138,19 @@ namespace StammGenerator.ViewModel
}
}
public ESchachtType SchachtType
{
get => _model.SchachtType;
set
{
if(_model.SchachtType != value)
{
_model.SchachtType = value;
OnPropertyChanged();
}
}
}
public ManholeEditViewModel(ISchachtDataService schachtDataService,IActualState actualState, IRenavigator renavigator)
{
_schachtDataService = schachtDataService;

View File

@@ -1,4 +1,5 @@
using SewerStammGen.Shared.Domain;
using Microsoft.Win32;
using SewerStammGen.Shared.Domain;
using System;
using System.Collections.Generic;
using System.Linq;
@@ -9,6 +10,10 @@ namespace StammGenerator.ViewModel
{
internal class ActualState : IActualState
{
const string userroot = "HKEY_CURRENT_USER\\Software";
const string firmkey = "WWTech";
const string subkey = "StammGenerator";
// TODO: set auf private set setzen
public int ProjektID { get; set; }
@@ -25,6 +30,9 @@ namespace StammGenerator.ViewModel
{
OnProjektChanged();
}
string keyName = userroot + "\\" + firmkey + "\\" + subkey;
Registry.SetValue(keyName, "LastProjekt", ProjektID);
}
public void SetSchacht(Schacht schacht, bool notification = true)
{
@@ -62,5 +70,16 @@ namespace StammGenerator.ViewModel
HaltungChanged?.Invoke(this, new EventArgs());
}
public void LoadLastProjekt()
{
string keyName = userroot + "\\" + firmkey + "\\" + subkey;
if(Registry.GetValue(keyName,"LastProjekt","")!= null)
{
ProjektID = Convert.ToInt32(Registry.GetValue(keyName, "LastProjekt", ""));
OnProjektChanged();
}
}
}
}

View File

@@ -20,5 +20,7 @@ namespace StammGenerator.ViewModel
void SetProjekt(Projekt projekt, bool notification = true);
void SetSchacht(Schacht schacht, bool notification = true);
void SetHaltung(Kanal haltung, bool notification = true);
void LoadLastProjekt();
}
}

View File

@@ -7,6 +7,6 @@
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800">
<Grid>
<TextBlock Text="Willkommen dieses Programm generiert Stammdaten für die TV Inspektion" />
<TextBlock Text="Version Test - 0.1" />
</Grid>
</UserControl>

View File

@@ -29,6 +29,7 @@
<RowDefinition Height="auto" />
<RowDefinition Height="auto" />
<RowDefinition Height="auto" />
<RowDefinition Height="auto" />
<RowDefinition />
</Grid.RowDefinitions>
@@ -42,6 +43,7 @@
<Label Grid.Column="0" Grid.Row="7" Content="Vermesser" />
<Label Grid.Column="0" Grid.Row="8" Content="Aufnahmedatum" />
<Label Grid.Column="0" Grid.Row="9" Content="Entwässerungsart" />
<Label Grid.Column="0" Grid.Row="10" Content="SchachtType" />
<TextBox Margin="2" Grid.Column="1" Grid.Row="0" Text="{Binding Objektbezeichnung}" />
<TextBox Margin="2" Grid.Column="1" Grid.Row="1" Text="{Binding DeckelRechtsWert}" />
@@ -59,8 +61,14 @@
<RadioButton Style="{StaticResource ToggleButtonList}" Content="Mischwasser" IsChecked="{Binding Entwaeserung, Converter={StaticResource EqualValueToParameterConverter},ConverterParameter={x:Static stat:EEntwaeserung.Mischwasser}}" />
</DockPanel>
<DockPanel Grid.Column="1" Grid.Row="10">
<!-- SchachtType-->
<RadioButton Style="{StaticResource ToggleButtonList}" Content="Hauptkanal" IsChecked="{Binding SchachtType, Converter={StaticResource EqualValueToParameterConverter},ConverterParameter={x:Static stat:ESchachtType.Hauptkanal}}" />
<RadioButton Style="{StaticResource ToggleButtonList}" Content="Revision" IsChecked="{Binding SchachtType, Converter={StaticResource EqualValueToParameterConverter},ConverterParameter={x:Static stat:ESchachtType.Revisionschacht}}" />
</DockPanel>
<StackPanel Grid.ColumnSpan="2" Grid.Row="10">
<StackPanel Grid.ColumnSpan="2" Grid.Row="11">
<Button Content="Speichern" Command="{Binding Speichern}" />
</StackPanel>

View File

@@ -20,6 +20,7 @@
<!--<DataGridTextColumn Header="Sohlhöhe" Binding="{Binding SohlHoehe}" />-->
<!--<DataGridTextColumn Header="Deckelhöhe" Binding="{Binding DeckelHoehe}" />-->
<DataGridTextColumn Header="Entwässerung" Binding="{Binding Entwaesserung}" />
<DataGridTextColumn Header="SchachtTyp" Binding="{Binding SchachtType}" />
</DataGrid.Columns>
</DataGrid>
<StackPanel Grid.Row="1">

View File

@@ -1,4 +1,5 @@
using SewerStammGen.Shared.Domain;
using SewerStammGen.Shared;
using SewerStammGen.Shared.Domain;
using SewerStammGen.Shared.Enum;
using Shared.Contracts;
using System;
@@ -16,10 +17,21 @@ namespace WWTech_KanalSchnittstelle.Exporter
{
public static IExport Export(EExportType exportType)
{
using(WWRuntime wWRuntime = new WWRuntime(21))
{
if(!wWRuntime.CheckDongleVorhanden())
{
throw new DongleNotFoundException();
}
wWRuntime.IncrementExportCounter();
wWRuntime.CleanDongle();
}
switch(exportType)
{
case EExportType.KANDIS6: return new KANDIS60();
case EExportType.XML2006: return new XML2006();
case EExportType.XML2013: return new XML2013();
case EExportType.XML2017: return new XML2017();
default: throw new NotImplementedException();
}
}

View File

@@ -15,7 +15,8 @@ namespace WWTech_KanalSchnittstelle.Exporter.Kandis
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, log);
KANDIS_SCHACHT60 schacht = new KANDIS_SCHACHT60(projektname, schaechte, log);
KANDIS_SCHACHT60 hauptschacht = new KANDIS_SCHACHT60(projektname, schaechte.FindAll(x => x.SchachtType == ESchachtType.Hauptkanal), log);
KANDIS_HAUSREV60 revisschacht = new KANDIS_HAUSREV60(projektname, schaechte.FindAll(x => x.SchachtType == ESchachtType.Revisionschacht), log);
return true;
}
}

View File

@@ -23,8 +23,13 @@ namespace WWTech_KanalSchnittstelle.Exporter.Kandis
WriteContent(new Tuple<uint, uint>(293,307), schacht.SohlRechtsWert.ToString());
WriteContent(new Tuple<uint, uint>(309, 323), schacht.SohlHochWert.ToString());
WriteContent(new Tuple<uint, uint>(325, 334), "1"); // Status Schachtmittelkoordinaten
}
// Deckelkoordinaten
WriteContent(new Tuple<uint, uint>(336, 350), schacht.DeckelRechtsWert.ToString());
WriteContent(new Tuple<uint, uint>(352, 366), schacht.DeckelHochWert.ToString());
WriteContent(new Tuple<uint, uint>(368, 377), "1");
WriteLineInFile();
}
CloseStream();
}
}
}

View File

@@ -10,6 +10,16 @@ using System.Text;
using System.Threading.Tasks;
using System.Xml;
// TODO: Admindaten fehlen
// TODO: Datenkollektive fehlen Datenstatus und Erstellungsdatum
// Stammdatenkollektiv auszufüllen
/*
Stammdatenkollektiv fehlt: GeoObjektart unter Geometrie
*/
namespace WWTech_KanalSchnittstelle.Exporter.XML
{
public class XML2006 : IExport
@@ -17,6 +27,14 @@ namespace WWTech_KanalSchnittstelle.Exporter.XML
private XmlDocument _file;
private List<Schacht> _schaechte;
private List<Kanal> _haltungen;
private static Dictionary<EExportType, Tuple<string, string>> ExportVersionen = new Dictionary<EExportType, Tuple<string, string>>()
{
{ EExportType.XML2006, new Tuple<string, string>("2006-10","2") },
{ EExportType.XML2013, new Tuple<string, string>("2013-02","5") },
{ EExportType.XML2017, new Tuple<string, string>("2017-07","6") }
};
public async Task<bool> Export(string projektname, EKodierungssystem kodierungssystem,List<Kanal> haltungen, List<Schacht> schaechte, IWWLog logger)
{
_schaechte = schaechte;
@@ -27,11 +45,12 @@ namespace WWTech_KanalSchnittstelle.Exporter.XML
XmlElement xmlElement = CreateElementFor("Identifikation", _file);
xmlElement.SetAttribute("xmlns", "http://www.ofd-hannover.la/Identifikation");
XmlElement xmlElement2 = CreateElementFor("Version", xmlElement);
xmlElement2.InnerText = "2006-2"; // XML Version
xmlElement2.InnerText = ExportVersionen[EExportType.XML2006].Item1; // XML Version
DoAdmindata(xmlElement);
DoCollectives(xmlElement);
_file.Save("test.xml");
_file.Save(projektname+".xml");
return true;
}
@@ -45,12 +64,30 @@ namespace WWTech_KanalSchnittstelle.Exporter.XML
private void DoAdmindata(XmlElement idElement)
{
XmlElement parentElement = CreateElementFor("Admindaten", idElement);
XmlElement Liegenschaft = CreateElementFor("Liegenschaft", parentElement);
DoRowValue(Liegenschaft, "Liegenschaftsnummer", "0");
DoRowValue(Liegenschaft, "Objektnummer", "0");
DoRowValue(Liegenschaft, "Liegenschaftsbezeichnung", "0");
DoRowValue(Liegenschaft, "Liegenschaftsort", "0");
DoRowValue(Liegenschaft, "Liegenschaftsnutzung", "komunal");
XmlElement Verwaltung = CreateElementFor("Verwaltung", parentElement);
DoRowValue(Verwaltung, "DienststelleVerwaltend", "123");
DoRowValue(Verwaltung, "DienststelleHausverwaltend", "123");
DoRowValue(Verwaltung, "DienststelleBauaufsicht", "123");
DoRowValue(Verwaltung, "DienststelleBaudurchfuehrung", "123");
DoRowValue(Verwaltung, "NummerDienststelleBaudurchfuehrung", "123");
DoRowValue(Verwaltung, "Zustaendigkeitsbereich", "123");
DoRowValue(Verwaltung, "Aktenzeichen", "123");
DoRowValue(Verwaltung, "Abwasserbeseitigungspflicht", "1");
DoRowValue(Verwaltung, "Wasserbehoerde", "123");
}
private void DoCollectives(XmlElement idElement)
{
XmlElement dataCollectiveElement = DoRow(idElement, "Datenkollektive");
DoRowValue(dataCollectiveElement, "Datenstatus", "1");
DoRowValue(dataCollectiveElement, "Erstellungsdatum", "2023-07-25");
DoCollectives1Labels(dataCollectiveElement);
DoCollectives2Base(dataCollectiveElement);
}
@@ -87,15 +124,16 @@ namespace WWTech_KanalSchnittstelle.Exporter.XML
DoRowValue(xmlElement2, "SchachtFunktion", "1");
XmlElement GeometrieElement = CreateElementFor("Geometrie", xmlElement);
XmlElement KnotenElement = CreateElementFor("Knoten", GeometrieElement);
XmlElement GeometrieDaten = CreateElementFor("Geometriedaten", GeometrieElement);
XmlElement KnotenElement = CreateElementFor("Knoten", GeometrieDaten);
XmlElement PunktElement = CreateElementFor("Punkt", KnotenElement);
DoRowValue(PunktElement, "Rechtswert", schacht.SohlRechtsWert.ToString().Replace(',', '.'));
DoRowValue(PunktElement, "Hochwert", schacht.SohlHochWert.ToString().Replace(',', '.'));
DoRowValue(PunktElement, "Punkthoehe", schacht.SohlHoehe.ToString().Replace(',', '.'));
DoRowValue(PunktElement, "PunktattributAbwasser", "SMP");
PunktElement = CreateElementFor("Punkt", KnotenElement);
DoRowValue(PunktElement, "Rechtswert", schacht.DeckelRechtsWert.ToString().Replace(',', '.'));
DoRowValue(PunktElement, "Hochwert", schacht.DeckelHochWert.ToString().Replace(',', '.'));
if(schacht.DeckelRechtsWert != 0) DoRowValue(PunktElement, "Rechtswert", schacht.DeckelRechtsWert.ToString().Replace(',', '.'));
if(schacht.DeckelHochWert != 0) DoRowValue(PunktElement, "Hochwert", schacht.DeckelHochWert.ToString().Replace(',', '.'));
DoRowValue(PunktElement, "Punkthoehe", schacht.DeckelHoehe.ToString().Replace(',', '.'));
DoRowValue(PunktElement, "PunktattributAbwasser", "DMP");
return xmlElement;
@@ -169,11 +207,17 @@ namespace WWTech_KanalSchnittstelle.Exporter.XML
DoRowValue(xmlElement, "Kennung", "STA01");
DoRowValue(xmlElement, "Kollektivart", "1");
XmlElement parentElement2 = CreateElementFor("Kollektiveigenschaft", xmlElement);
DoRow(parentElement2, "Stammdaten");
DoRow(parentElement2, "Zustandsdaten");
DoRow(parentElement2, "Hydraulikdaten");
DoRow(parentElement2, "Betriebsdaten");
DoRowValue(xmlElement, "Regelwerk", "2");
XmlElement parentElement3 = CreateElementFor("Stammdaten", parentElement2);
DoRowValue(parentElement3, "Stammdatentyp", "1");
DoRowValue(parentElement3, "Bautechnik", "1");
DoRowValue(parentElement3, "Geometrie", "1");
DoRowValue(parentElement3, "Sanierung", "0");
DoRowValue(parentElement3, "Umfeld", "0");
//DoRow(parentElement2, "Zustandsdaten");
//DoRow(parentElement2, "Hydraulikdaten");
//DoRow(parentElement2, "Betriebsdaten");
DoRowValue(xmlElement, "Regelwerk", ExportVersionen[EExportType.XML2006].Item2);
DoRowValue(xmlElement, "Bearbeitungsstand", "2");
DoRowValue(xmlElement, "Kommentar", "test");
}

View File

@@ -0,0 +1,235 @@
using Microsoft.Win32.SafeHandles;
using SewerStammGen.Shared.Contracts;
using SewerStammGen.Shared.Domain;
using SewerStammGen.Shared.Enum;
using Shared.Contracts;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml;
// TODO: Admindaten fehlen
// TODO: Datenkollektive fehlen Datenstatus und Erstellungsdatum
// Stammdatenkollektiv auszufüllen
/*
Stammdatenkollektiv fehlt: GeoObjektart unter Geometrie
*/
namespace WWTech_KanalSchnittstelle.Exporter.XML
{
public class XML2013 : IExport
{
private XmlDocument _file;
private List<Schacht> _schaechte;
private List<Kanal> _haltungen;
private static Dictionary<EExportType, Tuple<string, string>> ExportVersionen = new Dictionary<EExportType, Tuple<string, string>>()
{
{ EExportType.XML2006, new Tuple<string, string>("2006-10","2") },
{ EExportType.XML2013, new Tuple<string, string>("2013-02","5") },
{ EExportType.XML2017, new Tuple<string, string>("2017-07","6") }
};
public async Task<bool> Export(string projektname, EKodierungssystem kodierungssystem,List<Kanal> haltungen, List<Schacht> schaechte, IWWLog logger)
{
_schaechte = schaechte;
_haltungen = haltungen;
_file = new XmlDocument();
XmlDeclaration newChild = _file.CreateXmlDeclaration("1.0", "ISO-8859-1", "yes");
_file.AppendChild(newChild);
XmlElement xmlElement = CreateElementFor("Identifikation", _file);
xmlElement.SetAttribute("xmlns", "http://www.ofd-hannover.la/Identifikation");
XmlElement xmlElement2 = CreateElementFor("Version", xmlElement);
xmlElement2.InnerText = ExportVersionen[EExportType.XML2013].Item1; // XML Version
DoAdmindata(xmlElement);
DoCollectives(xmlElement);
_file.Save(projektname + ".xml");
return true;
}
private XmlElement CreateElementFor(string name, XmlNode parentElement)
{
XmlElement xmlElement = _file.CreateElement(name);
parentElement.AppendChild(xmlElement);
return xmlElement;
}
private void DoAdmindata(XmlElement idElement)
{
XmlElement parentElement = CreateElementFor("Admindaten", idElement);
XmlElement Liegenschaft = CreateElementFor("Liegenschaft", parentElement);
DoRowValue(Liegenschaft, "Liegenschaftsnummer", "0");
DoRowValue(Liegenschaft, "Objektnummer", "0");
DoRowValue(Liegenschaft, "Liegenschaftsbezeichnung", "0");
DoRowValue(Liegenschaft, "Liegenschaftsort", "0");
DoRowValue(Liegenschaft, "Liegenschaftsnutzung", "komunal");
XmlElement Verwaltung = CreateElementFor("Verwaltung", parentElement);
DoRowValue(Verwaltung, "DienststelleVerwaltend", "123");
DoRowValue(Verwaltung, "DienststelleHausverwaltend", "123");
DoRowValue(Verwaltung, "DienststelleBauaufsicht", "123");
DoRowValue(Verwaltung, "DienststelleBaudurchfuehrung", "123");
DoRowValue(Verwaltung, "NummerDienststelleBaudurchfuehrung", "123");
DoRowValue(Verwaltung, "Zustaendigkeitsbereich", "123");
DoRowValue(Verwaltung, "Aktenzeichen", "123");
DoRowValue(Verwaltung, "Abwasserbeseitigungspflicht", "1");
DoRowValue(Verwaltung, "Wasserbehoerde", "123");
}
private void DoCollectives(XmlElement idElement)
{
XmlElement dataCollectiveElement = DoRow(idElement, "Datenkollektive");
DoRowValue(dataCollectiveElement, "Datenstatus", "1");
DoRowValue(dataCollectiveElement, "Erstellungsdatum", "2023-07-25");
DoCollectives1Labels(dataCollectiveElement);
DoCollectives2Base(dataCollectiveElement);
}
private void DoCollectives2Base(XmlElement dataCollectiveElement)
{
XmlElement parentElement = DoRow(dataCollectiveElement, "Stammdatenkollektiv");
foreach (Kanal haltung in _haltungen)
{
XmlElement xmlElement = DoHaltungRow(haltung, parentElement, "AbwassertechnischeAnlage");
}
foreach (Schacht schacht in _schaechte)
{
XmlElement xmlElement = DoSchachtRow(schacht, parentElement, "AbwassertechnischeAnlage");
}
}
private XmlElement DoSchachtRow(Schacht schacht, XmlElement parentElement, string originTableName)
{
XmlElement xmlElement = null;
xmlElement = _file.CreateElement(originTableName);
parentElement.AppendChild(xmlElement);
DoRowValue(xmlElement, "Objektbezeichnung", schacht.Objektbezeichnung);
DoRowValue(xmlElement, "Objektart", "2");
DoRowValue(xmlElement, "Entwaesserungsart", schacht.Entwaesserung == EEntwaeserung.Regenwasser ? "KR" : schacht.Entwaesserung == EEntwaeserung.Schmutzwasser ? "KS" : "KM");
XmlElement xmlElement1 = CreateElementFor("Knoten", xmlElement);
DoRowValue(xmlElement1, "KnotenTyp", "0");
XmlElement xmlElement2 = CreateElementFor("Schacht", xmlElement1);
DoRowValue(xmlElement2, "SchachtFunktion", "1");
XmlElement GeometrieElement = CreateElementFor("Geometrie", xmlElement);
XmlElement GeometrieDaten = CreateElementFor("Geometriedaten", GeometrieElement);
XmlElement KnotenElement = CreateElementFor("Knoten", GeometrieDaten);
XmlElement PunktElement = CreateElementFor("Punkt", KnotenElement);
DoRowValue(PunktElement, "Rechtswert", schacht.SohlRechtsWert.ToString().Replace(',', '.'));
DoRowValue(PunktElement, "Hochwert", schacht.SohlHochWert.ToString().Replace(',', '.'));
DoRowValue(PunktElement, "Punkthoehe", schacht.SohlHoehe.ToString().Replace(',', '.'));
DoRowValue(PunktElement, "PunktattributAbwasser", "SMP");
PunktElement = CreateElementFor("Punkt", KnotenElement);
if(schacht.DeckelRechtsWert != 0) DoRowValue(PunktElement, "Rechtswert", schacht.DeckelRechtsWert.ToString().Replace(',', '.'));
if(schacht.DeckelHochWert != 0) DoRowValue(PunktElement, "Hochwert", schacht.DeckelHochWert.ToString().Replace(',', '.'));
DoRowValue(PunktElement, "Punkthoehe", schacht.DeckelHoehe.ToString().Replace(',', '.'));
DoRowValue(PunktElement, "PunktattributAbwasser", "DMP");
return xmlElement;
}
private XmlElement DoHaltungRow(Kanal haltung, XmlElement parentElement, string orginalTableName)
{
XmlElement xmlElement = null;
xmlElement = _file.CreateElement(orginalTableName);
parentElement.AppendChild(xmlElement);
DoRowValue(xmlElement, "Objektbezeichnung", haltung.Objektbezeichnung);
DoRowValue(xmlElement, "Objektart", "1");
DoRowValue(xmlElement, "Entwaesserungsart", haltung.Entwaesserung == EEntwaeserung.Regenwasser ? "KR" : haltung.Entwaesserung == EEntwaeserung.Schmutzwasser ? "KS" : "KM");
XmlElement xmlElement1 = CreateElementFor("Kante", xmlElement);
DoRowValue(xmlElement1, "KantenTyp", "0");
DoRowValue(xmlElement1, "KnotenZulauf", haltung.StartSchacht.Objektbezeichnung);
DoRowValue(xmlElement1, "KnotenZulaufTyp", "0");
DoRowValue(xmlElement1, "KnotenAblauf", haltung.EndSchacht.Objektbezeichnung);
DoRowValue(xmlElement1, "KnotenAblaufTyp", "0");
DoRowValue(xmlElement1, "Material", haltung.Material);
XmlElement xmlElement2 = CreateElementFor("Profil", xmlElement1);
DoRowValue(xmlElement2, "SonderprofilVorhanden", "0");
DoRowValue(xmlElement2, "Profilart", "0");
DoRowValue(xmlElement2, "Profilbreite", haltung.DN.ToString());
DoRowValue(xmlElement2, "Profilhoehe", haltung.DN.ToString());
xmlElement2 = CreateElementFor("Haltung", xmlElement1);
DoRowValue(xmlElement2, "HaltungsFunktion", "1");
DoRowValue(xmlElement2, "DMPLaenge", haltung.Haltungslaenge.ToString().Replace(',', '.'));
xmlElement1 = CreateElementFor("Lage", xmlElement);
xmlElement1 = CreateElementFor("Geometrie", xmlElement);
DoRowValue(xmlElement1, "GeoObjekttyp", "L");
xmlElement2 = CreateElementFor("Geometriedaten", xmlElement1);
XmlElement xmlElement3 = CreateElementFor("Kanten", xmlElement2);
XmlElement xmlElement4 = CreateElementFor("Kante", xmlElement3);
XmlElement xmlElement5 = CreateElementFor("Start", xmlElement4);
DoRowValue(xmlElement5, "Rechtswert", haltung.StartSchacht.SohlRechtsWert.ToString().Replace(',', '.'));
DoRowValue(xmlElement5, "Hochwert", haltung.StartSchacht.SohlHochWert.ToString().Replace(',', '.'));
DoRowValue(xmlElement5, "Punkthoehe", haltung.StartSchacht.SohlHoehe.ToString().Replace(',', '.'));
DoRowValue(xmlElement5, "PunktattributAbwasser", "SMP");
xmlElement5 = CreateElementFor("Ende", xmlElement4);
DoRowValue(xmlElement5, "Rechtswert", haltung.EndSchacht.SohlRechtsWert.ToString().Replace(',', '.'));
DoRowValue(xmlElement5, "Hochwert", haltung.EndSchacht.SohlHochWert.ToString().Replace(',', '.'));
DoRowValue(xmlElement5, "Punkthoehe", haltung.EndSchacht.SohlHoehe.ToString().Replace(',', '.'));
DoRowValue(xmlElement5, "PunktattributAbwasser", "SMP");
return xmlElement;
}
private XmlElement DoRow(XmlElement parentElement, string originTableName)
{
XmlElement xmlElement = null;
xmlElement = _file.CreateElement(originTableName);
parentElement.AppendChild(xmlElement);
return xmlElement;
}
private void DoCollectives1Labels(XmlElement dataCollectiveElement)
{
XmlElement parentElement = CreateElementFor("Kennungen", dataCollectiveElement);
XmlElement xmlElement = CreateElementFor("Kollektiv", parentElement);
DoRowValue(xmlElement, "Kennung", "STA01");
DoRowValue(xmlElement, "Kollektivart", "1");
XmlElement parentElement2 = CreateElementFor("Kollektiveigenschaft", xmlElement);
XmlElement parentElement3 = CreateElementFor("Stammdaten", parentElement2);
DoRowValue(parentElement3, "Stammdatentyp", "1");
DoRowValue(parentElement3, "Bautechnik", "1");
DoRowValue(parentElement3, "Geometrie", "1");
DoRowValue(parentElement3, "Sanierung", "0");
DoRowValue(parentElement3, "Umfeld", "0");
//DoRow(parentElement2, "Zustandsdaten");
//DoRow(parentElement2, "Hydraulikdaten");
//DoRow(parentElement2, "Betriebsdaten");
DoRowValue(xmlElement, "Regelwerk", ExportVersionen[EExportType.XML2013].Item2);
DoRowValue(xmlElement, "Bearbeitungsstand", "2");
DoRowValue(xmlElement, "Kommentar", "test");
}
private XmlElement DoRowValue(XmlElement rowElement, string originColName, string value)
{
XmlElement xmlElement = CreateElementFor(originColName, rowElement);
if (value != "")
{
xmlElement.InnerText = value;
}
return xmlElement;
}
}
}

View File

@@ -0,0 +1,235 @@
using Microsoft.Win32.SafeHandles;
using SewerStammGen.Shared.Contracts;
using SewerStammGen.Shared.Domain;
using SewerStammGen.Shared.Enum;
using Shared.Contracts;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml;
// TODO: Admindaten fehlen
// TODO: Datenkollektive fehlen Datenstatus und Erstellungsdatum
// Stammdatenkollektiv auszufüllen
/*
Stammdatenkollektiv fehlt: GeoObjektart unter Geometrie
*/
namespace WWTech_KanalSchnittstelle.Exporter.XML
{
public class XML2017 : IExport
{
private XmlDocument _file;
private List<Schacht> _schaechte;
private List<Kanal> _haltungen;
private static Dictionary<EExportType, Tuple<string, string>> ExportVersionen = new Dictionary<EExportType, Tuple<string, string>>()
{
{ EExportType.XML2006, new Tuple<string, string>("2006-10","2") },
{ EExportType.XML2013, new Tuple<string, string>("2013-02","5") },
{ EExportType.XML2017, new Tuple<string, string>("2017-07","6") }
};
public async Task<bool> Export(string projektname, EKodierungssystem kodierungssystem,List<Kanal> haltungen, List<Schacht> schaechte, IWWLog logger)
{
_schaechte = schaechte;
_haltungen = haltungen;
_file = new XmlDocument();
XmlDeclaration newChild = _file.CreateXmlDeclaration("1.0", "ISO-8859-1", "yes");
_file.AppendChild(newChild);
XmlElement xmlElement = CreateElementFor("Identifikation", _file);
xmlElement.SetAttribute("xmlns", "http://www.ofd-hannover.la/Identifikation");
XmlElement xmlElement2 = CreateElementFor("Version", xmlElement);
xmlElement2.InnerText = ExportVersionen[EExportType.XML2017].Item1; // XML Version
DoAdmindata(xmlElement);
DoCollectives(xmlElement);
_file.Save(projektname + ".xml");
return true;
}
private XmlElement CreateElementFor(string name, XmlNode parentElement)
{
XmlElement xmlElement = _file.CreateElement(name);
parentElement.AppendChild(xmlElement);
return xmlElement;
}
private void DoAdmindata(XmlElement idElement)
{
XmlElement parentElement = CreateElementFor("Admindaten", idElement);
XmlElement Liegenschaft = CreateElementFor("Liegenschaft", parentElement);
DoRowValue(Liegenschaft, "Liegenschaftsnummer", "0");
DoRowValue(Liegenschaft, "Objektnummer", "0");
DoRowValue(Liegenschaft, "Liegenschaftsbezeichnung", "0");
DoRowValue(Liegenschaft, "Liegenschaftsort", "0");
DoRowValue(Liegenschaft, "Liegenschaftsnutzung", "komunal");
XmlElement Verwaltung = CreateElementFor("Verwaltung", parentElement);
DoRowValue(Verwaltung, "DienststelleVerwaltend", "123");
DoRowValue(Verwaltung, "DienststelleHausverwaltend", "123");
DoRowValue(Verwaltung, "DienststelleBauaufsicht", "123");
DoRowValue(Verwaltung, "DienststelleBaudurchfuehrung", "123");
DoRowValue(Verwaltung, "NummerDienststelleBaudurchfuehrung", "123");
DoRowValue(Verwaltung, "Zustaendigkeitsbereich", "123");
DoRowValue(Verwaltung, "Aktenzeichen", "123");
DoRowValue(Verwaltung, "Abwasserbeseitigungspflicht", "1");
DoRowValue(Verwaltung, "Wasserbehoerde", "123");
}
private void DoCollectives(XmlElement idElement)
{
XmlElement dataCollectiveElement = DoRow(idElement, "Datenkollektive");
DoRowValue(dataCollectiveElement, "Datenstatus", "1");
DoRowValue(dataCollectiveElement, "Erstellungsdatum", "2023-07-25");
DoCollectives1Labels(dataCollectiveElement);
DoCollectives2Base(dataCollectiveElement);
}
private void DoCollectives2Base(XmlElement dataCollectiveElement)
{
XmlElement parentElement = DoRow(dataCollectiveElement, "Stammdatenkollektiv");
foreach (Kanal haltung in _haltungen)
{
XmlElement xmlElement = DoHaltungRow(haltung, parentElement, "AbwassertechnischeAnlage");
}
foreach (Schacht schacht in _schaechte)
{
XmlElement xmlElement = DoSchachtRow(schacht, parentElement, "AbwassertechnischeAnlage");
}
}
private XmlElement DoSchachtRow(Schacht schacht, XmlElement parentElement, string originTableName)
{
XmlElement xmlElement = null;
xmlElement = _file.CreateElement(originTableName);
parentElement.AppendChild(xmlElement);
DoRowValue(xmlElement, "Objektbezeichnung", schacht.Objektbezeichnung);
DoRowValue(xmlElement, "Objektart", "2");
DoRowValue(xmlElement, "Entwaesserungsart", schacht.Entwaesserung == EEntwaeserung.Regenwasser ? "KR" : schacht.Entwaesserung == EEntwaeserung.Schmutzwasser ? "KS" : "KM");
XmlElement xmlElement1 = CreateElementFor("Knoten", xmlElement);
DoRowValue(xmlElement1, "KnotenTyp", "0");
XmlElement xmlElement2 = CreateElementFor("Schacht", xmlElement1);
DoRowValue(xmlElement2, "SchachtFunktion", "1");
XmlElement GeometrieElement = CreateElementFor("Geometrie", xmlElement);
XmlElement GeometrieDaten = CreateElementFor("Geometriedaten", GeometrieElement);
XmlElement KnotenElement = CreateElementFor("Knoten", GeometrieDaten);
XmlElement PunktElement = CreateElementFor("Punkt", KnotenElement);
DoRowValue(PunktElement, "Rechtswert", schacht.SohlRechtsWert.ToString().Replace(',', '.'));
DoRowValue(PunktElement, "Hochwert", schacht.SohlHochWert.ToString().Replace(',', '.'));
DoRowValue(PunktElement, "Punkthoehe", schacht.SohlHoehe.ToString().Replace(',', '.'));
DoRowValue(PunktElement, "PunktattributAbwasser", "SMP");
PunktElement = CreateElementFor("Punkt", KnotenElement);
if(schacht.DeckelRechtsWert != 0) DoRowValue(PunktElement, "Rechtswert", schacht.DeckelRechtsWert.ToString().Replace(',', '.'));
if(schacht.DeckelHochWert != 0) DoRowValue(PunktElement, "Hochwert", schacht.DeckelHochWert.ToString().Replace(',', '.'));
DoRowValue(PunktElement, "Punkthoehe", schacht.DeckelHoehe.ToString().Replace(',', '.'));
DoRowValue(PunktElement, "PunktattributAbwasser", "DMP");
return xmlElement;
}
private XmlElement DoHaltungRow(Kanal haltung, XmlElement parentElement, string orginalTableName)
{
XmlElement xmlElement = null;
xmlElement = _file.CreateElement(orginalTableName);
parentElement.AppendChild(xmlElement);
DoRowValue(xmlElement, "Objektbezeichnung", haltung.Objektbezeichnung);
DoRowValue(xmlElement, "Objektart", "1");
DoRowValue(xmlElement, "Entwaesserungsart", haltung.Entwaesserung == EEntwaeserung.Regenwasser ? "KR" : haltung.Entwaesserung == EEntwaeserung.Schmutzwasser ? "KS" : "KM");
XmlElement xmlElement1 = CreateElementFor("Kante", xmlElement);
DoRowValue(xmlElement1, "KantenTyp", "0");
DoRowValue(xmlElement1, "KnotenZulauf", haltung.StartSchacht.Objektbezeichnung);
DoRowValue(xmlElement1, "KnotenZulaufTyp", "0");
DoRowValue(xmlElement1, "KnotenAblauf", haltung.EndSchacht.Objektbezeichnung);
DoRowValue(xmlElement1, "KnotenAblaufTyp", "0");
DoRowValue(xmlElement1, "Material", haltung.Material);
XmlElement xmlElement2 = CreateElementFor("Profil", xmlElement1);
DoRowValue(xmlElement2, "SonderprofilVorhanden", "0");
DoRowValue(xmlElement2, "Profilart", "0");
DoRowValue(xmlElement2, "Profilbreite", haltung.DN.ToString());
DoRowValue(xmlElement2, "Profilhoehe", haltung.DN.ToString());
xmlElement2 = CreateElementFor("Haltung", xmlElement1);
DoRowValue(xmlElement2, "HaltungsFunktion", "1");
DoRowValue(xmlElement2, "DMPLaenge", haltung.Haltungslaenge.ToString().Replace(',', '.'));
xmlElement1 = CreateElementFor("Lage", xmlElement);
xmlElement1 = CreateElementFor("Geometrie", xmlElement);
DoRowValue(xmlElement1, "GeoObjekttyp", "L");
xmlElement2 = CreateElementFor("Geometriedaten", xmlElement1);
XmlElement xmlElement3 = CreateElementFor("Kanten", xmlElement2);
XmlElement xmlElement4 = CreateElementFor("Kante", xmlElement3);
XmlElement xmlElement5 = CreateElementFor("Start", xmlElement4);
DoRowValue(xmlElement5, "Rechtswert", haltung.StartSchacht.SohlRechtsWert.ToString().Replace(',', '.'));
DoRowValue(xmlElement5, "Hochwert", haltung.StartSchacht.SohlHochWert.ToString().Replace(',', '.'));
DoRowValue(xmlElement5, "Punkthoehe", haltung.StartSchacht.SohlHoehe.ToString().Replace(',', '.'));
DoRowValue(xmlElement5, "PunktattributAbwasser", "SMP");
xmlElement5 = CreateElementFor("Ende", xmlElement4);
DoRowValue(xmlElement5, "Rechtswert", haltung.EndSchacht.SohlRechtsWert.ToString().Replace(',', '.'));
DoRowValue(xmlElement5, "Hochwert", haltung.EndSchacht.SohlHochWert.ToString().Replace(',', '.'));
DoRowValue(xmlElement5, "Punkthoehe", haltung.EndSchacht.SohlHoehe.ToString().Replace(',', '.'));
DoRowValue(xmlElement5, "PunktattributAbwasser", "SMP");
return xmlElement;
}
private XmlElement DoRow(XmlElement parentElement, string originTableName)
{
XmlElement xmlElement = null;
xmlElement = _file.CreateElement(originTableName);
parentElement.AppendChild(xmlElement);
return xmlElement;
}
private void DoCollectives1Labels(XmlElement dataCollectiveElement)
{
XmlElement parentElement = CreateElementFor("Kennungen", dataCollectiveElement);
XmlElement xmlElement = CreateElementFor("Kollektiv", parentElement);
DoRowValue(xmlElement, "Kennung", "STA01");
DoRowValue(xmlElement, "Kollektivart", "1");
XmlElement parentElement2 = CreateElementFor("Kollektiveigenschaft", xmlElement);
XmlElement parentElement3 = CreateElementFor("Stammdaten", parentElement2);
DoRowValue(parentElement3, "Stammdatentyp", "1");
DoRowValue(parentElement3, "Bautechnik", "1");
DoRowValue(parentElement3, "Geometrie", "1");
DoRowValue(parentElement3, "Sanierung", "0");
DoRowValue(parentElement3, "Umfeld", "0");
//DoRow(parentElement2, "Zustandsdaten");
//DoRow(parentElement2, "Hydraulikdaten");
//DoRow(parentElement2, "Betriebsdaten");
DoRowValue(xmlElement, "Regelwerk", ExportVersionen[EExportType.XML2017].Item2);
DoRowValue(xmlElement, "Bearbeitungsstand", "2");
DoRowValue(xmlElement, "Kommentar", "test");
}
private XmlElement DoRowValue(XmlElement rowElement, string originColName, string value)
{
XmlElement xmlElement = CreateElementFor(originColName, rowElement);
if (value != "")
{
xmlElement.InnerText = value;
}
return xmlElement;
}
}
}

View File

@@ -50,6 +50,16 @@ namespace WWTech_KanalSchnittstelle.Importer
{ "3310", EEntwaeserung.Regenwasser }
};
Dictionary<string, ESchachtType> schachtKennung = new Dictionary<string, ESchachtType>()
{
{ "1100", ESchachtType.Hauptkanal },
{ "1200", ESchachtType.Hauptkanal },
{ "1300", ESchachtType.Hauptkanal },
{ "3110", ESchachtType.Revisionschacht },
{ "3210", ESchachtType.Revisionschacht },
{ "3310", ESchachtType.Revisionschacht }
};
if (!File.Exists(filename))
{
throw new FileNotFoundException(filename);
@@ -90,13 +100,15 @@ namespace WWTech_KanalSchnittstelle.Importer
schacht.SohlHoehe = parseKoordinate(parsed[3]);
}
if (parsed.Length >= 4)
if (parsed.Length > 4)
{
schacht.Entwaesserung = entwaesserungKennung[parsed[4]];
schacht.SchachtType = schachtKennung[parsed[4]];
}
else
{
schacht.Entwaesserung = EEntwaeserung.Schmutzwasser;
schacht.SchachtType = ESchachtType.Hauptkanal;
}
schacht.Projekt = projekt;

View File

@@ -20,37 +20,59 @@ namespace WWTech_KanalSchnittstelle.Exporter.XML.Tests
{
new Schacht()
{
Objektbezeichnung = "SW01",
SohlHoehe = 0112.7m,
DeckelHoehe = 0108.8m,
SohlHochWert = 123.93m,
SohlRechtsWert = 123.92m,
DeckelHochWert = 14785,
Objektbezeichnung = "08930438",
SohlHoehe = -3.000m,
DeckelHoehe = 0.670m,
SohlHochWert = 5927107.130m,
SohlRechtsWert = 389469.142m,
Entwaesserung = EEntwaeserung.Schmutzwasser
},
new Schacht()
{
Objektbezeichnung = "SW02",
SohlHoehe = 145,
SohlHochWert = 14,
SohlRechtsWert = 28,
DeckelHochWert = 14,
}
Objektbezeichnung = "08930437",
SohlHoehe = -2.060m,
DeckelHoehe = 0.690m,
SohlHochWert = 5927131.379m,
SohlRechtsWert = 389524.332m,
Entwaesserung = EEntwaeserung.Schmutzwasser
},
new Schacht()
{
Objektbezeichnung = "08930436",
SohlHoehe = -1.900m,
DeckelHoehe = 0.680m,
SohlHochWert = 5927154.010m,
SohlRechtsWert = 389575.684m,
Entwaesserung = EEntwaeserung.Schmutzwasser
},
};
List<Kanal> haltungen = new List<Kanal>()
{
new Kanal()
{
StartSchacht = schaechte[0],
EndSchacht = schaechte[1],
DN = 200,
Entwaesserung = EEntwaeserung.Regenwasser,
Haltungslaenge = 53.93m,
StartSchacht = schaechte[1],
EndSchacht = schaechte[0],
DN = 250,
Entwaesserung = EEntwaeserung.Schmutzwasser,
Haltungslaenge = 60.20m,
Material = "STZ",
Objektbezeichnung = schaechte[0].Objektbezeichnung
Objektbezeichnung = schaechte[1].Objektbezeichnung
},
new Kanal()
{
StartSchacht = schaechte[2],
EndSchacht = schaechte[1],
DN = 250,
Entwaesserung = EEntwaeserung.Schmutzwasser,
Haltungslaenge = 56.30m,
Material = "STZ",
Objektbezeichnung = schaechte[2].Objektbezeichnung
}
};
XML2006 xmloutput = new XML2006();
xmloutput.Export("test.xml", EKodierungssystem.EN13508_2_2011, haltungen, schaechte,null);
xmloutput.Export("test.xml", EKodierungssystem.EN13508_2_2011, EExportType.XML2013, haltungen, schaechte,null);
}
}
}